Roll src/third_party/skia 7b05ff1:dab1f60
[chromium-blink-merge.git] / cc / surfaces / surface_manager.h
blobaaaa44422bfd31993114995eca0f8fdde0a79670
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 void RegisterSurfaceIdNamespace(uint32_t id_namespace);
54 // Invalidate a namespace that might still have associated sequences,
55 // possibly because a renderer process has crashed.
56 void InvalidateSurfaceIdNamespace(uint32_t id_namespace);
58 private:
59 void SearchForSatisfaction();
61 typedef base::hash_map<SurfaceId, Surface*> SurfaceMap;
62 SurfaceMap surface_map_;
63 base::ObserverList<SurfaceDamageObserver> observer_list_;
64 base::ThreadChecker thread_checker_;
66 // List of surfaces to be destroyed, along with what sequences they're still
67 // waiting on.
68 typedef std::list<Surface*> SurfaceDestroyList;
69 SurfaceDestroyList surfaces_to_destroy_;
71 // Set of SurfaceSequences that have been satisfied by a frame but not yet
72 // waited on.
73 base::hash_set<SurfaceSequence> satisfied_sequences_;
75 // Set of valid surface ID namespaces. When a namespace is removed from
76 // this set, any remaining sequences with that namespace are considered
77 // satisfied.
78 base::hash_set<uint32_t> valid_surface_id_namespaces_;
80 DISALLOW_COPY_AND_ASSIGN(SurfaceManager);
83 } // namespace cc
85 #endif // CC_SURFACES_SURFACE_MANAGER_H_