summaryrefslogtreecommitdiffstats
path: root/content/renderer
diff options
context:
space:
mode:
authorwjmaclean <wjmaclean@chromium.org>2015-06-15 09:49:22 -0700
committerCommit bot <commit-bot@chromium.org>2015-06-15 16:49:49 +0000
commit53032adf732a092a342ae1ef2f3039adf89082d1 (patch)
treec4eb0c2c6d115a1e2d55f5d09178b21c27a50595 /content/renderer
parent07bbd38f13474770ab04769480dddefd2042e812 (diff)
downloadchromium_src-53032adf732a092a342ae1ef2f3039adf89082d1.zip
chromium_src-53032adf732a092a342ae1ef2f3039adf89082d1.tar.gz
chromium_src-53032adf732a092a342ae1ef2f3039adf89082d1.tar.bz2
Convert BrowserPlugin to render using cc::Surfaces.
This CL adds the appropriate machinery to allow BrowserPlugin to render using surfaces. This directly affects WebView and other GuestView types, such as the out-of-process PDF viewer. Where possible, functionality in RenderWidgetHostViewChildFrame that did not need to be replicated in RenderWidgetHostViewGuest was left untouched. This CL is based closely on https://codereview.chromium.org/1094113003/. BUG=none Review URL: https://codereview.chromium.org/1169983006 Cr-Commit-Position: refs/heads/master@{#334392}
Diffstat (limited to 'content/renderer')
-rw-r--r--content/renderer/browser_plugin/browser_plugin.cc24
-rw-r--r--content/renderer/browser_plugin/browser_plugin.h13
-rw-r--r--content/renderer/child_frame_compositing_helper.cc32
-rw-r--r--content/renderer/child_frame_compositing_helper.h6
4 files changed, 70 insertions, 5 deletions
diff --git a/content/renderer/browser_plugin/browser_plugin.cc b/content/renderer/browser_plugin/browser_plugin.cc
index 1013656..c2b7324 100644
--- a/content/renderer/browser_plugin/browser_plugin.cc
+++ b/content/renderer/browser_plugin/browser_plugin.cc
@@ -10,6 +10,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/thread_task_runner_handle.h"
+#include "cc/surfaces/surface.h"
#include "content/common/browser_plugin/browser_plugin_constants.h"
#include "content/common/browser_plugin/browser_plugin_messages.h"
#include "content/common/view_messages.h"
@@ -108,10 +109,33 @@ bool BrowserPlugin::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetTooltipText, OnSetTooltipText)
IPC_MESSAGE_HANDLER(BrowserPluginMsg_ShouldAcceptTouchEvents,
OnShouldAcceptTouchEvents)
+ IPC_MESSAGE_HANDLER(BrowserPluginMsg_SetChildFrameSurface,
+ OnSetChildFrameSurface)
IPC_END_MESSAGE_MAP()
return handled;
}
+void BrowserPlugin::OnSetChildFrameSurface(
+ int browser_plugin_instance_id,
+ const cc::SurfaceId& surface_id,
+ const gfx::Size& frame_size,
+ float scale_factor,
+ const cc::SurfaceSequence& sequence) {
+ if (!attached())
+ return;
+
+ EnableCompositing(true);
+ DCHECK(compositing_helper_.get());
+
+ compositing_helper_->OnSetSurface(surface_id, frame_size, scale_factor,
+ sequence);
+}
+
+void BrowserPlugin::SendSatisfySequence(const cc::SurfaceSequence& sequence) {
+ BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_SatisfySequence(
+ render_frame_routing_id_, browser_plugin_instance_id_, sequence));
+}
+
void BrowserPlugin::UpdateDOMAttribute(const std::string& attribute_name,
const base::string16& attribute_value) {
if (!container())
diff --git a/content/renderer/browser_plugin/browser_plugin.h b/content/renderer/browser_plugin/browser_plugin.h
index 88165aa..730b9214 100644
--- a/content/renderer/browser_plugin/browser_plugin.h
+++ b/content/renderer/browser_plugin/browser_plugin.h
@@ -20,6 +20,11 @@
struct BrowserPluginHostMsg_ResizeGuest_Params;
struct FrameMsg_BuffersSwapped_Params;
+namespace cc {
+struct SurfaceId;
+struct SurfaceSequence;
+}
+
namespace content {
class BrowserPluginDelegate;
@@ -55,6 +60,9 @@ class CONTENT_EXPORT BrowserPlugin :
// A request to enable hardware compositing.
void EnableCompositing(bool enable);
+ // Called by CompositingHelper to send current SurfaceSequence to browser.
+ void SendSatisfySequence(const cc::SurfaceSequence& sequence);
+
// Provided that a guest instance ID has been allocated, this method attaches
// this BrowserPlugin instance to that guest.
void Attach();
@@ -158,6 +166,11 @@ class CONTENT_EXPORT BrowserPlugin :
void OnAdvanceFocus(int instance_id, bool reverse);
void OnCompositorFrameSwapped(const IPC::Message& message);
void OnGuestGone(int instance_id);
+ void OnSetChildFrameSurface(int instance_id,
+ const cc::SurfaceId& surface_id,
+ const gfx::Size& frame_size,
+ float scale_factor,
+ const cc::SurfaceSequence& sequence);
void OnSetContentsOpaque(int instance_id, bool opaque);
void OnSetCursor(int instance_id, const WebCursor& cursor);
void OnSetMouseLock(int instance_id, bool enable);
diff --git a/content/renderer/child_frame_compositing_helper.cc b/content/renderer/child_frame_compositing_helper.cc
index d72b3e9..e6a3fab 100644
--- a/content/renderer/child_frame_compositing_helper.cc
+++ b/content/renderer/child_frame_compositing_helper.cc
@@ -288,6 +288,17 @@ void ChildFrameCompositingHelper::RequireCallback(
sender->Send(new FrameHostMsg_RequireSequence(host_routing_id, id, sequence));
}
+void ChildFrameCompositingHelper::RequireCallbackBrowserPlugin(
+ scoped_refptr<ThreadSafeSender> sender,
+ int host_routing_id,
+ int browser_plugin_instance_id,
+ cc::SurfaceId id,
+ cc::SurfaceSequence sequence) {
+ // This may be called on either the main or impl thread.
+ sender->Send(new BrowserPluginHostMsg_RequireSequence(
+ host_routing_id, browser_plugin_instance_id, id, sequence));
+}
+
void ChildFrameCompositingHelper::OnSetSurface(
const cc::SurfaceId& surface_id,
const gfx::Size& frame_size,
@@ -308,8 +319,13 @@ void ChildFrameCompositingHelper::OnSetSurface(
base::Bind(&ChildFrameCompositingHelper::SatisfyCallback, sender,
host_routing_id_);
cc::SurfaceLayer::RequireCallback require_callback =
- base::Bind(&ChildFrameCompositingHelper::RequireCallback, sender,
- host_routing_id_);
+ render_frame_proxy_
+ ? base::Bind(&ChildFrameCompositingHelper::RequireCallback, sender,
+ host_routing_id_)
+ : base::Bind(
+ &ChildFrameCompositingHelper::RequireCallbackBrowserPlugin,
+ sender, host_routing_id_,
+ browser_plugin_->browser_plugin_instance_id());
surface_layer_ =
cc::SurfaceLayer::Create(cc_blink::WebLayerImpl::LayerSettings(),
satisfy_callback, require_callback);
@@ -320,9 +336,15 @@ void ChildFrameCompositingHelper::OnSetSurface(
background_layer_->AddChild(surface_layer_);
// The RWHV creates a destruction dependency on the surface that needs to be
- // satisfied.
- render_frame_proxy_->Send(
- new FrameHostMsg_SatisfySequence(host_routing_id_, sequence));
+ // satisfied. Note: render_frame_proxy_ is null in the case our client is a
+ // BrowserPlugin; in this case the BrowserPlugin sends its own SatisfySequence
+ // message.
+ if (render_frame_proxy_) {
+ render_frame_proxy_->Send(
+ new FrameHostMsg_SatisfySequence(host_routing_id_, sequence));
+ } else if (browser_plugin_.get()) {
+ browser_plugin_->SendSatisfySequence(sequence);
+ }
CheckSizeAndAdjustLayerProperties(frame_size, scale_factor,
surface_layer_.get());
diff --git a/content/renderer/child_frame_compositing_helper.h b/content/renderer/child_frame_compositing_helper.h
index 7442472..a6fb0f03 100644
--- a/content/renderer/child_frame_compositing_helper.h
+++ b/content/renderer/child_frame_compositing_helper.h
@@ -114,6 +114,12 @@ class CONTENT_EXPORT ChildFrameCompositingHelper
int host_routing_id,
cc::SurfaceId id,
cc::SurfaceSequence sequence);
+ static void RequireCallbackBrowserPlugin(
+ scoped_refptr<ThreadSafeSender> sender,
+ int host_routing_id,
+ int browser_plugin_instance_id,
+ cc::SurfaceId id,
+ cc::SurfaceSequence sequence);
int host_routing_id_;
int last_route_id_;