Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: cc/scheduler/scheduler_state_machine.cc

Issue 246753008: cc: Unify use of DidSwapBuffers() and did_request_swap (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Introduce HasSentDrawRequestThisFrame() Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
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/format_macros.h" 8 #include "base/format_macros.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "ui/gfx/frame_time.h" 12 #include "ui/gfx/frame_time.h"
13 13
14 namespace cc { 14 namespace cc {
15 15
16 SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings) 16 SchedulerStateMachine::SchedulerStateMachine(const SchedulerSettings& settings)
17 : settings_(settings), 17 : settings_(settings),
18 output_surface_state_(OUTPUT_SURFACE_LOST), 18 output_surface_state_(OUTPUT_SURFACE_LOST),
19 begin_impl_frame_state_(BEGIN_IMPL_FRAME_STATE_IDLE), 19 begin_impl_frame_state_(BEGIN_IMPL_FRAME_STATE_IDLE),
20 commit_state_(COMMIT_STATE_IDLE), 20 commit_state_(COMMIT_STATE_IDLE),
21 forced_redraw_state_(FORCED_REDRAW_STATE_IDLE), 21 forced_redraw_state_(FORCED_REDRAW_STATE_IDLE),
22 readback_state_(READBACK_STATE_IDLE), 22 readback_state_(READBACK_STATE_IDLE),
23 commit_count_(0), 23 commit_count_(0),
24 current_frame_number_(0), 24 current_frame_number_(0),
25 last_frame_number_swap_performed_(-1), 25 last_frame_number_swap_performed_(-1),
26 last_frame_number_begin_main_frame_sent_(-1), 26 last_frame_number_begin_main_frame_sent_(-1),
27 last_frame_number_draw_request_sent_(-1),
27 last_frame_number_update_visible_tiles_was_called_(-1), 28 last_frame_number_update_visible_tiles_was_called_(-1),
28 manage_tiles_funnel_(0), 29 manage_tiles_funnel_(0),
29 consecutive_checkerboard_animations_(0), 30 consecutive_checkerboard_animations_(0),
30 max_pending_swaps_(1), 31 max_pending_swaps_(1),
31 pending_swaps_(0), 32 pending_swaps_(0),
32 needs_redraw_(false), 33 needs_redraw_(false),
33 needs_manage_tiles_(false), 34 needs_manage_tiles_(false),
34 swap_used_incomplete_tile_(false), 35 swap_used_incomplete_tile_(false),
35 needs_commit_(false), 36 needs_commit_(false),
36 inside_poll_for_anticipated_draw_triggers_(false), 37 inside_poll_for_anticipated_draw_triggers_(false),
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 scoped_ptr<base::DictionaryValue> minor_state(new base::DictionaryValue); 216 scoped_ptr<base::DictionaryValue> minor_state(new base::DictionaryValue);
216 minor_state->SetInteger("commit_count", commit_count_); 217 minor_state->SetInteger("commit_count", commit_count_);
217 minor_state->SetInteger("current_frame_number", current_frame_number_); 218 minor_state->SetInteger("current_frame_number", current_frame_number_);
218 219
219 minor_state->SetInteger("last_frame_number_swap_performed", 220 minor_state->SetInteger("last_frame_number_swap_performed",
220 last_frame_number_swap_performed_); 221 last_frame_number_swap_performed_);
221 minor_state->SetInteger( 222 minor_state->SetInteger(
222 "last_frame_number_begin_main_frame_sent", 223 "last_frame_number_begin_main_frame_sent",
223 last_frame_number_begin_main_frame_sent_); 224 last_frame_number_begin_main_frame_sent_);
224 minor_state->SetInteger( 225 minor_state->SetInteger(
226 "last_frame_number_draw_request_sent",
227 last_frame_number_draw_request_sent_);
228 minor_state->SetInteger(
225 "last_frame_number_update_visible_tiles_was_called", 229 "last_frame_number_update_visible_tiles_was_called",
226 last_frame_number_update_visible_tiles_was_called_); 230 last_frame_number_update_visible_tiles_was_called_);
227 231
228 minor_state->SetInteger("manage_tiles_funnel", manage_tiles_funnel_); 232 minor_state->SetInteger("manage_tiles_funnel", manage_tiles_funnel_);
229 minor_state->SetInteger("consecutive_checkerboard_animations", 233 minor_state->SetInteger("consecutive_checkerboard_animations",
230 consecutive_checkerboard_animations_); 234 consecutive_checkerboard_animations_);
231 minor_state->SetInteger("max_pending_swaps_", max_pending_swaps_); 235 minor_state->SetInteger("max_pending_swaps_", max_pending_swaps_);
232 minor_state->SetInteger("pending_swaps_", pending_swaps_); 236 minor_state->SetInteger("pending_swaps_", pending_swaps_);
233 minor_state->SetBoolean("needs_redraw", needs_redraw_); 237 minor_state->SetBoolean("needs_redraw", needs_redraw_);
234 minor_state->SetBoolean("needs_manage_tiles", needs_manage_tiles_); 238 minor_state->SetBoolean("needs_manage_tiles", needs_manage_tiles_);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 283
280 bool SchedulerStateMachine::HasUpdatedVisibleTilesThisFrame() const { 284 bool SchedulerStateMachine::HasUpdatedVisibleTilesThisFrame() const {
281 return current_frame_number_ == 285 return current_frame_number_ ==
282 last_frame_number_update_visible_tiles_was_called_; 286 last_frame_number_update_visible_tiles_was_called_;
283 } 287 }
284 288
285 bool SchedulerStateMachine::HasSwappedThisFrame() const { 289 bool SchedulerStateMachine::HasSwappedThisFrame() const {
286 return current_frame_number_ == last_frame_number_swap_performed_; 290 return current_frame_number_ == last_frame_number_swap_performed_;
287 } 291 }
288 292
293 bool SchedulerStateMachine::HasSentDrawRequestThisFrame() const {
294 return current_frame_number_ == last_frame_number_draw_request_sent_;
295 }
296
289 bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const { 297 bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const {
290 // These are all the cases where we normally cannot or do not want to draw 298 // These are all the cases where we normally cannot or do not want to draw
291 // but, if needs_redraw_ is true and we do not draw to make forward progress, 299 // but, if needs_redraw_ is true and we do not draw to make forward progress,
292 // we might deadlock with the main thread. 300 // we might deadlock with the main thread.
293 // This should be a superset of PendingActivationsShouldBeForced() since 301 // This should be a superset of PendingActivationsShouldBeForced() since
294 // activation of the pending tree is blocked by drawing of the active tree and 302 // activation of the pending tree is blocked by drawing of the active tree and
295 // the main thread might be blocked on activation of the most recent commit. 303 // the main thread might be blocked on activation of the most recent commit.
296 if (PendingActivationsShouldBeForced()) 304 if (PendingActivationsShouldBeForced())
297 return true; 305 return true;
298 306
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 return true; 365 return true;
358 366
359 // If we need to abort draws, we should do so ASAP since the draw could 367 // If we need to abort draws, we should do so ASAP since the draw could
360 // be blocking other important actions (like output surface initialization), 368 // be blocking other important actions (like output surface initialization),
361 // from occuring. If we are waiting for the first draw, then perfom the 369 // from occuring. If we are waiting for the first draw, then perfom the
362 // aborted draw to keep things moving. If we are not waiting for the first 370 // aborted draw to keep things moving. If we are not waiting for the first
363 // draw however, we don't want to abort for no reason. 371 // draw however, we don't want to abort for no reason.
364 if (PendingDrawsShouldBeAborted()) 372 if (PendingDrawsShouldBeAborted())
365 return active_tree_needs_first_draw_; 373 return active_tree_needs_first_draw_;
366 374
367 // After this line, we only want to swap once per frame. 375 // After this line, we only want to send draw request once per frame.
368 if (HasSwappedThisFrame()) 376 if (HasSentDrawRequestThisFrame())
369 return false; 377 return false;
370 378
371 // Do not queue too many swaps. 379 // Do not queue too many swaps.
372 if (pending_swaps_ >= max_pending_swaps_) 380 if (pending_swaps_ >= max_pending_swaps_)
373 return false; 381 return false;
374 382
375 // Except for the cases above, do not draw outside of the BeginImplFrame 383 // Except for the cases above, do not draw outside of the BeginImplFrame
376 // deadline. 384 // deadline.
377 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) 385 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE)
378 return false; 386 return false;
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 current_frame_number_; 594 current_frame_number_;
587 return; 595 return;
588 596
589 case ACTION_COMMIT: { 597 case ACTION_COMMIT: {
590 bool commit_was_aborted = false; 598 bool commit_was_aborted = false;
591 UpdateStateOnCommit(commit_was_aborted); 599 UpdateStateOnCommit(commit_was_aborted);
592 return; 600 return;
593 } 601 }
594 602
595 case ACTION_DRAW_AND_SWAP_FORCED: 603 case ACTION_DRAW_AND_SWAP_FORCED:
596 case ACTION_DRAW_AND_SWAP_IF_POSSIBLE: { 604 case ACTION_DRAW_AND_SWAP_IF_POSSIBLE:
597 bool did_request_swap = true; 605 case ACTION_DRAW_AND_SWAP_ABORT:
598 UpdateStateOnDraw(did_request_swap); 606 case ACTION_DRAW_AND_READBACK: {
607 UpdateStateOnDraw();
599 return; 608 return;
600 } 609 }
601 610
602 case ACTION_DRAW_AND_SWAP_ABORT:
603 case ACTION_DRAW_AND_READBACK: {
604 bool did_request_swap = false;
605 UpdateStateOnDraw(did_request_swap);
606 return;
607 }
608
609 case ACTION_BEGIN_OUTPUT_SURFACE_CREATION: 611 case ACTION_BEGIN_OUTPUT_SURFACE_CREATION:
610 DCHECK_EQ(output_surface_state_, OUTPUT_SURFACE_LOST); 612 DCHECK_EQ(output_surface_state_, OUTPUT_SURFACE_LOST);
611 output_surface_state_ = OUTPUT_SURFACE_CREATING; 613 output_surface_state_ = OUTPUT_SURFACE_CREATING;
612 614
613 // The following DCHECKs make sure we are in the proper quiescent state. 615 // The following DCHECKs make sure we are in the proper quiescent state.
614 // The pipeline should be flushed entirely before we start output 616 // The pipeline should be flushed entirely before we start output
615 // surface creation to avoid complicated corner cases. 617 // surface creation to avoid complicated corner cases.
616 DCHECK_EQ(commit_state_, COMMIT_STATE_IDLE); 618 DCHECK_EQ(commit_state_, COMMIT_STATE_IDLE);
617 DCHECK(!has_pending_tree_); 619 DCHECK(!has_pending_tree_);
618 DCHECK(!active_tree_needs_first_draw_); 620 DCHECK(!active_tree_needs_first_draw_);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 readback_state_ = READBACK_STATE_IDLE; 734 readback_state_ = READBACK_STATE_IDLE;
733 } 735 }
734 } 736 }
735 737
736 has_pending_tree_ = false; 738 has_pending_tree_ = false;
737 pending_tree_is_ready_for_activation_ = false; 739 pending_tree_is_ready_for_activation_ = false;
738 active_tree_needs_first_draw_ = true; 740 active_tree_needs_first_draw_ = true;
739 needs_redraw_ = true; 741 needs_redraw_ = true;
740 } 742 }
741 743
742 void SchedulerStateMachine::UpdateStateOnDraw(bool did_request_swap) { 744 void SchedulerStateMachine::UpdateStateOnDraw() {
743 DCHECK(readback_state_ != READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT && 745 DCHECK(readback_state_ != READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT &&
744 readback_state_ != READBACK_STATE_WAITING_FOR_REPLACEMENT_ACTIVATION) 746 readback_state_ != READBACK_STATE_WAITING_FOR_REPLACEMENT_ACTIVATION)
745 << *AsValue(); 747 << *AsValue();
746 748
747 if (readback_state_ == READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK) { 749 if (readback_state_ == READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK) {
748 // The draw corresponds to a readback commit. 750 // The draw corresponds to a readback commit.
749 // We are blocking commits from the main thread until after this draw, so 751 // We are blocking commits from the main thread until after this draw, so
750 // we should not have a pending tree. 752 // we should not have a pending tree.
751 DCHECK(!has_pending_tree_); 753 DCHECK(!has_pending_tree_);
752 // We transition to COMMIT_STATE_BEGIN_MAIN_FRAME_SENT because there is a 754 // We transition to COMMIT_STATE_BEGIN_MAIN_FRAME_SENT because there is a
753 // pending BeginMainFrame behind the readback request. 755 // pending BeginMainFrame behind the readback request.
754 commit_state_ = COMMIT_STATE_BEGIN_MAIN_FRAME_SENT; 756 commit_state_ = COMMIT_STATE_BEGIN_MAIN_FRAME_SENT;
755 readback_state_ = READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT; 757 readback_state_ = READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT;
756 } else if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) { 758 } else if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) {
757 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; 759 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE;
758 } 760 }
759 761
760 if (commit_state_ == COMMIT_STATE_WAITING_FOR_FIRST_DRAW) 762 if (commit_state_ == COMMIT_STATE_WAITING_FOR_FIRST_DRAW)
761 commit_state_ = COMMIT_STATE_IDLE; 763 commit_state_ = COMMIT_STATE_IDLE;
762 764
763 needs_redraw_ = false; 765 needs_redraw_ = false;
764 draw_if_possible_failed_ = false; 766 draw_if_possible_failed_ = false;
765 active_tree_needs_first_draw_ = false; 767 active_tree_needs_first_draw_ = false;
766 768 last_frame_number_draw_request_sent_ = current_frame_number_;
brianderson 2014/05/02 04:08:58 Hmmm. This would mean that a readback, which didn'
simonhong 2014/05/08 01:14:57 Yep. I created last_frame_number_swap_request_sent
767 if (did_request_swap)
768 last_frame_number_swap_performed_ = current_frame_number_;
769 } 769 }
770 770
771 void SchedulerStateMachine::UpdateStateOnManageTiles() { 771 void SchedulerStateMachine::UpdateStateOnManageTiles() {
772 needs_manage_tiles_ = false; 772 needs_manage_tiles_ = false;
773 } 773 }
774 774
775 void SchedulerStateMachine::SetSkipNextBeginMainFrameToReduceLatency() { 775 void SchedulerStateMachine::SetSkipNextBeginMainFrameToReduceLatency() {
776 skip_next_begin_main_frame_to_reduce_latency_ = true; 776 skip_next_begin_main_frame_to_reduce_latency_ = true;
777 } 777 }
778 778
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 // Changing priorities may allow us to activate (given the new priorities), 868 // Changing priorities may allow us to activate (given the new priorities),
869 // which may result in a new frame. 869 // which may result in a new frame.
870 if (needs_manage_tiles_) 870 if (needs_manage_tiles_)
871 return true; 871 return true;
872 872
873 // If we just swapped, it's likely that we are going to produce another 873 // If we just swapped, it's likely that we are going to produce another
874 // frame soon. This helps avoid negative glitches in our 874 // frame soon. This helps avoid negative glitches in our
875 // SetNeedsBeginFrame requests, which may propagate to the BeginImplFrame 875 // SetNeedsBeginFrame requests, which may propagate to the BeginImplFrame
876 // provider and get sampled at an inopportune time, delaying the next 876 // provider and get sampled at an inopportune time, delaying the next
877 // BeginImplFrame. 877 // BeginImplFrame.
878 if (last_frame_number_swap_performed_ == current_frame_number_) 878 if (HasSwappedThisFrame())
brianderson 2014/05/02 04:08:58 Probably want to use HasSentDrawRequestThisFrame()
simonhong 2014/05/08 01:14:57 Done.
879 return true; 879 return true;
880 880
881 return false; 881 return false;
882 } 882 }
883 883
884 void SchedulerStateMachine::OnBeginImplFrame(const BeginFrameArgs& args) { 884 void SchedulerStateMachine::OnBeginImplFrame(const BeginFrameArgs& args) {
885 AdvanceCurrentFrameNumber(); 885 AdvanceCurrentFrameNumber();
886 begin_impl_frame_args_ = args; 886 begin_impl_frame_args_ = args;
887 DCHECK_EQ(begin_impl_frame_state_, BEGIN_IMPL_FRAME_STATE_IDLE) << *AsValue(); 887 DCHECK_EQ(begin_impl_frame_state_, BEGIN_IMPL_FRAME_STATE_IDLE) << *AsValue();
888 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING; 888 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 } 949 }
950 950
951 bool SchedulerStateMachine::MainThreadIsInHighLatencyMode() const { 951 bool SchedulerStateMachine::MainThreadIsInHighLatencyMode() const {
952 // If a commit is pending before the previous commit has been drawn, we 952 // If a commit is pending before the previous commit has been drawn, we
953 // are definitely in a high latency mode. 953 // are definitely in a high latency mode.
954 if (CommitPending() && (active_tree_needs_first_draw_ || has_pending_tree_)) 954 if (CommitPending() && (active_tree_needs_first_draw_ || has_pending_tree_))
955 return true; 955 return true;
956 956
957 // If we just sent a BeginMainFrame and haven't hit the deadline yet, the main 957 // If we just sent a BeginMainFrame and haven't hit the deadline yet, the main
958 // thread is in a low latency mode. 958 // thread is in a low latency mode.
959 if (last_frame_number_begin_main_frame_sent_ == current_frame_number_ && 959 if (HasSentBeginMainFrameThisFrame() &&
960 (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING || 960 (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING ||
961 begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME)) 961 begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME))
962 return false; 962 return false;
963 963
964 // If there's a commit in progress it must either be from the previous frame 964 // If there's a commit in progress it must either be from the previous frame
965 // or it started after the impl thread's deadline. In either case the main 965 // or it started after the impl thread's deadline. In either case the main
966 // thread is in high latency mode. 966 // thread is in high latency mode.
967 if (commit_state_ == COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || 967 if (CommitPending())
968 commit_state_ == COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED ||
969 commit_state_ == COMMIT_STATE_READY_TO_COMMIT)
970 return true; 968 return true;
971 969
972 // Similarly, if there's a pending tree the main thread is in high latency 970 // Similarly, if there's a pending tree the main thread is in high latency
973 // mode, because either 971 // mode, because either
974 // it's from the previous frame 972 // it's from the previous frame
975 // or 973 // or
976 // we're currently drawing the active tree and the pending tree will thus 974 // we're currently drawing the active tree and the pending tree will thus
977 // only be drawn in the next frame. 975 // only be drawn in the next frame.
978 if (has_pending_tree_) 976 if (has_pending_tree_)
979 return true; 977 return true;
980 978
981 if (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) { 979 if (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) {
982 // Even if there's a new active tree to draw at the deadline or we've just 980 // Even if there's a new active tree to draw at the deadline or we've just
983 // drawn it, it may have been triggered by a previous BeginImplFrame, in 981 // drawn it, it may have been triggered by a previous BeginImplFrame, in
984 // which case the main thread is in a high latency mode. 982 // which case the main thread is in a high latency mode.
985 return (active_tree_needs_first_draw_ || 983 return (active_tree_needs_first_draw_ || HasSwappedThisFrame()) &&
brianderson 2014/05/02 04:08:58 Please keep this HasSwappedThisFrame(). I didn't t
simonhong 2014/05/08 01:14:57 Done.
986 last_frame_number_swap_performed_ == current_frame_number_) && 984 !HasSentBeginMainFrameThisFrame();
987 last_frame_number_begin_main_frame_sent_ != current_frame_number_;
988 } 985 }
989 986
990 // If the active tree needs its first draw in any other state, we know the 987 // If the active tree needs its first draw in any other state, we know the
991 // main thread is in a high latency mode. 988 // main thread is in a high latency mode.
992 return active_tree_needs_first_draw_; 989 return active_tree_needs_first_draw_;
993 } 990 }
994 991
995 void SchedulerStateMachine::DidEnterPollForAnticipatedDrawTriggers() { 992 void SchedulerStateMachine::DidEnterPollForAnticipatedDrawTriggers() {
996 AdvanceCurrentFrameNumber(); 993 AdvanceCurrentFrameNumber();
997 inside_poll_for_anticipated_draw_triggers_ = true; 994 inside_poll_for_anticipated_draw_triggers_ = true;
(...skipping 17 matching lines...) Expand all
1015 } 1012 }
1016 } 1013 }
1017 1014
1018 void SchedulerStateMachine::SetMaxSwapsPending(int max) { 1015 void SchedulerStateMachine::SetMaxSwapsPending(int max) {
1019 max_pending_swaps_ = max; 1016 max_pending_swaps_ = max;
1020 } 1017 }
1021 1018
1022 void SchedulerStateMachine::DidSwapBuffers() { 1019 void SchedulerStateMachine::DidSwapBuffers() {
1023 pending_swaps_++; 1020 pending_swaps_++;
1024 DCHECK_LE(pending_swaps_, max_pending_swaps_); 1021 DCHECK_LE(pending_swaps_, max_pending_swaps_);
1022
1023 last_frame_number_swap_performed_ = current_frame_number_;
1025 } 1024 }
1026 1025
1027 void SchedulerStateMachine::SetSwapUsedIncompleteTile( 1026 void SchedulerStateMachine::SetSwapUsedIncompleteTile(
1028 bool used_incomplete_tile) { 1027 bool used_incomplete_tile) {
1029 swap_used_incomplete_tile_ = used_incomplete_tile; 1028 swap_used_incomplete_tile_ = used_incomplete_tile;
1030 } 1029 }
1031 1030
1032 void SchedulerStateMachine::DidSwapBuffersComplete() { 1031 void SchedulerStateMachine::DidSwapBuffersComplete() {
1033 DCHECK_GT(pending_swaps_, 0); 1032 DCHECK_GT(pending_swaps_, 0);
1034 pending_swaps_--; 1033 pending_swaps_--;
1035 } 1034 }
1036 1035
1037 void SchedulerStateMachine::SetSmoothnessTakesPriority( 1036 void SchedulerStateMachine::SetSmoothnessTakesPriority(
1038 bool smoothness_takes_priority) { 1037 bool smoothness_takes_priority) {
1039 smoothness_takes_priority_ = smoothness_takes_priority; 1038 smoothness_takes_priority_ = smoothness_takes_priority;
1040 } 1039 }
1041 1040
1042 void SchedulerStateMachine::DidDrawIfPossibleCompleted( 1041 void SchedulerStateMachine::DidDrawIfPossibleCompleted(DrawResult result) {
1043 DrawSwapReadbackResult::DrawResult result) {
1044 switch (result) { 1042 switch (result) {
1045 case DrawSwapReadbackResult::INVALID_RESULT: 1043 case INVALID_RESULT:
1046 NOTREACHED() << "Uninitialized DrawSwapReadbackResult."; 1044 NOTREACHED() << "Uninitialized DrawResult.";
1047 break; 1045 break;
1048 case DrawSwapReadbackResult::DRAW_ABORTED_CANT_DRAW: 1046 case DRAW_ABORTED_CANT_DRAW:
1049 case DrawSwapReadbackResult::DRAW_ABORTED_CANT_READBACK: 1047 case DRAW_ABORTED_CANT_READBACK:
1050 case DrawSwapReadbackResult::DRAW_ABORTED_CONTEXT_LOST: 1048 case DRAW_ABORTED_CONTEXT_LOST:
1051 NOTREACHED() << "Invalid return value from DrawAndSwapIfPossible:" 1049 NOTREACHED() << "Invalid return value from DrawAndSwapIfPossible:"
1052 << result; 1050 << result;
1053 break; 1051 break;
1054 case DrawSwapReadbackResult::DRAW_SUCCESS: 1052 case DRAW_SUCCESS:
1055 consecutive_checkerboard_animations_ = 0; 1053 consecutive_checkerboard_animations_ = 0;
1056 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; 1054 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE;
1057 break; 1055 break;
1058 case DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS: 1056 case DRAW_ABORTED_CHECKERBOARD_ANIMATIONS:
1059 needs_redraw_ = true; 1057 needs_redraw_ = true;
1060 1058
1061 // If we're already in the middle of a redraw, we don't need to 1059 // If we're already in the middle of a redraw, we don't need to
1062 // restart it. 1060 // restart it.
1063 if (forced_redraw_state_ != FORCED_REDRAW_STATE_IDLE) 1061 if (forced_redraw_state_ != FORCED_REDRAW_STATE_IDLE)
1064 return; 1062 return;
1065 1063
1066 needs_commit_ = true; 1064 needs_commit_ = true;
1067 consecutive_checkerboard_animations_++; 1065 consecutive_checkerboard_animations_++;
1068 if (settings_.timeout_and_draw_when_animation_checkerboards && 1066 if (settings_.timeout_and_draw_when_animation_checkerboards &&
1069 consecutive_checkerboard_animations_ >= 1067 consecutive_checkerboard_animations_ >=
1070 settings_.maximum_number_of_failed_draws_before_draw_is_forced_) { 1068 settings_.maximum_number_of_failed_draws_before_draw_is_forced_) {
1071 consecutive_checkerboard_animations_ = 0; 1069 consecutive_checkerboard_animations_ = 0;
1072 // We need to force a draw, but it doesn't make sense to do this until 1070 // We need to force a draw, but it doesn't make sense to do this until
1073 // we've committed and have new textures. 1071 // we've committed and have new textures.
1074 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_COMMIT; 1072 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_COMMIT;
1075 } 1073 }
1076 break; 1074 break;
1077 case DrawSwapReadbackResult::DRAW_ABORTED_MISSING_HIGH_RES_CONTENT: 1075 case DRAW_ABORTED_MISSING_HIGH_RES_CONTENT:
1078 // It's not clear whether this missing content is because of missing 1076 // It's not clear whether this missing content is because of missing
1079 // pictures (which requires a commit) or because of memory pressure 1077 // pictures (which requires a commit) or because of memory pressure
1080 // removing textures (which might not). To be safe, request a commit 1078 // removing textures (which might not). To be safe, request a commit
1081 // anyway. 1079 // anyway.
1082 needs_commit_ = true; 1080 needs_commit_ = true;
1083 break; 1081 break;
1084 } 1082 }
1085 } 1083 }
1086 1084
1087 void SchedulerStateMachine::SetNeedsCommit() { needs_commit_ = true; } 1085 void SchedulerStateMachine::SetNeedsCommit() { needs_commit_ = true; }
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 case OUTPUT_SURFACE_ACTIVE: 1185 case OUTPUT_SURFACE_ACTIVE:
1188 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: 1186 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT:
1189 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: 1187 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION:
1190 return true; 1188 return true;
1191 } 1189 }
1192 NOTREACHED(); 1190 NOTREACHED();
1193 return false; 1191 return false;
1194 } 1192 }
1195 1193
1196 } // namespace cc 1194 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698