Index: content/browser/gpu/gpu_process_host.cc |
diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc |
index dba523986873529bff45497ecff55b73b628e11e..66ca0fe44a610986a2f7a6c2e6e56065719581f0 100644 |
--- a/content/browser/gpu/gpu_process_host.cc |
+++ b/content/browser/gpu/gpu_process_host.cc |
@@ -18,9 +18,11 @@ |
#include "content/browser/gpu/gpu_data_manager_impl.h" |
#include "content/browser/gpu/gpu_process_host_ui_shim.h" |
#include "content/browser/gpu/gpu_surface_tracker.h" |
+#include "content/browser/renderer_host/render_widget_helper.h" |
#include "content/browser/renderer_host/render_widget_host_impl.h" |
#include "content/common/child_process_host_impl.h" |
#include "content/common/gpu/gpu_messages.h" |
+#include "content/common/view_messages.h" |
#include "content/gpu/gpu_child_thread.h" |
#include "content/gpu/gpu_process.h" |
#include "content/public/browser/browser_thread.h" |
@@ -410,6 +412,10 @@ bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { |
IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) |
IPC_MESSAGE_HANDLER(GpuHostMsg_CommandBufferCreated, OnCommandBufferCreated) |
IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyCommandBuffer, OnDestroyCommandBuffer) |
+#if defined(OS_MACOSX) |
+ IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, |
+ OnAcceleratedSurfaceBuffersSwapped) |
+#endif |
#if defined(OS_WIN) && !defined(USE_AURA) |
IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, |
OnAcceleratedSurfaceBuffersSwapped) |
@@ -535,6 +541,52 @@ void GpuProcessHost::OnDestroyCommandBuffer(int32 surface_id) { |
#endif // defined(TOOLKIT_GTK) |
} |
+#if defined(OS_MACOSX) |
+void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( |
+ const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { |
+ TRACE_EVENT0("renderer", |
+ "GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped"); |
+ |
+ base::ScopedClosureRunner scoped_completion_runner( |
+ base::Bind(&AcceleratedSurfaceBuffersSwappedCompleted, |
+ host_id_, params.route_id, true)); |
+ |
+ gfx::PluginWindowHandle handle = |
+ GpuSurfaceTracker::Get()->GetSurfaceWindowHandle(params.surface_id); |
+ // Compositor window is always gfx::kNullPluginWindow. |
+ // TODO(jbates) http://crbug.com/105344 This will be removed when there are no |
+ // plugin windows. |
+ if (handle != gfx::kNullPluginWindow) { |
+ scoped_completion_runner.Release(); |
darin (slow to review)
2012/04/20 17:11:27
I presume this .Release() call prevents the Scoped
jbates
2012/04/20 23:01:04
Done.
|
+ RouteOnUIThread(GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params)); |
+ return; |
+ } |
+ |
+ int render_process_id = 0; |
+ int render_widget_id = 0; |
+ if (!GpuSurfaceTracker::Get()->GetRenderWidgetIDForSurface( |
+ params.surface_id, &render_process_id, &render_widget_id)) { |
darin (slow to review)
2012/04/20 17:11:27
nit: indent line continuations by 4 spaces
jbates
2012/04/20 23:01:04
Done.
|
+ return; |
+ } |
+ std::map<int, scoped_refptr<RenderWidgetHelper> >::const_iterator ci = |
darin (slow to review)
2012/04/20 17:11:27
perhaps this should just be a static map defined b
jbates
2012/04/20 23:01:04
Done.
|
+ render_widget_helpers_.find(render_process_id); |
+ if (ci == render_widget_helpers_.end()) |
+ return; |
+ |
+ // Pass the SwapBuffers on to the RenderWidgetHelper to wake up the UI thread |
+ // if the browser is waiting for a new frame. Otherwise the RenderWidgetHelper |
+ // will forward to the RenderWidgetHostView via RenderProcessHostImpl and |
+ // RenderWidgetHostImpl. |
+ scoped_completion_runner.Release(); |
+ ci->second->DidReceiveUpdateMsg(ViewHostMsg_CompositorSurfaceBuffersSwapped( |
darin (slow to review)
2012/04/20 17:11:27
i'm confused to see you passing a message to DidRe
jbates
2012/04/20 23:01:04
Done. Replaced UpdateMsg with BackingStoreMsg (ins
|
+ render_widget_id, |
+ params.surface_id, |
+ params.surface_handle, |
+ params.route_id, |
+ host_id_)); |
+} |
+#endif // OS_MACOSX |
+ |
#if defined(OS_WIN) && !defined(USE_AURA) |
void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( |
@@ -638,6 +690,16 @@ void GpuProcessHost::ForceShutdown() { |
process_->ForceShutdown(); |
} |
+void GpuProcessHost::RegisterRenderWidgetHelper( |
+ int render_process_id, |
+ const scoped_refptr<RenderWidgetHelper>& render_widget_helper) { |
+ render_widget_helpers_[render_process_id] = render_widget_helper; |
+} |
+ |
+void GpuProcessHost::UnregisterRenderWidgetHelper(int render_process_id) { |
+ render_widget_helpers_.erase(render_process_id); |
+} |
+ |
bool GpuProcessHost::LaunchGpuProcess(const std::string& channel_id) { |
if (!(gpu_enabled_ && |
GpuDataManagerImpl::GetInstance()->ShouldUseSoftwareRendering()) && |