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