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 <memory> | 8 #include <memory> |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "cc/surfaces/surface_id.h" | 11 #include "cc/surfaces/surface_id.h" |
12 #include "cc/surfaces/surface_reference_factory.h" | 12 #include "cc/surfaces/surface_reference_factory.h" |
13 #include "mojo/public/cpp/bindings/binding.h" | 13 #include "mojo/public/cpp/bindings/binding.h" |
14 #include "platform/PlatformExport.h" | 14 #include "platform/PlatformExport.h" |
| 15 #include "platform/graphics/SurfaceLayerBridge.h" |
| 16 #include "public/platform/WebSurfaceLayerBridgeObserver.h" |
15 #include "public/platform/modules/offscreencanvas/offscreen_canvas_surface.mojom
-blink.h" | 17 #include "public/platform/modules/offscreencanvas/offscreen_canvas_surface.mojom
-blink.h" |
16 | 18 |
17 namespace cc { | 19 namespace cc { |
18 class Layer; | 20 class Layer; |
19 class SurfaceInfo; | 21 class SurfaceInfo; |
20 } // namespace cc | 22 } // namespace cc |
21 | 23 |
22 namespace blink { | 24 namespace blink { |
23 | 25 |
24 class WebLayer; | 26 class WebLayer; |
25 class WebLayerTreeView; | 27 class WebLayerTreeView; |
26 | 28 |
27 class PLATFORM_EXPORT CanvasSurfaceLayerBridgeObserver { | 29 class PLATFORM_EXPORT CanvasSurfaceLayerBridge |
| 30 : public NON_EXPORTED_BASE(SurfaceLayerBridge) { |
28 public: | 31 public: |
29 CanvasSurfaceLayerBridgeObserver() {} | 32 explicit CanvasSurfaceLayerBridge(WebSurfaceLayerBridgeObserver*, |
30 virtual ~CanvasSurfaceLayerBridgeObserver() {} | |
31 | |
32 virtual void OnWebLayerReplaced() = 0; | |
33 }; | |
34 | |
35 class PLATFORM_EXPORT CanvasSurfaceLayerBridge | |
36 : NON_EXPORTED_BASE( | |
37 public blink::mojom::blink::OffscreenCanvasSurfaceClient) { | |
38 public: | |
39 explicit CanvasSurfaceLayerBridge(CanvasSurfaceLayerBridgeObserver*, | |
40 WebLayerTreeView*); | 33 WebLayerTreeView*); |
41 ~CanvasSurfaceLayerBridge(); | 34 ~CanvasSurfaceLayerBridge(); |
42 void CreateSolidColorLayer(); | 35 |
43 WebLayer* GetWebLayer() const { return web_layer_.get(); } | 36 // Implementation of SurfaceLayerBridge. |
44 const cc::FrameSinkId& GetFrameSinkId() const { return frame_sink_id_; } | 37 void CreateSolidColorLayer() override; |
| 38 void SatisfyCallback(const cc::SurfaceSequence&) override; |
| 39 void RequireCallback(const cc::SurfaceId&, |
| 40 const cc::SurfaceSequence&) override; |
45 | 41 |
46 // Implementation of blink::mojom::blink::OffscreenCanvasSurfaceClient | 42 // Implementation of blink::mojom::blink::OffscreenCanvasSurfaceClient |
47 void OnSurfaceCreated(const cc::SurfaceInfo&) override; | 43 void OnSurfaceCreated(const cc::SurfaceInfo&) override; |
48 | 44 |
49 void SatisfyCallback(const cc::SurfaceSequence&); | 45 WebLayer* GetWebLayer() const { return web_layer_.get(); } |
50 void RequireCallback(const cc::SurfaceId&, const cc::SurfaceSequence&); | 46 const cc::FrameSinkId& GetFrameSinkId() const { return frame_sink_id_; } |
51 | 47 |
52 private: | 48 private: |
53 scoped_refptr<cc::Layer> cc_layer_; | 49 scoped_refptr<cc::Layer> cc_layer_; |
54 std::unique_ptr<WebLayer> web_layer_; | 50 std::unique_ptr<WebLayer> web_layer_; |
55 | 51 |
56 scoped_refptr<cc::SurfaceReferenceFactory> ref_factory_; | 52 scoped_refptr<cc::SurfaceReferenceFactory> ref_factory_; |
57 base::WeakPtrFactory<CanvasSurfaceLayerBridge> weak_factory_; | 53 base::WeakPtrFactory<CanvasSurfaceLayerBridge> weak_factory_; |
58 | 54 |
59 CanvasSurfaceLayerBridgeObserver* observer_; | 55 WebSurfaceLayerBridgeObserver* observer_; |
60 | 56 |
61 mojom::blink::OffscreenCanvasSurfacePtr service_; | 57 mojom::blink::OffscreenCanvasSurfacePtr service_; |
62 mojo::Binding<blink::mojom::blink::OffscreenCanvasSurfaceClient> binding_; | 58 mojo::Binding<blink::mojom::blink::OffscreenCanvasSurfaceClient> binding_; |
63 | 59 |
64 const cc::FrameSinkId frame_sink_id_; | 60 const cc::FrameSinkId frame_sink_id_; |
65 cc::SurfaceId current_surface_id_; | 61 cc::SurfaceId current_surface_id_; |
66 const cc::FrameSinkId parent_frame_sink_id_; | 62 const cc::FrameSinkId parent_frame_sink_id_; |
67 }; | 63 }; |
68 | 64 |
69 } // namespace blink | 65 } // namespace blink |
70 | 66 |
71 #endif // CanvasSurfaceLayerBridge_h | 67 #endif // CanvasSurfaceLayerBridge_h |
OLD | NEW |