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 b13d9ad7c36c2260ff386af7f2fdae63c4b4564e..029dc1d7a8ecb4e1c796cf3e4cf2792bc97eb404 100644 |
| --- a/third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridge.cpp |
| +++ b/third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridge.cpp |
| @@ -4,24 +4,53 @@ |
| #include "platform/graphics/CanvasSurfaceLayerBridge.h" |
| -#include "cc/layers/solid_color_layer.h" |
| +#include "cc/layers/surface_layer.h" |
| +#include "cc/surfaces/surface_id.h" |
| +#include "cc/surfaces/surface_sequence.h" |
| #include "platform/graphics/GraphicsLayer.h" |
| +#include "platform/mojo/MojoHelper.h" |
| #include "public/platform/Platform.h" |
| #include "public/platform/WebCompositorSupport.h" |
| #include "public/platform/WebLayer.h" |
| +#include "ui/gfx/geometry/size.h" |
| +#include "wtf/Functional.h" |
| namespace blink { |
| -CanvasSurfaceLayerBridge::CanvasSurfaceLayerBridge() |
| +CanvasSurfaceLayerBridge::CanvasSurfaceLayerBridge(PassOwnPtr<CanvasSurfaceLayerBridgeClient> client) |
| { |
| - m_solidColorLayer = cc::SolidColorLayer::Create(); |
| - m_solidColorLayer->SetBackgroundColor(SK_ColorBLUE); |
| - m_webLayer = adoptPtr(Platform::current()->compositorSupport()->createLayerFromCCLayer(m_solidColorLayer.get())); |
| - GraphicsLayer::registerContentsLayer(m_webLayer.get()); |
| + m_client = std::move(client); |
| } |
| CanvasSurfaceLayerBridge::~CanvasSurfaceLayerBridge() |
| { |
| + m_client.reset(); |
|
jbroman
2016/06/16 21:11:48
OwnPtrs should be automatically deleted. If this r
xlai (Olivia)
2016/06/16 23:16:21
Done.
|
| +} |
| + |
| +bool CanvasSurfaceLayerBridge::createSurfaceLayer(int canvasWidth, int canvasHeight) |
| +{ |
| + if (!m_client->syncGetSurfaceId(&m_surfaceId)) |
| + return false; |
| + |
| + m_client->asyncRequestSurfaceCreation(m_surfaceId); |
| + cc::SurfaceLayer::SatisfyCallback satisfyCallback = createBaseCallback(bind<cc::SurfaceSequence>(&CanvasSurfaceLayerBridge::satisfyCallback, this)); |
| + cc::SurfaceLayer::RequireCallback requireCallback = createBaseCallback(bind<cc::SurfaceId, cc::SurfaceSequence>(&CanvasSurfaceLayerBridge::requireCallback, this)); |
| + m_surfaceLayer = cc::SurfaceLayer::Create(std::move(satisfyCallback), std::move(requireCallback)); |
| + m_surfaceLayer->SetSurfaceId(m_surfaceId, 1.f, gfx::Size(canvasWidth, canvasHeight)); |
| + |
| + m_webLayer = adoptPtr(Platform::current()->compositorSupport()->createLayerFromCCLayer(m_surfaceLayer.get())); |
| + GraphicsLayer::registerContentsLayer(m_webLayer.get()); |
| + return true; |
| +} |
| + |
| +void CanvasSurfaceLayerBridge::satisfyCallback(cc::SurfaceSequence sequence) |
| +{ |
| + m_client->asyncSatisfy(sequence); |
| } |
| +void CanvasSurfaceLayerBridge::requireCallback(cc::SurfaceId surfaceId, cc::SurfaceSequence sequence) |
| +{ |
| + m_client->asyncRequire(surfaceId, sequence); |
| } |
| + |
| +} // namespace blink |