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_
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"
21 class CompositorFrame
;
24 class CC_SURFACES_EXPORT 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
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
);
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
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
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
78 base::hash_set
<uint32_t> valid_surface_id_namespaces_
;
80 DISALLOW_COPY_AND_ASSIGN(SurfaceManager
);
85 #endif // CC_SURFACES_SURFACE_MANAGER_H_