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 <list> | 8 #include <list> |
9 #include <set> | |
10 #include <vector> | 9 #include <vector> |
11 | 10 |
12 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
13 #include "base/macros.h" | 12 #include "base/macros.h" |
14 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
15 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
16 #include "cc/surfaces/surface_damage_observer.h" | 15 #include "cc/surfaces/surface_damage_observer.h" |
17 #include "cc/surfaces/surface_id.h" | 16 #include "cc/surfaces/surface_id.h" |
18 #include "cc/surfaces/surface_sequence.h" | 17 #include "cc/surfaces/surface_sequence.h" |
19 #include "cc/surfaces/surfaces_export.h" | 18 #include "cc/surfaces/surfaces_export.h" |
20 | 19 |
21 namespace cc { | 20 namespace cc { |
22 class CompositorFrame; | 21 class CompositorFrame; |
23 class Surface; | 22 class Surface; |
24 | 23 |
25 class CC_SURFACES_EXPORT SurfaceManager { | 24 class CC_SURFACES_EXPORT SurfaceManager { |
26 public: | 25 public: |
27 SurfaceManager(); | 26 SurfaceManager(); |
28 ~SurfaceManager(); | 27 ~SurfaceManager(); |
29 | 28 |
30 void RegisterSurface(Surface* surface); | 29 void RegisterSurface(Surface* surface); |
31 void DeregisterSurface(SurfaceId surface_id); | 30 void DeregisterSurface(SurfaceId surface_id); |
32 | 31 |
33 // Destroy the Surface once a set of sequence numbers has been satisfied. | 32 // Destroy the Surface once a set of sequence numbers has been satisfied. |
34 void DestroyOnSequence(scoped_ptr<Surface> surface, | 33 void Destroy(scoped_ptr<Surface> surface); |
35 const std::set<SurfaceSequence>& dependency_set); | |
36 | 34 |
37 Surface* GetSurfaceForId(SurfaceId surface_id); | 35 Surface* GetSurfaceForId(SurfaceId surface_id); |
38 | 36 |
39 void AddObserver(SurfaceDamageObserver* obs) { | 37 void AddObserver(SurfaceDamageObserver* obs) { |
40 observer_list_.AddObserver(obs); | 38 observer_list_.AddObserver(obs); |
41 } | 39 } |
42 | 40 |
43 void RemoveObserver(SurfaceDamageObserver* obs) { | 41 void RemoveObserver(SurfaceDamageObserver* obs) { |
44 observer_list_.RemoveObserver(obs); | 42 observer_list_.RemoveObserver(obs); |
45 } | 43 } |
46 | 44 |
47 void SurfaceModified(SurfaceId surface_id); | 45 void SurfaceModified(SurfaceId surface_id); |
48 | 46 |
49 // A frame for a surface satisfies a set of sequence numbers. | 47 // A frame for a surface satisfies a set of sequence numbers in a particular |
50 void DidSatisfySequences(SurfaceId id, std::vector<uint32_t>* sequence); | 48 // id namespace. |
| 49 void DidSatisfySequences(uint32_t id_namespace, |
| 50 std::vector<uint32_t>* sequence); |
51 | 51 |
52 private: | 52 private: |
53 void SearchForSatisfaction(); | 53 void SearchForSatisfaction(); |
54 | 54 |
55 typedef base::hash_map<SurfaceId, Surface*> SurfaceMap; | 55 typedef base::hash_map<SurfaceId, Surface*> SurfaceMap; |
56 SurfaceMap surface_map_; | 56 SurfaceMap surface_map_; |
57 ObserverList<SurfaceDamageObserver> observer_list_; | 57 ObserverList<SurfaceDamageObserver> observer_list_; |
58 base::ThreadChecker thread_checker_; | 58 base::ThreadChecker thread_checker_; |
59 | 59 |
60 // List of surfaces to be destroyed, along with what sequences they're still | 60 // List of surfaces to be destroyed, along with what sequences they're still |
61 // waiting on. | 61 // waiting on. |
62 typedef std::list<std::pair<Surface*, std::set<SurfaceSequence>>> | 62 typedef std::list<Surface*> SurfaceDestroyList; |
63 SurfaceDestroyList; | |
64 SurfaceDestroyList surfaces_to_destroy_; | 63 SurfaceDestroyList surfaces_to_destroy_; |
65 | 64 |
66 // Set of SurfaceSequences that have been satisfied by a frame but not yet | 65 // Set of SurfaceSequences that have been satisfied by a frame but not yet |
67 // waited on. | 66 // waited on. |
68 std::set<SurfaceSequence> satisfied_sequences_; | 67 base::hash_set<SurfaceSequence> satisfied_sequences_; |
69 | 68 |
70 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); | 69 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); |
71 }; | 70 }; |
72 | 71 |
73 } // namespace cc | 72 } // namespace cc |
74 | 73 |
75 #endif // CC_SURFACES_SURFACE_MANAGER_H_ | 74 #endif // CC_SURFACES_SURFACE_MANAGER_H_ |
OLD | NEW |