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