| 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" |
| 14 #include "cc/surfaces/surface_manager.h" |
| 13 | 15 |
| 14 namespace cc { | 16 namespace cc { |
| 15 | 17 |
| 16 DisplayScheduler::DisplayScheduler(base::SingleThreadTaskRunner* task_runner, | 18 DisplayScheduler::DisplayScheduler(base::SingleThreadTaskRunner* task_runner, |
| 17 int max_pending_swaps) | 19 int max_pending_swaps) |
| 18 : client_(nullptr), | 20 : client_(nullptr), |
| 19 begin_frame_source_(nullptr), | 21 begin_frame_source_(nullptr), |
| 22 surface_manager_(nullptr), |
| 20 task_runner_(task_runner), | 23 task_runner_(task_runner), |
| 21 inside_surface_damaged_(false), | 24 inside_surface_damaged_(false), |
| 22 visible_(false), | 25 visible_(false), |
| 23 output_surface_lost_(false), | 26 output_surface_lost_(false), |
| 24 root_surface_resources_locked_(true), | 27 root_surface_resources_locked_(true), |
| 25 inside_begin_frame_deadline_interval_(false), | 28 inside_begin_frame_deadline_interval_(false), |
| 26 needs_draw_(false), | 29 needs_draw_(false), |
| 27 expecting_root_surface_damage_because_of_resize_(false), | 30 expecting_root_surface_damage_because_of_resize_(false), |
| 28 all_active_child_surfaces_ready_to_draw_(false), | 31 has_pending_surfaces_(false), |
| 29 next_swap_id_(1), | 32 next_swap_id_(1), |
| 30 pending_swaps_(0), | 33 pending_swaps_(0), |
| 31 max_pending_swaps_(max_pending_swaps), | 34 max_pending_swaps_(max_pending_swaps), |
| 32 observing_begin_frame_source_(false), | 35 observing_begin_frame_source_(false), |
| 33 root_surface_damaged_(false), | |
| 34 expect_damage_from_root_surface_(false), | |
| 35 weak_ptr_factory_(this) { | 36 weak_ptr_factory_(this) { |
| 36 begin_frame_deadline_closure_ = base::Bind( | 37 begin_frame_deadline_closure_ = base::Bind( |
| 37 &DisplayScheduler::OnBeginFrameDeadline, weak_ptr_factory_.GetWeakPtr()); | 38 &DisplayScheduler::OnBeginFrameDeadline, weak_ptr_factory_.GetWeakPtr()); |
| 38 } | 39 } |
| 39 | 40 |
| 40 DisplayScheduler::~DisplayScheduler() { | 41 DisplayScheduler::~DisplayScheduler() { |
| 41 StopObservingBeginFrames(); | 42 StopObservingBeginFrames(); |
| 42 } | 43 } |
| 43 | 44 |
| 44 void DisplayScheduler::SetClient(DisplaySchedulerClient* client) { | 45 void DisplayScheduler::SetClient(DisplaySchedulerClient* client) { |
| 45 client_ = client; | 46 client_ = client; |
| 46 } | 47 } |
| 47 | 48 |
| 48 void DisplayScheduler::SetBeginFrameSource( | 49 void DisplayScheduler::SetBeginFrameSource( |
| 49 BeginFrameSource* begin_frame_source) { | 50 BeginFrameSource* begin_frame_source) { |
| 50 begin_frame_source_ = begin_frame_source; | 51 begin_frame_source_ = begin_frame_source; |
| 51 } | 52 } |
| 52 | 53 |
| 54 void DisplayScheduler::SetSurfaceManager(SurfaceManager* surface_manager) { |
| 55 surface_manager_ = surface_manager; |
| 56 } |
| 57 |
| 53 void DisplayScheduler::SetVisible(bool visible) { | 58 void DisplayScheduler::SetVisible(bool visible) { |
| 54 if (visible_ == visible) | 59 if (visible_ == visible) |
| 55 return; | 60 return; |
| 56 | 61 |
| 57 visible_ = visible; | 62 visible_ = visible; |
| 58 // If going invisible, we'll stop observing begin frames once we try | 63 // If going invisible, we'll stop observing begin frames once we try |
| 59 // to draw and fail. | 64 // to draw and fail. |
| 60 StartObservingBeginFrames(); | 65 StartObservingBeginFrames(); |
| 61 ScheduleBeginFrameDeadline(); | 66 ScheduleBeginFrameDeadline(); |
| 62 } | 67 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 74 void DisplayScheduler::ForceImmediateSwapIfPossible() { | 79 void DisplayScheduler::ForceImmediateSwapIfPossible() { |
| 75 TRACE_EVENT0("cc", "DisplayScheduler::ForceImmediateSwapIfPossible"); | 80 TRACE_EVENT0("cc", "DisplayScheduler::ForceImmediateSwapIfPossible"); |
| 76 bool in_begin = inside_begin_frame_deadline_interval_; | 81 bool in_begin = inside_begin_frame_deadline_interval_; |
| 77 bool did_draw = AttemptDrawAndSwap(); | 82 bool did_draw = AttemptDrawAndSwap(); |
| 78 if (in_begin) | 83 if (in_begin) |
| 79 DidFinishFrame(did_draw); | 84 DidFinishFrame(did_draw); |
| 80 } | 85 } |
| 81 | 86 |
| 82 void DisplayScheduler::DisplayResized() { | 87 void DisplayScheduler::DisplayResized() { |
| 83 expecting_root_surface_damage_because_of_resize_ = true; | 88 expecting_root_surface_damage_because_of_resize_ = true; |
| 84 expect_damage_from_root_surface_ = true; | |
| 85 needs_draw_ = true; | 89 needs_draw_ = true; |
| 86 ScheduleBeginFrameDeadline(); | 90 ScheduleBeginFrameDeadline(); |
| 87 } | 91 } |
| 88 | 92 |
| 89 // Notification that there was a resize or the root surface changed and | 93 // Notification that there was a resize or the root surface changed and |
| 90 // that we should just draw immediately. | 94 // that we should just draw immediately. |
| 91 void DisplayScheduler::SetNewRootSurface(const SurfaceId& root_surface_id) { | 95 void DisplayScheduler::SetNewRootSurface(const SurfaceId& root_surface_id) { |
| 92 TRACE_EVENT0("cc", "DisplayScheduler::SetNewRootSurface"); | 96 TRACE_EVENT0("cc", "DisplayScheduler::SetNewRootSurface"); |
| 93 root_surface_id_ = root_surface_id; | 97 root_surface_id_ = root_surface_id; |
| 94 SurfaceDamaged(root_surface_id); | 98 SurfaceDamaged(root_surface_id); |
| 95 } | 99 } |
| 96 | 100 |
| 97 // Indicates that there was damage to one of the surfaces. | 101 // Indicates that there was damage to one of the surfaces. |
| 98 // Has some logic to wait for multiple active surfaces before | 102 // Has some logic to wait for multiple active surfaces before |
| 99 // triggering the deadline. | 103 // triggering the deadline. |
| 100 void DisplayScheduler::SurfaceDamaged(const SurfaceId& surface_id) { | 104 void DisplayScheduler::SurfaceDamaged(const SurfaceId& surface_id) { |
| 101 TRACE_EVENT1("cc", "DisplayScheduler::SurfaceDamaged", "surface_id", | 105 TRACE_EVENT1("cc", "DisplayScheduler::SurfaceDamaged", "surface_id", |
| 102 surface_id.ToString()); | 106 surface_id.ToString()); |
| 103 | 107 |
| 104 // We may cause a new BeginFrame to be run inside this method, but to help | 108 // 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 | 109 // avoid being reentrant to the caller of SurfaceDamaged, track when this is |
| 106 // happening with |inside_surface_damaged_|. | 110 // happening with |inside_surface_damaged_|. |
| 107 base::AutoReset<bool> auto_reset(&inside_surface_damaged_, true); | 111 base::AutoReset<bool> auto_reset(&inside_surface_damaged_, true); |
| 108 | 112 |
| 109 needs_draw_ = true; | 113 needs_draw_ = true; |
| 110 | 114 |
| 111 if (surface_id == root_surface_id_) { | 115 if (surface_id == root_surface_id_) |
| 112 root_surface_damaged_ = true; | |
| 113 expecting_root_surface_damage_because_of_resize_ = false; | 116 expecting_root_surface_damage_because_of_resize_ = false; |
| 114 } else { | |
| 115 child_surface_ids_damaged_.insert(surface_id); | |
| 116 | |
| 117 // TODO(mithro): Use hints from SetNeedsBeginFrames and SwapAborts. | |
| 118 all_active_child_surfaces_ready_to_draw_ = base::STLIncludes( | |
| 119 child_surface_ids_damaged_, child_surface_ids_to_expect_damage_from_); | |
| 120 } | |
| 121 | 117 |
| 122 StartObservingBeginFrames(); | 118 StartObservingBeginFrames(); |
| 123 ScheduleBeginFrameDeadline(); | 119 ScheduleBeginFrameDeadline(); |
| 124 } | 120 } |
| 125 | 121 |
| 122 void DisplayScheduler::SurfaceCreated(const SurfaceInfo& surface_info) { |
| 123 SurfaceId surface_id = surface_info.id(); |
| 124 DCHECK(!base::ContainsKey(surface_states_, surface_id)); |
| 125 surface_states_[surface_id] = SurfaceBeginFrameState(); |
| 126 } |
| 127 |
| 128 void DisplayScheduler::SurfaceDestroyed(const SurfaceId& surface_id) { |
| 129 auto it = surface_states_.find(surface_id); |
| 130 if (it == surface_states_.end()) |
| 131 return; |
| 132 surface_states_.erase(it); |
| 133 } |
| 134 |
| 135 void DisplayScheduler::SurfaceReceivedBeginFrame(const SurfaceId& surface_id, |
| 136 const BeginFrameArgs& args) { |
| 137 TRACE_EVENT1("cc", "DisplayScheduler::SurfaceReceivedBeginFrame", |
| 138 "surface_id", surface_id.ToString()); |
| 139 auto it = surface_states_.find(surface_id); |
| 140 if (it == surface_states_.end()) |
| 141 return; |
| 142 it->second.last_args = args; |
| 143 if (UpdateHasPendingSurfaces(surface_id)) |
| 144 ScheduleBeginFrameDeadline(); |
| 145 } |
| 146 |
| 147 void DisplayScheduler::SurfaceFinishedBeginFrame(const SurfaceId& surface_id, |
| 148 const BeginFrameAck& ack) { |
| 149 TRACE_EVENT1("cc", "DisplayScheduler::SurfaceFinishedBeginFrame", |
| 150 "surface_id", surface_id.ToString()); |
| 151 auto it = surface_states_.find(surface_id); |
| 152 if (it == surface_states_.end()) |
| 153 return; |
| 154 it->second.last_ack = ack; |
| 155 if (UpdateHasPendingSurfaces(surface_id)) |
| 156 ScheduleBeginFrameDeadline(); |
| 157 } |
| 158 |
| 159 bool DisplayScheduler::UpdateHasPendingSurfaces( |
| 160 const SurfaceId& changed_surface_id) { |
| 161 if (!client_ || !surface_manager_ || |
| 162 !base::ContainsKey(client_->GetPreviousContainedSurfaces(), |
| 163 changed_surface_id)) { |
| 164 return false; |
| 165 } |
| 166 |
| 167 bool old_value = has_pending_surfaces_; |
| 168 |
| 169 // We only need to check for the state of previously referenced surfaced, as |
| 170 // newly referenced child surfaces will already have damage. (An exception to |
| 171 // this are surfaces referenced by a CompositorFrame that is activated because |
| 172 // of a surface synchronization deadline. By activating the parent frame, |
| 173 // however, we decided not to wait for these child surfaces.) |
| 174 for (const std::pair<SurfaceId, int>& entry : |
| 175 client_->GetPreviousContainedSurfaces()) { |
| 176 const SurfaceId& surface_id = entry.first; |
| 177 auto it = surface_states_.find(surface_id); |
| 178 |
| 179 // Surface is ready if it was destroyed or doesn't exist yet (see above). |
| 180 if (it == surface_states_.end()) |
| 181 continue; |
| 182 |
| 183 const SurfaceBeginFrameState& state = it->second; |
| 184 |
| 185 // Surface is ready if it has acknowledged the last BeginFrame it |
| 186 // received or hasn't ever received a BeginFrame. |
| 187 if (!state.last_args.IsValid() || |
| 188 (state.last_args.source_id == state.last_ack.source_id && |
| 189 state.last_args.sequence_number == state.last_ack.sequence_number)) { |
| 190 continue; |
| 191 } |
| 192 |
| 193 // Surface is ready if there is an undrawn (active or pending) |
| 194 // CompositorFrame, because its producer is CompositorFrameAck throttled. |
| 195 Surface* surface = surface_manager_->GetSurfaceForId(entry.first); |
| 196 DCHECK(surface); |
| 197 if (surface->HasUndrawnFrame()) |
| 198 continue; |
| 199 |
| 200 has_pending_surfaces_ = true; |
| 201 TRACE_EVENT_INSTANT2("cc", "DisplayScheduler::UpdateHasPendingSurfaces", |
| 202 TRACE_EVENT_SCOPE_THREAD, "has_pending_surfaces", |
| 203 has_pending_surfaces_, "pending_surface_id", |
| 204 surface_id.ToString()); |
| 205 return has_pending_surfaces_ != old_value; |
| 206 } |
| 207 has_pending_surfaces_ = false; |
| 208 TRACE_EVENT_INSTANT1("cc", "DisplayScheduler::UpdateHasPendingSurfaces", |
| 209 TRACE_EVENT_SCOPE_THREAD, "has_pending_surfaces", |
| 210 has_pending_surfaces_); |
| 211 return has_pending_surfaces_ != old_value; |
| 212 } |
| 213 |
| 126 void DisplayScheduler::OutputSurfaceLost() { | 214 void DisplayScheduler::OutputSurfaceLost() { |
| 127 TRACE_EVENT0("cc", "DisplayScheduler::OutputSurfaceLost"); | 215 TRACE_EVENT0("cc", "DisplayScheduler::OutputSurfaceLost"); |
| 128 output_surface_lost_ = true; | 216 output_surface_lost_ = true; |
| 129 ScheduleBeginFrameDeadline(); | 217 ScheduleBeginFrameDeadline(); |
| 130 } | 218 } |
| 131 | 219 |
| 132 bool DisplayScheduler::DrawAndSwap() { | 220 bool DisplayScheduler::DrawAndSwap() { |
| 133 TRACE_EVENT0("cc", "DisplayScheduler::DrawAndSwap"); | 221 TRACE_EVENT0("cc", "DisplayScheduler::DrawAndSwap"); |
| 134 DCHECK_LT(pending_swaps_, max_pending_swaps_); | 222 DCHECK_LT(pending_swaps_, max_pending_swaps_); |
| 135 DCHECK(!output_surface_lost_); | 223 DCHECK(!output_surface_lost_); |
| 136 | 224 |
| 137 bool success = client_->DrawAndSwap(); | 225 bool success = client_->DrawAndSwap(); |
| 138 if (!success) | 226 if (!success) |
| 139 return false; | 227 return false; |
| 140 | 228 |
| 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; | 229 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; | 230 return true; |
| 155 } | 231 } |
| 156 | 232 |
| 157 bool DisplayScheduler::OnBeginFrameDerivedImpl(const BeginFrameArgs& args) { | 233 bool DisplayScheduler::OnBeginFrameDerivedImpl(const BeginFrameArgs& args) { |
| 158 base::TimeTicks now = base::TimeTicks::Now(); | 234 base::TimeTicks now = base::TimeTicks::Now(); |
| 159 TRACE_EVENT2("cc", "DisplayScheduler::BeginFrame", "args", args.AsValue(), | 235 TRACE_EVENT2("cc", "DisplayScheduler::BeginFrame", "args", args.AsValue(), |
| 160 "now", now); | 236 "now", now); |
| 161 | 237 |
| 162 if (inside_surface_damaged_) { | 238 if (inside_surface_damaged_) { |
| 163 // Repost this so that we don't run a missed BeginFrame on the same | 239 // Repost this so that we don't run a missed BeginFrame on the same |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 TRACE_EVENT_INSTANT0("cc", "Lost output surface", TRACE_EVENT_SCOPE_THREAD); | 312 TRACE_EVENT_INSTANT0("cc", "Lost output surface", TRACE_EVENT_SCOPE_THREAD); |
| 237 return base::TimeTicks(); | 313 return base::TimeTicks(); |
| 238 } | 314 } |
| 239 | 315 |
| 240 if (pending_swaps_ >= max_pending_swaps_) { | 316 if (pending_swaps_ >= max_pending_swaps_) { |
| 241 TRACE_EVENT_INSTANT0("cc", "Swap throttled", TRACE_EVENT_SCOPE_THREAD); | 317 TRACE_EVENT_INSTANT0("cc", "Swap throttled", TRACE_EVENT_SCOPE_THREAD); |
| 242 return current_begin_frame_args_.frame_time + | 318 return current_begin_frame_args_.frame_time + |
| 243 current_begin_frame_args_.interval; | 319 current_begin_frame_args_.interval; |
| 244 } | 320 } |
| 245 | 321 |
| 246 if (!needs_draw_) { | 322 bool all_surfaces_ready = |
| 323 !has_pending_surfaces_ && root_surface_id_.is_valid(); |
| 324 if (!needs_draw_ && !all_surfaces_ready) { |
| 247 TRACE_EVENT_INSTANT0("cc", "No damage yet", TRACE_EVENT_SCOPE_THREAD); | 325 TRACE_EVENT_INSTANT0("cc", "No damage yet", TRACE_EVENT_SCOPE_THREAD); |
| 248 return current_begin_frame_args_.frame_time + | 326 return current_begin_frame_args_.frame_time + |
| 249 current_begin_frame_args_.interval; | 327 current_begin_frame_args_.interval; |
| 250 } | 328 } |
| 251 | 329 |
| 252 if (root_surface_resources_locked_) { | 330 if (root_surface_resources_locked_) { |
| 253 TRACE_EVENT_INSTANT0("cc", "Root surface resources locked", | 331 TRACE_EVENT_INSTANT0("cc", "Root surface resources locked", |
| 254 TRACE_EVENT_SCOPE_THREAD); | 332 TRACE_EVENT_SCOPE_THREAD); |
| 255 return current_begin_frame_args_.frame_time + | 333 return current_begin_frame_args_.frame_time + |
| 256 current_begin_frame_args_.interval; | 334 current_begin_frame_args_.interval; |
| 257 } | 335 } |
| 258 | 336 |
| 259 bool root_ready_to_draw = | 337 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", | 338 TRACE_EVENT_INSTANT0("cc", "All active surfaces ready", |
| 264 TRACE_EVENT_SCOPE_THREAD); | 339 TRACE_EVENT_SCOPE_THREAD); |
| 265 return base::TimeTicks(); | 340 return base::TimeTicks(); |
| 266 } | 341 } |
| 267 | 342 |
| 268 // TODO(mithro): Be smarter about resize deadlines. | 343 // TODO(mithro): Be smarter about resize deadlines. |
| 269 if (expecting_root_surface_damage_because_of_resize_) { | 344 if (expecting_root_surface_damage_because_of_resize_) { |
| 270 TRACE_EVENT_INSTANT0("cc", "Entire display damaged", | 345 TRACE_EVENT_INSTANT0("cc", "Entire display damaged", |
| 271 TRACE_EVENT_SCOPE_THREAD); | 346 TRACE_EVENT_SCOPE_THREAD); |
| 272 return current_begin_frame_args_.frame_time + | 347 return current_begin_frame_args_.frame_time + |
| 273 current_begin_frame_args_.interval; | 348 current_begin_frame_args_.interval; |
| 274 } | 349 } |
| 275 | 350 |
| 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", | 351 TRACE_EVENT_INSTANT0("cc", "More damage expected soon", |
| 298 TRACE_EVENT_SCOPE_THREAD); | 352 TRACE_EVENT_SCOPE_THREAD); |
| 299 return current_begin_frame_args_.deadline; | 353 return current_begin_frame_args_.deadline; |
| 300 } | 354 } |
| 301 | 355 |
| 302 void DisplayScheduler::ScheduleBeginFrameDeadline() { | 356 void DisplayScheduler::ScheduleBeginFrameDeadline() { |
| 303 TRACE_EVENT0("cc", "DisplayScheduler::ScheduleBeginFrameDeadline"); | 357 TRACE_EVENT0("cc", "DisplayScheduler::ScheduleBeginFrameDeadline"); |
| 304 | 358 |
| 305 // We need to wait for the next BeginFrame before scheduling a deadline. | 359 // We need to wait for the next BeginFrame before scheduling a deadline. |
| 306 if (!inside_begin_frame_deadline_interval_) { | 360 if (!inside_begin_frame_deadline_interval_) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 337 bool DisplayScheduler::AttemptDrawAndSwap() { | 391 bool DisplayScheduler::AttemptDrawAndSwap() { |
| 338 inside_begin_frame_deadline_interval_ = false; | 392 inside_begin_frame_deadline_interval_ = false; |
| 339 begin_frame_deadline_task_.Cancel(); | 393 begin_frame_deadline_task_.Cancel(); |
| 340 begin_frame_deadline_task_time_ = base::TimeTicks(); | 394 begin_frame_deadline_task_time_ = base::TimeTicks(); |
| 341 | 395 |
| 342 if (ShouldDraw()) { | 396 if (ShouldDraw()) { |
| 343 if (pending_swaps_ < max_pending_swaps_ && !root_surface_resources_locked_) | 397 if (pending_swaps_ < max_pending_swaps_ && !root_surface_resources_locked_) |
| 344 return DrawAndSwap(); | 398 return DrawAndSwap(); |
| 345 } else { | 399 } else { |
| 346 // We are going idle, so reset expectations. | 400 // We are going idle, so reset expectations. |
| 347 child_surface_ids_to_expect_damage_from_.clear(); | 401 // TODO(eseckler): Should we avoid going idle if |
| 348 child_surface_ids_damaged_prev_.clear(); | 402 // |expecting_root_surface_damage_because_of_resize_| is true? |
| 349 child_surface_ids_damaged_.clear(); | 403 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 | 404 |
| 353 StopObservingBeginFrames(); | 405 StopObservingBeginFrames(); |
| 354 } | 406 } |
| 355 return false; | 407 return false; |
| 356 } | 408 } |
| 357 | 409 |
| 358 void DisplayScheduler::OnBeginFrameDeadline() { | 410 void DisplayScheduler::OnBeginFrameDeadline() { |
| 359 TRACE_EVENT0("cc", "DisplayScheduler::OnBeginFrameDeadline"); | 411 TRACE_EVENT0("cc", "DisplayScheduler::OnBeginFrameDeadline"); |
| 360 DCHECK(inside_begin_frame_deadline_interval_); | 412 DCHECK(inside_begin_frame_deadline_interval_); |
| 361 | 413 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 378 } | 430 } |
| 379 | 431 |
| 380 void DisplayScheduler::DidReceiveSwapBuffersAck() { | 432 void DisplayScheduler::DidReceiveSwapBuffersAck() { |
| 381 uint32_t swap_id = next_swap_id_ - pending_swaps_; | 433 uint32_t swap_id = next_swap_id_ - pending_swaps_; |
| 382 pending_swaps_--; | 434 pending_swaps_--; |
| 383 TRACE_EVENT_ASYNC_END0("cc", "DisplayScheduler:pending_swaps", swap_id); | 435 TRACE_EVENT_ASYNC_END0("cc", "DisplayScheduler:pending_swaps", swap_id); |
| 384 ScheduleBeginFrameDeadline(); | 436 ScheduleBeginFrameDeadline(); |
| 385 } | 437 } |
| 386 | 438 |
| 387 } // namespace cc | 439 } // namespace cc |
| OLD | NEW |