Chromium Code Reviews| Index: content/browser/browser_plugin/browser_plugin_host_helper.cc |
| diff --git a/content/browser/browser_plugin/browser_plugin_host_helper.cc b/content/browser/browser_plugin/browser_plugin_host_helper.cc |
| index 0f4267a69136d575b01701e8031680f77beba367..4fd0be42e71fa5b83d9372790c8014c5dccae861 100644 |
| --- a/content/browser/browser_plugin/browser_plugin_host_helper.cc |
| +++ b/content/browser/browser_plugin/browser_plugin_host_helper.cc |
| @@ -8,20 +8,88 @@ |
| #include "content/browser/browser_plugin/browser_plugin_host.h" |
| #include "content/browser/renderer_host/render_view_host_impl.h" |
| #include "content/browser/renderer_host/render_widget_host_impl.h" |
| +#include "content/browser/renderer_host/render_widget_host_view_base.h" |
| #include "content/common/browser_plugin_messages.h" |
| #include "content/common/view_messages.h" |
| #include "content/public/browser/render_process_host.h" |
| +#include "content/common/gpu/gpu_messages.h" |
| #include "content/public/browser/render_view_host.h" |
| #include "content/public/browser/render_widget_host_view.h" |
| #include "ui/gfx/size.h" |
| namespace content { |
| +class BrowserPluginCompositingDelegate : |
| + public RenderWidgetHostViewBase::CompositingDelegate { |
| + public: |
| + virtual gfx::GLSurfaceHandle GetCompositingSurface() { |
| + gfx::GLSurfaceHandle handle = |
| + gfx::GLSurfaceHandle(gfx::kNullPluginWindow, true); |
| + handle.parent_gpu_process_id = helper_->surface_params_.gpu_process_id; |
| + handle.parent_client_id = helper_->surface_params_.client_id; |
| + handle.parent_context_id = helper_->surface_params_.context_id; |
| + handle.parent_texture_id[0] = helper_->surface_params_.texture_id[0]; |
| + handle.parent_texture_id[1] = helper_->surface_params_.texture_id[1]; |
| + handle.sync_point = helper_->surface_params_.sync_point; |
| + return handle; |
| + } |
| + |
| + virtual bool ResizeNeedsNewSurface() { return false; } |
| + BrowserPluginHostHelper* helper_; |
| + BrowserPluginCompositingDelegate(BrowserPluginHostHelper* helper) |
| + : helper_(helper) { |
| + } |
| + |
| + virtual void AcceleratedSurfaceBuffersSwapped( |
| + const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, |
| + int gpu_host_id) OVERRIDE { |
| + BrowserPlugin_SwapInfo info; |
| + info.route_id = params.route_id; |
| + info.gpu_host_id = gpu_host_id; |
| + |
| + helper_->browser_plugin_host_->SendBuffersSwappedToEmbedder( |
| + params.surface_handle, |
| + info); |
| + } |
| + |
| + virtual void AcceleratedSurfacePostSubBuffer( |
| + const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params, |
| + int gpu_host_id) OVERRIDE { |
| + // WebPluginContents does not allow for partial invalidation, so we just |
| + // invalidate the whole thing. |
|
scshunt
2012/08/12 01:42:45
Verify that these are the correct semantics for a
scshunt
2012/08/17 17:30:28
They are not and not easily. Made a TODO since I h
|
| + BrowserPlugin_SwapInfo info; |
| + info.route_id = params.route_id; |
| + info.gpu_host_id = gpu_host_id; |
| + |
| + helper_->browser_plugin_host_->SendBuffersSwappedToEmbedder( |
| + params.surface_handle, |
| + info); |
| + } |
| + |
| + virtual void AcceleratedSurfaceNew( |
| + int32 width_in_pixel, |
| + int32 height_in_pixel, |
| + uint64 surface_handle) { |
| + helper_->browser_plugin_host_->SendSurfaceResizeToEmbedder( |
| + gfx::Size(width_in_pixel, height_in_pixel)); |
| + } |
| + virtual void AcceleratedSurfaceRelease( |
| + uint64 surface_handle) { |
| + } |
| +}; |
| + |
| BrowserPluginHostHelper::BrowserPluginHostHelper( |
| BrowserPluginHost* browser_plugin_host, |
| - RenderViewHost* render_view_host) |
| + RenderViewHost* render_view_host, |
| + const BrowserPluginHostMsg_Surface_Params& params) |
| : RenderViewHostObserver(render_view_host), |
| - browser_plugin_host_(browser_plugin_host) { |
| + browser_plugin_host_(browser_plugin_host), |
| + surface_params_(params) { |
| + if (browser_plugin_host->embedder_render_process_host()) |
| + static_cast<RenderWidgetHostViewBase*>(render_view_host->GetView())-> |
| + SetCompositingDelegate( |
| + scoped_ptr<RenderWidgetHostViewBase::CompositingDelegate>( |
| + new BrowserPluginCompositingDelegate(this)).Pass()); |
| } |
| BrowserPluginHostHelper::~BrowserPluginHostHelper() { |
| @@ -39,6 +107,9 @@ bool BrowserPluginHostHelper::OnMessageReceived(const IPC::Message& message) { |
| IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest) |
| IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UpdateRect_ACK, OnUpdateRectACK) |
| IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_SetFocus, OnSetFocus) |
| + IPC_MESSAGE_HANDLER( |
| + BrowserPluginHostMsg_BuffersSwappedACK, |
| + OnSwapBuffersACK) |
| IPC_MESSAGE_HANDLER_GENERIC(BrowserPluginHostMsg_HandleInputEvent, |
| OnHandleInputEvent(*static_cast<const IPC::SyncMessage*>(&message), |
| &handled)) |
| @@ -67,12 +138,14 @@ bool BrowserPluginHostHelper::OnMessageReceived(const IPC::Message& message) { |
| void BrowserPluginHostHelper::OnNavigateOrCreateGuest( |
| int instance_id, |
| long long frame_id, |
| - const std::string& src) { |
| + const std::string& src, |
| + const BrowserPluginHostMsg_Surface_Params& params) { |
| browser_plugin_host_->NavigateOrCreateGuest( |
| render_view_host(), |
| instance_id, |
| frame_id, |
| - src); |
| + src, |
| + params); |
| } |
| void BrowserPluginHostHelper::OnResizeGuest( |
| @@ -124,7 +197,16 @@ void BrowserPluginHostHelper::OnHandleInputEventAck( |
| } |
| void BrowserPluginHostHelper::OnTakeFocus(bool reverse) { |
| - browser_plugin_host_->TakeFocus(reverse); |
| + browser_plugin_host_->TakeFocus(0, reverse); |
| +} |
| + |
| +void BrowserPluginHostHelper::OnSwapBuffersACK( |
| + const BrowserPlugin_SwapInfo& info, |
| + uint32 sync_point) { |
| + RenderWidgetHostImpl::AcknowledgeBufferPresent( |
| + info.route_id, |
| + info.gpu_host_id, |
| + sync_point); |
| } |
| void BrowserPluginHostHelper::OnShowWidget( |