Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridge.h

Issue 2584643002: Revamp OffscreenCanvas commit flow (Closed)
Patch Set: rebase and fix conflict Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/memory/weak_ptr.h" 9 #include "base/memory/weak_ptr.h"
10 #include "cc/surfaces/surface_id.h" 10 #include "cc/surfaces/surface_id.h"
11 #include "cc/surfaces/surface_reference_factory.h" 11 #include "cc/surfaces/surface_reference_factory.h"
12 #include "mojo/public/cpp/bindings/binding.h"
12 #include "platform/PlatformExport.h" 13 #include "platform/PlatformExport.h"
13 #include "public/platform/modules/offscreencanvas/offscreen_canvas_surface.mojom -blink.h" 14 #include "public/platform/modules/offscreencanvas/offscreen_canvas_surface.mojom -blink.h"
14 #include <memory> 15 #include <memory>
15 16
16 namespace cc { 17 namespace cc {
17 class SurfaceLayer; 18 class Layer;
18 } // namespace cc 19 } // namespace cc
19 20
20 namespace blink { 21 namespace blink {
21 22
22 class WebLayer; 23 class WebLayer;
23 24
24 class PLATFORM_EXPORT CanvasSurfaceLayerBridge { 25 class PLATFORM_EXPORT CanvasSurfaceLayerBridgeObserver {
25 public: 26 public:
26 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(CanvasSurfaceLayerBridgeObserver*);
27 ~CanvasSurfaceLayerBridge(); 37 ~CanvasSurfaceLayerBridge();
28 bool createSurfaceLayer(int canvasWidth, int canvasHeight); 38 void createSolidColorLayer();
29 WebLayer* getWebLayer() const { return m_webLayer.get(); } 39 WebLayer* getWebLayer() const { return m_webLayer.get(); }
30 const cc::SurfaceId& getSurfaceId() const { return m_surfaceId; } 40 const cc::FrameSinkId& getFrameSinkId() const { return m_frameSinkId; }
41
42 // Implementation of mojom::blink::OffscreenCanvasSurfaceClient
43 void OnSurfaceCreated(const cc::SurfaceId&,
44 int32_t width,
45 int32_t height,
46 float deviceScaleFactor) override;
31 47
32 void satisfyCallback(const cc::SurfaceSequence&); 48 void satisfyCallback(const cc::SurfaceSequence&);
33 void requireCallback(const cc::SurfaceId&, const cc::SurfaceSequence&); 49 void requireCallback(const cc::SurfaceId&, const cc::SurfaceSequence&);
34 50
35 private: 51 private:
36 scoped_refptr<cc::SurfaceLayer> m_surfaceLayer; 52 scoped_refptr<cc::Layer> m_CCLayer;
37 std::unique_ptr<WebLayer> m_webLayer; 53 std::unique_ptr<WebLayer> m_webLayer;
38 const mojom::blink::OffscreenCanvasSurfacePtr m_service; 54
39 cc::SurfaceId m_surfaceId;
40 scoped_refptr<cc::SurfaceReferenceFactory> m_refFactory; 55 scoped_refptr<cc::SurfaceReferenceFactory> m_refFactory;
56 base::WeakPtrFactory<CanvasSurfaceLayerBridge> m_weakFactory;
41 57
42 base::WeakPtrFactory<CanvasSurfaceLayerBridge> m_weakFactory; 58 CanvasSurfaceLayerBridgeObserver* m_observer;
59
60 mojom::blink::OffscreenCanvasSurfacePtr m_service;
61 mojo::Binding<mojom::blink::OffscreenCanvasSurfaceClient> m_binding;
62
63 cc::FrameSinkId m_frameSinkId;
64 cc::SurfaceId m_currentSurfaceId;
43 }; 65 };
44 66
45 } // namespace blink 67 } // namespace blink
46 68
47 #endif // CanvasSurfaceLayerBridge_h 69 #endif // CanvasSurfaceLayerBridge_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/BUILD.gn ('k') | third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridge.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698