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 #ifndef CanvasSurfaceLayerBridge_h | 5 #ifndef CanvasSurfaceLayerBridge_h |
6 #define CanvasSurfaceLayerBridge_h | 6 #define CanvasSurfaceLayerBridge_h |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "cc/surfaces/surface_id.h" | 9 #include "cc/surfaces/surface_id.h" |
| 10 #include "mojo/public/cpp/bindings/binding.h" |
10 #include "platform/PlatformExport.h" | 11 #include "platform/PlatformExport.h" |
11 #include "public/platform/modules/offscreencanvas/offscreen_canvas_surface.mojom
-blink.h" | 12 #include "public/platform/modules/offscreencanvas/offscreen_canvas_surface.mojom
-blink.h" |
12 #include <memory> | 13 #include <memory> |
13 | 14 |
14 namespace cc { | 15 namespace cc { |
| 16 class SolidColorLayer; |
15 class SurfaceLayer; | 17 class SurfaceLayer; |
16 struct SurfaceSequence; | 18 struct SurfaceSequence; |
17 } // namespace cc | 19 } // namespace cc |
18 | 20 |
19 namespace blink { | 21 namespace blink { |
20 | 22 |
21 class WebLayer; | 23 class WebLayer; |
22 | 24 |
23 class PLATFORM_EXPORT CanvasSurfaceLayerBridge { | 25 class PLATFORM_EXPORT CanvasSurfaceLayerBridgeObserver { |
24 public: | 26 public: |
25 explicit CanvasSurfaceLayerBridge(mojom::blink::OffscreenCanvasSurfacePtr); | 27 CanvasSurfaceLayerBridgeObserver() {} |
| 28 virtual ~CanvasSurfaceLayerBridgeObserver() {} |
| 29 |
| 30 virtual void OnWebLayerReplaced() = 0; |
| 31 }; |
| 32 |
| 33 class PLATFORM_EXPORT CanvasSurfaceLayerBridge |
| 34 : NON_EXPORTED_BASE(public mojom::blink::OffscreenCanvasSurfaceClient) { |
| 35 public: |
| 36 explicit CanvasSurfaceLayerBridge(CanvasSurfaceLayerBridgeObserver*); |
26 ~CanvasSurfaceLayerBridge(); | 37 ~CanvasSurfaceLayerBridge(); |
27 bool createSurfaceLayer(int canvasWidth, int canvasHeight); | 38 void createSolidColorLayer(); |
28 WebLayer* getWebLayer() const { return m_webLayer.get(); } | 39 WebLayer* getWebLayer() const { return m_webLayer.get(); } |
29 const cc::SurfaceId& getSurfaceId() const { return m_surfaceId; } | 40 const cc::FrameSinkId& getFrameSinkId() const { return m_frameSinkId; } |
| 41 |
| 42 // Implementation of mojom::blink::OffscreenCanvasSurfaceClient |
| 43 void OnSurfaceCreated(const cc::SurfaceId&, |
| 44 int32_t width, |
| 45 int32_t height, |
| 46 float deviceScaleFactor) override; |
30 | 47 |
31 void satisfyCallback(const cc::SurfaceSequence&); | 48 void satisfyCallback(const cc::SurfaceSequence&); |
32 void requireCallback(const cc::SurfaceId&, const cc::SurfaceSequence&); | 49 void requireCallback(const cc::SurfaceId&, const cc::SurfaceSequence&); |
33 | 50 |
34 private: | 51 private: |
35 scoped_refptr<cc::SurfaceLayer> m_surfaceLayer; | 52 scoped_refptr<cc::SurfaceLayer> m_surfaceLayer; |
| 53 scoped_refptr<cc::SolidColorLayer> m_solidColorLayer; |
36 std::unique_ptr<WebLayer> m_webLayer; | 54 std::unique_ptr<WebLayer> m_webLayer; |
| 55 |
| 56 CanvasSurfaceLayerBridgeObserver* m_observer; |
| 57 |
37 mojom::blink::OffscreenCanvasSurfacePtr m_service; | 58 mojom::blink::OffscreenCanvasSurfacePtr m_service; |
38 cc::SurfaceId m_surfaceId; | 59 mojo::Binding<mojom::blink::OffscreenCanvasSurfaceClient> m_binding; |
| 60 |
| 61 cc::FrameSinkId m_frameSinkId; |
| 62 cc::SurfaceId m_currentSurfaceId; |
39 }; | 63 }; |
40 | 64 |
41 } // namespace blink | 65 } // namespace blink |
42 | 66 |
43 #endif // CanvasSurfaceLayerBridge_h | 67 #endif // CanvasSurfaceLayerBridge_h |
OLD | NEW |