Adding Peter Thatcher to the owners file.
[chromium-blink-merge.git] / cc / surfaces / surface_manager.h
blobd7d78c42e285bdeeb44d7dad76f35d28cca21de4
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.
5 #ifndef CC_SURFACES_SURFACE_MANAGER_H_
6 #define CC_SURFACES_SURFACE_MANAGER_H_
8 #include <list>
9 #include <vector>
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"
20 namespace cc {
21 class CompositorFrame;
22 class Surface;
24 class CC_SURFACES_EXPORT SurfaceManager {
25 public:
26 SurfaceManager();
27 ~SurfaceManager();
29 void RegisterSurface(Surface* surface);
30 void DeregisterSurface(SurfaceId surface_id);
32 // Destroy the Surface once a set of sequence numbers has been satisfied.
33 void Destroy(scoped_ptr<Surface> surface);
35 Surface* GetSurfaceForId(SurfaceId surface_id);
37 void AddObserver(SurfaceDamageObserver* obs) {
38 observer_list_.AddObserver(obs);
41 void RemoveObserver(SurfaceDamageObserver* obs) {
42 observer_list_.RemoveObserver(obs);
45 bool SurfaceModified(SurfaceId surface_id);
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);
52 private:
53 void SearchForSatisfaction();
55 typedef base::hash_map<SurfaceId, Surface*> SurfaceMap;
56 SurfaceMap surface_map_;
57 ObserverList<SurfaceDamageObserver> observer_list_;
58 base::ThreadChecker thread_checker_;
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_;
65 // Set of SurfaceSequences that have been satisfied by a frame but not yet
66 // waited on.
67 base::hash_set<SurfaceSequence> satisfied_sequences_;
69 DISALLOW_COPY_AND_ASSIGN(SurfaceManager);
72 } // namespace cc
74 #endif // CC_SURFACES_SURFACE_MANAGER_H_