| 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 // Registration of the frame sink with the given frame sink id to its parent |
| 24 // frame sink (if it has one), so that parent frame is able to send signals |
| 25 // to it on begin frame. |
| 26 void RegisterFrameSinkToItsParent(cc::FrameSinkId); |
| 27 void UnregisterFrameSinkFromItsParent(cc::FrameSinkId); |
| 28 |
| 23 void RegisterOffscreenCanvasSurfaceInstance(cc::FrameSinkId, | 29 void RegisterOffscreenCanvasSurfaceInstance(cc::FrameSinkId, |
| 24 OffscreenCanvasSurfaceImpl*); | 30 OffscreenCanvasSurfaceImpl*); |
| 25 void UnregisterOffscreenCanvasSurfaceInstance(cc::FrameSinkId); | 31 void UnregisterOffscreenCanvasSurfaceInstance(cc::FrameSinkId); |
| 26 OffscreenCanvasSurfaceImpl* GetSurfaceInstance(cc::FrameSinkId); | 32 OffscreenCanvasSurfaceImpl* GetSurfaceInstance(cc::FrameSinkId); |
| 27 | 33 |
| 28 private: | 34 private: |
| 29 friend class OffscreenCanvasSurfaceManagerTest; | 35 friend class OffscreenCanvasSurfaceManagerTest; |
| 30 | 36 |
| 31 // cc::SurfaceObserver implementation. | 37 // cc::SurfaceObserver implementation. |
| 32 void OnSurfaceCreated(const cc::SurfaceInfo& surface_info) override; | 38 void OnSurfaceCreated(const cc::SurfaceInfo& surface_info) override; |
| 33 void OnSurfaceDamaged(const cc::SurfaceId&, bool* changed) override {} | 39 void OnSurfaceDamaged(const cc::SurfaceId&, bool* changed) override {} |
| 34 | 40 |
| 35 // When an OffscreenCanvasSurfaceImpl instance is destructed, it will | 41 // When an OffscreenCanvasSurfaceImpl instance is destructed, it will |
| 36 // unregister the corresponding entry from this map. | 42 // unregister the corresponding entry from this map. |
| 37 std::unordered_map<cc::FrameSinkId, | 43 std::unordered_map<cc::FrameSinkId, |
| 38 OffscreenCanvasSurfaceImpl*, | 44 OffscreenCanvasSurfaceImpl*, |
| 39 cc::FrameSinkIdHash> | 45 cc::FrameSinkIdHash> |
| 40 registered_surface_instances_; | 46 registered_surface_instances_; |
| 41 DISALLOW_COPY_AND_ASSIGN(OffscreenCanvasSurfaceManager); | 47 DISALLOW_COPY_AND_ASSIGN(OffscreenCanvasSurfaceManager); |
| 42 }; | 48 }; |
| 43 | 49 |
| 44 } // namespace content | 50 } // namespace content |
| 45 | 51 |
| 46 #endif // CONTENT_BROWSER_RENDERER_HOST_OFFSCREEN_CANVAS_SURFACE_MANAGER_H_ | 52 #endif // CONTENT_BROWSER_RENDERER_HOST_OFFSCREEN_CANVAS_SURFACE_MANAGER_H_ |
| OLD | NEW |