| 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> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <unordered_map> | 12 #include <unordered_map> |
| 13 #include <unordered_set> | 13 #include <unordered_set> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
| 18 #include "base/threading/thread_checker.h" | 18 #include "base/threading/thread_checker.h" |
| 19 #include "cc/surfaces/frame_sink_id.h" | 19 #include "cc/surfaces/frame_sink_id.h" |
| 20 #include "cc/surfaces/surface_damage_observer.h" | |
| 21 #include "cc/surfaces/surface_id.h" | 20 #include "cc/surfaces/surface_id.h" |
| 21 #include "cc/surfaces/surface_observer.h" |
| 22 #include "cc/surfaces/surface_sequence.h" | 22 #include "cc/surfaces/surface_sequence.h" |
| 23 #include "cc/surfaces/surfaces_export.h" | 23 #include "cc/surfaces/surfaces_export.h" |
| 24 | 24 |
| 25 namespace cc { | 25 namespace cc { |
| 26 class BeginFrameSource; | 26 class BeginFrameSource; |
| 27 class CompositorFrame; | 27 class CompositorFrame; |
| 28 class Surface; | 28 class Surface; |
| 29 class SurfaceFactoryClient; | 29 class SurfaceFactoryClient; |
| 30 | 30 |
| 31 class CC_SURFACES_EXPORT SurfaceManager { | 31 class CC_SURFACES_EXPORT SurfaceManager { |
| 32 public: | 32 public: |
| 33 SurfaceManager(); | 33 SurfaceManager(); |
| 34 ~SurfaceManager(); | 34 ~SurfaceManager(); |
| 35 | 35 |
| 36 void RegisterSurface(Surface* surface); | 36 void RegisterSurface(Surface* surface); |
| 37 void DeregisterSurface(const SurfaceId& surface_id); | 37 void DeregisterSurface(const SurfaceId& surface_id); |
| 38 | 38 |
| 39 // Destroy the Surface once a set of sequence numbers has been satisfied. | 39 // Destroy the Surface once a set of sequence numbers has been satisfied. |
| 40 void Destroy(std::unique_ptr<Surface> surface); | 40 void Destroy(std::unique_ptr<Surface> surface); |
| 41 | 41 |
| 42 Surface* GetSurfaceForId(const SurfaceId& surface_id); | 42 Surface* GetSurfaceForId(const SurfaceId& surface_id); |
| 43 | 43 |
| 44 void AddObserver(SurfaceDamageObserver* obs) { | 44 void AddObserver(SurfaceObserver* obs) { observer_list_.AddObserver(obs); } |
| 45 observer_list_.AddObserver(obs); | |
| 46 } | |
| 47 | 45 |
| 48 void RemoveObserver(SurfaceDamageObserver* obs) { | 46 void RemoveObserver(SurfaceObserver* obs) { |
| 49 observer_list_.RemoveObserver(obs); | 47 observer_list_.RemoveObserver(obs); |
| 50 } | 48 } |
| 51 | 49 |
| 52 bool SurfaceModified(const SurfaceId& surface_id); | 50 bool SurfaceModified(const SurfaceId& surface_id); |
| 53 | 51 |
| 52 // Called when a CompositorFrame is submitted to a SurfaceFactory for a given |
| 53 // |surface_id| for the first time. |
| 54 void SurfaceCreated(const SurfaceId& surface_id, |
| 55 const gfx::Size& frame_size, |
| 56 float device_scale_factor); |
| 57 |
| 54 // A frame for a surface satisfies a set of sequence numbers in a particular | 58 // A frame for a surface satisfies a set of sequence numbers in a particular |
| 55 // id namespace. | 59 // id namespace. |
| 56 void DidSatisfySequences(const FrameSinkId& frame_sink_id, | 60 void DidSatisfySequences(const FrameSinkId& frame_sink_id, |
| 57 std::vector<uint32_t>* sequence); | 61 std::vector<uint32_t>* sequence); |
| 58 | 62 |
| 59 void RegisterFrameSinkId(const FrameSinkId& frame_sink_id); | 63 void RegisterFrameSinkId(const FrameSinkId& frame_sink_id); |
| 60 | 64 |
| 61 // Invalidate a frame_sink_id that might still have associated sequences, | 65 // Invalidate a frame_sink_id that might still have associated sequences, |
| 62 // possibly because a renderer process has crashed. | 66 // possibly because a renderer process has crashed. |
| 63 void InvalidateFrameSinkId(const FrameSinkId& frame_sink_id); | 67 void InvalidateFrameSinkId(const FrameSinkId& frame_sink_id); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 BeginFrameSource* source); | 107 BeginFrameSource* source); |
| 104 // Returns true if |child namespace| is or has |search_frame_sink_id| as a | 108 // Returns true if |child namespace| is or has |search_frame_sink_id| as a |
| 105 // child. | 109 // child. |
| 106 bool ChildContains(const FrameSinkId& child_frame_sink_id, | 110 bool ChildContains(const FrameSinkId& child_frame_sink_id, |
| 107 const FrameSinkId& search_frame_sink_id) const; | 111 const FrameSinkId& search_frame_sink_id) const; |
| 108 | 112 |
| 109 void GarbageCollectSurfaces(); | 113 void GarbageCollectSurfaces(); |
| 110 | 114 |
| 111 using SurfaceMap = std::unordered_map<SurfaceId, Surface*, SurfaceIdHash>; | 115 using SurfaceMap = std::unordered_map<SurfaceId, Surface*, SurfaceIdHash>; |
| 112 SurfaceMap surface_map_; | 116 SurfaceMap surface_map_; |
| 113 base::ObserverList<SurfaceDamageObserver> observer_list_; | 117 base::ObserverList<SurfaceObserver> observer_list_; |
| 114 base::ThreadChecker thread_checker_; | 118 base::ThreadChecker thread_checker_; |
| 115 | 119 |
| 116 // List of surfaces to be destroyed, along with what sequences they're still | 120 // List of surfaces to be destroyed, along with what sequences they're still |
| 117 // waiting on. | 121 // waiting on. |
| 118 using SurfaceDestroyList = std::list<std::unique_ptr<Surface>>; | 122 using SurfaceDestroyList = std::list<std::unique_ptr<Surface>>; |
| 119 SurfaceDestroyList surfaces_to_destroy_; | 123 SurfaceDestroyList surfaces_to_destroy_; |
| 120 | 124 |
| 121 // Set of SurfaceSequences that have been satisfied by a frame but not yet | 125 // Set of SurfaceSequences that have been satisfied by a frame but not yet |
| 122 // waited on. | 126 // waited on. |
| 123 std::unordered_set<SurfaceSequence, SurfaceSequenceHash> satisfied_sequences_; | 127 std::unordered_set<SurfaceSequence, SurfaceSequenceHash> satisfied_sequences_; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 147 // that is implicitly using this namespace must be reachable by the | 151 // that is implicitly using this namespace must be reachable by the |
| 148 // parent in the dag. | 152 // parent in the dag. |
| 149 std::unordered_map<BeginFrameSource*, FrameSinkId> registered_sources_; | 153 std::unordered_map<BeginFrameSource*, FrameSinkId> registered_sources_; |
| 150 | 154 |
| 151 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); | 155 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); |
| 152 }; | 156 }; |
| 153 | 157 |
| 154 } // namespace cc | 158 } // namespace cc |
| 155 | 159 |
| 156 #endif // CC_SURFACES_SURFACE_MANAGER_H_ | 160 #endif // CC_SURFACES_SURFACE_MANAGER_H_ |
| OLD | NEW |