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

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

Issue 2880023002: cc::SurfaceDependencyTracker should not crash when a Display goes away (Closed)
Patch Set: StrictMock => NiceMock Created 3 years, 7 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_FRAME_SINK_MANAGER_H_ 5 #ifndef CC_SURFACES_FRAME_SINK_MANAGER_H_
6 #define CC_SURFACES_FRAME_SINK_MANAGER_H_ 6 #define CC_SURFACES_FRAME_SINK_MANAGER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <unordered_map> 10 #include <unordered_map>
11 #include <unordered_set> 11 #include <unordered_set>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/observer_list.h"
16 #include "cc/surfaces/frame_sink_id.h" 17 #include "cc/surfaces/frame_sink_id.h"
18 #include "cc/surfaces/frame_sink_observer.h"
17 #include "cc/surfaces/surfaces_export.h" 19 #include "cc/surfaces/surfaces_export.h"
18 20
19 namespace cc { 21 namespace cc {
20 class BeginFrameSource; 22 class BeginFrameSource;
21 class FrameSinkManagerClient; 23 class FrameSinkManagerClient;
22 24
23 namespace test { 25 namespace test {
24 class SurfaceSynchronizationTest; 26 class SurfaceSynchronizationTest;
25 } 27 }
26 28
(...skipping 16 matching lines...) Expand all
43 // However, DelegatedFrameHost can register itself as a client before its 45 // However, DelegatedFrameHost can register itself as a client before its
44 // relationship with the ui::Compositor is known. 46 // relationship with the ui::Compositor is known.
45 47
46 // Associates a FrameSinkManagerClient with the frame_sink_id it uses. 48 // Associates a FrameSinkManagerClient with the frame_sink_id it uses.
47 // FrameSinkManagerClient and framesink allocators have a 1:1 mapping. 49 // FrameSinkManagerClient and framesink allocators have a 1:1 mapping.
48 // Caller guarantees the client is alive between register/unregister. 50 // Caller guarantees the client is alive between register/unregister.
49 void RegisterFrameSinkManagerClient(const FrameSinkId& frame_sink_id, 51 void RegisterFrameSinkManagerClient(const FrameSinkId& frame_sink_id,
50 FrameSinkManagerClient* client); 52 FrameSinkManagerClient* client);
51 void UnregisterFrameSinkManagerClient(const FrameSinkId& frame_sink_id); 53 void UnregisterFrameSinkManagerClient(const FrameSinkId& frame_sink_id);
52 54
55 // Creates a BeginFrameSource that tracks the first registered
56 // BeginFrameSource.
57 std::unique_ptr<BeginFrameSource> CreatePrimaryBeginFrameSource();
58
59 void AddObserver(FrameSinkObserver* obs) { observer_list_.AddObserver(obs); }
60
61 void RemoveObserver(FrameSinkObserver* obs) {
62 observer_list_.RemoveObserver(obs);
63 }
64
53 // Associates a |source| with a particular framesink. That framesink and 65 // Associates a |source| with a particular framesink. That framesink and
54 // any children of that framesink with valid clients can potentially use 66 // any children of that framesink with valid clients can potentially use
55 // that |source|. 67 // that |source|.
56 void RegisterBeginFrameSource(BeginFrameSource* source, 68 void RegisterBeginFrameSource(BeginFrameSource* source,
57 const FrameSinkId& frame_sink_id); 69 const FrameSinkId& frame_sink_id);
58 void UnregisterBeginFrameSource(BeginFrameSource* source); 70 void UnregisterBeginFrameSource(BeginFrameSource* source);
71 BeginFrameSource* GetPrimaryBeginFrameSource();
59 72
60 // Register a relationship between two framesinks. This relationship means 73 // Register a relationship between two framesinks. This relationship means
61 // that surfaces from the child framesik will be displayed in the parent. 74 // that surfaces from the child framesik will be displayed in the parent.
62 // Children are allowed to use any begin frame source that their parent can 75 // Children are allowed to use any begin frame source that their parent can
63 // use. 76 // use.
64 void RegisterFrameSinkHierarchy(const FrameSinkId& parent_frame_sink_id, 77 void RegisterFrameSinkHierarchy(const FrameSinkId& parent_frame_sink_id,
65 const FrameSinkId& child_frame_sink_id); 78 const FrameSinkId& child_frame_sink_id);
66 void UnregisterFrameSinkHierarchy(const FrameSinkId& parent_frame_sink_id, 79 void UnregisterFrameSinkHierarchy(const FrameSinkId& parent_frame_sink_id,
67 const FrameSinkId& child_frame_sink_id); 80 const FrameSinkId& child_frame_sink_id);
68 81
(...skipping 23 matching lines...) Expand all
92 105
93 // Begin frame source routing. Both BeginFrameSource and 106 // Begin frame source routing. Both BeginFrameSource and
94 // CompositorFrameSinkSupport pointers guaranteed alive by callers until 107 // CompositorFrameSinkSupport pointers guaranteed alive by callers until
95 // unregistered. 108 // unregistered.
96 struct FrameSinkSourceMapping { 109 struct FrameSinkSourceMapping {
97 FrameSinkSourceMapping(); 110 FrameSinkSourceMapping();
98 FrameSinkSourceMapping(const FrameSinkSourceMapping& other); 111 FrameSinkSourceMapping(const FrameSinkSourceMapping& other);
99 ~FrameSinkSourceMapping(); 112 ~FrameSinkSourceMapping();
100 bool has_children() const { return !children.empty(); } 113 bool has_children() const { return !children.empty(); }
101 // The currently assigned begin frame source for this client. 114 // The currently assigned begin frame source for this client.
102 BeginFrameSource* source; 115 BeginFrameSource* source = nullptr;
103 // This represents a dag of parent -> children mapping. 116 // This represents a dag of parent -> children mapping.
104 std::vector<FrameSinkId> children; 117 std::vector<FrameSinkId> children;
105 }; 118 };
106 119
120 base::ObserverList<FrameSinkObserver> observer_list_;
121
107 std::unordered_map<FrameSinkId, FrameSinkManagerClient*, FrameSinkIdHash> 122 std::unordered_map<FrameSinkId, FrameSinkManagerClient*, FrameSinkIdHash>
108 clients_; 123 clients_;
109 124
110 std::unordered_map<FrameSinkId, FrameSinkSourceMapping, FrameSinkIdHash> 125 std::unordered_map<FrameSinkId, FrameSinkSourceMapping, FrameSinkIdHash>
111 frame_sink_source_map_; 126 frame_sink_source_map_;
112 127
113 // Set of which sources are registered to which frmesinks. Any child 128 // Set of BeginFrameSource along with associated FrameSinkIds. Any child
114 // that is implicitly using this framesink must be reachable by the 129 // that is implicitly using this framesink must be reachable by the
115 // parent in the dag. 130 // parent in the dag.
116 std::unordered_map<BeginFrameSource*, FrameSinkId> registered_sources_; 131 std::unordered_map<BeginFrameSource*, FrameSinkId> registered_sources_;
117 132
118 DISALLOW_COPY_AND_ASSIGN(FrameSinkManager); 133 DISALLOW_COPY_AND_ASSIGN(FrameSinkManager);
119 }; 134 };
120 135
121 } // namespace cc 136 } // namespace cc
122 137
123 #endif // CC_SURFACES_FRAME_SINK_MANAGER_H_ 138 #endif // CC_SURFACES_FRAME_SINK_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698