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
);
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
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
67 base::hash_set
<SurfaceSequence
> satisfied_sequences_
;
69 DISALLOW_COPY_AND_ASSIGN(SurfaceManager
);
74 #endif // CC_SURFACES_SURFACE_MANAGER_H_