Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: cc/surfaces/surface_manager.h

Issue 553213003: Avoid destroying surface before the parent surface stops referencing it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CC_SURFACES_SURFACE_MANAGER_H_ 5 #ifndef CC_SURFACES_SURFACE_MANAGER_H_
6 #define CC_SURFACES_SURFACE_MANAGER_H_ 6 #define CC_SURFACES_SURFACE_MANAGER_H_
7 7
8 #include <list>
9 #include <set>
jamesr 2014/09/12 01:08:55 #include <vector> since you use it on line 48 and
jbauman 2014/09/23 01:58:05 Done.
10
8 #include "base/containers/hash_tables.h" 11 #include "base/containers/hash_tables.h"
9 #include "base/macros.h" 12 #include "base/macros.h"
10 #include "base/observer_list.h" 13 #include "base/observer_list.h"
11 #include "cc/surfaces/surface_damage_observer.h" 14 #include "cc/surfaces/surface_damage_observer.h"
12 #include "cc/surfaces/surface_id.h" 15 #include "cc/surfaces/surface_id.h"
16 #include "cc/surfaces/surface_sequence.h"
13 #include "cc/surfaces/surfaces_export.h" 17 #include "cc/surfaces/surfaces_export.h"
14 18
15 namespace cc { 19 namespace cc {
16 class CompositorFrame; 20 class CompositorFrame;
17 class Surface; 21 class Surface;
18 22
19 class CC_SURFACES_EXPORT SurfaceManager { 23 class CC_SURFACES_EXPORT SurfaceManager {
20 public: 24 public:
21 SurfaceManager(); 25 SurfaceManager();
22 ~SurfaceManager(); 26 ~SurfaceManager();
23 27
24 void RegisterSurface(Surface* surface); 28 void RegisterSurface(Surface* surface);
25 void DeregisterSurface(SurfaceId surface_id); 29 void DeregisterSurface(SurfaceId surface_id);
26 30
31 // Destroy the Surface once a set of sequence numbers has been received.
jamesr 2014/09/12 01:08:55 terminology nit: s/received/satisfied/
jbauman 2014/09/23 01:58:05 Done.
32 void DestroyOnSequence(scoped_ptr<Surface> surface,
33 const std::set<SurfaceSequence>& dependency_set);
34
27 Surface* GetSurfaceForId(SurfaceId surface_id); 35 Surface* GetSurfaceForId(SurfaceId surface_id);
28 36
29 void AddObserver(SurfaceDamageObserver* obs) { 37 void AddObserver(SurfaceDamageObserver* obs) {
30 observer_list_.AddObserver(obs); 38 observer_list_.AddObserver(obs);
31 } 39 }
32 40
33 void RemoveObserver(SurfaceDamageObserver* obs) { 41 void RemoveObserver(SurfaceDamageObserver* obs) {
34 observer_list_.RemoveObserver(obs); 42 observer_list_.RemoveObserver(obs);
35 } 43 }
36 44
37 void SurfaceModified(SurfaceId surface_id); 45 void SurfaceModified(SurfaceId surface_id);
38 46
47 // A frame for a surface satisfies a set of sequence numbers.
48 void SatisfiesSequence(SurfaceId id, std::vector<uint32_t>* sequence);
49
39 private: 50 private:
51 void AttemptSatisfyDestroy();
jamesr 2014/09/12 01:08:55 i feel like this name could be a bit better. This
jbauman 2014/09/23 01:58:05 Done.
52
40 typedef base::hash_map<SurfaceId, Surface*> SurfaceMap; 53 typedef base::hash_map<SurfaceId, Surface*> SurfaceMap;
41 SurfaceMap surface_map_; 54 SurfaceMap surface_map_;
42 ObserverList<SurfaceDamageObserver> observer_list_; 55 ObserverList<SurfaceDamageObserver> observer_list_;
43 56
57 // List of surfaces to be destroyed, along with what sequences they're still
58 // waiting on.
59 typedef std::list<std::pair<Surface*, std::set<SurfaceSequence> > >
jamesr 2014/09/12 01:08:55 we can do >>> now
60 SurfaceDestroyList;
61 SurfaceDestroyList surfaces_to_destroy_;
62
63 // Set of SurfaceSequences that have been satisfied by a frame but not yet
64 // waited on.
65 std::set<SurfaceSequence> satisfied_sequences_;
66
44 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); 67 DISALLOW_COPY_AND_ASSIGN(SurfaceManager);
45 }; 68 };
46 69
47 } // namespace cc 70 } // namespace cc
48 71
49 #endif // CC_SURFACES_SURFACE_MANAGER_H_ 72 #endif // CC_SURFACES_SURFACE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698