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

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

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

Powered by Google App Engine
This is Rietveld 408576698