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 CONTENT_BROWSER_RENDERER_HOST_OFFSCREEN_CANVAS_SURFACE_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_OFFSCREEN_CANVAS_SURFACE_MANAGER_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_OFFSCREEN_CANVAS_SURFACE_MANAGER_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_OFFSCREEN_CANVAS_SURFACE_MANAGER_H_ |
7 | 7 |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "cc/surfaces/surface_id.h" | 9 #include "cc/surfaces/surface_id.h" |
10 #include "cc/surfaces/surface_observer.h" | 10 #include "cc/surfaces/surface_observer.h" |
11 #include "content/browser/renderer_host/offscreen_canvas_surface_impl.h" | 11 #include "content/browser/renderer_host/offscreen_canvas_surface_impl.h" |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 | 14 |
15 class CONTENT_EXPORT OffscreenCanvasSurfaceManager | 15 class CONTENT_EXPORT OffscreenCanvasSurfaceManager |
16 : public cc::SurfaceObserver { | 16 : public cc::SurfaceObserver { |
17 public: | 17 public: |
18 OffscreenCanvasSurfaceManager(); | 18 OffscreenCanvasSurfaceManager(); |
19 virtual ~OffscreenCanvasSurfaceManager(); | 19 virtual ~OffscreenCanvasSurfaceManager(); |
20 | 20 |
21 static OffscreenCanvasSurfaceManager* GetInstance(); | 21 static OffscreenCanvasSurfaceManager* GetInstance(); |
22 | 22 |
23 void RegisterOffscreenCanvasSurfaceInstance(cc::FrameSinkId, | 23 // Registration of the frame sink with the given frame sink id to its parent |
24 OffscreenCanvasSurfaceImpl*); | 24 // frame sink (if it has one), so that parent frame is able to send signals |
25 void UnregisterOffscreenCanvasSurfaceInstance(cc::FrameSinkId); | 25 // to it on begin frame. |
26 OffscreenCanvasSurfaceImpl* GetSurfaceInstance(cc::FrameSinkId); | 26 void RegisterFrameSinkToParent(const cc::FrameSinkId& frame_sink_id); |
| 27 void UnregisterFrameSinkFromParent(const cc::FrameSinkId& frame_sink_id); |
| 28 |
| 29 void RegisterOffscreenCanvasSurfaceInstance( |
| 30 const cc::FrameSinkId& frame_sink_id, |
| 31 OffscreenCanvasSurfaceImpl* offscreen_canvas_surface); |
| 32 void UnregisterOffscreenCanvasSurfaceInstance( |
| 33 const cc::FrameSinkId& frame_sink_id); |
| 34 OffscreenCanvasSurfaceImpl* GetSurfaceInstance( |
| 35 const cc::FrameSinkId& frame_sink_id); |
27 | 36 |
28 private: | 37 private: |
29 friend class OffscreenCanvasSurfaceManagerTest; | 38 friend class OffscreenCanvasSurfaceManagerTest; |
30 | 39 |
31 // cc::SurfaceObserver implementation. | 40 // cc::SurfaceObserver implementation. |
32 void OnSurfaceCreated(const cc::SurfaceInfo& surface_info) override; | 41 void OnSurfaceCreated(const cc::SurfaceInfo& surface_info) override; |
33 void OnSurfaceDamaged(const cc::SurfaceId&, bool* changed) override {} | 42 void OnSurfaceDamaged(const cc::SurfaceId&, bool* changed) override {} |
34 | 43 |
35 // When an OffscreenCanvasSurfaceImpl instance is destructed, it will | 44 // When an OffscreenCanvasSurfaceImpl instance is destructed, it will |
36 // unregister the corresponding entry from this map. | 45 // unregister the corresponding entry from this map. |
37 std::unordered_map<cc::FrameSinkId, | 46 std::unordered_map<cc::FrameSinkId, |
38 OffscreenCanvasSurfaceImpl*, | 47 OffscreenCanvasSurfaceImpl*, |
39 cc::FrameSinkIdHash> | 48 cc::FrameSinkIdHash> |
40 registered_surface_instances_; | 49 registered_surface_instances_; |
41 DISALLOW_COPY_AND_ASSIGN(OffscreenCanvasSurfaceManager); | 50 DISALLOW_COPY_AND_ASSIGN(OffscreenCanvasSurfaceManager); |
42 }; | 51 }; |
43 | 52 |
44 } // namespace content | 53 } // namespace content |
45 | 54 |
46 #endif // CONTENT_BROWSER_RENDERER_HOST_OFFSCREEN_CANVAS_SURFACE_MANAGER_H_ | 55 #endif // CONTENT_BROWSER_RENDERER_HOST_OFFSCREEN_CANVAS_SURFACE_MANAGER_H_ |
OLD | NEW |