diff options
Diffstat (limited to 'content/browser')
15 files changed, 120 insertions, 39 deletions
diff --git a/content/browser/gpu/gpu_process_host_ui_shim.cc b/content/browser/gpu/gpu_process_host_ui_shim.cc index 503a429..e7bda6d 100644 --- a/content/browser/gpu/gpu_process_host_ui_shim.cc +++ b/content/browser/gpu/gpu_process_host_ui_shim.cc @@ -174,6 +174,8 @@ bool GpuProcessHostUIShim::OnControlMessageReceived( IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, OnAcceleratedSurfaceBuffersSwapped) + IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfacePostSubBuffer, + OnAcceleratedSurfacePostSubBuffer) #if defined(TOOLKIT_USES_GTK) || defined(OS_WIN) IPC_MESSAGE_HANDLER(GpuHostMsg_ResizeView, OnResizeView) @@ -340,6 +342,30 @@ void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped( view->AcceleratedSurfaceBuffersSwapped(params, host_id_); } +void GpuProcessHostUIShim::OnAcceleratedSurfacePostSubBuffer( + const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params) { + TRACE_EVENT0("renderer", + "GpuProcessHostUIShim::OnAcceleratedSurfacePostSubBuffer"); + + ScopedSendOnIOThread delayed_send( + host_id_, + new AcceleratedSurfaceMsg_PostSubBufferACK(params.route_id)); + + RenderViewHost* host = RenderViewHost::FromID(params.renderer_id, + params.render_view_id); + if (!host) + return; + + RenderWidgetHostView* view = host->view(); + if (!view) + return; + + delayed_send.Cancel(); + + // View must send ACK message after next composite. + view->AcceleratedSurfacePostSubBuffer(params, host_id_); +} + #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) void GpuProcessHostUIShim::OnAcceleratedSurfaceRelease( diff --git a/content/browser/gpu/gpu_process_host_ui_shim.h b/content/browser/gpu/gpu_process_host_ui_shim.h index d4f566f..b274bad 100644 --- a/content/browser/gpu/gpu_process_host_ui_shim.h +++ b/content/browser/gpu/gpu_process_host_ui_shim.h @@ -22,6 +22,7 @@ #include "content/common/message_router.h" struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; +struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params; struct GpuHostMsg_AcceleratedSurfaceNew_Params; struct GpuHostMsg_AcceleratedSurfaceRelease_Params; @@ -96,6 +97,8 @@ class GpuProcessHostUIShim void OnAcceleratedSurfaceBuffersSwapped( const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params); + void OnAcceleratedSurfacePostSubBuffer( + const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params); #if defined(OS_MACOSX) || defined(UI_COMPOSITOR_IMAGE_TRANSPORT) void OnAcceleratedSurfaceNew( diff --git a/content/browser/renderer_host/render_widget_host.cc b/content/browser/renderer_host/render_widget_host.cc index 6da29ab..1eeb8e8 100644 --- a/content/browser/renderer_host/render_widget_host.cc +++ b/content/browser/renderer_host/render_widget_host.cc @@ -1479,9 +1479,18 @@ bool RenderWidgetHost::GotResponseToLockMouseRequest(bool allowed) { } #if defined(OS_MACOSX) || defined(UI_COMPOSITOR_IMAGE_TRANSPORT) +// static void RenderWidgetHost::AcknowledgeSwapBuffers(int32 route_id, int gpu_host_id) { GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(gpu_host_id); if (ui_shim) ui_shim->Send(new AcceleratedSurfaceMsg_BuffersSwappedACK(route_id)); } + +// static +void RenderWidgetHost::AcknowledgePostSubBuffer(int32 route_id, + int gpu_host_id) { + GpuProcessHostUIShim* ui_shim = GpuProcessHostUIShim::FromID(gpu_host_id); + if (ui_shim) + ui_shim->Send(new AcceleratedSurfaceMsg_PostSubBufferACK(route_id)); +} #endif diff --git a/content/browser/renderer_host/render_widget_host.h b/content/browser/renderer_host/render_widget_host.h index 2ed1e50..71db8b7 100644 --- a/content/browser/renderer_host/render_widget_host.h +++ b/content/browser/renderer_host/render_widget_host.h @@ -443,7 +443,8 @@ class CONTENT_EXPORT RenderWidgetHost : public IPC::Channel::Listener, #if defined(OS_MACOSX) || defined(UI_COMPOSITOR_IMAGE_TRANSPORT) // Called by the view in response to AcceleratedSurfaceBuffersSwapped. - void AcknowledgeSwapBuffers(int32 route_id, int gpu_host_id); + static void AcknowledgeSwapBuffers(int32 route_id, int gpu_host_id); + static void AcknowledgePostSubBuffer(int32 route_id, int gpu_host_id); #endif protected: diff --git a/content/browser/renderer_host/render_widget_host_view.h b/content/browser/renderer_host/render_widget_host_view.h index 44a8427..6ed0974 100644 --- a/content/browser/renderer_host/render_widget_host_view.h +++ b/content/browser/renderer_host/render_widget_host_view.h @@ -27,6 +27,7 @@ #include "ui/gfx/surface/transport_dib.h" struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; +struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params; class BackingStore; class RenderWidgetHost; @@ -197,6 +198,11 @@ class RenderWidgetHostView { virtual void AcceleratedSurfaceBuffersSwapped( const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, int gpu_host_id) = 0; + // Similar to above, except |params.(x|y|width|height)| define the region + // of the surface that changed. + virtual void AcceleratedSurfacePostSubBuffer( + const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, + int gpu_host_id) = 0; #if defined(OS_MACOSX) // Tells the view whether or not to accept first responder status. If |flag| diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index 62b1d27e..3dbf572 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -277,8 +277,8 @@ void RenderWidgetHostViewAura::OnAcceleratedCompositingStateChange() { } void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( - const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, - int gpu_host_id) { + const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, + int gpu_host_id) { #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) window_->layer()->SetExternalTexture( accelerated_surface_containers_[params.surface_id]->GetTexture()); @@ -287,14 +287,44 @@ void RenderWidgetHostViewAura::AcceleratedSurfaceBuffersSwapped( if (!window_->layer()->GetCompositor()) { // We have no compositor, so we have no way to display the surface. // Must still send the ACK. - host_->AcknowledgeSwapBuffers(params.route_id, gpu_host_id); + RenderWidgetHost::AcknowledgeSwapBuffers(params.route_id, gpu_host_id); } else { window_->layer()->ScheduleDraw(); // Add sending an ACK to the list of things to do OnCompositingEnded on_compositing_ended_callbacks_.push_back( base::Bind(&RenderWidgetHost::AcknowledgeSwapBuffers, - base::Unretained(host_), params.route_id, gpu_host_id)); + params.route_id, gpu_host_id)); + ui::Compositor* compositor = window_->layer()->GetCompositor(); + if (!compositor->HasObserver(this)) + compositor->AddObserver(this); + } +#else + NOTREACHED(); +#endif +} + +void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( + const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, + int gpu_host_id) { +#if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) + window_->layer()->SetExternalTexture( + accelerated_surface_containers_[params.surface_id]->GetTexture()); + glFlush(); + + if (!window_->layer()->GetCompositor()) { + // We have no compositor, so we have no way to display the surface + // Must still send the ACK + RenderWidgetHost::AcknowledgePostSubBuffer(params.route_id, gpu_host_id); + } else { + // TODO(backer): Plumb the damage rect to the ui compositor so that we + // can do a partial swap to display. + window_->layer()->ScheduleDraw(); + + // Add sending an ACK to the list of things to do OnCompositingEnded + on_compositing_ended_callbacks_.push_back( + base::Bind(&RenderWidgetHost::AcknowledgePostSubBuffer, + params.route_id, gpu_host_id)); ui::Compositor* compositor = window_->layer()->GetCompositor(); if (!compositor->HasObserver(this)) compositor->AddObserver(this); diff --git a/content/browser/renderer_host/render_widget_host_view_aura.h b/content/browser/renderer_host/render_widget_host_view_aura.h index 3bef8a3..3e256dc 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.h +++ b/content/browser/renderer_host/render_widget_host_view_aura.h @@ -74,6 +74,9 @@ class CONTENT_EXPORT RenderWidgetHostViewAura virtual void AcceleratedSurfaceBuffersSwapped( const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, int gpu_host_id) OVERRIDE; + virtual void AcceleratedSurfacePostSubBuffer( + const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, + int gpu_host_id) OVERRIDE; #if defined(UI_COMPOSITOR_IMAGE_TRANSPORT) virtual void AcceleratedSurfaceNew( int32 width, diff --git a/content/browser/renderer_host/render_widget_host_view_gtk.cc b/content/browser/renderer_host/render_widget_host_view_gtk.cc index 100c48a..b014f6a 100644 --- a/content/browser/renderer_host/render_widget_host_view_gtk.cc +++ b/content/browser/renderer_host/render_widget_host_view_gtk.cc @@ -1011,6 +1011,12 @@ void RenderWidgetHostViewGtk::AcceleratedSurfaceBuffersSwapped( NOTREACHED(); } +void RenderWidgetHostViewGtk::AcceleratedSurfacePostSubBuffer( + const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, + int gpu_host_id) { + NOTREACHED(); +} + void RenderWidgetHostViewGtk::SetBackground(const SkBitmap& background) { RenderWidgetHostView::SetBackground(background); host_->Send(new ViewMsg_SetBackground(host_->routing_id(), background)); diff --git a/content/browser/renderer_host/render_widget_host_view_gtk.h b/content/browser/renderer_host/render_widget_host_view_gtk.h index 39837e5..8eb1a29 100644 --- a/content/browser/renderer_host/render_widget_host_view_gtk.h +++ b/content/browser/renderer_host/render_widget_host_view_gtk.h @@ -98,6 +98,9 @@ class CONTENT_EXPORT RenderWidgetHostViewGtk : public RenderWidgetHostView, virtual void AcceleratedSurfaceBuffersSwapped( const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, int gpu_host_id) OVERRIDE; + virtual void AcceleratedSurfacePostSubBuffer( + const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, + int gpu_host_id) OVERRIDE; virtual void SetBackground(const SkBitmap& background) OVERRIDE; virtual void CreatePluginContainer(gfx::PluginWindowHandle id) OVERRIDE; virtual void DestroyPluginContainer(gfx::PluginWindowHandle id) OVERRIDE; diff --git a/content/browser/renderer_host/render_widget_host_view_mac.h b/content/browser/renderer_host/render_widget_host_view_mac.h index 5726aa7..aad12de 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.h +++ b/content/browser/renderer_host/render_widget_host_view_mac.h @@ -260,6 +260,9 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView { virtual void AcceleratedSurfaceBuffersSwapped( const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, int gpu_host_id) OVERRIDE; + virtual void AcceleratedSurfacePostSubBuffer( + const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, + int gpu_host_id) OVERRIDE; virtual void GetScreenInfo(WebKit::WebScreenInfo* results) OVERRIDE; virtual gfx::Rect GetRootWindowBounds() OVERRIDE; virtual gfx::PluginWindowHandle GetCompositingSurface() OVERRIDE; @@ -305,12 +308,6 @@ class RenderWidgetHostViewMac : public RenderWidgetHostView { // should be called after the software backing store has been painted to. void HandleDelayedGpuViewHiding(); - // This is called from the display link thread, and provides the GPU - // process a notion of how quickly the browser is able to keep up with it. - void AcknowledgeSwapBuffers(int renderer_id, - int32 route_id, - int gpu_host_id); - // These member variables should be private, but the associated ObjC class // needs access to them and can't be made a friend. diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm index 3300a41..46a5c4f6 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm @@ -884,13 +884,17 @@ void RenderWidgetHostViewMac::AcceleratedSurfaceBuffersSwapped( [view drawView]; } - if (params.renderer_id != 0 || params.route_id != 0) { - AcknowledgeSwapBuffers(params.renderer_id, - params.route_id, - gpu_host_id); + if (params.route_id != 0) { + RenderWidgetHost::AcknowledgeSwapBuffers(params.route_id, gpu_host_id); } } +void RenderWidgetHostViewMac::AcceleratedSurfacePostSubBuffer( + const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, + int gpu_host_id) { + NOTIMPLEMENTED(); +} + void RenderWidgetHostViewMac::UpdateRootGpuViewVisibility( bool show_gpu_widget) { // Plugins are destroyed on page navigate. The compositor layer on the other @@ -920,26 +924,6 @@ void RenderWidgetHostViewMac::HandleDelayedGpuViewHiding() { } } -void RenderWidgetHostViewMac::AcknowledgeSwapBuffers( - int renderer_id, - int32 route_id, - int gpu_host_id) { - TRACE_EVENT0("gpu", "RenderWidgetHostViewMac::AcknowledgeSwapBuffers"); - // Called on the display link thread. Hand actual work off to the IO thread, - // because |GpuProcessHost::Get()| can only be called there. - // Currently, this is never called for plugins. - if (render_widget_host_) { - DCHECK_EQ(render_widget_host_->process()->GetID(), renderer_id); - // |render_widget_host_->routing_id()| and |route_id| are usually not - // equal: The former identifies the channel from the RWH in the browser - // process to the corresponding render widget in the renderer process, while - // the latter identifies the channel from the GpuCommandBufferStub in the - // GPU process to the corresponding command buffer client in the renderer. - - render_widget_host_->AcknowledgeSwapBuffers(route_id, gpu_host_id); - } -} - void RenderWidgetHostViewMac::OnAcceleratedCompositingStateChange() { CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); bool activated = GetRenderWidgetHost()->is_accelerated_compositing_active(); diff --git a/content/browser/renderer_host/render_widget_host_view_win.cc b/content/browser/renderer_host/render_widget_host_view_win.cc index d8c85df..2eecc7f 100644 --- a/content/browser/renderer_host/render_widget_host_view_win.cc +++ b/content/browser/renderer_host/render_widget_host_view_win.cc @@ -2102,6 +2102,12 @@ void RenderWidgetHostViewWin::AcceleratedSurfaceBuffersSwapped( acknowledge_task)); } +void RenderWidgetHostViewWin::AcceleratedSurfacePostSubBuffer( + const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, + int gpu_host_id) { + NOTREACHED(); +} + void RenderWidgetHostViewWin::SetAccessibilityFocus(int acc_obj_id) { if (!render_widget_host_) return; diff --git a/content/browser/renderer_host/render_widget_host_view_win.h b/content/browser/renderer_host/render_widget_host_view_win.h index b55e7cc..d0fa783 100644 --- a/content/browser/renderer_host/render_widget_host_view_win.h +++ b/content/browser/renderer_host/render_widget_host_view_win.h @@ -205,6 +205,9 @@ class RenderWidgetHostViewWin virtual void AcceleratedSurfaceBuffersSwapped( const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, int gpu_host_id) OVERRIDE; + virtual void AcceleratedSurfacePostSubBuffer( + const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, + int gpu_host_id) OVERRIDE; virtual void OnAccessibilityNotifications( const std::vector<ViewHostMsg_AccessibilityNotification_Params>& params ) OVERRIDE; diff --git a/content/browser/renderer_host/test_render_view_host.cc b/content/browser/renderer_host/test_render_view_host.cc index 0524288..9647381 100644 --- a/content/browser/renderer_host/test_render_view_host.cc +++ b/content/browser/renderer_host/test_render_view_host.cc @@ -184,6 +184,11 @@ void TestRenderWidgetHostView::AcceleratedSurfaceBuffersSwapped( int gpu_host_id) { } +void TestRenderWidgetHostView::AcceleratedSurfacePostSubBuffer( + const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, + int gpu_host_id) { +} + #if defined(OS_MACOSX) gfx::Rect TestRenderWidgetHostView::GetViewCocoaBounds() const { diff --git a/content/browser/renderer_host/test_render_view_host.h b/content/browser/renderer_host/test_render_view_host.h index 8e1462b..ebfe62f 100644 --- a/content/browser/renderer_host/test_render_view_host.h +++ b/content/browser/renderer_host/test_render_view_host.h @@ -92,6 +92,9 @@ class TestRenderWidgetHostView : public RenderWidgetHostView { virtual void AcceleratedSurfaceBuffersSwapped( const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, int gpu_host_id) OVERRIDE; + virtual void AcceleratedSurfacePostSubBuffer( + const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, + int gpu_host_id) OVERRIDE; #if defined(OS_MACOSX) virtual void SetTakesFocusOnlyOnMouseDown(bool flag) OVERRIDE {} virtual gfx::Rect GetViewCocoaBounds() const OVERRIDE; @@ -136,10 +139,6 @@ class TestRenderWidgetHostView : public RenderWidgetHostView { virtual void AcceleratedSurfaceNew( int32 width, int32 height, uint64* surface_id, TransportDIB::Handle* surface_handle) { } - virtual void AcceleratedSurfaceBuffersSwapped( - uint64 surface_id, - int32 route_id, - int gpu_host_id) OVERRIDE {} virtual void AcceleratedSurfaceRelease(uint64 surface_id) { } #endif |