| 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..ec00cb99338919da6c8dc5d3eaac7c7dd3558258 100644
|
| --- a/third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridge.cpp
|
| +++ b/third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridge.cpp
|
| @@ -4,24 +4,70 @@
|
|
|
| #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/ServiceRegistry.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()
|
| {
|
| - 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());
|
| + DCHECK(!m_service.is_bound());
|
| + Platform::current()->serviceRegistry()->connectToRemoteService(mojo::GetProxy(&m_service));
|
| }
|
|
|
| CanvasSurfaceLayerBridge::~CanvasSurfaceLayerBridge()
|
| {
|
| }
|
|
|
| +bool CanvasSurfaceLayerBridge::createSurfaceLayer(int canvasWidth, int canvasHeight)
|
| +{
|
| + // Get SurfaceId from browser.
|
| + bool success = this->syncGetServiceId();
|
| + if (!success)
|
| + return false;
|
| +
|
| + // Immediately send an Async message to browser to request Surface creation.
|
| + this->asyncRequestSurfaceCreation();
|
| +
|
| + // Create SurfaceLayer.
|
| + const cc::SurfaceLayer::SatisfyCallback& satisfyCallback = createBaseCallback(bind<cc::SurfaceSequence>(&CanvasSurfaceLayerBridge::satisfyCallback, this));
|
| + const cc::SurfaceLayer::RequireCallback& requireCallback = createBaseCallback(bind<cc::SurfaceId, cc::SurfaceSequence>(&CanvasSurfaceLayerBridge::requireCallback, this));
|
| + m_surfaceLayer = cc::SurfaceLayer::Create(satisfyCallback, requireCallback);
|
| + m_surfaceLayer->SetSurfaceId(m_surfaceId, 1.f, gfx::Size(canvasWidth, canvasHeight));
|
| +
|
| + // Convert SurfaceLayer to WebLayer and register it.
|
| + m_webLayer = adoptPtr(Platform::current()->compositorSupport()->createLayerFromCCLayer(m_surfaceLayer.get()));
|
| + GraphicsLayer::registerContentsLayer(m_webLayer.get());
|
| + return true;
|
| +}
|
| +
|
| +void CanvasSurfaceLayerBridge::satisfyCallback(cc::SurfaceSequence sequence)
|
| +{
|
| + m_service->Satisfy(sequence);
|
| }
|
| +
|
| +void CanvasSurfaceLayerBridge::requireCallback(cc::SurfaceId surfaceId, cc::SurfaceSequence sequence)
|
| +{
|
| + m_service->Require(surfaceId, sequence);
|
| +}
|
| +
|
| +bool CanvasSurfaceLayerBridge::syncGetServiceId()
|
| +{
|
| + return m_service->GetSurfaceId(&m_surfaceId);
|
| +}
|
| +
|
| +void CanvasSurfaceLayerBridge::asyncRequestSurfaceCreation()
|
| +{
|
| + m_service->RequestSurfaceCreation(m_surfaceId);
|
| +}
|
| +
|
| +} // namespace blink
|
|
|