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

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

Issue 2684933003: Move frame_sink_id management to framesink_manager.cc/h from (Closed)
Patch Set: Changed the patch to call frmesink_manager from surface_manager Created 3 years, 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CC_SURFACES_FRAMESINK_MANAGER_H_
6 #define CC_SURFACES_FRAMESINK_MANAGER_H_
7
8 #include <stdint.h>
9
10 #include <list>
11 #include <memory>
12 #include <unordered_map>
13 #include <unordered_set>
14 #include <vector>
15
16 #include "base/logging.h"
17 #include "base/macros.h"
18 #include "cc/surfaces/frame_sink_id.h"
19 #include "cc/surfaces/surfaces_export.h"
20
21 #if DCHECK_IS_ON()
enne (OOO) 2017/03/20 18:28:53 These don't appear to be used in this header file.
22 #include <iosfwd>
23 #include <string>
24 #endif
25
26 namespace cc {
27 class BeginFrameSource;
28 class CompositorFrame;
29 class SurfaceFactoryClient;
30
31 namespace test {
32 class CompositorFrameSinkSupportTest;
33 }
34
35 class CC_SURFACES_EXPORT FrameSinkManager {
36 public:
37 FrameSinkManager();
38 ~FrameSinkManager();
39
40 void RegisterFrameSinkId(const FrameSinkId& frame_sink_id);
41
42 // Invalidate a frame_sink_id that might still have associated sequences,
43 // possibly because a renderer process has crashed.
44 void InvalidateFrameSinkId(const FrameSinkId& frame_sink_id);
45
46 // SurfaceFactoryClient, hierarchy, and BeginFrameSource can be registered
47 // and unregistered in any order with respect to each other.
48 //
49 // This happens in practice, e.g. the relationship to between ui::Compositor /
50 // DelegatedFrameHost is known before ui::Compositor has a surface/client).
51 // However, DelegatedFrameHost can register itself as a client before its
52 // relationship with the ui::Compositor is known.
53
54 // Associates a SurfaceFactoryClient with the surface id frame_sink_id it
55 // uses.
56 // SurfaceFactoryClient and surface namespaces/allocators have a 1:1 mapping.
57 // Caller guarantees the client is alive between register/unregister.
58 // Reregistering the same namespace when a previous client is active is not
59 // valid.
60 void RegisterSurfaceFactoryClient(const FrameSinkId& frame_sink_id,
61 SurfaceFactoryClient* client);
62 void UnregisterSurfaceFactoryClient(const FrameSinkId& frame_sink_id);
63
64 // Associates a |source| with a particular namespace. That namespace and
enne (OOO) 2017/03/20 18:28:53 Might be good to clean up this antiquated namespac
65 // any children of that namespace with valid clients can potentially use
66 // that |source|.
67 void RegisterBeginFrameSource(BeginFrameSource* source,
68 const FrameSinkId& frame_sink_id);
69 void UnregisterBeginFrameSource(BeginFrameSource* source);
70
71 // Register a relationship between two namespaces. This relationship means
72 // that surfaces from the child namespace will be displayed in the parent.
73 // Children are allowed to use any begin frame source that their parent can
74 // use.
75 void RegisterFrameSinkHierarchy(const FrameSinkId& parent_frame_sink_id,
76 const FrameSinkId& child_frame_sink_id);
77 void UnregisterFrameSinkHierarchy(const FrameSinkId& parent_frame_sink_id,
78 const FrameSinkId& child_frame_sink_id);
79 // Export list of valid frame_sink_ids for SatisfyDestructionDeps in surface
80 // may be removed later when References replace Sequences
81 std::unordered_set<FrameSinkId, FrameSinkIdHash>* GetValidFrameSinkIds(){
82 return &valid_frame_sink_ids_;
83 }
84
85 private:
86 friend class test::CompositorFrameSinkSupportTest;
87
88 void RecursivelyAttachBeginFrameSource(const FrameSinkId& frame_sink_id,
89 BeginFrameSource* source);
90 void RecursivelyDetachBeginFrameSource(const FrameSinkId& frame_sink_id,
91 BeginFrameSource* source);
92
93 // Returns true if |child namespace| is or has |search_frame_sink_id| as a
94 // child.
95 bool ChildContains(const FrameSinkId& child_frame_sink_id,
96 const FrameSinkId& search_frame_sink_id) const;
97
98 // Set of valid surface ID namespaces. When a namespace is removed from
99 // this set, any remaining sequences with that namespace are considered
100 // satisfied.
101 std::unordered_set<FrameSinkId, FrameSinkIdHash> valid_frame_sink_ids_;
102
103 // Begin frame source routing. Both BeginFrameSource and SurfaceFactoryClient
104 // pointers guaranteed alive by callers until unregistered.
105 struct FrameSinkSourceMapping {
106 FrameSinkSourceMapping();
107 FrameSinkSourceMapping(const FrameSinkSourceMapping& other);
108 ~FrameSinkSourceMapping();
109 bool has_children() const { return !children.empty(); }
110 // The currently assigned begin frame source for this client.
111 BeginFrameSource* source;
112 // This represents a dag of parent -> children mapping.
113 std::vector<FrameSinkId> children;
114 };
115
116 std::unordered_map<FrameSinkId, SurfaceFactoryClient*, FrameSinkIdHash>
117 clients_;
118
119 std::unordered_map<FrameSinkId, FrameSinkSourceMapping, FrameSinkIdHash>
120 frame_sink_source_map_;
121
122 // Set of which sources are registered to which namespace. Any child
123 // that is implicitly using this namespace must be reachable by the
124 // parent in the dag.
125 std::unordered_map<BeginFrameSource*, FrameSinkId> registered_sources_;
126
127 DISALLOW_COPY_AND_ASSIGN(FrameSinkManager);
128 };
129
130 } // namespace cc
131
132 #endif // CC_SURFACES_FRAMESINK_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698