Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(960)

Unified Diff: content/renderer/child_frame_compositing_helper.cc

Issue 2514033002: Introducing SurfaceReferenceFactory (Closed)
Patch Set: x Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/child_frame_compositing_helper.cc
diff --git a/content/renderer/child_frame_compositing_helper.cc b/content/renderer/child_frame_compositing_helper.cc
index ca8009acffcd4d44246419ab6c873e4bcc7a1ddb..7a29dc9e8d3d5656c6b163d90eb18c9c26347540 100644
--- a/content/renderer/child_frame_compositing_helper.cc
+++ b/content/renderer/child_frame_compositing_helper.cc
@@ -14,6 +14,7 @@
#include "cc/output/copy_output_request.h"
#include "cc/output/copy_output_result.h"
#include "cc/resources/single_release_callback.h"
+#include "cc/surfaces/surface_embedding.h"
#include "content/child/thread_safe_sender.h"
#include "content/common/browser_plugin/browser_plugin_messages.h"
#include "content/common/content_switches_internal.h"
@@ -38,6 +39,64 @@
namespace content {
+namespace {
+
+class SurfaceEmbedding : public cc::SurfaceEmbeddingUsingSequence {
Fady Samuel 2016/12/07 23:29:05 ChildFrameSurfaceEmbedding?
+ public:
+ SurfaceEmbedding(const cc::SurfaceInfo& info,
+ scoped_refptr<ThreadSafeSender> sender,
+ int routing_id)
+ : SurfaceEmbeddingUsingSequence(info),
+ sender_(sender),
+ routing_id_(routing_id) {}
+
+ protected:
+ void RequireSequence(const cc::SurfaceSequence& seq) override {
+ sender_->Send(new FrameHostMsg_RequireSequence(routing_id_, id(), seq));
+ }
+
+ void SatisfySequence(const cc::SurfaceSequence& seq) override {
+ sender_->Send(new FrameHostMsg_SatisfySequence(routing_id_, seq));
+ }
+
+ private:
+ SurfaceEmbedding* CloneImpl() override { return new SurfaceEmbedding(*this); }
+ scoped_refptr<ThreadSafeSender> sender_;
+ int routing_id_;
+};
+
+class PluginSurfaceEmbedding : public cc::SurfaceEmbeddingUsingSequence {
Fady Samuel 2016/12/07 23:29:05 BrowserPluginSurfaceEmbedding
+ public:
+ PluginSurfaceEmbedding(const cc::SurfaceInfo& info,
+ scoped_refptr<ThreadSafeSender> sender,
+ int routing_id,
+ int plugin_id)
+ : SurfaceEmbeddingUsingSequence(info),
+ sender_(sender),
+ routing_id_(routing_id),
+ plugin_id_(plugin_id) {}
+
+ protected:
+ void SatisfySequence(const cc::SurfaceSequence& seq) override {
+ sender_->Send(
+ new BrowserPluginHostMsg_SatisfySequence(routing_id_, plugin_id_, seq));
+ }
+ void RequireSequence(const cc::SurfaceSequence& seq) override {
+ sender_->Send(new BrowserPluginHostMsg_RequireSequence(
+ routing_id_, plugin_id_, id(), seq));
+ }
+
+ private:
+ PluginSurfaceEmbedding* CloneImpl() override {
+ return new PluginSurfaceEmbedding(*this);
+ }
+ scoped_refptr<ThreadSafeSender> sender_;
+ int routing_id_;
+ int plugin_id_;
+};
+
+} // namespace
+
ChildFrameCompositingHelper*
ChildFrameCompositingHelper::CreateForBrowserPlugin(
const base::WeakPtr<BrowserPlugin>& browser_plugin) {
@@ -133,46 +192,6 @@ void ChildFrameCompositingHelper::ChildFrameGone() {
UpdateWebLayer(std::move(layer));
}
-// static
-void ChildFrameCompositingHelper::SatisfyCallback(
- scoped_refptr<ThreadSafeSender> sender,
- int host_routing_id,
- const cc::SurfaceSequence& sequence) {
- // This may be called on either the main or impl thread.
- sender->Send(new FrameHostMsg_SatisfySequence(host_routing_id, sequence));
-}
-
-// static
-void ChildFrameCompositingHelper::SatisfyCallbackBrowserPlugin(
- scoped_refptr<ThreadSafeSender> sender,
- int host_routing_id,
- int browser_plugin_instance_id,
- const cc::SurfaceSequence& sequence) {
- sender->Send(new BrowserPluginHostMsg_SatisfySequence(
- host_routing_id, browser_plugin_instance_id, sequence));
-}
-
-// static
-void ChildFrameCompositingHelper::RequireCallback(
- scoped_refptr<ThreadSafeSender> sender,
- int host_routing_id,
- const cc::SurfaceId& id,
- const cc::SurfaceSequence& sequence) {
- // This may be called on either the main or impl thread.
- 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,
- const cc::SurfaceId& id,
- const 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,
@@ -181,31 +200,21 @@ void ChildFrameCompositingHelper::OnSetSurface(
surface_id_ = surface_id;
scoped_refptr<ThreadSafeSender> sender(
RenderThreadImpl::current()->thread_safe_sender());
- cc::SurfaceLayer::SatisfyCallback satisfy_callback =
- render_frame_proxy_
- ? base::Bind(&ChildFrameCompositingHelper::SatisfyCallback, sender,
- host_routing_id_)
- : base::Bind(
- &ChildFrameCompositingHelper::SatisfyCallbackBrowserPlugin,
- sender, host_routing_id_,
- browser_plugin_->browser_plugin_instance_id());
- cc::SurfaceLayer::RequireCallback require_callback =
- 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());
- scoped_refptr<cc::SurfaceLayer> surface_layer =
- cc::SurfaceLayer::Create(satisfy_callback, require_callback);
+ scoped_refptr<cc::SurfaceLayer> surface_layer = cc::SurfaceLayer::Create();
// TODO(oshima): This is a stopgap fix so that the compositor does not
// scaledown the content when 2x frame data is added to 1x parent frame data.
// Fix this in cc/.
if (IsUseZoomForDSFEnabled())
scale_factor = 1.0f;
-
- surface_layer->SetSurfaceId(surface_id, scale_factor, frame_size);
+ cc::SurfaceInfo info(surface_id, scale_factor, frame_size);
+ cc::SurfaceEmbeddingPtr surface_ref;
+ if (render_frame_proxy_)
+ surface_ref.reset(new SurfaceEmbedding(info, sender, host_routing_id_));
+ else
+ surface_ref.reset(new PluginSurfaceEmbedding(
+ info, sender, host_routing_id_,
+ browser_plugin_->browser_plugin_instance_id()));
+ surface_layer->SetSurfaceEmbedding(std::move(surface_ref));
surface_layer->SetMasksToBounds(true);
std::unique_ptr<cc_blink::WebLayerImpl> layer(
new cc_blink::WebLayerImpl(surface_layer));

Powered by Google App Engine
This is Rietveld 408576698