OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "cc/surfaces/display_scheduler.h" | 5 #include "cc/surfaces/display_scheduler.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
11 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
12 #include "cc/output/output_surface.h" | 12 #include "cc/output/output_surface.h" |
| 13 #include "cc/surfaces/surface_info.h" |
13 | 14 |
14 namespace cc { | 15 namespace cc { |
15 | 16 |
16 DisplayScheduler::DisplayScheduler(base::SingleThreadTaskRunner* task_runner, | 17 DisplayScheduler::DisplayScheduler(base::SingleThreadTaskRunner* task_runner, |
17 int max_pending_swaps) | 18 int max_pending_swaps) |
18 : client_(nullptr), | 19 : client_(nullptr), |
19 begin_frame_source_(nullptr), | 20 begin_frame_source_(nullptr), |
20 task_runner_(task_runner), | 21 task_runner_(task_runner), |
21 inside_surface_damaged_(false), | 22 inside_surface_damaged_(false), |
22 visible_(false), | 23 visible_(false), |
23 output_surface_lost_(false), | 24 output_surface_lost_(false), |
24 root_surface_resources_locked_(true), | 25 root_surface_resources_locked_(true), |
25 inside_begin_frame_deadline_interval_(false), | 26 inside_begin_frame_deadline_interval_(false), |
26 needs_draw_(false), | 27 needs_draw_(false), |
27 expecting_root_surface_damage_because_of_resize_(false), | 28 expecting_root_surface_damage_because_of_resize_(false), |
28 all_active_child_surfaces_ready_to_draw_(false), | 29 has_pending_surfaces_(false), |
29 next_swap_id_(1), | 30 next_swap_id_(1), |
30 pending_swaps_(0), | 31 pending_swaps_(0), |
31 max_pending_swaps_(max_pending_swaps), | 32 max_pending_swaps_(max_pending_swaps), |
32 observing_begin_frame_source_(false), | 33 observing_begin_frame_source_(false), |
33 root_surface_damaged_(false), | |
34 expect_damage_from_root_surface_(false), | |
35 weak_ptr_factory_(this) { | 34 weak_ptr_factory_(this) { |
36 begin_frame_deadline_closure_ = base::Bind( | 35 begin_frame_deadline_closure_ = base::Bind( |
37 &DisplayScheduler::OnBeginFrameDeadline, weak_ptr_factory_.GetWeakPtr()); | 36 &DisplayScheduler::OnBeginFrameDeadline, weak_ptr_factory_.GetWeakPtr()); |
38 } | 37 } |
39 | 38 |
40 DisplayScheduler::~DisplayScheduler() { | 39 DisplayScheduler::~DisplayScheduler() { |
41 StopObservingBeginFrames(); | 40 StopObservingBeginFrames(); |
42 } | 41 } |
43 | 42 |
44 void DisplayScheduler::SetClient(DisplaySchedulerClient* client) { | 43 void DisplayScheduler::SetClient(DisplaySchedulerClient* client) { |
(...skipping 29 matching lines...) Expand all Loading... |
74 void DisplayScheduler::ForceImmediateSwapIfPossible() { | 73 void DisplayScheduler::ForceImmediateSwapIfPossible() { |
75 TRACE_EVENT0("cc", "DisplayScheduler::ForceImmediateSwapIfPossible"); | 74 TRACE_EVENT0("cc", "DisplayScheduler::ForceImmediateSwapIfPossible"); |
76 bool in_begin = inside_begin_frame_deadline_interval_; | 75 bool in_begin = inside_begin_frame_deadline_interval_; |
77 bool did_draw = AttemptDrawAndSwap(); | 76 bool did_draw = AttemptDrawAndSwap(); |
78 if (in_begin) | 77 if (in_begin) |
79 DidFinishFrame(did_draw); | 78 DidFinishFrame(did_draw); |
80 } | 79 } |
81 | 80 |
82 void DisplayScheduler::DisplayResized() { | 81 void DisplayScheduler::DisplayResized() { |
83 expecting_root_surface_damage_because_of_resize_ = true; | 82 expecting_root_surface_damage_because_of_resize_ = true; |
84 expect_damage_from_root_surface_ = true; | |
85 needs_draw_ = true; | 83 needs_draw_ = true; |
86 ScheduleBeginFrameDeadline(); | 84 ScheduleBeginFrameDeadline(); |
87 } | 85 } |
88 | 86 |
89 // Notification that there was a resize or the root surface changed and | 87 // Notification that there was a resize or the root surface changed and |
90 // that we should just draw immediately. | 88 // that we should just draw immediately. |
91 void DisplayScheduler::SetNewRootSurface(const SurfaceId& root_surface_id) { | 89 void DisplayScheduler::SetNewRootSurface(const SurfaceId& root_surface_id) { |
92 TRACE_EVENT0("cc", "DisplayScheduler::SetNewRootSurface"); | 90 TRACE_EVENT0("cc", "DisplayScheduler::SetNewRootSurface"); |
93 root_surface_id_ = root_surface_id; | 91 root_surface_id_ = root_surface_id; |
94 SurfaceDamaged(root_surface_id); | 92 BeginFrameAck ack; |
| 93 ack.has_damage = true; |
| 94 SurfaceDamaged(root_surface_id, ack, true); |
95 } | 95 } |
96 | 96 |
97 // Indicates that there was damage to one of the surfaces. | 97 // Indicates that there was damage to one of the surfaces. |
98 // Has some logic to wait for multiple active surfaces before | 98 // Has some logic to wait for multiple active surfaces before |
99 // triggering the deadline. | 99 // triggering the deadline. |
100 void DisplayScheduler::SurfaceDamaged(const SurfaceId& surface_id) { | 100 void DisplayScheduler::SurfaceDamaged(const SurfaceId& surface_id, |
| 101 const BeginFrameAck& ack, |
| 102 bool display_damaged) { |
101 TRACE_EVENT1("cc", "DisplayScheduler::SurfaceDamaged", "surface_id", | 103 TRACE_EVENT1("cc", "DisplayScheduler::SurfaceDamaged", "surface_id", |
102 surface_id.ToString()); | 104 surface_id.ToString()); |
103 | 105 |
104 // We may cause a new BeginFrame to be run inside this method, but to help | 106 // We may cause a new BeginFrame to be run inside this method, but to help |
105 // avoid being reentrant to the caller of SurfaceDamaged, track when this is | 107 // avoid being reentrant to the caller of SurfaceDamaged, track when this is |
106 // happening with |inside_surface_damaged_|. | 108 // happening with |inside_surface_damaged_|. |
107 base::AutoReset<bool> auto_reset(&inside_surface_damaged_, true); | 109 base::AutoReset<bool> auto_reset(&inside_surface_damaged_, true); |
108 | 110 |
109 needs_draw_ = true; | 111 if (display_damaged) { |
| 112 needs_draw_ = true; |
110 | 113 |
111 if (surface_id == root_surface_id_) { | 114 if (surface_id == root_surface_id_) |
112 root_surface_damaged_ = true; | 115 expecting_root_surface_damage_because_of_resize_ = false; |
113 expecting_root_surface_damage_because_of_resize_ = false; | |
114 } else { | |
115 child_surface_ids_damaged_.insert(surface_id); | |
116 | 116 |
117 // TODO(mithro): Use hints from SetNeedsBeginFrames and SwapAborts. | 117 StartObservingBeginFrames(); |
118 all_active_child_surfaces_ready_to_draw_ = base::STLIncludes( | |
119 child_surface_ids_damaged_, child_surface_ids_to_expect_damage_from_); | |
120 } | 118 } |
121 | 119 |
122 StartObservingBeginFrames(); | 120 // Update surface state. |
123 ScheduleBeginFrameDeadline(); | 121 bool valid_ack = ack.sequence_number != BeginFrameArgs::kInvalidFrameNumber; |
| 122 if (valid_ack) { |
| 123 auto it = surface_states_.find(surface_id); |
| 124 if (it != surface_states_.end()) |
| 125 it->second.last_ack = ack; |
| 126 else |
| 127 valid_ack = false; |
| 128 } |
| 129 |
| 130 bool pending_surfaces_changed = false; |
| 131 if (display_damaged || valid_ack) |
| 132 pending_surfaces_changed = UpdateHasPendingSurfaces(); |
| 133 |
| 134 if (display_damaged || pending_surfaces_changed) |
| 135 ScheduleBeginFrameDeadline(); |
| 136 } |
| 137 |
| 138 void DisplayScheduler::SurfaceCreated(const SurfaceInfo& surface_info) { |
| 139 SurfaceId surface_id = surface_info.id(); |
| 140 DCHECK(!base::ContainsKey(surface_states_, surface_id)); |
| 141 surface_states_[surface_id] = SurfaceBeginFrameState(); |
| 142 } |
| 143 |
| 144 void DisplayScheduler::SurfaceDestroyed(const SurfaceId& surface_id) { |
| 145 auto it = surface_states_.find(surface_id); |
| 146 if (it == surface_states_.end()) |
| 147 return; |
| 148 surface_states_.erase(it); |
| 149 if (UpdateHasPendingSurfaces()) |
| 150 ScheduleBeginFrameDeadline(); |
| 151 } |
| 152 |
| 153 void DisplayScheduler::SurfaceDamageExpected(const SurfaceId& surface_id, |
| 154 const BeginFrameArgs& args) { |
| 155 TRACE_EVENT1("cc", "DisplayScheduler::SurfaceDamageExpected", "surface_id", |
| 156 surface_id.ToString()); |
| 157 auto it = surface_states_.find(surface_id); |
| 158 if (it == surface_states_.end()) |
| 159 return; |
| 160 it->second.last_args = args; |
| 161 if (UpdateHasPendingSurfaces()) |
| 162 ScheduleBeginFrameDeadline(); |
| 163 } |
| 164 |
| 165 bool DisplayScheduler::UpdateHasPendingSurfaces() { |
| 166 // If we're not currently inside a deadline interval, we will call |
| 167 // UpdateHasPendingSurfaces() again during OnBeginFrameImpl(). |
| 168 if (!inside_begin_frame_deadline_interval_ || !client_) |
| 169 return false; |
| 170 |
| 171 bool old_value = has_pending_surfaces_; |
| 172 |
| 173 for (const std::pair<SurfaceId, SurfaceBeginFrameState>& entry : |
| 174 surface_states_) { |
| 175 const SurfaceId& surface_id = entry.first; |
| 176 const SurfaceBeginFrameState& state = entry.second; |
| 177 |
| 178 // Surface is ready if it hasn't received the current BeginFrame or receives |
| 179 // BeginFrames from a different source and thus likely belongs to a |
| 180 // different surface hierarchy. |
| 181 uint32_t source_id = current_begin_frame_args_.source_id; |
| 182 uint64_t sequence_number = current_begin_frame_args_.sequence_number; |
| 183 if (!state.last_args.IsValid() || state.last_args.source_id != source_id || |
| 184 state.last_args.sequence_number != sequence_number) { |
| 185 continue; |
| 186 } |
| 187 |
| 188 // Surface is ready if it has acknowledged the current BeginFrame. |
| 189 if (state.last_ack.source_id == source_id && |
| 190 state.last_ack.sequence_number == sequence_number) { |
| 191 continue; |
| 192 } |
| 193 |
| 194 // Surface is ready if there is an undrawn active CompositorFrame, because |
| 195 // its producer is CompositorFrameAck throttled. |
| 196 if (client_->SurfaceHasUndrawnFrame(entry.first)) |
| 197 continue; |
| 198 |
| 199 has_pending_surfaces_ = true; |
| 200 TRACE_EVENT_INSTANT2("cc", "DisplayScheduler::UpdateHasPendingSurfaces", |
| 201 TRACE_EVENT_SCOPE_THREAD, "has_pending_surfaces", |
| 202 has_pending_surfaces_, "pending_surface_id", |
| 203 surface_id.ToString()); |
| 204 return has_pending_surfaces_ != old_value; |
| 205 } |
| 206 has_pending_surfaces_ = false; |
| 207 TRACE_EVENT_INSTANT1("cc", "DisplayScheduler::UpdateHasPendingSurfaces", |
| 208 TRACE_EVENT_SCOPE_THREAD, "has_pending_surfaces", |
| 209 has_pending_surfaces_); |
| 210 return has_pending_surfaces_ != old_value; |
124 } | 211 } |
125 | 212 |
126 void DisplayScheduler::OutputSurfaceLost() { | 213 void DisplayScheduler::OutputSurfaceLost() { |
127 TRACE_EVENT0("cc", "DisplayScheduler::OutputSurfaceLost"); | 214 TRACE_EVENT0("cc", "DisplayScheduler::OutputSurfaceLost"); |
128 output_surface_lost_ = true; | 215 output_surface_lost_ = true; |
129 ScheduleBeginFrameDeadline(); | 216 ScheduleBeginFrameDeadline(); |
130 } | 217 } |
131 | 218 |
132 bool DisplayScheduler::DrawAndSwap() { | 219 bool DisplayScheduler::DrawAndSwap() { |
133 TRACE_EVENT0("cc", "DisplayScheduler::DrawAndSwap"); | 220 TRACE_EVENT0("cc", "DisplayScheduler::DrawAndSwap"); |
134 DCHECK_LT(pending_swaps_, max_pending_swaps_); | 221 DCHECK_LT(pending_swaps_, max_pending_swaps_); |
135 DCHECK(!output_surface_lost_); | 222 DCHECK(!output_surface_lost_); |
136 | 223 |
137 bool success = client_->DrawAndSwap(); | 224 bool success = client_->DrawAndSwap(); |
138 if (!success) | 225 if (!success) |
139 return false; | 226 return false; |
140 | 227 |
141 child_surface_ids_to_expect_damage_from_ = | |
142 base::STLSetIntersection<std::vector<SurfaceId>>( | |
143 child_surface_ids_damaged_, child_surface_ids_damaged_prev_); | |
144 | |
145 child_surface_ids_damaged_prev_.swap(child_surface_ids_damaged_); | |
146 child_surface_ids_damaged_.clear(); | |
147 | |
148 needs_draw_ = false; | 228 needs_draw_ = false; |
149 all_active_child_surfaces_ready_to_draw_ = | |
150 child_surface_ids_to_expect_damage_from_.empty(); | |
151 | |
152 expect_damage_from_root_surface_ = root_surface_damaged_; | |
153 root_surface_damaged_ = false; | |
154 return true; | 229 return true; |
155 } | 230 } |
156 | 231 |
157 bool DisplayScheduler::OnBeginFrameDerivedImpl(const BeginFrameArgs& args) { | 232 bool DisplayScheduler::OnBeginFrameDerivedImpl(const BeginFrameArgs& args) { |
158 base::TimeTicks now = base::TimeTicks::Now(); | 233 base::TimeTicks now = base::TimeTicks::Now(); |
159 TRACE_EVENT2("cc", "DisplayScheduler::BeginFrame", "args", args.AsValue(), | 234 TRACE_EVENT2("cc", "DisplayScheduler::BeginFrame", "args", args.AsValue(), |
160 "now", now); | 235 "now", now); |
161 | 236 |
162 if (inside_surface_damaged_) { | 237 if (inside_surface_damaged_) { |
163 // Repost this so that we don't run a missed BeginFrame on the same | 238 // Repost this so that we don't run a missed BeginFrame on the same |
(...skipping 15 matching lines...) Expand all Loading... |
179 // destroyed if we StopObservingBeginFrames(), and it would take the |args| | 254 // destroyed if we StopObservingBeginFrames(), and it would take the |args| |
180 // with it. Instead save the args and cancel the |missed_begin_frame_task_|. | 255 // with it. Instead save the args and cancel the |missed_begin_frame_task_|. |
181 BeginFrameArgs save_args = args; | 256 BeginFrameArgs save_args = args; |
182 // If we get another BeginFrame before a posted missed frame, just drop the | 257 // If we get another BeginFrame before a posted missed frame, just drop the |
183 // missed frame. Also if this was the missed frame, drop the Callback inside | 258 // missed frame. Also if this was the missed frame, drop the Callback inside |
184 // it. | 259 // it. |
185 missed_begin_frame_task_.Cancel(); | 260 missed_begin_frame_task_.Cancel(); |
186 | 261 |
187 // If we get another BeginFrame before the previous deadline, | 262 // If we get another BeginFrame before the previous deadline, |
188 // synchronously trigger the previous deadline before progressing. | 263 // synchronously trigger the previous deadline before progressing. |
189 if (inside_begin_frame_deadline_interval_) { | 264 if (inside_begin_frame_deadline_interval_) |
190 OnBeginFrameDeadline(); | 265 OnBeginFrameDeadline(); |
191 } | |
192 | 266 |
193 // Schedule the deadline. | 267 // Schedule the deadline. |
194 current_begin_frame_args_ = save_args; | 268 current_begin_frame_args_ = save_args; |
195 current_begin_frame_args_.deadline -= | 269 current_begin_frame_args_.deadline -= |
196 BeginFrameArgs::DefaultEstimatedParentDrawTime(); | 270 BeginFrameArgs::DefaultEstimatedParentDrawTime(); |
197 inside_begin_frame_deadline_interval_ = true; | 271 inside_begin_frame_deadline_interval_ = true; |
| 272 UpdateHasPendingSurfaces(); |
198 ScheduleBeginFrameDeadline(); | 273 ScheduleBeginFrameDeadline(); |
199 | 274 |
200 return true; | 275 return true; |
201 } | 276 } |
202 | 277 |
203 void DisplayScheduler::StartObservingBeginFrames() { | 278 void DisplayScheduler::StartObservingBeginFrames() { |
204 if (!observing_begin_frame_source_ && ShouldDraw()) { | 279 if (!observing_begin_frame_source_ && ShouldDraw()) { |
205 begin_frame_source_->AddObserver(this); | 280 begin_frame_source_->AddObserver(this); |
206 observing_begin_frame_source_ = true; | 281 observing_begin_frame_source_ = true; |
207 } | 282 } |
(...skipping 28 matching lines...) Expand all Loading... |
236 TRACE_EVENT_INSTANT0("cc", "Lost output surface", TRACE_EVENT_SCOPE_THREAD); | 311 TRACE_EVENT_INSTANT0("cc", "Lost output surface", TRACE_EVENT_SCOPE_THREAD); |
237 return base::TimeTicks(); | 312 return base::TimeTicks(); |
238 } | 313 } |
239 | 314 |
240 if (pending_swaps_ >= max_pending_swaps_) { | 315 if (pending_swaps_ >= max_pending_swaps_) { |
241 TRACE_EVENT_INSTANT0("cc", "Swap throttled", TRACE_EVENT_SCOPE_THREAD); | 316 TRACE_EVENT_INSTANT0("cc", "Swap throttled", TRACE_EVENT_SCOPE_THREAD); |
242 return current_begin_frame_args_.frame_time + | 317 return current_begin_frame_args_.frame_time + |
243 current_begin_frame_args_.interval; | 318 current_begin_frame_args_.interval; |
244 } | 319 } |
245 | 320 |
246 if (!needs_draw_) { | 321 bool all_surfaces_ready = |
| 322 !has_pending_surfaces_ && root_surface_id_.is_valid(); |
| 323 if (!needs_draw_ && !all_surfaces_ready) { |
247 TRACE_EVENT_INSTANT0("cc", "No damage yet", TRACE_EVENT_SCOPE_THREAD); | 324 TRACE_EVENT_INSTANT0("cc", "No damage yet", TRACE_EVENT_SCOPE_THREAD); |
248 return current_begin_frame_args_.frame_time + | 325 return current_begin_frame_args_.frame_time + |
249 current_begin_frame_args_.interval; | 326 current_begin_frame_args_.interval; |
250 } | 327 } |
251 | 328 |
252 if (root_surface_resources_locked_) { | 329 if (root_surface_resources_locked_) { |
253 TRACE_EVENT_INSTANT0("cc", "Root surface resources locked", | 330 TRACE_EVENT_INSTANT0("cc", "Root surface resources locked", |
254 TRACE_EVENT_SCOPE_THREAD); | 331 TRACE_EVENT_SCOPE_THREAD); |
255 return current_begin_frame_args_.frame_time + | 332 return current_begin_frame_args_.frame_time + |
256 current_begin_frame_args_.interval; | 333 current_begin_frame_args_.interval; |
257 } | 334 } |
258 | 335 |
259 bool root_ready_to_draw = | 336 if (all_surfaces_ready && !expecting_root_surface_damage_because_of_resize_) { |
260 !expect_damage_from_root_surface_ || root_surface_damaged_; | |
261 | |
262 if (all_active_child_surfaces_ready_to_draw_ && root_ready_to_draw) { | |
263 TRACE_EVENT_INSTANT0("cc", "All active surfaces ready", | 337 TRACE_EVENT_INSTANT0("cc", "All active surfaces ready", |
264 TRACE_EVENT_SCOPE_THREAD); | 338 TRACE_EVENT_SCOPE_THREAD); |
265 return base::TimeTicks(); | 339 return base::TimeTicks(); |
266 } | 340 } |
267 | 341 |
268 // TODO(mithro): Be smarter about resize deadlines. | 342 // TODO(mithro): Be smarter about resize deadlines. |
269 if (expecting_root_surface_damage_because_of_resize_) { | 343 if (expecting_root_surface_damage_because_of_resize_) { |
270 TRACE_EVENT_INSTANT0("cc", "Entire display damaged", | 344 TRACE_EVENT_INSTANT0("cc", "Entire display damaged", |
271 TRACE_EVENT_SCOPE_THREAD); | 345 TRACE_EVENT_SCOPE_THREAD); |
272 return current_begin_frame_args_.frame_time + | 346 return current_begin_frame_args_.frame_time + |
273 current_begin_frame_args_.interval; | 347 current_begin_frame_args_.interval; |
274 } | 348 } |
275 | 349 |
276 // Use an earlier deadline if we are only waiting for the root surface | |
277 // in case our expect_damage_from_root_surface heuristic is incorrect. | |
278 // TODO(mithro): Replace this with SetNeedsBeginFrame and SwapAbort | |
279 // logic. | |
280 if (all_active_child_surfaces_ready_to_draw_ && | |
281 expect_damage_from_root_surface_) { | |
282 TRACE_EVENT_INSTANT0("cc", "Waiting for damage from root surface", | |
283 TRACE_EVENT_SCOPE_THREAD); | |
284 // This adjusts the deadline by DefaultEstimatedParentDrawTime for | |
285 // a second time. The first one represented the Surfaces draw to display | |
286 // latency. This one represents root surface commit+raster+draw latency. | |
287 // We treat the root surface differently since it lives on the same thread | |
288 // as Surfaces and waiting for it too long may push out the Surfaces draw. | |
289 // If we also assume the root surface is fast to start a commit after the | |
290 // beginning of a frame, it'll have a chance to lock its resources, which | |
291 // will cause us to wait for it to unlock its resources above. | |
292 // TODO(mithro): Replace hard coded estimates. | |
293 return current_begin_frame_args_.deadline - | |
294 BeginFrameArgs::DefaultEstimatedParentDrawTime(); | |
295 } | |
296 | |
297 TRACE_EVENT_INSTANT0("cc", "More damage expected soon", | 350 TRACE_EVENT_INSTANT0("cc", "More damage expected soon", |
298 TRACE_EVENT_SCOPE_THREAD); | 351 TRACE_EVENT_SCOPE_THREAD); |
299 return current_begin_frame_args_.deadline; | 352 return current_begin_frame_args_.deadline; |
300 } | 353 } |
301 | 354 |
302 void DisplayScheduler::ScheduleBeginFrameDeadline() { | 355 void DisplayScheduler::ScheduleBeginFrameDeadline() { |
303 TRACE_EVENT0("cc", "DisplayScheduler::ScheduleBeginFrameDeadline"); | 356 TRACE_EVENT0("cc", "DisplayScheduler::ScheduleBeginFrameDeadline"); |
304 | 357 |
305 // We need to wait for the next BeginFrame before scheduling a deadline. | 358 // We need to wait for the next BeginFrame before scheduling a deadline. |
306 if (!inside_begin_frame_deadline_interval_) { | 359 if (!inside_begin_frame_deadline_interval_) { |
(...skipping 30 matching lines...) Expand all Loading... |
337 bool DisplayScheduler::AttemptDrawAndSwap() { | 390 bool DisplayScheduler::AttemptDrawAndSwap() { |
338 inside_begin_frame_deadline_interval_ = false; | 391 inside_begin_frame_deadline_interval_ = false; |
339 begin_frame_deadline_task_.Cancel(); | 392 begin_frame_deadline_task_.Cancel(); |
340 begin_frame_deadline_task_time_ = base::TimeTicks(); | 393 begin_frame_deadline_task_time_ = base::TimeTicks(); |
341 | 394 |
342 if (ShouldDraw()) { | 395 if (ShouldDraw()) { |
343 if (pending_swaps_ < max_pending_swaps_ && !root_surface_resources_locked_) | 396 if (pending_swaps_ < max_pending_swaps_ && !root_surface_resources_locked_) |
344 return DrawAndSwap(); | 397 return DrawAndSwap(); |
345 } else { | 398 } else { |
346 // We are going idle, so reset expectations. | 399 // We are going idle, so reset expectations. |
347 child_surface_ids_to_expect_damage_from_.clear(); | 400 // TODO(eseckler): Should we avoid going idle if |
348 child_surface_ids_damaged_prev_.clear(); | 401 // |expecting_root_surface_damage_because_of_resize_| is true? |
349 child_surface_ids_damaged_.clear(); | 402 expecting_root_surface_damage_because_of_resize_ = false; |
350 all_active_child_surfaces_ready_to_draw_ = true; | |
351 expect_damage_from_root_surface_ = false; | |
352 | 403 |
353 StopObservingBeginFrames(); | 404 StopObservingBeginFrames(); |
354 } | 405 } |
355 return false; | 406 return false; |
356 } | 407 } |
357 | 408 |
358 void DisplayScheduler::OnBeginFrameDeadline() { | 409 void DisplayScheduler::OnBeginFrameDeadline() { |
359 TRACE_EVENT0("cc", "DisplayScheduler::OnBeginFrameDeadline"); | 410 TRACE_EVENT0("cc", "DisplayScheduler::OnBeginFrameDeadline"); |
360 DCHECK(inside_begin_frame_deadline_interval_); | 411 DCHECK(inside_begin_frame_deadline_interval_); |
361 | 412 |
(...skipping 14 matching lines...) Expand all Loading... |
376 } | 427 } |
377 | 428 |
378 void DisplayScheduler::DidReceiveSwapBuffersAck() { | 429 void DisplayScheduler::DidReceiveSwapBuffersAck() { |
379 uint32_t swap_id = next_swap_id_ - pending_swaps_; | 430 uint32_t swap_id = next_swap_id_ - pending_swaps_; |
380 pending_swaps_--; | 431 pending_swaps_--; |
381 TRACE_EVENT_ASYNC_END0("cc", "DisplayScheduler:pending_swaps", swap_id); | 432 TRACE_EVENT_ASYNC_END0("cc", "DisplayScheduler:pending_swaps", swap_id); |
382 ScheduleBeginFrameDeadline(); | 433 ScheduleBeginFrameDeadline(); |
383 } | 434 } |
384 | 435 |
385 } // namespace cc | 436 } // namespace cc |
OLD | NEW |