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 | 17 |
13 namespace blink { | 18 namespace blink { |
14 | 19 |
15 CanvasSurfaceLayerBridge::CanvasSurfaceLayerBridge() | 20 CanvasSurfaceLayerBridge::CanvasSurfaceLayerBridge(PassOwnPtr<CanvasSurfaceLayer
BridgeClient> client) |
16 { | 21 { |
17 m_solidColorLayer = cc::SolidColorLayer::Create(); | 22 m_client = std::move(client); |
18 m_solidColorLayer->SetBackgroundColor(SK_ColorBLUE); | |
19 m_webLayer = adoptPtr(Platform::current()->compositorSupport()->createLayerF
romCCLayer(m_solidColorLayer.get())); | |
20 GraphicsLayer::registerContentsLayer(m_webLayer.get()); | |
21 } | 23 } |
22 | 24 |
23 CanvasSurfaceLayerBridge::~CanvasSurfaceLayerBridge() | 25 CanvasSurfaceLayerBridge::~CanvasSurfaceLayerBridge() |
24 { | 26 { |
25 } | 27 } |
26 | 28 |
| 29 bool CanvasSurfaceLayerBridge::createSurfaceLayer(int canvasWidth, int canvasHei
ght) |
| 30 { |
| 31 if (!m_client->syncGetSurfaceId(&m_surfaceId)) |
| 32 return false; |
| 33 |
| 34 m_client->asyncRequestSurfaceCreation(m_surfaceId); |
| 35 cc::SurfaceLayer::SatisfyCallback satisfyCallback = createBaseCallback(bind<
cc::SurfaceSequence>(&CanvasSurfaceLayerBridge::satisfyCallback, this)); |
| 36 cc::SurfaceLayer::RequireCallback requireCallback = createBaseCallback(bind<
cc::SurfaceId, cc::SurfaceSequence>(&CanvasSurfaceLayerBridge::requireCallback,
this)); |
| 37 m_surfaceLayer = cc::SurfaceLayer::Create(std::move(satisfyCallback), std::m
ove(requireCallback)); |
| 38 m_surfaceLayer->SetSurfaceId(m_surfaceId, 1.f, gfx::Size(canvasWidth, canvas
Height)); |
| 39 |
| 40 m_webLayer = adoptPtr(Platform::current()->compositorSupport()->createLayerF
romCCLayer(m_surfaceLayer.get())); |
| 41 GraphicsLayer::registerContentsLayer(m_webLayer.get()); |
| 42 return true; |
27 } | 43 } |
| 44 |
| 45 void CanvasSurfaceLayerBridge::satisfyCallback(cc::SurfaceSequence sequence) |
| 46 { |
| 47 m_client->asyncSatisfy(sequence); |
| 48 } |
| 49 |
| 50 void CanvasSurfaceLayerBridge::requireCallback(cc::SurfaceId surfaceId, cc::Surf
aceSequence sequence) |
| 51 { |
| 52 m_client->asyncRequire(surfaceId, sequence); |
| 53 } |
| 54 |
| 55 } // namespace blink |
OLD | NEW |