| 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..e84f08bc78d18c0a206cc554b60e39713a552f5d 100644
|
| --- a/third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridge.cpp
|
| +++ b/third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridge.cpp
|
| @@ -19,29 +19,20 @@ namespace blink {
|
|
|
| CanvasSurfaceLayerBridge::CanvasSurfaceLayerBridge(
|
| mojom::blink::OffscreenCanvasSurfacePtr service)
|
| - : m_service(std::move(service)) {}
|
| + : m_service(std::move(service)), m_binding(this) {}
|
|
|
| CanvasSurfaceLayerBridge::~CanvasSurfaceLayerBridge() {}
|
|
|
| bool CanvasSurfaceLayerBridge::createSurfaceLayer(int canvasWidth,
|
| int canvasHeight) {
|
| - if (!m_service->GetSurfaceId(&m_surfaceId))
|
| + if (!m_service->GetSurfaceId(m_binding.CreateInterfacePtrAndBind(),
|
| + &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));
|
| -
|
| + createNewSurfaceLayer(m_surfaceId, gfx::Size(canvasWidth, canvasHeight));
|
| m_webLayer = Platform::current()->compositorSupport()->createLayerFromCCLayer(
|
| m_surfaceLayer.get());
|
| GraphicsLayer::registerContentsLayer(m_webLayer.get());
|
| +
|
| return true;
|
| }
|
|
|
| @@ -56,4 +47,32 @@ void CanvasSurfaceLayerBridge::requireCallback(
|
| m_service->Require(surfaceId, sequence);
|
| }
|
|
|
| +void CanvasSurfaceLayerBridge::OnSurfaceSizeChanged(
|
| + const cc::SurfaceId& newSurfaceId,
|
| + uint32_t newWidth,
|
| + uint32_t newHeight) {
|
| + if (m_surfaceLayer && m_surfaceLayer->surface_id() != newSurfaceId) {
|
| + GraphicsLayer::unregisterContentsLayer(m_webLayer.get());
|
| + createNewSurfaceLayer(newSurfaceId, gfx::Size(newWidth, newHeight));
|
| + m_webLayer =
|
| + Platform::current()->compositorSupport()->createLayerFromCCLayer(
|
| + m_surfaceLayer.get());
|
| + GraphicsLayer::registerContentsLayer(m_webLayer.get());
|
| + }
|
| +}
|
| +
|
| +void CanvasSurfaceLayerBridge::createNewSurfaceLayer(
|
| + const cc::SurfaceId& surfaceId,
|
| + gfx::Size size) {
|
| + 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, size);
|
| +}
|
| +
|
| } // namespace blink
|
|
|