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

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

Issue 2520513002: Add DisplayCompositorTest. (Closed)
Patch Set: Add non-exported base. Created 4 years 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/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/compiler_specific.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/frame_sink_id.h" 20 #include "cc/surfaces/frame_sink_id.h"
20 #include "cc/surfaces/surface_id.h" 21 #include "cc/surfaces/surface_id.h"
21 #include "cc/surfaces/surface_observer.h" 22 #include "cc/surfaces/surface_observer.h"
23 #include "cc/surfaces/surface_reference_manager.h"
22 #include "cc/surfaces/surface_sequence.h" 24 #include "cc/surfaces/surface_sequence.h"
23 #include "cc/surfaces/surfaces_export.h" 25 #include "cc/surfaces/surfaces_export.h"
24 26
25 namespace cc { 27 namespace cc {
26 class BeginFrameSource; 28 class BeginFrameSource;
27 class CompositorFrame; 29 class CompositorFrame;
28 class Surface; 30 class Surface;
29 class SurfaceFactoryClient; 31 class SurfaceFactoryClient;
30 32
31 class CC_SURFACES_EXPORT SurfaceManager { 33 class CC_SURFACES_EXPORT SurfaceManager
34 : public NON_EXPORTED_BASE(SurfaceReferenceManager) {
32 public: 35 public:
33 SurfaceManager(); 36 SurfaceManager();
34 ~SurfaceManager(); 37 ~SurfaceManager() override;
35 38
36 void RegisterSurface(Surface* surface); 39 void RegisterSurface(Surface* surface);
37 void DeregisterSurface(const SurfaceId& surface_id); 40 void DeregisterSurface(const SurfaceId& surface_id);
38 41
39 // Destroy the Surface once a set of sequence numbers has been satisfied. 42 // Destroy the Surface once a set of sequence numbers has been satisfied.
40 void Destroy(std::unique_ptr<Surface> surface); 43 void Destroy(std::unique_ptr<Surface> surface);
41 44
42 Surface* GetSurfaceForId(const SurfaceId& surface_id); 45 Surface* GetSurfaceForId(const SurfaceId& surface_id);
43 46
44 void AddObserver(SurfaceObserver* obs) { observer_list_.AddObserver(obs); } 47 void AddObserver(SurfaceObserver* obs) { observer_list_.AddObserver(obs); }
(...skipping 14 matching lines...) Expand all
59 // id namespace. 62 // id namespace.
60 void DidSatisfySequences(const FrameSinkId& frame_sink_id, 63 void DidSatisfySequences(const FrameSinkId& frame_sink_id,
61 std::vector<uint32_t>* sequence); 64 std::vector<uint32_t>* sequence);
62 65
63 void RegisterFrameSinkId(const FrameSinkId& frame_sink_id); 66 void RegisterFrameSinkId(const FrameSinkId& frame_sink_id);
64 67
65 // Invalidate a frame_sink_id that might still have associated sequences, 68 // Invalidate a frame_sink_id that might still have associated sequences,
66 // possibly because a renderer process has crashed. 69 // possibly because a renderer process has crashed.
67 void InvalidateFrameSinkId(const FrameSinkId& frame_sink_id); 70 void InvalidateFrameSinkId(const FrameSinkId& frame_sink_id);
68 71
69 // Adds a reference from a parent surface to a child surface. Any surface
70 // embedding a child surface should have a reference added so that the child
71 // surface is not garbage collected until after the parent surface.
72 void AddSurfaceReference(const SurfaceId& parent_id,
73 const SurfaceId& child_id);
74
75 // Removes a reference from a parent surface to a child surface.
76 void RemoveSurfaceReference(const SurfaceId& parent_id,
77 const SurfaceId& child_id);
78
79 // Returns the number of surfaces that have references to |surface_id|. When
80 // the count is zero nothing is referencing the surface and it may be garbage
81 // collected.
82 size_t GetSurfaceReferenceCount(const SurfaceId& surface_id) const;
83
84 // Returns the number of surfaces that |surface_id| has references to.
85 size_t GetReferencedSurfaceCount(const SurfaceId& surface_id) const;
86
87 // SurfaceFactoryClient, hierarchy, and BeginFrameSource can be registered 72 // SurfaceFactoryClient, hierarchy, and BeginFrameSource can be registered
88 // and unregistered in any order with respect to each other. 73 // and unregistered in any order with respect to each other.
89 // 74 //
90 // This happens in practice, e.g. the relationship to between ui::Compositor / 75 // This happens in practice, e.g. the relationship to between ui::Compositor /
91 // DelegatedFrameHost is known before ui::Compositor has a surface/client). 76 // DelegatedFrameHost is known before ui::Compositor has a surface/client).
92 // However, DelegatedFrameHost can register itself as a client before its 77 // However, DelegatedFrameHost can register itself as a client before its
93 // relationship with the ui::Compositor is known. 78 // relationship with the ui::Compositor is known.
94 79
95 // Associates a SurfaceFactoryClient with the surface id frame_sink_id it 80 // Associates a SurfaceFactoryClient with the surface id frame_sink_id it
96 // uses. 81 // uses.
(...skipping 14 matching lines...) Expand all
111 96
112 // Register a relationship between two namespaces. This relationship means 97 // Register a relationship between two namespaces. This relationship means
113 // that surfaces from the child namespace will be displayed in the parent. 98 // that surfaces from the child namespace will be displayed in the parent.
114 // Children are allowed to use any begin frame source that their parent can 99 // Children are allowed to use any begin frame source that their parent can
115 // use. 100 // use.
116 void RegisterFrameSinkHierarchy(const FrameSinkId& parent_frame_sink_id, 101 void RegisterFrameSinkHierarchy(const FrameSinkId& parent_frame_sink_id,
117 const FrameSinkId& child_frame_sink_id); 102 const FrameSinkId& child_frame_sink_id);
118 void UnregisterFrameSinkHierarchy(const FrameSinkId& parent_frame_sink_id, 103 void UnregisterFrameSinkHierarchy(const FrameSinkId& parent_frame_sink_id,
119 const FrameSinkId& child_frame_sink_id); 104 const FrameSinkId& child_frame_sink_id);
120 105
121 const SurfaceId& GetRootSurfaceId() { return kRootSurfaceId; } 106 // SurfaceReferenceManager:
107 const SurfaceId& GetRootSurfaceId() const override;
108 void AddSurfaceReference(const SurfaceId& parent_id,
109 const SurfaceId& child_id) override;
110 void RemoveSurfaceReference(const SurfaceId& parent_id,
111 const SurfaceId& child_id) override;
112 size_t GetSurfaceReferenceCount(const SurfaceId& surface_id) const override;
113 size_t GetReferencedSurfaceCount(const SurfaceId& surface_id) const override;
122 114
123 private: 115 private:
124 void RecursivelyAttachBeginFrameSource(const FrameSinkId& frame_sink_id, 116 void RecursivelyAttachBeginFrameSource(const FrameSinkId& frame_sink_id,
125 BeginFrameSource* source); 117 BeginFrameSource* source);
126 void RecursivelyDetachBeginFrameSource(const FrameSinkId& frame_sink_id, 118 void RecursivelyDetachBeginFrameSource(const FrameSinkId& frame_sink_id,
127 BeginFrameSource* source); 119 BeginFrameSource* source);
128 // Returns true if |child namespace| is or has |search_frame_sink_id| as a 120 // Returns true if |child namespace| is or has |search_frame_sink_id| as a
129 // child. 121 // child.
130 bool ChildContains(const FrameSinkId& child_frame_sink_id, 122 bool ChildContains(const FrameSinkId& child_frame_sink_id,
131 const FrameSinkId& search_frame_sink_id) const; 123 const FrameSinkId& search_frame_sink_id) const;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // Root SurfaceId that references display root surfaces. There is no Surface 184 // Root SurfaceId that references display root surfaces. There is no Surface
193 // with this id, it's for bookkeeping purposes only. 185 // with this id, it's for bookkeeping purposes only.
194 const SurfaceId kRootSurfaceId; 186 const SurfaceId kRootSurfaceId;
195 187
196 DISALLOW_COPY_AND_ASSIGN(SurfaceManager); 188 DISALLOW_COPY_AND_ASSIGN(SurfaceManager);
197 }; 189 };
198 190
199 } // namespace cc 191 } // namespace cc
200 192
201 #endif // CC_SURFACES_SURFACE_MANAGER_H_ 193 #endif // CC_SURFACES_SURFACE_MANAGER_H_
OLDNEW
« no previous file with comments | « cc/surfaces/BUILD.gn ('k') | cc/surfaces/surface_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698