Chromium Code Reviews| 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..c967505e5f3b2337b7234467e0473e9e7f15d4fd 100644 |
| --- a/third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridge.cpp |
| +++ b/third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridge.cpp |
| @@ -5,6 +5,7 @@ |
| #include "platform/graphics/CanvasSurfaceLayerBridge.h" |
| #include "cc/layers/surface_layer.h" |
| +#include "cc/surfaces/surface_embedding.h" |
| #include "cc/surfaces/surface_id.h" |
| #include "cc/surfaces/surface_sequence.h" |
| #include "platform/graphics/GraphicsLayer.h" |
| @@ -17,6 +18,27 @@ |
| namespace blink { |
| +namespace { |
| + |
| +class SurfaceEmbedding : public cc::SurfaceEmbeddingUsingSequence { |
|
Fady Samuel
2016/12/07 23:29:05
OffscreenCanvasSurfaceEmbedding
|
| + public: |
| + SurfaceEmbedding(cc::SurfaceInfo info, |
|
Fady Samuel
2016/12/07 23:29:05
const cc::SurfaceInfo& info
|
| + const mojom::blink::OffscreenCanvasSurfacePtr& m_service) |
| + : cc::SurfaceEmbeddingUsingSequence(info), m_service(m_service) {} |
| + void RequireSequence(const cc::SurfaceSequence& seq) override { |
| + m_service->Require(id(), seq); |
| + } |
| + void SatisfySequence(const cc::SurfaceSequence& seq) override { |
| + m_service->Satisfy(seq); |
| + } |
| + |
| + private: |
| + SurfaceEmbedding* CloneImpl() override { return new SurfaceEmbedding(*this); } |
| + const mojom::blink::OffscreenCanvasSurfacePtr& m_service; |
| +}; |
| + |
| +} // namespace |
| + |
| CanvasSurfaceLayerBridge::CanvasSurfaceLayerBridge( |
| mojom::blink::OffscreenCanvasSurfacePtr service) |
| : m_service(std::move(service)) {} |
| @@ -28,16 +50,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)); |
| + cc::SurfaceInfo info(m_surfaceId, 1.f, gfx::Size(canvasWidth, canvasHeight)); |
| + cc::SurfaceEmbeddingPtr ref(new SurfaceEmbedding(info, m_service)); |
| + m_surfaceLayer = cc::SurfaceLayer::Create(std::move(ref)); |
| m_webLayer = Platform::current()->compositorSupport()->createLayerFromCCLayer( |
| m_surfaceLayer.get()); |
| @@ -45,15 +60,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 |