| 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/ipc/display_compositor.mojom-blink.h" | 11 #include "cc/ipc/frame_sink_manager.mojom-blink.h" |
| 12 #include "cc/surfaces/surface_id.h" | 12 #include "cc/surfaces/surface_id.h" |
| 13 #include "cc/surfaces/surface_reference_factory.h" | 13 #include "cc/surfaces/surface_reference_factory.h" |
| 14 #include "mojo/public/cpp/bindings/binding.h" | 14 #include "mojo/public/cpp/bindings/binding.h" |
| 15 #include "platform/PlatformExport.h" | 15 #include "platform/PlatformExport.h" |
| 16 #include "public/platform/modules/offscreencanvas/offscreen_canvas_surface.mojom
-blink.h" | 16 #include "public/platform/modules/offscreencanvas/offscreen_canvas_surface.mojom
-blink.h" |
| 17 | 17 |
| 18 namespace cc { | 18 namespace cc { |
| 19 class Layer; | 19 class Layer; |
| 20 class SurfaceInfo; | 20 class SurfaceInfo; |
| 21 } // namespace cc | 21 } // namespace cc |
| 22 | 22 |
| 23 namespace blink { | 23 namespace blink { |
| 24 | 24 |
| 25 class WebLayer; | 25 class WebLayer; |
| 26 class WebLayerTreeView; | 26 class WebLayerTreeView; |
| 27 | 27 |
| 28 class PLATFORM_EXPORT CanvasSurfaceLayerBridgeObserver { | 28 class PLATFORM_EXPORT CanvasSurfaceLayerBridgeObserver { |
| 29 public: | 29 public: |
| 30 CanvasSurfaceLayerBridgeObserver() {} | 30 CanvasSurfaceLayerBridgeObserver() {} |
| 31 virtual ~CanvasSurfaceLayerBridgeObserver() {} | 31 virtual ~CanvasSurfaceLayerBridgeObserver() {} |
| 32 | 32 |
| 33 virtual void OnWebLayerReplaced() = 0; | 33 virtual void OnWebLayerReplaced() = 0; |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 class PLATFORM_EXPORT CanvasSurfaceLayerBridge | 36 class PLATFORM_EXPORT CanvasSurfaceLayerBridge |
| 37 : NON_EXPORTED_BASE(public cc::mojom::blink::DisplayCompositorClient) { | 37 : NON_EXPORTED_BASE(public cc::mojom::blink::FrameSinkManagerClient) { |
| 38 public: | 38 public: |
| 39 explicit CanvasSurfaceLayerBridge(CanvasSurfaceLayerBridgeObserver*, | 39 explicit CanvasSurfaceLayerBridge(CanvasSurfaceLayerBridgeObserver*, |
| 40 WebLayerTreeView*); | 40 WebLayerTreeView*); |
| 41 ~CanvasSurfaceLayerBridge(); | 41 ~CanvasSurfaceLayerBridge(); |
| 42 void createSolidColorLayer(); | 42 void createSolidColorLayer(); |
| 43 WebLayer* getWebLayer() const { return m_webLayer.get(); } | 43 WebLayer* getWebLayer() const { return m_webLayer.get(); } |
| 44 const cc::FrameSinkId& getFrameSinkId() const { return m_frameSinkId; } | 44 const cc::FrameSinkId& getFrameSinkId() const { return m_frameSinkId; } |
| 45 | 45 |
| 46 // Implementation of cc::mojom::blink::DisplayCompositorClient | 46 // Implementation of cc::mojom::blink::FrameSinkManagerClient |
| 47 void OnSurfaceCreated(const cc::SurfaceInfo&) override; | 47 void OnSurfaceCreated(const cc::SurfaceInfo&) override; |
| 48 | 48 |
| 49 void satisfyCallback(const cc::SurfaceSequence&); | 49 void satisfyCallback(const cc::SurfaceSequence&); |
| 50 void requireCallback(const cc::SurfaceId&, const cc::SurfaceSequence&); | 50 void requireCallback(const cc::SurfaceId&, const cc::SurfaceSequence&); |
| 51 | 51 |
| 52 private: | 52 private: |
| 53 scoped_refptr<cc::Layer> m_CCLayer; | 53 scoped_refptr<cc::Layer> m_CCLayer; |
| 54 std::unique_ptr<WebLayer> m_webLayer; | 54 std::unique_ptr<WebLayer> m_webLayer; |
| 55 | 55 |
| 56 scoped_refptr<cc::SurfaceReferenceFactory> m_refFactory; | 56 scoped_refptr<cc::SurfaceReferenceFactory> m_refFactory; |
| 57 base::WeakPtrFactory<CanvasSurfaceLayerBridge> m_weakFactory; | 57 base::WeakPtrFactory<CanvasSurfaceLayerBridge> m_weakFactory; |
| 58 | 58 |
| 59 CanvasSurfaceLayerBridgeObserver* m_observer; | 59 CanvasSurfaceLayerBridgeObserver* m_observer; |
| 60 | 60 |
| 61 mojom::blink::OffscreenCanvasSurfacePtr m_service; | 61 mojom::blink::OffscreenCanvasSurfacePtr m_service; |
| 62 mojo::Binding<cc::mojom::blink::DisplayCompositorClient> m_binding; | 62 mojo::Binding<cc::mojom::blink::FrameSinkManagerClient> m_binding; |
| 63 | 63 |
| 64 const cc::FrameSinkId m_frameSinkId; | 64 const cc::FrameSinkId m_frameSinkId; |
| 65 cc::SurfaceId m_currentSurfaceId; | 65 cc::SurfaceId m_currentSurfaceId; |
| 66 const cc::FrameSinkId m_parentFrameSinkId; | 66 const cc::FrameSinkId m_parentFrameSinkId; |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 } // namespace blink | 69 } // namespace blink |
| 70 | 70 |
| 71 #endif // CanvasSurfaceLayerBridge_h | 71 #endif // CanvasSurfaceLayerBridge_h |
| OLD | NEW |