| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/scheduler/scheduler_state_machine.h" | 5 #include "cc/scheduler/scheduler_state_machine.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/debug/trace_event_argument.h" | 8 #include "base/debug/trace_event_argument.h" |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 | 335 |
| 336 bool SchedulerStateMachine::ShouldDraw() const { | 336 bool SchedulerStateMachine::ShouldDraw() const { |
| 337 // If we need to abort draws, we should do so ASAP since the draw could | 337 // If we need to abort draws, we should do so ASAP since the draw could |
| 338 // be blocking other important actions (like output surface initialization), | 338 // be blocking other important actions (like output surface initialization), |
| 339 // from occuring. If we are waiting for the first draw, then perfom the | 339 // from occuring. If we are waiting for the first draw, then perfom the |
| 340 // aborted draw to keep things moving. If we are not waiting for the first | 340 // aborted draw to keep things moving. If we are not waiting for the first |
| 341 // draw however, we don't want to abort for no reason. | 341 // draw however, we don't want to abort for no reason. |
| 342 if (PendingDrawsShouldBeAborted()) | 342 if (PendingDrawsShouldBeAborted()) |
| 343 return active_tree_needs_first_draw_; | 343 return active_tree_needs_first_draw_; |
| 344 | 344 |
| 345 // Don't draw if we are waiting on the first commit after a surface. |
| 346 if (output_surface_state_ != OUTPUT_SURFACE_ACTIVE) |
| 347 return false; |
| 348 |
| 345 // If a commit has occurred after the animate call, we need to call animate | 349 // If a commit has occurred after the animate call, we need to call animate |
| 346 // again before we should draw. | 350 // again before we should draw. |
| 347 if (did_commit_after_animating_) | 351 if (did_commit_after_animating_) |
| 348 return false; | 352 return false; |
| 349 | 353 |
| 350 // After this line, we only want to send a swap request once per frame. | 354 // After this line, we only want to send a swap request once per frame. |
| 351 if (HasRequestedSwapThisFrame()) | 355 if (HasRequestedSwapThisFrame()) |
| 352 return false; | 356 return false; |
| 353 | 357 |
| 354 // Do not queue too many swaps. | 358 // Do not queue too many swaps. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 380 | 384 |
| 381 // If we want to force activation, do so ASAP. | 385 // If we want to force activation, do so ASAP. |
| 382 if (PendingActivationsShouldBeForced()) | 386 if (PendingActivationsShouldBeForced()) |
| 383 return true; | 387 return true; |
| 384 | 388 |
| 385 // At this point, only activate if we are ready to activate. | 389 // At this point, only activate if we are ready to activate. |
| 386 return pending_tree_is_ready_for_activation_; | 390 return pending_tree_is_ready_for_activation_; |
| 387 } | 391 } |
| 388 | 392 |
| 389 bool SchedulerStateMachine::ShouldAnimate() const { | 393 bool SchedulerStateMachine::ShouldAnimate() const { |
| 394 // Don't animate if we are waiting on the first commit after a surface. |
| 395 if (output_surface_state_ != OUTPUT_SURFACE_ACTIVE) |
| 396 return false; |
| 397 |
| 390 // If a commit occurred after our last call, we need to do animation again. | 398 // If a commit occurred after our last call, we need to do animation again. |
| 391 if (HasAnimatedThisFrame() && !did_commit_after_animating_) | 399 if (HasAnimatedThisFrame() && !did_commit_after_animating_) |
| 392 return false; | 400 return false; |
| 393 | 401 |
| 394 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING && | 402 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING && |
| 395 begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) | 403 begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) |
| 396 return false; | 404 return false; |
| 397 | 405 |
| 398 return needs_redraw_ || needs_animate_; | 406 return needs_redraw_ || needs_animate_; |
| 399 } | 407 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 417 if (commit_state_ != COMMIT_STATE_IDLE) | 425 if (commit_state_ != COMMIT_STATE_IDLE) |
| 418 return false; | 426 return false; |
| 419 | 427 |
| 420 // Don't send BeginMainFrame early if we are prioritizing the active tree | 428 // Don't send BeginMainFrame early if we are prioritizing the active tree |
| 421 // because of impl_latency_takes_priority_. | 429 // because of impl_latency_takes_priority_. |
| 422 if (impl_latency_takes_priority_ && | 430 if (impl_latency_takes_priority_ && |
| 423 (has_pending_tree_ || active_tree_needs_first_draw_)) { | 431 (has_pending_tree_ || active_tree_needs_first_draw_)) { |
| 424 return false; | 432 return false; |
| 425 } | 433 } |
| 426 | 434 |
| 427 // We want to start the first commit after we get a new output surface ASAP. | |
| 428 if (output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT) | |
| 429 return true; | |
| 430 | |
| 431 // We should not send BeginMainFrame while we are in | 435 // We should not send BeginMainFrame while we are in |
| 432 // BEGIN_IMPL_FRAME_STATE_IDLE since we might have new | 436 // BEGIN_IMPL_FRAME_STATE_IDLE since we might have new |
| 433 // user input arriving soon. | 437 // user input arriving soon. |
| 434 // TODO(brianderson): Allow sending BeginMainFrame while idle when the main | 438 // TODO(brianderson): Allow sending BeginMainFrame while idle when the main |
| 435 // thread isn't consuming user input. | 439 // thread isn't consuming user input. |
| 436 if (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_IDLE && | 440 if (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_IDLE && |
| 437 BeginFrameNeeded()) | 441 BeginFrameNeeded()) |
| 438 return false; | 442 return false; |
| 439 | 443 |
| 440 // We need a new commit for the forced redraw. This honors the | 444 // We need a new commit for the forced redraw. This honors the |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 static_cast<int>(begin_impl_frame_state_), | 1103 static_cast<int>(begin_impl_frame_state_), |
| 1100 static_cast<int>(commit_state_), | 1104 static_cast<int>(commit_state_), |
| 1101 has_pending_tree_ ? 'T' : 'F', | 1105 has_pending_tree_ ? 'T' : 'F', |
| 1102 pending_tree_is_ready_for_activation_ ? 'T' : 'F', | 1106 pending_tree_is_ready_for_activation_ ? 'T' : 'F', |
| 1103 active_tree_needs_first_draw_ ? 'T' : 'F', | 1107 active_tree_needs_first_draw_ ? 'T' : 'F', |
| 1104 max_pending_swaps_, | 1108 max_pending_swaps_, |
| 1105 pending_swaps_); | 1109 pending_swaps_); |
| 1106 } | 1110 } |
| 1107 | 1111 |
| 1108 } // namespace cc | 1112 } // namespace cc |
| OLD | NEW |