diff options
-rw-r--r-- | chrome/browser/gpu_process_host_ui_shim.cc | 3 | ||||
-rw-r--r-- | content/browser/renderer_host/render_widget_host.cc | 18 | ||||
-rw-r--r-- | content/browser/renderer_host/render_widget_host_unittest.cc | 2 | ||||
-rw-r--r-- | content/common/gpu/gpu_channel_manager.cc | 8 | ||||
-rw-r--r-- | content/common/gpu/gpu_channel_manager.h | 2 | ||||
-rw-r--r-- | content/common/gpu_messages.h | 5 | ||||
-rw-r--r-- | content/common/gpu_process_launch_causes.h | 1 |
7 files changed, 38 insertions, 1 deletions
diff --git a/chrome/browser/gpu_process_host_ui_shim.cc b/chrome/browser/gpu_process_host_ui_shim.cc index 73be07d..d4e8fc9 100644 --- a/chrome/browser/gpu_process_host_ui_shim.cc +++ b/chrome/browser/gpu_process_host_ui_shim.cc @@ -212,6 +212,9 @@ GpuProcessHostUIShim* GpuProcessHostUIShim::GetForRenderer(int renderer_id, return it.GetCurrentValue(); } + if (cause_for_gpu_launch == content::CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH) + return NULL; + int host_id; if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess) || CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessGPU)) { diff --git a/content/browser/renderer_host/render_widget_host.cc b/content/browser/renderer_host/render_widget_host.cc index 162f484..57004c9 100644 --- a/content/browser/renderer_host/render_widget_host.cc +++ b/content/browser/renderer_host/render_widget_host.cc @@ -9,6 +9,7 @@ #include "base/message_loop.h" #include "base/metrics/histogram.h" #include "chrome/browser/accessibility/browser_accessibility_state.h" +#include "chrome/browser/gpu_process_host_ui_shim.h" #include "chrome/browser/metrics/user_metrics.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/render_messages.h" @@ -18,6 +19,7 @@ #include "content/browser/renderer_host/render_process_host.h" #include "content/browser/renderer_host/render_widget_helper.h" #include "content/browser/renderer_host/render_widget_host_view.h" +#include "content/common/gpu_messages.h" #include "content/common/native_web_keyboard_event.h" #include "content/common/notification_service.h" #include "content/common/result_codes.h" @@ -220,6 +222,14 @@ void RenderWidgetHost::WasHidden() { // reduce its resource utilization. Send(new ViewMsg_WasHidden(routing_id_)); + GpuProcessHostUIShim* host_ui_shim = + GpuProcessHostUIShim::GetForRenderer( + process()->id(), content::CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH); + if (host_ui_shim) { + host_ui_shim->Send(new GpuMsg_VisibilityChanged( + routing_id_, process()->id(), false)); + } + // TODO(darin): what about constrained windows? it doesn't look like they // see a message when their parent is hidden. maybe there is something more // generic we can do at the TabContents API level instead of relying on @@ -256,6 +266,14 @@ void RenderWidgetHost::WasRestored() { } Send(new ViewMsg_WasRestored(routing_id_, needs_repainting)); + GpuProcessHostUIShim* host_ui_shim = + GpuProcessHostUIShim::GetForRenderer( + process()->id(), content::CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH); + if (host_ui_shim) { + host_ui_shim->Send(new GpuMsg_VisibilityChanged( + routing_id_, process()->id(), true)); + } + process_->WidgetRestored(); bool is_visible = true; diff --git a/content/browser/renderer_host/render_widget_host_unittest.cc b/content/browser/renderer_host/render_widget_host_unittest.cc index cc759ab..40c6fe3 100644 --- a/content/browser/renderer_host/render_widget_host_unittest.cc +++ b/content/browser/renderer_host/render_widget_host_unittest.cc @@ -9,6 +9,7 @@ #include "build/build_config.h" #include "chrome/common/render_messages.h" #include "chrome/test/testing_profile.h" +#include "content/browser/browser_thread.h" #include "content/browser/renderer_host/backing_store.h" #include "content/browser/renderer_host/test_render_view_host.h" #include "content/common/notification_details.h" @@ -530,6 +531,7 @@ TEST_F(RenderWidgetHostTest, GetBackingStore_RepaintAck) { // Test that we don't paint when we're hidden, but we still send the ACK. Most // of the rest of the painting is tested in the GetBackingStore* ones. TEST_F(RenderWidgetHostTest, HiddenPaint) { + BrowserThread ui_thread(BrowserThread::UI, MessageLoop::current()); // Hide the widget, it should have sent out a message to the renderer. EXPECT_FALSE(host_->is_hidden_); host_->WasHidden(); diff --git a/content/common/gpu/gpu_channel_manager.cc b/content/common/gpu/gpu_channel_manager.cc index e7721a4..f6d39a9 100644 --- a/content/common/gpu/gpu_channel_manager.cc +++ b/content/common/gpu/gpu_channel_manager.cc @@ -49,8 +49,9 @@ bool GpuChannelManager::OnMessageReceived(const IPC::Message& msg) { IPC_MESSAGE_HANDLER(GpuMsg_EstablishChannel, OnEstablishChannel) IPC_MESSAGE_HANDLER(GpuMsg_CloseChannel, OnCloseChannel) IPC_MESSAGE_HANDLER(GpuMsg_CreateViewCommandBuffer, - OnCreateViewCommandBuffer); + OnCreateViewCommandBuffer) IPC_MESSAGE_HANDLER(GpuMsg_Synchronize, OnSynchronize) + IPC_MESSAGE_HANDLER(GpuMsg_VisibilityChanged, OnVisibilityChanged) #if defined(OS_MACOSX) IPC_MESSAGE_HANDLER(GpuMsg_AcceleratedSurfaceBuffersSwappedACK, OnAcceleratedSurfaceBuffersSwappedACK) @@ -112,6 +113,11 @@ void GpuChannelManager::OnSynchronize() { Send(new GpuHostMsg_SynchronizeReply()); } +void GpuChannelManager::OnVisibilityChanged( + int32 render_view_id, int32 renderer_id, bool visible) { + // TODO(amarinichev): this will be used for context eviction +} + void GpuChannelManager::OnCreateViewCommandBuffer( gfx::PluginWindowHandle window, int32 render_view_id, diff --git a/content/common/gpu/gpu_channel_manager.h b/content/common/gpu/gpu_channel_manager.h index a89d9a4..d42b6d4 100644 --- a/content/common/gpu/gpu_channel_manager.h +++ b/content/common/gpu/gpu_channel_manager.h @@ -63,6 +63,8 @@ class GpuChannelManager : public IPC::Channel::Listener, // Message handlers. void OnEstablishChannel(int renderer_id); void OnCloseChannel(const IPC::ChannelHandle& channel_handle); + void OnVisibilityChanged( + int32 render_view_id, int32 renderer_id, bool visible); void OnSynchronize(); void OnCreateViewCommandBuffer( gfx::PluginWindowHandle window, diff --git a/content/common/gpu_messages.h b/content/common/gpu_messages.h index 9ea9beb..88fab8a 100644 --- a/content/common/gpu_messages.h +++ b/content/common/gpu_messages.h @@ -144,6 +144,11 @@ IPC_MESSAGE_CONTROL1(GpuMsg_CloseChannel, // asynchronously.) Results in a GpuHostMsg_SynchronizeReply. IPC_MESSAGE_CONTROL0(GpuMsg_Synchronize) +IPC_MESSAGE_CONTROL3(GpuMsg_VisibilityChanged, + int32, /*render_view_id */ + int32, /* renderer_id */ + bool /* is_visible */) + // Tells the GPU process to create a new command buffer that renders directly // to a native view. A corresponding GpuCommandBufferStub is created. IPC_MESSAGE_CONTROL4(GpuMsg_CreateViewCommandBuffer, diff --git a/content/common/gpu_process_launch_causes.h b/content/common/gpu_process_launch_causes.h index c84f9fe9..db4f62a 100644 --- a/content/common/gpu_process_launch_causes.h +++ b/content/common/gpu_process_launch_causes.h @@ -15,6 +15,7 @@ enum CauseForGpuLaunch { CAUSE_FOR_GPU_LAUNCH_RENDERWIDGETFULLSCREENPEPPER_CREATECONTEXT, CAUSE_FOR_GPU_LAUNCH_RENDERWIDGETHOSTVIEWMAC_DEALLOCFAKEPLUGINWINDOWHANDLE, CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE, + CAUSE_FOR_GPU_LAUNCH_NO_LAUNCH, CAUSE_FOR_GPU_LAUNCH_MAX_ENUM }; |