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

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

Issue 2403573002: cc: Introduce mechanism to observe CompositorFrames submitted to new surfaceIDs (Closed)
Patch Set: Created 4 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
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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <list> 10 #include <list>
11 #include <memory> 11 #include <memory>
12 #include <unordered_map> 12 #include <unordered_map>
13 #include <unordered_set> 13 #include <unordered_set>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/observer_list.h" 17 #include "base/observer_list.h"
18 #include "base/threading/thread_checker.h" 18 #include "base/threading/thread_checker.h"
19 #include "cc/surfaces/frame_sink_id.h" 19 #include "cc/surfaces/frame_sink_id.h"
20 #include "cc/surfaces/surface_damage_observer.h"
21 #include "cc/surfaces/surface_id.h" 20 #include "cc/surfaces/surface_id.h"
21 #include "cc/surfaces/surface_manager_observer.h"
22 #include "cc/surfaces/surface_sequence.h" 22 #include "cc/surfaces/surface_sequence.h"
23 #include "cc/surfaces/surfaces_export.h" 23 #include "cc/surfaces/surfaces_export.h"
24 24
25 namespace cc { 25 namespace cc {
26 class BeginFrameSource; 26 class BeginFrameSource;
27 class CompositorFrame; 27 class CompositorFrame;
28 class Surface; 28 class Surface;
29 class SurfaceFactoryClient; 29 class SurfaceFactoryClient;
30 30
31 class CC_SURFACES_EXPORT SurfaceManager { 31 class CC_SURFACES_EXPORT SurfaceManager {
32 public: 32 public:
33 SurfaceManager(); 33 SurfaceManager();
34 ~SurfaceManager(); 34 ~SurfaceManager();
35 35
36 void RegisterSurface(Surface* surface); 36 void RegisterSurface(Surface* surface);
37 void DeregisterSurface(const SurfaceId& surface_id); 37 void DeregisterSurface(const SurfaceId& surface_id);
38 38
39 // Destroy the Surface once a set of sequence numbers has been satisfied. 39 // Destroy the Surface once a set of sequence numbers has been satisfied.
40 void Destroy(std::unique_ptr<Surface> surface); 40 void Destroy(std::unique_ptr<Surface> surface);
41 41
42 Surface* GetSurfaceForId(const SurfaceId& surface_id); 42 Surface* GetSurfaceForId(const SurfaceId& surface_id);
43 43
44 void AddObserver(SurfaceDamageObserver* obs) { 44 void AddObserver(SurfaceManagerObserver* obs) {
45 observer_list_.AddObserver(obs); 45 observer_list_.AddObserver(obs);
46 } 46 }
47 47
48 void RemoveObserver(SurfaceDamageObserver* obs) { 48 void RemoveObserver(SurfaceManagerObserver* obs) {
49 observer_list_.RemoveObserver(obs); 49 observer_list_.RemoveObserver(obs);
50 } 50 }
51 51
52 bool SurfaceModified(const SurfaceId& surface_id); 52 bool SurfaceModified(const SurfaceId& surface_id);
53 53
54 // Called when a CompositorFrame is submitted to a SurfaceFactory for a given
55 // |surface_id| for the first time.
56 void SurfaceCreated(const SurfaceId& surface_id,
57 const gfx::Size& frame_size,
58 float device_scale_factor);
59
54 // A frame for a surface satisfies a set of sequence numbers in a particular 60 // A frame for a surface satisfies a set of sequence numbers in a particular
55 // id namespace. 61 // id namespace.
56 void DidSatisfySequences(const FrameSinkId& frame_sink_id, 62 void DidSatisfySequences(const FrameSinkId& frame_sink_id,
57 std::vector<uint32_t>* sequence); 63 std::vector<uint32_t>* sequence);
58 64
59 void RegisterFrameSinkId(const FrameSinkId& frame_sink_id); 65 void RegisterFrameSinkId(const FrameSinkId& frame_sink_id);
60 66
61 // Invalidate a frame_sink_id that might still have associated sequences, 67 // Invalidate a frame_sink_id that might still have associated sequences,
62 // possibly because a renderer process has crashed. 68 // possibly because a renderer process has crashed.
63 void InvalidateFrameSinkId(const FrameSinkId& frame_sink_id); 69 void InvalidateFrameSinkId(const FrameSinkId& frame_sink_id);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 BeginFrameSource* source); 109 BeginFrameSource* source);
104 // Returns true if |child namespace| is or has |search_frame_sink_id| as a 110 // Returns true if |child namespace| is or has |search_frame_sink_id| as a
105 // child. 111 // child.
106 bool ChildContains(const FrameSinkId& child_frame_sink_id, 112 bool ChildContains(const FrameSinkId& child_frame_sink_id,
107 const FrameSinkId& search_frame_sink_id) const; 113 const FrameSinkId& search_frame_sink_id) const;
108 114
109 void GarbageCollectSurfaces(); 115 void GarbageCollectSurfaces();
110 116
111 using SurfaceMap = std::unordered_map<SurfaceId, Surface*, SurfaceIdHash>; 117 using SurfaceMap = std::unordered_map<SurfaceId, Surface*, SurfaceIdHash>;
112 SurfaceMap surface_map_; 118 SurfaceMap surface_map_;
113 base::ObserverList<SurfaceDamageObserver> observer_list_; 119 base::ObserverList<SurfaceManagerObserver> observer_list_;
114 base::ThreadChecker thread_checker_; 120 base::ThreadChecker thread_checker_;
115 121
116 // List of surfaces to be destroyed, along with what sequences they're still 122 // List of surfaces to be destroyed, along with what sequences they're still
117 // waiting on. 123 // waiting on.
118 using SurfaceDestroyList = std::list<std::unique_ptr<Surface>>; 124 using SurfaceDestroyList = std::list<std::unique_ptr<Surface>>;
119 SurfaceDestroyList surfaces_to_destroy_; 125 SurfaceDestroyList surfaces_to_destroy_;
120 126
121 // Set of SurfaceSequences that have been satisfied by a frame but not yet 127 // Set of SurfaceSequences that have been satisfied by a frame but not yet
122 // waited on. 128 // waited on.
123 std::unordered_set<SurfaceSequence, SurfaceSequenceHash> satisfied_sequences_; 129 std::unordered_set<SurfaceSequence, SurfaceSequenceHash> satisfied_sequences_;
(...skipping 23 matching lines...) Expand all
147 // that is implicitly using this namespace must be reachable by the 153 // that is implicitly using this namespace must be reachable by the
148 // parent in the dag. 154 // parent in the dag.
149 std::unordered_map<BeginFrameSource*, FrameSinkId> registered_sources_; 155 std::unordered_map<BeginFrameSource*, FrameSinkId> registered_sources_;
150 156
151 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); 157 DISALLOW_COPY_AND_ASSIGN(SurfaceManager);
152 }; 158 };
153 159
154 } // namespace cc 160 } // namespace cc
155 161
156 #endif // CC_SURFACES_SURFACE_MANAGER_H_ 162 #endif // CC_SURFACES_SURFACE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698