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

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

Powered by Google App Engine
This is Rietveld 408576698