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

Unified Diff: third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridge.cpp

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: third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridge.cpp
diff --git a/third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridge.cpp b/third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridge.cpp
index 4355caed2a27dd712a886705e5bd9e97539d3cf5..42b0f070b4e5f1e84bfaf235102cbd0b97910c17 100644
--- a/third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridge.cpp
+++ b/third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridge.cpp
@@ -5,7 +5,9 @@
#include "platform/graphics/CanvasSurfaceLayerBridge.h"
#include "cc/layers/surface_layer.h"
+#include "cc/surfaces/sequence_surface_reference_factory.h"
#include "cc/surfaces/surface_id.h"
+#include "cc/surfaces/surface_info.h"
#include "cc/surfaces/surface_sequence.h"
#include "platform/graphics/GraphicsLayer.h"
#include "platform/mojo/MojoHelper.h"
@@ -17,9 +19,37 @@
namespace blink {
+namespace {
+
+class OffscreenCanvasSurfaceReferenceFactory
+ : public cc::SequenceSurfaceReferenceFactory {
+ public:
+ OffscreenCanvasSurfaceReferenceFactory(
+ const mojom::blink::OffscreenCanvasSurfacePtr& m_service)
+ : m_service(m_service) {}
Fady Samuel 2016/12/13 22:55:06 nit: new line.
Saman Sami 2016/12/14 17:50:02 Done.
+ void RequireSequence(const cc::SurfaceId& id,
+ const cc::SurfaceSequence& sequence) const override {
+ m_service->Require(id, sequence);
+ }
Fady Samuel 2016/12/13 22:55:06 nit: new line
Saman Sami 2016/12/14 17:50:02 Done.
+ void SatisfySequence(const cc::SurfaceSequence& sequence) const override {
+ m_service->Satisfy(sequence);
+ }
+
+ protected:
+ ~OffscreenCanvasSurfaceReferenceFactory() override = default;
+
+ private:
+ const mojom::blink::OffscreenCanvasSurfacePtr& m_service;
Fady Samuel 2016/12/13 22:55:06 This isn't safe because OffscreenCanvasSurfaceRefe
Saman Sami 2016/12/14 17:50:02 Will do in a future patch.
+
+ DISALLOW_COPY_AND_ASSIGN(OffscreenCanvasSurfaceReferenceFactory);
+};
+
+} // namespace
+
CanvasSurfaceLayerBridge::CanvasSurfaceLayerBridge(
mojom::blink::OffscreenCanvasSurfacePtr service)
- : m_service(std::move(service)) {}
+ : m_service(std::move(service)),
+ m_refFactory(new OffscreenCanvasSurfaceReferenceFactory(m_service)) {}
CanvasSurfaceLayerBridge::~CanvasSurfaceLayerBridge() {}
@@ -28,16 +58,9 @@ bool CanvasSurfaceLayerBridge::createSurfaceLayer(int canvasWidth,
if (!m_service->GetSurfaceId(&m_surfaceId))
return false;
- cc::SurfaceLayer::SatisfyCallback satisfyCallback =
- convertToBaseCallback(WTF::bind(
- &CanvasSurfaceLayerBridge::satisfyCallback, WTF::unretained(this)));
- cc::SurfaceLayer::RequireCallback requireCallback =
- convertToBaseCallback(WTF::bind(
- &CanvasSurfaceLayerBridge::requireCallback, WTF::unretained(this)));
- m_surfaceLayer = cc::SurfaceLayer::Create(std::move(satisfyCallback),
- std::move(requireCallback));
- m_surfaceLayer->SetSurfaceId(m_surfaceId, 1.f,
- gfx::Size(canvasWidth, canvasHeight));
+ m_surfaceLayer = cc::SurfaceLayer::Create(m_refFactory);
+ cc::SurfaceInfo info(m_surfaceId, 1.f, gfx::Size(canvasWidth, canvasHeight));
+ m_surfaceLayer->SetSurfaceInfo(info);
m_webLayer = Platform::current()->compositorSupport()->createLayerFromCCLayer(
m_surfaceLayer.get());
@@ -45,15 +68,4 @@ bool CanvasSurfaceLayerBridge::createSurfaceLayer(int canvasWidth,
return true;
}
-void CanvasSurfaceLayerBridge::satisfyCallback(
- const cc::SurfaceSequence& sequence) {
- m_service->Satisfy(sequence);
-}
-
-void CanvasSurfaceLayerBridge::requireCallback(
- const cc::SurfaceId& surfaceId,
- const cc::SurfaceSequence& sequence) {
- m_service->Require(surfaceId, sequence);
-}
-
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698