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