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

Unified Diff: content/renderer/child_frame_compositing_helper.cc

Issue 2514033002: Introducing SurfaceReferenceFactory (Closed)
Patch Set: up 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..5a53e6127bcaf3ed72b0f962666e1708c066e770 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/sequence_surface_reference_factory.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,67 @@
namespace content {
+namespace {
+
+class IframeSurfaceReferenceFactory
+ : public cc::SequenceSurfaceReferenceFactory {
+ public:
+ IframeSurfaceReferenceFactory(scoped_refptr<ThreadSafeSender> sender,
+ int routing_id)
+ : sender_(sender), routing_id_(routing_id) {}
+
+ protected:
+ ~IframeSurfaceReferenceFactory() override = default;
+
+ private:
+ void RequireSequence(const cc::SurfaceId& surface_id,
+ const cc::SurfaceSequence& sequence) const override {
+ sender_->Send(
+ new FrameHostMsg_RequireSequence(routing_id_, surface_id, sequence));
+ }
+ void SatisfySequence(const cc::SurfaceSequence& sequence) const override {
+ sender_->Send(new FrameHostMsg_SatisfySequence(routing_id_, sequence));
+ }
+
+ const scoped_refptr<ThreadSafeSender> sender_;
+ const int routing_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(IframeSurfaceReferenceFactory);
+};
+
+class BrowserPluginSurfaceReferenceFactory
+ : public cc::SequenceSurfaceReferenceFactory {
+ public:
+ BrowserPluginSurfaceReferenceFactory(scoped_refptr<ThreadSafeSender> sender,
+ int routing_id,
+ int browser_plugin_instance_id)
+ : sender_(sender),
+ routing_id_(routing_id),
+ browser_plugin_instance_id_(browser_plugin_instance_id) {}
+
+ protected:
+ ~BrowserPluginSurfaceReferenceFactory() override = default;
+
+ private:
+ void SatisfySequence(const cc::SurfaceSequence& seq) const override {
+ sender_->Send(new BrowserPluginHostMsg_SatisfySequence(
+ routing_id_, browser_plugin_instance_id_, seq));
+ }
+ void RequireSequence(const cc::SurfaceId& surface_id,
+ const cc::SurfaceSequence& sequence) const override {
+ sender_->Send(new BrowserPluginHostMsg_RequireSequence(
+ routing_id_, browser_plugin_instance_id_, surface_id, sequence));
+ }
+
+ const scoped_refptr<ThreadSafeSender> sender_;
+ const int routing_id_;
+ const int browser_plugin_instance_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(BrowserPluginSurfaceReferenceFactory);
+};
+
+} // namespace
+
ChildFrameCompositingHelper*
ChildFrameCompositingHelper::CreateForBrowserPlugin(
const base::WeakPtr<BrowserPlugin>& browser_plugin) {
@@ -133,46 +195,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 +203,23 @@ 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::SurfaceReferenceFactory> ref_factory;
Fady Samuel 2016/12/12 23:35:46 What if ChildFrameCompositingHelper has-a SurfaceR
+ if (render_frame_proxy_) {
+ ref_factory = new IframeSurfaceReferenceFactory(sender, host_routing_id_);
+ } else {
+ ref_factory = new BrowserPluginSurfaceReferenceFactory(
+ sender, host_routing_id_,
+ browser_plugin_->browser_plugin_instance_id());
+ }
scoped_refptr<cc::SurfaceLayer> surface_layer =
- cc::SurfaceLayer::Create(satisfy_callback, require_callback);
+ cc::SurfaceLayer::Create(std::move(ref_factory));
// 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);
+ surface_layer->SetSurfaceInfo(info);
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