| 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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 // We only want to start output surface initialization after the | 313 // We only want to start output surface initialization after the |
| 314 // previous commit is complete. | 314 // previous commit is complete. |
| 315 if (commit_state_ != COMMIT_STATE_IDLE) | 315 if (commit_state_ != COMMIT_STATE_IDLE) |
| 316 return false; | 316 return false; |
| 317 | 317 |
| 318 // Make sure the BeginImplFrame from any previous OutputSurfaces | 318 // Make sure the BeginImplFrame from any previous OutputSurfaces |
| 319 // are complete before creating the new OutputSurface. | 319 // are complete before creating the new OutputSurface. |
| 320 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_IDLE) | 320 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_IDLE) |
| 321 return false; | 321 return false; |
| 322 | 322 |
| 323 // We want to clear the pipeline of any pending draws and activations | 323 // We want to clear the pipline of any pending draws and activations |
| 324 // before starting output surface initialization. This allows us to avoid | 324 // before starting output surface initialization. This allows us to avoid |
| 325 // weird corner cases where we abort draws or force activation while we | 325 // weird corner cases where we abort draws or force activation while we |
| 326 // are initializing the output surface. | 326 // are initializing the output surface. |
| 327 if (active_tree_needs_first_draw_ || has_pending_tree_) | 327 if (active_tree_needs_first_draw_ || has_pending_tree_) |
| 328 return false; | 328 return false; |
| 329 | 329 |
| 330 // We need to create the output surface if we don't have one and we haven't | 330 // We need to create the output surface if we don't have one and we haven't |
| 331 // started creating one yet. | 331 // started creating one yet. |
| 332 return output_surface_state_ == OUTPUT_SURFACE_LOST; | 332 return output_surface_state_ == OUTPUT_SURFACE_LOST; |
| 333 } | 333 } |
| 334 | 334 |
| 335 bool SchedulerStateMachine::ShouldDraw() const { | 335 bool SchedulerStateMachine::ShouldDraw() const { |
| 336 // If we need to abort draws, we should do so ASAP since the draw could | 336 // If we need to abort draws, we should do so ASAP since the draw could |
| 337 // be blocking other important actions (like output surface initialization), | 337 // be blocking other important actions (like output surface initialization), |
| 338 // from occurring. If we are waiting for the first draw, then perform the | 338 // from occuring. If we are waiting for the first draw, then perfom the |
| 339 // aborted draw to keep things moving. If we are not waiting for the first | 339 // aborted draw to keep things moving. If we are not waiting for the first |
| 340 // draw however, we don't want to abort for no reason. | 340 // draw however, we don't want to abort for no reason. |
| 341 if (PendingDrawsShouldBeAborted()) | 341 if (PendingDrawsShouldBeAborted()) |
| 342 return active_tree_needs_first_draw_; | 342 return active_tree_needs_first_draw_; |
| 343 | 343 |
| 344 // After this line, we only want to send a swap request once per frame. | 344 // After this line, we only want to send a swap request once per frame. |
| 345 if (HasRequestedSwapThisFrame()) | 345 if (HasRequestedSwapThisFrame()) |
| 346 return false; | 346 return false; |
| 347 | 347 |
| 348 // Do not queue too many swaps. | 348 // Do not queue too many swaps. |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 return true; | 467 return true; |
| 468 | 468 |
| 469 // After this point, we only start a commit once per frame. | 469 // After this point, we only start a commit once per frame. |
| 470 if (HasSentBeginMainFrameThisFrame()) | 470 if (HasSentBeginMainFrameThisFrame()) |
| 471 return false; | 471 return false; |
| 472 | 472 |
| 473 // We shouldn't normally accept commits if there isn't an OutputSurface. | 473 // We shouldn't normally accept commits if there isn't an OutputSurface. |
| 474 if (!HasInitializedOutputSurface()) | 474 if (!HasInitializedOutputSurface()) |
| 475 return false; | 475 return false; |
| 476 | 476 |
| 477 // SwapAck throttle the BeginMainFrames unless we just swapped. |
| 478 // TODO(brianderson): Remove this restriction to improve throughput. |
| 479 bool just_swapped_in_deadline = |
| 480 begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE && |
| 481 HasSwappedThisFrame(); |
| 482 if (pending_swaps_ >= max_pending_swaps_ && !just_swapped_in_deadline) |
| 483 return false; |
| 484 |
| 477 if (skip_begin_main_frame_to_reduce_latency_) | 485 if (skip_begin_main_frame_to_reduce_latency_) |
| 478 return false; | 486 return false; |
| 479 | 487 |
| 480 return true; | 488 return true; |
| 481 } | 489 } |
| 482 | 490 |
| 483 bool SchedulerStateMachine::ShouldCommit() const { | 491 bool SchedulerStateMachine::ShouldCommit() const { |
| 484 if (commit_state_ != COMMIT_STATE_READY_TO_COMMIT) | 492 if (commit_state_ != COMMIT_STATE_READY_TO_COMMIT) |
| 485 return false; | 493 return false; |
| 486 | 494 |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 static_cast<int>(begin_impl_frame_state_), | 1091 static_cast<int>(begin_impl_frame_state_), |
| 1084 static_cast<int>(commit_state_), | 1092 static_cast<int>(commit_state_), |
| 1085 has_pending_tree_ ? 'T' : 'F', | 1093 has_pending_tree_ ? 'T' : 'F', |
| 1086 pending_tree_is_ready_for_activation_ ? 'T' : 'F', | 1094 pending_tree_is_ready_for_activation_ ? 'T' : 'F', |
| 1087 active_tree_needs_first_draw_ ? 'T' : 'F', | 1095 active_tree_needs_first_draw_ ? 'T' : 'F', |
| 1088 max_pending_swaps_, | 1096 max_pending_swaps_, |
| 1089 pending_swaps_); | 1097 pending_swaps_); |
| 1090 } | 1098 } |
| 1091 | 1099 |
| 1092 } // namespace cc | 1100 } // namespace cc |
| OLD | NEW |