summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authoramarinichev@chromium.org <amarinichev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-15 00:13:12 +0000
committeramarinichev@chromium.org <amarinichev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-15 00:13:12 +0000
commit8dc7fbda836a7a7e709085328787b3f71545c334 (patch)
tree225139c36220e1fbef3d8ae19cd08133da90bf4a /content
parent4284f83a3b146164dc35b30b05bcb66b4c8b5490 (diff)
downloadchromium_src-8dc7fbda836a7a7e709085328787b3f71545c334.zip
chromium_src-8dc7fbda836a7a7e709085328787b3f71545c334.tar.gz
chromium_src-8dc7fbda836a7a7e709085328787b3f71545c334.tar.bz2
Added GpuMsg_VisibilityChanged message.
The message is sent from the UI thread of the browser process to the GPU process when a tab changes visibility. It will be a hint for the GPU process to hold on to visible tabs. BUG=61038 TEST=breakpoint Review URL: http://codereview.chromium.org/6840034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81679 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/browser/renderer_host/render_widget_host.cc18
-rw-r--r--content/browser/renderer_host/render_widget_host_unittest.cc2
-rw-r--r--content/common/gpu/gpu_channel_manager.cc8
-rw-r--r--content/common/gpu/gpu_channel_manager.h2
-rw-r--r--content/common/gpu_messages.h5
-rw-r--r--content/common/gpu_process_launch_causes.h1
6 files changed, 35 insertions, 1 deletions
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
};