| 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 8b0c6f959010a51cc685fd4e87fe5ef2014054b0..8dcd1396ed2be728e9b05ec77775222c8b383d97 100644
|
| --- a/content/browser/browser_plugin/browser_plugin_host_helper.cc
|
| +++ b/content/browser/browser_plugin/browser_plugin_host_helper.cc
|
| @@ -8,20 +8,100 @@
|
| #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() {
|
| + // This is the signal for having no context
|
| + if (helper_->surface_params_.texture_id[0] == 0) {
|
| + DCHECK(helper_->surface_params_.texture_id[1] == 0);
|
| + return gfx::GLSurfaceHandle();
|
| + } else {
|
| + DCHECK(helper_->surface_params_.texture_id[1] != 0);
|
| + DCHECK(helper_->surface_params_.texture_id[0] !=
|
| + helper_->surface_params_.texture_id[1]);
|
| + }
|
| +
|
| + 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 {
|
| + // TODO(scshunt): We don't actually support posting a sub-buffer.
|
| + // However, we can't turn that off here; the TextureImageTransportSurface
|
| + // needs to know not to accept sub-buffers. Try to do an entire swap
|
| + // instead, which is probably better than ignoring the post altogether.
|
| + 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 +119,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))
|
| @@ -68,13 +151,15 @@ void BrowserPluginHostHelper::OnNavigateGuest(
|
| int instance_id,
|
| long long frame_id,
|
| const std::string& src,
|
| - const gfx::Size& size) {
|
| + const gfx::Size& size,
|
| + const BrowserPluginHostMsg_Surface_Params& params) {
|
| browser_plugin_host_->NavigateGuest(
|
| render_view_host(),
|
| instance_id,
|
| frame_id,
|
| src,
|
| - size);
|
| + size,
|
| + params);
|
| }
|
|
|
| void BrowserPluginHostHelper::OnResizeGuest(
|
| @@ -129,6 +214,15 @@ void BrowserPluginHostHelper::OnTakeFocus(bool 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(
|
| int route_id,
|
| const gfx::Rect& initial_pos) {
|
|
|