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

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..51f080a14726755b02cf8de1b81eba149b19897f 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:
Fady Samuel 2016/12/13 22:55:06 Can you mark this as private?
Saman Sami 2016/12/14 17:50:02 Done.
+ ~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));
+ }
Fady Samuel 2016/12/13 22:55:05 nit: leave blank line.
Saman Sami 2016/12/14 17:50:02 Done.
+ 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:
Fady Samuel 2016/12/13 22:55:05 Mark it as private?
Saman Sami 2016/12/14 17:50:02 Done.
+ ~BrowserPluginSurfaceReferenceFactory() override = default;
+
+ private:
+ void SatisfySequence(const cc::SurfaceSequence& seq) const override {
+ sender_->Send(new BrowserPluginHostMsg_SatisfySequence(
+ routing_id_, browser_plugin_instance_id_, seq));
+ }
Fady Samuel 2016/12/13 22:55:05 nit: leave blank line.
Saman Sami 2016/12/14 17:50:02 Done.
+ 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_;
Fady Samuel 2016/12/13 22:55:06 Weird to make a scoped_refptr const.
Saman Sami 2016/12/14 17:50:02 Done.
+ 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) {
@@ -62,7 +124,18 @@ ChildFrameCompositingHelper::ChildFrameCompositingHelper(
: host_routing_id_(host_routing_id),
browser_plugin_(browser_plugin),
render_frame_proxy_(render_frame_proxy),
- frame_(frame) {}
+ frame_(frame) {
+ scoped_refptr<ThreadSafeSender> sender(
+ RenderThreadImpl::current()->thread_safe_sender());
+ if (render_frame_proxy_) {
+ surface_reference_factory_ =
+ new IframeSurfaceReferenceFactory(sender, host_routing_id_);
+ } else {
+ surface_reference_factory_ = new BrowserPluginSurfaceReferenceFactory(
+ sender, host_routing_id_,
+ browser_plugin_->browser_plugin_instance_id());
+ }
+}
ChildFrameCompositingHelper::~ChildFrameCompositingHelper() {
}
@@ -133,79 +206,21 @@ 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,
float scale_factor,
const cc::SurfaceSequence& sequence) {
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);
+ cc::SurfaceLayer::Create(surface_reference_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