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 2854163003: [cc] Plumb BeginFrameAcks through SurfaceManager to DisplayScheduler. (Closed)
Patch Set: Track state per surface. Created 3 years, 7 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/compositor_frame.h"
21 #include "cc/output/copy_output_request.h" 22 #include "cc/output/copy_output_request.h"
22 #include "cc/surfaces/compositor_frame_sink_support.h"
23 #include "cc/surfaces/frame_sink_id.h" 23 #include "cc/surfaces/frame_sink_id.h"
24 #include "cc/surfaces/surface_id.h" 24 #include "cc/surfaces/surface_id.h"
25 #include "cc/surfaces/surface_sequence.h" 25 #include "cc/surfaces/surface_sequence.h"
26 #include "cc/surfaces/surfaces_export.h" 26 #include "cc/surfaces/surfaces_export.h"
27 #include "ui/gfx/geometry/size.h" 27 #include "ui/gfx/geometry/size.h"
28 28
29 namespace ui { 29 namespace ui {
30 class LatencyInfo; 30 class LatencyInfo;
31 } 31 }
32 32
33 namespace cc { 33 namespace cc {
34 34
35 class CompositorFrame; 35 class CompositorFrameSinkSupport;
36 class CopyOutputRequest; 36 class CopyOutputRequest;
37 class SurfaceManager;
37 38
38 class CC_SURFACES_EXPORT Surface { 39 class CC_SURFACES_EXPORT Surface {
39 public: 40 public:
40 using WillDrawCallback = 41 using WillDrawCallback =
41 base::RepeatingCallback<void(const LocalSurfaceId&, const gfx::Rect&)>; 42 base::RepeatingCallback<void(const LocalSurfaceId&, const gfx::Rect&)>;
42 43
44 // State of a CompositorFrame producer.
45 enum ProducerState {
46 IDLE, // Has acknowledged the latest BeginFrame or is inactive.
47 PENDING, // Waiting for response to the last BeginFrame.
48 READY // A CompositorFrame was submitted but not yet drawn.
49 };
50
43 Surface( 51 Surface(
44 const SurfaceId& id, 52 const SurfaceId& id,
45 base::WeakPtr<CompositorFrameSinkSupport> compositor_frame_sink_support); 53 base::WeakPtr<CompositorFrameSinkSupport> compositor_frame_sink_support);
46 ~Surface(); 54 ~Surface();
47 55
48 const SurfaceId& surface_id() const { return surface_id_; } 56 const SurfaceId& surface_id() const { return surface_id_; }
49 const SurfaceId& previous_frame_surface_id() const { 57 const SurfaceId& previous_frame_surface_id() const {
50 return previous_frame_surface_id_; 58 return previous_frame_surface_id_;
51 } 59 }
52 60
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 : nullptr; 121 : nullptr;
114 } 122 }
115 123
116 const base::flat_set<SurfaceId>& blocking_surfaces() const { 124 const base::flat_set<SurfaceId>& blocking_surfaces() const {
117 return blocking_surfaces_; 125 return blocking_surfaces_;
118 } 126 }
119 127
120 bool HasActiveFrame() const { return active_frame_data_.has_value(); } 128 bool HasActiveFrame() const { return active_frame_data_.has_value(); }
121 bool HasPendingFrame() const { return pending_frame_data_.has_value(); } 129 bool HasPendingFrame() const { return pending_frame_data_.has_value(); }
122 130
131 // Get/Set the state of the producer that submits CompositorFrames to this
132 // surface.
133 ProducerState GetProducerState() const { return producer_state_; }
134 void SetProducerState(ProducerState state);
135
123 bool destroyed() const { return destroyed_; } 136 bool destroyed() const { return destroyed_; }
124 void set_destroyed(bool destroyed) { destroyed_ = destroyed; } 137 void set_destroyed(bool destroyed) { destroyed_ = destroyed; }
125 138
126 private: 139 private:
127 struct FrameData { 140 struct FrameData {
128 FrameData(CompositorFrame&& frame, 141 FrameData(CompositorFrame&& frame,
129 const base::Closure& draw_callback, 142 const base::Closure& draw_callback,
130 const WillDrawCallback& will_draw_callback); 143 const WillDrawCallback& will_draw_callback);
131 FrameData(FrameData&& other); 144 FrameData(FrameData&& other);
132 ~FrameData(); 145 ~FrameData();
(...skipping 30 matching lines...) Expand all
163 176
164 base::Optional<FrameData> pending_frame_data_; 177 base::Optional<FrameData> pending_frame_data_;
165 base::Optional<FrameData> active_frame_data_; 178 base::Optional<FrameData> active_frame_data_;
166 int frame_index_; 179 int frame_index_;
167 bool closed_ = false; 180 bool closed_ = false;
168 bool destroyed_; 181 bool destroyed_;
169 std::vector<SurfaceSequence> destruction_dependencies_; 182 std::vector<SurfaceSequence> destruction_dependencies_;
170 183
171 base::flat_set<SurfaceId> blocking_surfaces_; 184 base::flat_set<SurfaceId> blocking_surfaces_;
172 185
186 // The current state of the producer that submits CompositorFrames to this
187 // surface. This state helps the DisplayScheduler decide whether to wait for
188 // damage on this surface.
189 ProducerState producer_state_ = IDLE;
190
173 DISALLOW_COPY_AND_ASSIGN(Surface); 191 DISALLOW_COPY_AND_ASSIGN(Surface);
174 }; 192 };
175 193
176 } // namespace cc 194 } // namespace cc
177 195
178 #endif // CC_SURFACES_SURFACE_H_ 196 #endif // CC_SURFACES_SURFACE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698