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

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

Issue 2802023002: Remove SurfaceFactory And SurfaceFactoryClient (Closed)
Patch Set: Rebase Created 3 years, 8 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
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_H_ 5 #ifndef CC_SURFACES_SURFACE_H_
6 #define CC_SURFACES_SURFACE_H_ 6 #define CC_SURFACES_SURFACE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <map> 11 #include <map>
12 #include <memory> 12 #include <memory>
13 #include <set> 13 #include <set>
14 #include <unordered_set> 14 #include <unordered_set>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/callback.h" 17 #include "base/callback.h"
18 #include "base/macros.h" 18 #include "base/macros.h"
19 #include "base/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
20 #include "base/optional.h" 20 #include "base/optional.h"
21 #include "cc/output/copy_output_request.h" 21 #include "cc/output/copy_output_request.h"
22 #include "cc/surfaces/compositor_frame_sink_support.h"
22 #include "cc/surfaces/frame_sink_id.h" 23 #include "cc/surfaces/frame_sink_id.h"
23 #include "cc/surfaces/pending_frame_observer.h" 24 #include "cc/surfaces/pending_frame_observer.h"
24 #include "cc/surfaces/surface_factory.h"
25 #include "cc/surfaces/surface_id.h" 25 #include "cc/surfaces/surface_id.h"
26 #include "cc/surfaces/surface_sequence.h" 26 #include "cc/surfaces/surface_sequence.h"
27 #include "cc/surfaces/surfaces_export.h" 27 #include "cc/surfaces/surfaces_export.h"
28 #include "ui/gfx/geometry/size.h" 28 #include "ui/gfx/geometry/size.h"
29 29
30 namespace ui { 30 namespace ui {
31 class LatencyInfo; 31 class LatencyInfo;
32 } 32 }
33 33
34 namespace cc { 34 namespace cc {
35 35
36 class BeginFrameSource; 36 class BeginFrameSource;
37 class CompositorFrame; 37 class CompositorFrame;
38 class CopyOutputRequest; 38 class CopyOutputRequest;
39 class SurfaceFactory;
40 39
41 class CC_SURFACES_EXPORT Surface { 40 class CC_SURFACES_EXPORT Surface {
42 public: 41 public:
43 using DrawCallback = SurfaceFactory::DrawCallback; 42 using DrawCallback = base::Callback<void()>;
44 43
45 Surface(const SurfaceId& id, base::WeakPtr<SurfaceFactory> factory); 44 Surface(
45 const SurfaceId& id,
46 base::WeakPtr<CompositorFrameSinkSupport> compositor_frame_sink_support);
46 ~Surface(); 47 ~Surface();
47 48
48 const SurfaceId& surface_id() const { return surface_id_; } 49 const SurfaceId& surface_id() const { return surface_id_; }
49 const SurfaceId& previous_frame_surface_id() const { 50 const SurfaceId& previous_frame_surface_id() const {
50 return previous_frame_surface_id_; 51 return previous_frame_surface_id_;
51 } 52 }
52 53
53 void SetPreviousFrameSurface(Surface* surface); 54 void SetPreviousFrameSurface(Surface* surface);
54 55
55 void QueueFrame(CompositorFrame frame, const DrawCallback& draw_callback); 56 void QueueFrame(CompositorFrame frame, const DrawCallback& draw_callback);
(...skipping 23 matching lines...) Expand all
79 // Returns the currently pending frame. You must check where HasPendingFrame() 80 // Returns the currently pending frame. You must check where HasPendingFrame()
80 // returns true before calling this method. 81 // returns true before calling this method.
81 const CompositorFrame& GetPendingFrame(); 82 const CompositorFrame& GetPendingFrame();
82 83
83 // Returns a number that increments by 1 every time a new frame is enqueued. 84 // Returns a number that increments by 1 every time a new frame is enqueued.
84 int frame_index() const { return frame_index_; } 85 int frame_index() const { return frame_index_; }
85 86
86 void TakeLatencyInfo(std::vector<ui::LatencyInfo>* latency_info); 87 void TakeLatencyInfo(std::vector<ui::LatencyInfo>* latency_info);
87 void RunDrawCallbacks(); 88 void RunDrawCallbacks();
88 89
89 base::WeakPtr<SurfaceFactory> factory() { return factory_; } 90 base::WeakPtr<CompositorFrameSinkSupport> compositor_frame_sink_support() {
91 return compositor_frame_sink_support_;
92 }
90 93
91 // Add a SurfaceSequence that must be satisfied before the Surface is 94 // Add a SurfaceSequence that must be satisfied before the Surface is
92 // destroyed. 95 // destroyed.
93 void AddDestructionDependency(SurfaceSequence sequence); 96 void AddDestructionDependency(SurfaceSequence sequence);
94 97
95 // Satisfy all destruction dependencies that are contained in sequences, and 98 // Satisfy all destruction dependencies that are contained in sequences, and
96 // remove them from sequences. 99 // remove them from sequences.
97 void SatisfyDestructionDependencies( 100 void SatisfyDestructionDependencies(
98 std::unordered_set<SurfaceSequence, SurfaceSequenceHash>* sequences, 101 std::unordered_set<SurfaceSequence, SurfaceSequenceHash>* sequences,
99 std::unordered_set<FrameSinkId, FrameSinkIdHash>* valid_id_namespaces); 102 std::unordered_set<FrameSinkId, FrameSinkIdHash>* valid_id_namespaces);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 void ClearCopyRequests(); 136 void ClearCopyRequests();
134 137
135 void TakeLatencyInfoFromPendingFrame( 138 void TakeLatencyInfoFromPendingFrame(
136 std::vector<ui::LatencyInfo>* latency_info); 139 std::vector<ui::LatencyInfo>* latency_info);
137 static void TakeLatencyInfoFromFrame( 140 static void TakeLatencyInfoFromFrame(
138 CompositorFrame* frame, 141 CompositorFrame* frame,
139 std::vector<ui::LatencyInfo>* latency_info); 142 std::vector<ui::LatencyInfo>* latency_info);
140 143
141 SurfaceId surface_id_; 144 SurfaceId surface_id_;
142 SurfaceId previous_frame_surface_id_; 145 SurfaceId previous_frame_surface_id_;
143 base::WeakPtr<SurfaceFactory> factory_; 146 base::WeakPtr<CompositorFrameSinkSupport> compositor_frame_sink_support_;
144 // TODO(jamesr): Support multiple frames in flight. 147 // TODO(jamesr): Support multiple frames in flight.
145 base::Optional<CompositorFrame> pending_frame_; 148 base::Optional<CompositorFrame> pending_frame_;
146 base::Optional<CompositorFrame> active_frame_; 149 base::Optional<CompositorFrame> active_frame_;
147 int frame_index_; 150 int frame_index_;
148 bool destroyed_; 151 bool destroyed_;
149 std::vector<SurfaceSequence> destruction_dependencies_; 152 std::vector<SurfaceSequence> destruction_dependencies_;
150 153
151 // This surface may have multiple BeginFrameSources if it is 154 // This surface may have multiple BeginFrameSources if it is
152 // on multiple Displays. 155 // on multiple Displays.
153 std::set<BeginFrameSource*> begin_frame_sources_; 156 std::set<BeginFrameSource*> begin_frame_sources_;
154 157
155 SurfaceDependencies blocking_surfaces_; 158 SurfaceDependencies blocking_surfaces_;
156 base::ObserverList<PendingFrameObserver, true> observers_; 159 base::ObserverList<PendingFrameObserver, true> observers_;
157 160
158 DrawCallback draw_callback_; 161 DrawCallback draw_callback_;
159 162
160 DISALLOW_COPY_AND_ASSIGN(Surface); 163 DISALLOW_COPY_AND_ASSIGN(Surface);
161 }; 164 };
162 165
163 } // namespace cc 166 } // namespace cc
164 167
165 #endif // CC_SURFACES_SURFACE_H_ 168 #endif // CC_SURFACES_SURFACE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698