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

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

Issue 2144733005: [WIP] cc: Plumb SurfaceId from clients Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ensure only SurfaceFactoy and tests can update hierarchy Created 4 years, 5 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/surface_id_allocator.cc ('k') | cc/surfaces/surface_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_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/gtest_prod_util.h"
16 #include "base/macros.h" 17 #include "base/macros.h"
17 #include "base/observer_list.h" 18 #include "base/observer_list.h"
18 #include "base/threading/thread_checker.h" 19 #include "base/threading/thread_checker.h"
19 #include "cc/surfaces/surface_damage_observer.h" 20 #include "cc/surfaces/surface_damage_observer.h"
20 #include "cc/surfaces/surface_id.h" 21 #include "cc/surfaces/surface_id.h"
21 #include "cc/surfaces/surface_sequence.h" 22 #include "cc/surfaces/surface_sequence.h"
22 #include "cc/surfaces/surfaces_export.h" 23 #include "cc/surfaces/surfaces_export.h"
23 24
24 namespace cc { 25 namespace cc {
25 class BeginFrameSource; 26 class BeginFrameSource;
26 class CompositorFrame; 27 class CompositorFrame;
27 class Surface; 28 class Surface;
28 class SurfaceFactoryClient; 29 class SurfaceFactoryClient;
29 30
31 namespace test {
32 class SurfaceDisplayOutputSurfaceTest;
33 }
34
30 class CC_SURFACES_EXPORT SurfaceManager { 35 class CC_SURFACES_EXPORT SurfaceManager {
31 public: 36 public:
32 SurfaceManager(); 37 SurfaceManager();
33 ~SurfaceManager(); 38 ~SurfaceManager();
34 39
35 void RegisterSurface(Surface* surface); 40 void RegisterSurface(Surface* surface);
36 void DeregisterSurface(const SurfaceId& surface_id); 41 void DeregisterSurface(const SurfaceId& surface_id);
37 42
38 // Destroy the Surface once a set of sequence numbers has been satisfied. 43 // Destroy the Surface once a set of sequence numbers has been satisfied.
39 void Destroy(std::unique_ptr<Surface> surface); 44 void Destroy(std::unique_ptr<Surface> surface);
40 45
41 Surface* GetSurfaceForId(const SurfaceId& surface_id); 46 Surface* GetSurfaceForId(const SurfaceId& surface_id);
42 47
43 void AddObserver(SurfaceDamageObserver* obs) { 48 void AddObserver(SurfaceDamageObserver* obs) {
44 observer_list_.AddObserver(obs); 49 observer_list_.AddObserver(obs);
45 } 50 }
46 51
47 void RemoveObserver(SurfaceDamageObserver* obs) { 52 void RemoveObserver(SurfaceDamageObserver* obs) {
48 observer_list_.RemoveObserver(obs); 53 observer_list_.RemoveObserver(obs);
49 } 54 }
50 55
51 bool SurfaceModified(const SurfaceId& surface_id); 56 bool SurfaceModified(const SurfaceId& surface_id);
52 57
53 // A frame for a surface satisfies a set of sequence numbers in a particular 58 // A frame for a surface satisfies a set of sequence numbers in a particular
54 // id namespace. 59 // id namespace.
55 void DidSatisfySequences(uint32_t client_id, std::vector<uint32_t>* sequence); 60 void DidSatisfySequences(uint32_t client_id, std::vector<uint32_t>* sequence);
56 61
57 void RegisterSurfaceClientId(uint32_t client_id); 62 // Associates a |source| with a particular namespace. That namespace and
63 // any children of that namespace with valid clients can potentially use
64 // that |source|.
65 void RegisterBeginFrameSource(BeginFrameSource* source, uint32_t client_id);
66 void UnregisterBeginFrameSource(BeginFrameSource* source);
58 67
59 // Invalidate a namespace that might still have associated sequences, 68 private:
60 // possibly because a renderer process has crashed. 69 FRIEND_TEST_ALL_PREFIXES(SurfaceManagerTest, SingleClients);
61 void InvalidateSurfaceClientId(uint32_t client_id); 70 FRIEND_TEST_ALL_PREFIXES(SurfaceManagerTest, MultipleDisplays);
71 friend class SurfaceManagerOrderingTest;
72 friend class SurfaceFactory;
73 friend class test::SurfaceDisplayOutputSurfaceTest;
74 friend class FakeSurfaceFactoryClient;
75
76 // Register a relationship between two clients. This relationship means
77 // that surfaces from the child client will be displayed in the parent.
78 // Children are allowed to use any begin frame source that their parent can
79 // use.
80 void RegisterSurfaceNamespaceHierarchy(uint32_t parent_namespace,
81 uint32_t child_namespace);
82 void UnregisterSurfaceNamespaceHierarchy(uint32_t parent_namespace,
83 uint32_t child_namespace);
62 84
63 // SurfaceFactoryClient, hierarchy, and BeginFrameSource can be registered 85 // SurfaceFactoryClient, hierarchy, and BeginFrameSource can be registered
64 // and unregistered in any order with respect to each other. 86 // and unregistered in any order with respect to each other.
65 // 87 //
66 // This happens in practice, e.g. the relationship to between ui::Compositor / 88 // This happens in practice, e.g. the relationship to between ui::Compositor /
67 // DelegatedFrameHost is known before ui::Compositor has a surface/client). 89 // DelegatedFrameHost is known before ui::Compositor has a surface/client).
68 // However, DelegatedFrameHost can register itself as a client before its 90 // However, DelegatedFrameHost can register itself as a client before its
69 // relationship with the ui::Compositor is known. 91 // relationship with the ui::Compositor is known.
70 92
71 // Associates a SurfaceFactoryClient with the surface id namespace it uses. 93 // Associates a SurfaceFactoryClient with the surface id namespace it uses.
72 // SurfaceFactoryClient and surface namespaces/allocators have a 1:1 mapping. 94 // SurfaceFactoryClient and surface namespaces/allocators have a 1:1 mapping.
73 // Caller guarantees the client is alive between register/unregister. 95 // Caller guarantees the client is alive between register/unregister.
74 // Reregistering the same namespace when a previous client is active is not 96 // Reregistering the same namespace when a previous client is active is not
75 // valid. 97 // valid.
76 void RegisterSurfaceFactoryClient(uint32_t client_id, 98 void RegisterClient(uint32_t client_id, SurfaceFactoryClient* client);
77 SurfaceFactoryClient* client); 99 void UnregisterClient(uint32_t client_id);
78 void UnregisterSurfaceFactoryClient(uint32_t client_id);
79 100
80 // Associates a |source| with a particular namespace. That namespace and
81 // any children of that namespace with valid clients can potentially use
82 // that |source|.
83 void RegisterBeginFrameSource(BeginFrameSource* source, uint32_t client_id);
84 void UnregisterBeginFrameSource(BeginFrameSource* source);
85
86 // Register a relationship between two namespaces. This relationship means
87 // that surfaces from the child namespace will be displayed in the parent.
88 // Children are allowed to use any begin frame source that their parent can
89 // use.
90 void RegisterSurfaceNamespaceHierarchy(uint32_t parent_namespace,
91 uint32_t child_namespace);
92 void UnregisterSurfaceNamespaceHierarchy(uint32_t parent_namespace,
93 uint32_t child_namespace);
94
95 private:
96 void RecursivelyAttachBeginFrameSource(uint32_t client_id, 101 void RecursivelyAttachBeginFrameSource(uint32_t client_id,
97 BeginFrameSource* source); 102 BeginFrameSource* source);
98 void RecursivelyDetachBeginFrameSource(uint32_t client_id, 103 void RecursivelyDetachBeginFrameSource(uint32_t client_id,
99 BeginFrameSource* source); 104 BeginFrameSource* source);
100 // Returns true if |child namespace| is or has |search_namespace| as a child. 105 // Returns true if |child namespace| is or has |search_namespace| as a child.
101 bool ChildContains(uint32_t child_namespace, uint32_t search_namespace) const; 106 bool ChildContains(uint32_t child_namespace, uint32_t search_namespace) const;
102 107
103 void GarbageCollectSurfaces(); 108 void GarbageCollectSurfaces();
104 109
105 using SurfaceMap = std::unordered_map<SurfaceId, Surface*, SurfaceIdHash>; 110 using SurfaceMap = std::unordered_map<SurfaceId, Surface*, SurfaceIdHash>;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // that is implicitly using this namespace must be reachable by the 145 // that is implicitly using this namespace must be reachable by the
141 // parent in the dag. 146 // parent in the dag.
142 std::unordered_map<BeginFrameSource*, uint32_t> registered_sources_; 147 std::unordered_map<BeginFrameSource*, uint32_t> registered_sources_;
143 148
144 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); 149 DISALLOW_COPY_AND_ASSIGN(SurfaceManager);
145 }; 150 };
146 151
147 } // namespace cc 152 } // namespace cc
148 153
149 #endif // CC_SURFACES_SURFACE_MANAGER_H_ 154 #endif // CC_SURFACES_SURFACE_MANAGER_H_
OLDNEW
« no previous file with comments | « cc/surfaces/surface_id_allocator.cc ('k') | cc/surfaces/surface_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698