summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorvangelis@chromium.org <vangelis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-07 17:10:46 +0000
committervangelis@chromium.org <vangelis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-07 17:10:46 +0000
commitedbcde93e4b267c19e38fdc584509a044481f602 (patch)
treeb65d41609d1a2b8ee253a3a880d999ab76ef889f /chrome
parent7f9323de177f6d58732ae49fd707249ffa197b3b (diff)
downloadchromium_src-edbcde93e4b267c19e38fdc584509a044481f602.zip
chromium_src-edbcde93e4b267c19e38fdc584509a044481f602.tar.gz
chromium_src-edbcde93e4b267c19e38fdc584509a044481f602.tar.bz2
Adding a new IPC message to notify the browser process when a render widget is using the gpu process for painting its contents so that the browser will stop rendering from its own backing surface. This will currently only trigger if a page
uses the accelerated compositing path. This patch can only land _after_ https://bugs.webkit.org/show_bug.cgi?id=38220 BUG=42677 TEST=NONE Review URL: http://codereview.chromium.org/1696014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46697 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/renderer_host/render_widget_host.cc7
-rw-r--r--chrome/browser/renderer_host/render_widget_host.h8
-rw-r--r--chrome/browser/renderer_host/render_widget_host_view_win.cc10
-rw-r--r--chrome/common/render_messages_internal.h5
-rw-r--r--chrome/renderer/render_widget.cc18
-rw-r--r--chrome/renderer/render_widget.h3
6 files changed, 50 insertions, 1 deletions
diff --git a/chrome/browser/renderer_host/render_widget_host.cc b/chrome/browser/renderer_host/render_widget_host.cc
index 6c77f07..c53c7be 100644
--- a/chrome/browser/renderer_host/render_widget_host.cc
+++ b/chrome/browser/renderer_host/render_widget_host.cc
@@ -64,6 +64,7 @@ RenderWidgetHost::RenderWidgetHost(RenderProcessHost* process,
routing_id_(routing_id),
is_loading_(false),
is_hidden_(false),
+ is_gpu_rendering_active_(false),
repaint_ack_pending_(false),
resize_ack_pending_(false),
mouse_move_pending_(false),
@@ -138,6 +139,8 @@ void RenderWidgetHost::OnMessageReceived(const IPC::Message &msg) {
IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnMsgFocusedNodeChanged)
IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnMsgSetCursor)
IPC_MESSAGE_HANDLER(ViewHostMsg_ImeUpdateStatus, OnMsgImeUpdateStatus)
+ IPC_MESSAGE_HANDLER(ViewHostMsg_GpuRenderingActivated,
+ OnMsgGpuRenderingActivated)
#if defined(OS_LINUX)
IPC_MESSAGE_HANDLER(ViewHostMsg_CreatePluginContainer,
OnMsgCreatePluginContainer)
@@ -881,6 +884,10 @@ void RenderWidgetHost::OnMsgImeUpdateStatus(int control,
}
}
+void RenderWidgetHost::OnMsgGpuRenderingActivated(bool activated) {
+ is_gpu_rendering_active_ = activated;
+}
+
#if defined(OS_LINUX)
void RenderWidgetHost::OnMsgCreatePluginContainer(gfx::PluginWindowHandle id) {
diff --git a/chrome/browser/renderer_host/render_widget_host.h b/chrome/browser/renderer_host/render_widget_host.h
index 7b87d13..4e5c903 100644
--- a/chrome/browser/renderer_host/render_widget_host.h
+++ b/chrome/browser/renderer_host/render_widget_host.h
@@ -199,6 +199,9 @@ class RenderWidgetHost : public IPC::Channel::Listener,
void Blur();
void LostCapture();
+ // Tells us whether the page is rendered directly via the GPU process.
+ bool is_gpu_rendering_active() { return is_gpu_rendering_active_; }
+
// Notifies the RenderWidgetHost that the View was destroyed.
void ViewDestroyed();
@@ -458,6 +461,8 @@ class RenderWidgetHost : public IPC::Channel::Listener,
// having to bring in render_messages.h in a header file.
void OnMsgImeUpdateStatus(int control, const gfx::Rect& caret_rect);
+ void OnMsgGpuRenderingActivated(bool activated);
+
#if defined(OS_LINUX)
void OnMsgCreatePluginContainer(gfx::PluginWindowHandle id);
void OnMsgDestroyPluginContainer(gfx::PluginWindowHandle id);
@@ -535,6 +540,9 @@ class RenderWidgetHost : public IPC::Channel::Listener,
// Indicates whether a page is hidden or not.
bool is_hidden_;
+ // True when a page is rendered directly via the GPU process.
+ bool is_gpu_rendering_active_;
+
// Set if we are waiting for a repaint ack for the view.
bool repaint_ack_pending_;
diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.cc b/chrome/browser/renderer_host/render_widget_host_view_win.cc
index 975609e..3fede8e 100644
--- a/chrome/browser/renderer_host/render_widget_host_view_win.cc
+++ b/chrome/browser/renderer_host/render_widget_host_view_win.cc
@@ -871,6 +871,16 @@ void RenderWidgetHostViewWin::OnPaint(HDC unused_dc) {
return;
}
+ // Don't do any painting if the GPU process is rendering directly
+ // into the View.
+ RenderWidgetHost* render_widget_host = GetRenderWidgetHost();
+ if (render_widget_host->is_gpu_rendering_active()) {
+ // We initialize paint_dc here so that BeginPaint()/EndPaint()
+ // get called to validate the region.
+ CPaintDC paint_dc(m_hWnd);
+ return;
+ }
+
about_to_validate_and_paint_ = true;
BackingStoreWin* backing_store = static_cast<BackingStoreWin*>(
render_widget_host_->GetBackingStore(true));
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 85ce45f..763715a 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -1115,6 +1115,11 @@ IPC_BEGIN_MESSAGES(ViewHost)
gfx::Rect /* bitmap_rect */)
IPC_MESSAGE_ROUTED0(ViewHostMsg_DestroyVideo)
+ // Sent by the renderer when GPU compositing is enabled or disabled to notify
+ // the browser whether or not is should do paiting.
+ IPC_MESSAGE_ROUTED1(ViewHostMsg_GpuRenderingActivated,
+ bool /* true if the GPU process renders to window */)
+
// Acknowledges receipt of a ViewMsg_HandleInputEvent message.
// Payload is a WebInputEvent::Type which is the type of the event, followed
// by an optional WebInputEvent which is provided only if the event was not
diff --git a/chrome/renderer/render_widget.cc b/chrome/renderer/render_widget.cc
index 7952982..d9fd8e7 100644
--- a/chrome/renderer/render_widget.cc
+++ b/chrome/renderer/render_widget.cc
@@ -70,7 +70,8 @@ RenderWidget::RenderWidget(RenderThreadBase* render_thread,
ime_control_busy_(false),
popup_type_(popup_type),
pending_window_rect_count_(0),
- suppress_next_char_events_(false) {
+ suppress_next_char_events_(false),
+ is_gpu_rendering_active_(false) {
RenderProcess::current()->AddRefProcess();
DCHECK(render_thread_);
}
@@ -440,6 +441,21 @@ void RenderWidget::DoDeferredUpdate() {
return;
}
+ // If we are using accelerated compositing then all the drawing
+ // to the associated window happens directly from the gpu process and the
+ // browser process shouldn't do any drawing.
+ // TODO(vangelis): Currently the accelerated compositing path relies on
+ // invalidating parts of the page so that we get a request to redraw.
+ // This needs to change to a model where the compositor updates the
+ // contents of the page independently and the browser process gets no
+ // longer involved.
+ if (webwidget_->isAcceleratedCompositingActive() !=
+ is_gpu_rendering_active_) {
+ is_gpu_rendering_active_ = webwidget_->isAcceleratedCompositingActive();
+ Send(new ViewHostMsg_GpuRenderingActivated(
+ routing_id_, is_gpu_rendering_active_));
+ }
+
// Layout may generate more invalidation.
webwidget_->layout();
diff --git a/chrome/renderer/render_widget.h b/chrome/renderer/render_widget.h
index 9577630..4232d28 100644
--- a/chrome/renderer/render_widget.h
+++ b/chrome/renderer/render_widget.h
@@ -325,6 +325,9 @@ class RenderWidget : public IPC::Channel::Listener,
// Indicates if the next sequence of Char events should be suppressed or not.
bool suppress_next_char_events_;
+ // Set to true if painting to the window is handled by the GPU process.
+ bool is_gpu_rendering_active_;
+
DISALLOW_COPY_AND_ASSIGN(RenderWidget);
};