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

Unified Diff: content/renderer/child_frame_compositing_helper.cc

Issue 2514033002: Introducing SurfaceReferenceFactory (Closed)
Patch Set: fix 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..80aeed5e7a50321ae818418bc6db199775aa3587 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_ref.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,52 @@
namespace content {
+namespace {
+
+class SurfaceRef : public cc::SurfaceRefWithSequence<SurfaceRef> {
+ public:
+ SurfaceRef(scoped_refptr<ThreadSafeSender> sender, int routing_id)
+ : 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:
+ scoped_refptr<ThreadSafeSender> sender_;
+ int routing_id_;
Fady Samuel 2016/11/30 19:51:29 const
+};
+
+class PluginSurfaceRef : public cc::SurfaceRefWithSequence<PluginSurfaceRef> {
Saman Sami 2016/11/30 18:05:52 Should I merge these two classes and also pass ren
Fady Samuel 2016/11/30 19:51:29 No, that's not thread safe.
+ public:
+ PluginSurfaceRef(scoped_refptr<ThreadSafeSender> sender,
+ int routing_id,
+ int plugin_id)
+ : 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:
+ scoped_refptr<ThreadSafeSender> sender_;
+ int routing_id_;
Fady Samuel 2016/11/30 19:51:29 const int.
+ int plugin_id_;
Fady Samuel 2016/11/30 19:51:29 const int
+};
+
+} // namespace
+
ChildFrameCompositingHelper*
ChildFrameCompositingHelper::CreateForBrowserPlugin(
const base::WeakPtr<BrowserPlugin>& browser_plugin) {
@@ -133,46 +180,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 +188,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::SurfaceRefPtr surface_ref;
+ if (render_frame_proxy_)
+ surface_ref.reset(new SurfaceRef(sender, host_routing_id_));
+ else
+ surface_ref.reset(
+ new PluginSurfaceRef(sender, host_routing_id_,
+ browser_plugin_->browser_plugin_instance_id()));
+ surface_ref->SetId(surface_id)->SetScale(scale_factor)->SetSize(frame_size);
+ surface_layer->SetSurfaceRef(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