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

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, 2 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
« no previous file with comments | « cc/surfaces/surface_id_allocator.h ('k') | cc/surfaces/surface_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
10 #include <vector>
11
8 #include "base/containers/hash_tables.h" 12 #include "base/containers/hash_tables.h"
9 #include "base/macros.h" 13 #include "base/macros.h"
10 #include "base/observer_list.h" 14 #include "base/observer_list.h"
11 #include "base/threading/thread_checker.h" 15 #include "base/threading/thread_checker.h"
12 #include "cc/surfaces/surface_damage_observer.h" 16 #include "cc/surfaces/surface_damage_observer.h"
13 #include "cc/surfaces/surface_id.h" 17 #include "cc/surfaces/surface_id.h"
18 #include "cc/surfaces/surface_sequence.h"
14 #include "cc/surfaces/surfaces_export.h" 19 #include "cc/surfaces/surfaces_export.h"
15 20
16 namespace cc { 21 namespace cc {
17 class CompositorFrame; 22 class CompositorFrame;
18 class Surface; 23 class Surface;
19 24
20 class CC_SURFACES_EXPORT SurfaceManager { 25 class CC_SURFACES_EXPORT SurfaceManager {
21 public: 26 public:
22 SurfaceManager(); 27 SurfaceManager();
23 ~SurfaceManager(); 28 ~SurfaceManager();
24 29
25 void RegisterSurface(Surface* surface); 30 void RegisterSurface(Surface* surface);
26 void DeregisterSurface(SurfaceId surface_id); 31 void DeregisterSurface(SurfaceId surface_id);
27 32
33 // Destroy the Surface once a set of sequence numbers has been satisfied.
34 void DestroyOnSequence(scoped_ptr<Surface> surface,
35 const std::set<SurfaceSequence>& dependency_set);
36
28 Surface* GetSurfaceForId(SurfaceId surface_id); 37 Surface* GetSurfaceForId(SurfaceId surface_id);
29 38
30 void AddObserver(SurfaceDamageObserver* obs) { 39 void AddObserver(SurfaceDamageObserver* obs) {
31 observer_list_.AddObserver(obs); 40 observer_list_.AddObserver(obs);
32 } 41 }
33 42
34 void RemoveObserver(SurfaceDamageObserver* obs) { 43 void RemoveObserver(SurfaceDamageObserver* obs) {
35 observer_list_.RemoveObserver(obs); 44 observer_list_.RemoveObserver(obs);
36 } 45 }
37 46
38 void SurfaceModified(SurfaceId surface_id); 47 void SurfaceModified(SurfaceId surface_id);
39 48
49 // A frame for a surface satisfies a set of sequence numbers.
50 void DidSatisfySequences(SurfaceId id, std::vector<uint32_t>* sequence);
51
40 private: 52 private:
53 void SearchForSatisfaction();
54
41 typedef base::hash_map<SurfaceId, Surface*> SurfaceMap; 55 typedef base::hash_map<SurfaceId, Surface*> SurfaceMap;
42 SurfaceMap surface_map_; 56 SurfaceMap surface_map_;
43 ObserverList<SurfaceDamageObserver> observer_list_; 57 ObserverList<SurfaceDamageObserver> observer_list_;
44 base::ThreadChecker thread_checker_; 58 base::ThreadChecker thread_checker_;
45 59
60 // List of surfaces to be destroyed, along with what sequences they're still
61 // waiting on.
62 typedef std::list<std::pair<Surface*, std::set<SurfaceSequence>>>
63 SurfaceDestroyList;
64 SurfaceDestroyList surfaces_to_destroy_;
65
66 // Set of SurfaceSequences that have been satisfied by a frame but not yet
67 // waited on.
68 std::set<SurfaceSequence> satisfied_sequences_;
69
46 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); 70 DISALLOW_COPY_AND_ASSIGN(SurfaceManager);
47 }; 71 };
48 72
49 } // namespace cc 73 } // namespace cc
50 74
51 #endif // CC_SURFACES_SURFACE_MANAGER_H_ 75 #endif // CC_SURFACES_SURFACE_MANAGER_H_
OLDNEW
« no previous file with comments | « cc/surfaces/surface_id_allocator.h ('k') | cc/surfaces/surface_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698