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