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 4358a19e6548753f2385242109d33e239c5bbccc..a6bbb425e6a3e667c2adfd30c07074080ea155d1 100644 |
| --- a/content/browser/browser_plugin/browser_plugin_host_helper.cc |
| +++ b/content/browser/browser_plugin/browser_plugin_host_helper.cc |
| @@ -9,19 +9,82 @@ |
| #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 "ipc/ipc_logging.h" |
| #include "ui/gfx/size.h" |
| +#include "content/browser/renderer_host/render_widget_host_view_base.h" |
| +#include "content/browser/renderer_host/render_widget_host_impl.h" |
| namespace content { |
| namespace browser_plugin { |
| +class CrappyCompositingDelegate : 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; |
| + printf("CrappyCompositingDelegate is giving textures %u and %u\n", handle.parent_texture_id[0], handle.parent_texture_id[1]); |
| + return handle; |
| + } |
| + |
| + virtual bool ResizeNeedsNewSurface() { return false;} |
|
Fady Samuel
2012/07/06 15:14:44
I'm confused why this is always false.
scshunt
2012/07/06 16:39:03
The Windows and GTK clients need to allocate new G
|
| + BrowserPluginHostHelper* helper_; |
| + CrappyCompositingDelegate(BrowserPluginHostHelper* helper) |
| + : helper_(helper) { |
| + } |
| + |
| + virtual void AcceleratedSurfaceBuffersSwapped( |
| + const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, |
| + int gpu_host_id) OVERRIDE { |
| + printf("CrappyCompositingDelegate is acknowledging a full swap on surface %lu\n", params.surface_handle); |
| + |
| + 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 { |
| + printf("CrappyCompositingDelegate is acknowledging a partial swap\n"); |
|
Fady Samuel
2012/07/06 15:14:44
We don't do anything here?
scshunt
2012/07/06 16:39:03
This codepath never got used in my testing. This c
|
| + // WebPluginContents does not allow for partial invalidation, so we just invalidate the whole thing. |
| + // helper_->browser_plugin_host->SendBuffersSwappedToEmbedder(params.surface_handle); |
| + // RenderWidgetHostImpl::AcknowledgeBufferPresent(params.route_id, gpu_host_id, 0); |
| + } |
| + |
| + virtual void AcceleratedSurfaceNew( |
| + int32 width_in_pixel, int32 height_in_pixel, uint64* surface_handle, TransportDIB::Handle* shm_handle) { |
| + printf("CrappyCompositingDelegate is making a new surface of width %d and height %d on surface %lu\n", width_in_pixel, height_in_pixel, *surface_handle); |
|
Fady Samuel
2012/07/06 15:14:44
I'm confused by this too. Why does this work? Why
scshunt
2012/07/06 16:39:03
For texture image transport, no TransportDIB is ne
|
| + } |
| + virtual void AcceleratedSurfaceRelease( |
| + uint64 surface_handle) { |
| + printf("CrappyCompositingDelegate is releasing a surface\n"); |
| + } |
| +}; |
| + |
| 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) { |
| + printf("Constructing helper..."); |
| + if (browser_plugin_host->embedder_render_process_host()) { |
| + printf(" in guest\n"); |
| + static_cast<RenderWidgetHostViewBase*>(render_view_host->GetView())->SetCompositingDelegate(scoped_ptr<RenderWidgetHostViewBase::CompositingDelegate>(new CrappyCompositingDelegate(this)).Pass()); |
| + } else { |
| + printf(" not in guest\n"); |
| + } |
| } |
| BrowserPluginHostHelper::~BrowserPluginHostHelper() { |
| @@ -39,6 +102,7 @@ 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))) |
| IPC_MESSAGE_UNHANDLED(handled = false) |
| @@ -63,12 +127,14 @@ bool BrowserPluginHostHelper::OnMessageReceived(const IPC::Message& message) { |
| void BrowserPluginHostHelper::OnNavigateGuestFromEmbedder( |
| int instance_id, |
| long long frame_id, |
| - const std::string& src) { |
| + const std::string& src, |
| + const BrowserPluginHostMsg_Surface_Params& params) { |
| browser_plugin_host_->NavigateGuestFromEmbedder( |
| render_view_host(), |
| instance_id, |
| frame_id, |
| - src); |
| + src, |
| + params); |
| } |
| void BrowserPluginHostHelper::OnResizeGuest( |
| @@ -129,6 +195,12 @@ void BrowserPluginHostHelper::OnUpdateRectACK(int instance_id, |
| guest->UpdateRectACK(message_id); |
| } |
| +void BrowserPluginHostHelper::OnSwapBuffersACK(const BrowserPlugin_SwapInfo& info, |
| + uint32 sync_point) { |
| + printf("Received swap ACK\n"); |
| + RenderWidgetHostImpl::AcknowledgeBufferPresent(info.route_id, info.gpu_host_id, sync_point); |
| +} |
| + |
| void BrowserPluginHostHelper::OnHandleInputEvent( |
| const IPC::SyncMessage& message) { |
| bool handled = true; |