OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "platform/graphics/CanvasSurfaceLayerBridge.h" | 5 #include "platform/graphics/CanvasSurfaceLayerBridge.h" |
6 | 6 |
7 #include "cc/layers/solid_color_layer.h" | 7 #include "cc/layers/surface_layer.h" |
| 8 #include "cc/surfaces/surface_id.h" |
| 9 #include "cc/surfaces/surface_sequence.h" |
8 #include "platform/graphics/GraphicsLayer.h" | 10 #include "platform/graphics/GraphicsLayer.h" |
| 11 #include "platform/mojo/MojoHelper.h" |
9 #include "public/platform/Platform.h" | 12 #include "public/platform/Platform.h" |
10 #include "public/platform/WebCompositorSupport.h" | 13 #include "public/platform/WebCompositorSupport.h" |
11 #include "public/platform/WebLayer.h" | 14 #include "public/platform/WebLayer.h" |
| 15 #include "ui/gfx/geometry/size.h" |
| 16 #include "wtf/Functional.h" |
12 #include "wtf/PtrUtil.h" | 17 #include "wtf/PtrUtil.h" |
13 | 18 |
14 namespace blink { | 19 namespace blink { |
15 | 20 |
16 CanvasSurfaceLayerBridge::CanvasSurfaceLayerBridge() | 21 CanvasSurfaceLayerBridge::CanvasSurfaceLayerBridge(std::unique_ptr<CanvasSurface
LayerBridgeClient> client) |
17 { | 22 { |
18 m_solidColorLayer = cc::SolidColorLayer::Create(); | 23 m_client = std::move(client); |
19 m_solidColorLayer->SetBackgroundColor(SK_ColorBLUE); | |
20 m_webLayer = wrapUnique(Platform::current()->compositorSupport()->createLaye
rFromCCLayer(m_solidColorLayer.get())); | |
21 GraphicsLayer::registerContentsLayer(m_webLayer.get()); | |
22 } | 24 } |
23 | 25 |
24 CanvasSurfaceLayerBridge::~CanvasSurfaceLayerBridge() | 26 CanvasSurfaceLayerBridge::~CanvasSurfaceLayerBridge() |
25 { | 27 { |
26 } | 28 } |
27 | 29 |
| 30 bool CanvasSurfaceLayerBridge::createSurfaceLayer(int canvasWidth, int canvasHei
ght) |
| 31 { |
| 32 if (!m_client->syncGetSurfaceId(&m_surfaceId)) |
| 33 return false; |
| 34 |
| 35 m_client->asyncRequestSurfaceCreation(m_surfaceId); |
| 36 cc::SurfaceLayer::SatisfyCallback satisfyCallback = createBaseCallback(bind<
cc::SurfaceSequence>(&CanvasSurfaceLayerBridge::satisfyCallback, this)); |
| 37 cc::SurfaceLayer::RequireCallback requireCallback = createBaseCallback(bind<
cc::SurfaceId, cc::SurfaceSequence>(&CanvasSurfaceLayerBridge::requireCallback,
this)); |
| 38 m_surfaceLayer = cc::SurfaceLayer::Create(std::move(satisfyCallback), std::m
ove(requireCallback)); |
| 39 m_surfaceLayer->SetSurfaceId(m_surfaceId, 1.f, gfx::Size(canvasWidth, canvas
Height)); |
| 40 |
| 41 m_webLayer = wrapUnique(Platform::current()->compositorSupport()->createLaye
rFromCCLayer(m_surfaceLayer.get())); |
| 42 GraphicsLayer::registerContentsLayer(m_webLayer.get()); |
| 43 return true; |
28 } | 44 } |
| 45 |
| 46 void CanvasSurfaceLayerBridge::satisfyCallback(cc::SurfaceSequence sequence) |
| 47 { |
| 48 m_client->asyncSatisfy(sequence); |
| 49 } |
| 50 |
| 51 void CanvasSurfaceLayerBridge::requireCallback(cc::SurfaceId surfaceId, cc::Surf
aceSequence sequence) |
| 52 { |
| 53 m_client->asyncRequire(surfaceId, sequence); |
| 54 } |
| 55 |
| 56 } // namespace blink |
OLD | NEW |