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

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

Issue 2802023002: Remove SurfaceFactory And SurfaceFactoryClient (Closed)
Patch Set: Rebase SurfaceSynchronizationTest 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
« no previous file with comments | « cc/surfaces/direct_compositor_frame_sink.h ('k') | cc/surfaces/frame_sink_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_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 "cc/surfaces/frame_sink_id.h" 16 #include "cc/surfaces/frame_sink_id.h"
17 #include "cc/surfaces/surfaces_export.h" 17 #include "cc/surfaces/surfaces_export.h"
18 18
19 namespace cc { 19 namespace cc {
20 class BeginFrameSource; 20 class BeginFrameSource;
21 class FrameSinkManagerClient; 21 class FrameSinkManagerClient;
22 22
23 namespace test { 23 namespace test {
24 class CompositorFrameSinkSupportTest; 24 class SurfaceSynchronizationTest;
25 } 25 }
26 26
27 class CC_SURFACES_EXPORT FrameSinkManager { 27 class CC_SURFACES_EXPORT FrameSinkManager {
28 public: 28 public:
29 FrameSinkManager(); 29 FrameSinkManager();
30 ~FrameSinkManager(); 30 ~FrameSinkManager();
31 31
32 void RegisterFrameSinkId(const FrameSinkId& frame_sink_id); 32 void RegisterFrameSinkId(const FrameSinkId& frame_sink_id);
33 33
34 // Invalidate a frame_sink_id that might still have associated sequences, 34 // Invalidate a frame_sink_id that might still have associated sequences,
35 // possibly because a renderer process has crashed. 35 // possibly because a renderer process has crashed.
36 void InvalidateFrameSinkId(const FrameSinkId& frame_sink_id); 36 void InvalidateFrameSinkId(const FrameSinkId& frame_sink_id);
37 37
38 // SurfaceFactoryClient, hierarchy, and BeginFrameSource can be registered 38 // CompositorFrameSinkSupport, hierarchy, and BeginFrameSource can be
39 // and unregistered in any order with respect to each other. 39 // registered and unregistered in any order with respect to each other.
40 // 40 //
41 // This happens in practice, e.g. the relationship to between ui::Compositor / 41 // This happens in practice, e.g. the relationship to between ui::Compositor /
42 // DelegatedFrameHost is known before ui::Compositor has a surface/client). 42 // DelegatedFrameHost is known before ui::Compositor has a surface/client).
43 // However, DelegatedFrameHost can register itself as a client before its 43 // However, DelegatedFrameHost can register itself as a client before its
44 // relationship with the ui::Compositor is known. 44 // relationship with the ui::Compositor is known.
45 45
46 // Associates a FrameSinkManagerClient with the frame_sink_id it uses. 46 // Associates a FrameSinkManagerClient with the frame_sink_id it uses.
47 // FrameSinkManagerClient and framesink allocators have a 1:1 mapping. 47 // FrameSinkManagerClient and framesink allocators have a 1:1 mapping.
48 // Caller guarantees the client is alive between register/unregister. 48 // Caller guarantees the client is alive between register/unregister.
49 void RegisterFrameSinkManagerClient(const FrameSinkId& frame_sink_id, 49 void RegisterFrameSinkManagerClient(const FrameSinkId& frame_sink_id,
(...skipping 16 matching lines...) Expand all
66 void UnregisterFrameSinkHierarchy(const FrameSinkId& parent_frame_sink_id, 66 void UnregisterFrameSinkHierarchy(const FrameSinkId& parent_frame_sink_id,
67 const FrameSinkId& child_frame_sink_id); 67 const FrameSinkId& child_frame_sink_id);
68 68
69 // Export list of valid frame_sink_ids for SatisfyDestructionDeps in surface 69 // Export list of valid frame_sink_ids for SatisfyDestructionDeps in surface
70 // may be removed later when References replace Sequences 70 // may be removed later when References replace Sequences
71 std::unordered_set<FrameSinkId, FrameSinkIdHash>* GetValidFrameSinkIds() { 71 std::unordered_set<FrameSinkId, FrameSinkIdHash>* GetValidFrameSinkIds() {
72 return &valid_frame_sink_ids_; 72 return &valid_frame_sink_ids_;
73 } 73 }
74 74
75 private: 75 private:
76 friend class test::CompositorFrameSinkSupportTest; 76 friend class test::SurfaceSynchronizationTest;
77 77
78 void RecursivelyAttachBeginFrameSource(const FrameSinkId& frame_sink_id, 78 void RecursivelyAttachBeginFrameSource(const FrameSinkId& frame_sink_id,
79 BeginFrameSource* source); 79 BeginFrameSource* source);
80 void RecursivelyDetachBeginFrameSource(const FrameSinkId& frame_sink_id, 80 void RecursivelyDetachBeginFrameSource(const FrameSinkId& frame_sink_id,
81 BeginFrameSource* source); 81 BeginFrameSource* source);
82 82
83 // Returns true if |child framesink| is or has |search_frame_sink_id| as a 83 // Returns true if |child framesink| is or has |search_frame_sink_id| as a
84 // child. 84 // child.
85 bool ChildContains(const FrameSinkId& child_frame_sink_id, 85 bool ChildContains(const FrameSinkId& child_frame_sink_id,
86 const FrameSinkId& search_frame_sink_id) const; 86 const FrameSinkId& search_frame_sink_id) const;
87 87
88 // Set of valid framesink Ids. When a framesink Id is removed from 88 // Set of valid framesink Ids. When a framesink Id is removed from
89 // this set, any remaining (surface) sequences with that framesink are 89 // this set, any remaining (surface) sequences with that framesink are
90 // considered satisfied. 90 // considered satisfied.
91 std::unordered_set<FrameSinkId, FrameSinkIdHash> valid_frame_sink_ids_; 91 std::unordered_set<FrameSinkId, FrameSinkIdHash> valid_frame_sink_ids_;
92 92
93 // Begin frame source routing. Both BeginFrameSource and SurfaceFactoryClient 93 // Begin frame source routing. Both BeginFrameSource and
94 // pointers guaranteed alive by callers until unregistered. 94 // CompositorFrameSinkSupport pointers guaranteed alive by callers until
95 // unregistered.
95 struct FrameSinkSourceMapping { 96 struct FrameSinkSourceMapping {
96 FrameSinkSourceMapping(); 97 FrameSinkSourceMapping();
97 FrameSinkSourceMapping(const FrameSinkSourceMapping& other); 98 FrameSinkSourceMapping(const FrameSinkSourceMapping& other);
98 ~FrameSinkSourceMapping(); 99 ~FrameSinkSourceMapping();
99 bool has_children() const { return !children.empty(); } 100 bool has_children() const { return !children.empty(); }
100 // The currently assigned begin frame source for this client. 101 // The currently assigned begin frame source for this client.
101 BeginFrameSource* source; 102 BeginFrameSource* source;
102 // This represents a dag of parent -> children mapping. 103 // This represents a dag of parent -> children mapping.
103 std::vector<FrameSinkId> children; 104 std::vector<FrameSinkId> children;
104 }; 105 };
105 106
106 std::unordered_map<FrameSinkId, FrameSinkManagerClient*, FrameSinkIdHash> 107 std::unordered_map<FrameSinkId, FrameSinkManagerClient*, FrameSinkIdHash>
107 clients_; 108 clients_;
108 109
109 std::unordered_map<FrameSinkId, FrameSinkSourceMapping, FrameSinkIdHash> 110 std::unordered_map<FrameSinkId, FrameSinkSourceMapping, FrameSinkIdHash>
110 frame_sink_source_map_; 111 frame_sink_source_map_;
111 112
112 // Set of which sources are registered to which frmesinks. Any child 113 // Set of which sources are registered to which frmesinks. Any child
113 // that is implicitly using this framesink must be reachable by the 114 // that is implicitly using this framesink must be reachable by the
114 // parent in the dag. 115 // parent in the dag.
115 std::unordered_map<BeginFrameSource*, FrameSinkId> registered_sources_; 116 std::unordered_map<BeginFrameSource*, FrameSinkId> registered_sources_;
116 117
117 DISALLOW_COPY_AND_ASSIGN(FrameSinkManager); 118 DISALLOW_COPY_AND_ASSIGN(FrameSinkManager);
118 }; 119 };
119 120
120 } // namespace cc 121 } // namespace cc
121 122
122 #endif // CC_SURFACES_FRAME_SINK_MANAGER_H_ 123 #endif // CC_SURFACES_FRAME_SINK_MANAGER_H_
OLDNEW
« no previous file with comments | « cc/surfaces/direct_compositor_frame_sink.h ('k') | cc/surfaces/frame_sink_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698