| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CC_SURFACES_SURFACE_MANAGER_H_ | 5 #ifndef CC_SURFACES_SURFACE_MANAGER_H_ |
| 6 #define CC_SURFACES_SURFACE_MANAGER_H_ | 6 #define CC_SURFACES_SURFACE_MANAGER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 #if DCHECK_IS_ON() | 30 #if DCHECK_IS_ON() |
| 31 #include <iosfwd> | 31 #include <iosfwd> |
| 32 #include <string> | 32 #include <string> |
| 33 #endif | 33 #endif |
| 34 | 34 |
| 35 namespace cc { | 35 namespace cc { |
| 36 class BeginFrameSource; | 36 class BeginFrameSource; |
| 37 class CompositorFrame; | 37 class CompositorFrame; |
| 38 class Surface; | 38 class Surface; |
| 39 class SurfaceFactory; |
| 39 class SurfaceFactoryClient; | 40 class SurfaceFactoryClient; |
| 40 | 41 |
| 41 namespace test { | 42 namespace test { |
| 42 class CompositorFrameSinkSupportTest; | 43 class CompositorFrameSinkSupportTest; |
| 43 } | 44 } |
| 44 | 45 |
| 45 class CC_SURFACES_EXPORT SurfaceManager { | 46 class CC_SURFACES_EXPORT SurfaceManager { |
| 46 public: | 47 public: |
| 47 enum class LifetimeType { | 48 enum class LifetimeType { |
| 48 REFERENCES, | 49 REFERENCES, |
| 49 SEQUENCES, | 50 SEQUENCES, |
| 50 }; | 51 }; |
| 51 | 52 |
| 52 explicit SurfaceManager(LifetimeType lifetime_type = LifetimeType::SEQUENCES); | 53 explicit SurfaceManager(LifetimeType lifetime_type = LifetimeType::SEQUENCES); |
| 53 ~SurfaceManager(); | 54 ~SurfaceManager(); |
| 54 | 55 |
| 55 #if DCHECK_IS_ON() | 56 #if DCHECK_IS_ON() |
| 56 // Returns a string representation of all reachable surface references. | 57 // Returns a string representation of all reachable surface references. |
| 57 std::string SurfaceReferencesToString(); | 58 std::string SurfaceReferencesToString(); |
| 58 #endif | 59 #endif |
| 59 | 60 |
| 60 void SetDependencyTracker( | 61 void SetDependencyTracker( |
| 61 std::unique_ptr<SurfaceDependencyTracker> dependency_tracker); | 62 std::unique_ptr<SurfaceDependencyTracker> dependency_tracker); |
| 62 SurfaceDependencyTracker* dependency_tracker() { | 63 SurfaceDependencyTracker* dependency_tracker() { |
| 63 return dependency_tracker_.get(); | 64 return dependency_tracker_.get(); |
| 64 } | 65 } |
| 65 | 66 |
| 66 void RequestSurfaceResolution(Surface* pending_surface); | 67 void RequestSurfaceResolution(Surface* pending_surface); |
| 67 | 68 |
| 68 void RegisterSurface(Surface* surface); | 69 std::unique_ptr<Surface> CreateSurface( |
| 69 void DeregisterSurface(const SurfaceId& surface_id); | 70 base::WeakPtr<SurfaceFactory> surface_factory, |
| 71 const LocalSurfaceId& local_surface_id); |
| 70 | 72 |
| 71 // Destroy the Surface once a set of sequence numbers has been satisfied. | 73 // Destroy the Surface once a set of sequence numbers has been satisfied. |
| 72 void Destroy(std::unique_ptr<Surface> surface); | 74 void DestroySurface(std::unique_ptr<Surface> surface); |
| 73 | 75 |
| 74 Surface* GetSurfaceForId(const SurfaceId& surface_id); | 76 Surface* GetSurfaceForId(const SurfaceId& surface_id); |
| 75 | 77 |
| 76 void AddObserver(SurfaceObserver* obs) { observer_list_.AddObserver(obs); } | 78 void AddObserver(SurfaceObserver* obs) { observer_list_.AddObserver(obs); } |
| 77 | 79 |
| 78 void RemoveObserver(SurfaceObserver* obs) { | 80 void RemoveObserver(SurfaceObserver* obs) { |
| 79 observer_list_.RemoveObserver(obs); | 81 observer_list_.RemoveObserver(obs); |
| 80 } | 82 } |
| 81 | 83 |
| 82 bool SurfaceModified(const SurfaceId& surface_id); | 84 bool SurfaceModified(const SurfaceId& surface_id); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 211 |
| 210 // Adds a temporary reference to |surface_id|. The reference will not have an | 212 // Adds a temporary reference to |surface_id|. The reference will not have an |
| 211 // owner initially. | 213 // owner initially. |
| 212 void AddTemporaryReference(const SurfaceId& surface_id); | 214 void AddTemporaryReference(const SurfaceId& surface_id); |
| 213 | 215 |
| 214 // Removes temporary reference to |surface_id|. If |remove_range| is true then | 216 // Removes temporary reference to |surface_id|. If |remove_range| is true then |
| 215 // all temporary references to surfaces with the same FrameSinkId as | 217 // all temporary references to surfaces with the same FrameSinkId as |
| 216 // |surface_id| that were added before |surface_id| will also be removed. | 218 // |surface_id| that were added before |surface_id| will also be removed. |
| 217 void RemoveTemporaryReference(const SurfaceId& surface_id, bool remove_range); | 219 void RemoveTemporaryReference(const SurfaceId& surface_id, bool remove_range); |
| 218 | 220 |
| 221 // Called when a surface is destroyed and it needs to be removed from the |
| 222 // surface map. |
| 223 void UnregisterSurface(const SurfaceId& surface_id); |
| 224 |
| 219 #if DCHECK_IS_ON() | 225 #if DCHECK_IS_ON() |
| 220 // Recursively prints surface references starting at |surface_id| to |str|. | 226 // Recursively prints surface references starting at |surface_id| to |str|. |
| 221 void SurfaceReferencesToStringImpl(const SurfaceId& surface_id, | 227 void SurfaceReferencesToStringImpl(const SurfaceId& surface_id, |
| 222 std::string indent, | 228 std::string indent, |
| 223 std::stringstream* str); | 229 std::stringstream* str); |
| 224 #endif | 230 #endif |
| 225 | 231 |
| 226 // Use reference or sequence based lifetime management. | 232 // Use reference or sequence based lifetime management. |
| 227 LifetimeType lifetime_type_; | 233 LifetimeType lifetime_type_; |
| 228 | 234 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 std::unique_ptr<SurfaceDependencyTracker> dependency_tracker_; | 314 std::unique_ptr<SurfaceDependencyTracker> dependency_tracker_; |
| 309 | 315 |
| 310 base::WeakPtrFactory<SurfaceManager> weak_factory_; | 316 base::WeakPtrFactory<SurfaceManager> weak_factory_; |
| 311 | 317 |
| 312 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); | 318 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); |
| 313 }; | 319 }; |
| 314 | 320 |
| 315 } // namespace cc | 321 } // namespace cc |
| 316 | 322 |
| 317 #endif // CC_SURFACES_SURFACE_MANAGER_H_ | 323 #endif // CC_SURFACES_SURFACE_MANAGER_H_ |
| OLD | NEW |