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