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/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_animate_performed_(-1), | 25 last_frame_number_animate_performed_(-1), |
26 last_frame_number_swap_performed_(-1), | 26 last_frame_number_swap_performed_(-1), |
27 last_frame_number_swap_request_sent_(-1), | |
27 last_frame_number_begin_main_frame_sent_(-1), | 28 last_frame_number_begin_main_frame_sent_(-1), |
29 last_frame_number_draw_request_sent_(-1), | |
28 last_frame_number_update_visible_tiles_was_called_(-1), | 30 last_frame_number_update_visible_tiles_was_called_(-1), |
29 manage_tiles_funnel_(0), | 31 manage_tiles_funnel_(0), |
30 consecutive_checkerboard_animations_(0), | 32 consecutive_checkerboard_animations_(0), |
31 max_pending_swaps_(1), | 33 max_pending_swaps_(1), |
32 pending_swaps_(0), | 34 pending_swaps_(0), |
33 needs_redraw_(false), | 35 needs_redraw_(false), |
34 needs_animate_(false), | 36 needs_animate_(false), |
35 needs_manage_tiles_(false), | 37 needs_manage_tiles_(false), |
36 swap_used_incomplete_tile_(false), | 38 swap_used_incomplete_tile_(false), |
37 needs_commit_(false), | 39 needs_commit_(false), |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 state->Set("major_timestamps_in_ms", timestamps_state.release()); | 219 state->Set("major_timestamps_in_ms", timestamps_state.release()); |
218 | 220 |
219 scoped_ptr<base::DictionaryValue> minor_state(new base::DictionaryValue); | 221 scoped_ptr<base::DictionaryValue> minor_state(new base::DictionaryValue); |
220 minor_state->SetInteger("commit_count", commit_count_); | 222 minor_state->SetInteger("commit_count", commit_count_); |
221 minor_state->SetInteger("current_frame_number", current_frame_number_); | 223 minor_state->SetInteger("current_frame_number", current_frame_number_); |
222 | 224 |
223 minor_state->SetInteger("last_frame_number_animate_performed", | 225 minor_state->SetInteger("last_frame_number_animate_performed", |
224 last_frame_number_animate_performed_); | 226 last_frame_number_animate_performed_); |
225 minor_state->SetInteger("last_frame_number_swap_performed", | 227 minor_state->SetInteger("last_frame_number_swap_performed", |
226 last_frame_number_swap_performed_); | 228 last_frame_number_swap_performed_); |
229 minor_state->SetInteger("last_frame_number_swap_request_sent", | |
230 last_frame_number_swap_request_sent_); | |
227 minor_state->SetInteger( | 231 minor_state->SetInteger( |
228 "last_frame_number_begin_main_frame_sent", | 232 "last_frame_number_begin_main_frame_sent", |
229 last_frame_number_begin_main_frame_sent_); | 233 last_frame_number_begin_main_frame_sent_); |
230 minor_state->SetInteger( | 234 minor_state->SetInteger( |
235 "last_frame_number_draw_request_sent", | |
236 last_frame_number_draw_request_sent_); | |
237 minor_state->SetInteger( | |
231 "last_frame_number_update_visible_tiles_was_called", | 238 "last_frame_number_update_visible_tiles_was_called", |
232 last_frame_number_update_visible_tiles_was_called_); | 239 last_frame_number_update_visible_tiles_was_called_); |
233 | 240 |
234 minor_state->SetInteger("manage_tiles_funnel", manage_tiles_funnel_); | 241 minor_state->SetInteger("manage_tiles_funnel", manage_tiles_funnel_); |
235 minor_state->SetInteger("consecutive_checkerboard_animations", | 242 minor_state->SetInteger("consecutive_checkerboard_animations", |
236 consecutive_checkerboard_animations_); | 243 consecutive_checkerboard_animations_); |
237 minor_state->SetInteger("max_pending_swaps_", max_pending_swaps_); | 244 minor_state->SetInteger("max_pending_swaps_", max_pending_swaps_); |
238 minor_state->SetInteger("pending_swaps_", pending_swaps_); | 245 minor_state->SetInteger("pending_swaps_", pending_swaps_); |
239 minor_state->SetBoolean("needs_redraw", needs_redraw_); | 246 minor_state->SetBoolean("needs_redraw", needs_redraw_); |
240 minor_state->SetBoolean("needs_animate_", needs_animate_); | 247 minor_state->SetBoolean("needs_animate_", needs_animate_); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
285 | 292 |
286 bool SchedulerStateMachine::HasUpdatedVisibleTilesThisFrame() const { | 293 bool SchedulerStateMachine::HasUpdatedVisibleTilesThisFrame() const { |
287 return current_frame_number_ == | 294 return current_frame_number_ == |
288 last_frame_number_update_visible_tiles_was_called_; | 295 last_frame_number_update_visible_tiles_was_called_; |
289 } | 296 } |
290 | 297 |
291 bool SchedulerStateMachine::HasSwappedThisFrame() const { | 298 bool SchedulerStateMachine::HasSwappedThisFrame() const { |
292 return current_frame_number_ == last_frame_number_swap_performed_; | 299 return current_frame_number_ == last_frame_number_swap_performed_; |
293 } | 300 } |
294 | 301 |
302 bool SchedulerStateMachine::HasSentSwapRequestThisFrame() const { | |
brianderson
2014/05/08 02:24:13
HasRequestedSwapThisFrame?
simonhong
2014/05/08 03:13:31
Done.
| |
303 return current_frame_number_ == last_frame_number_swap_request_sent_; | |
304 } | |
305 | |
306 bool SchedulerStateMachine::HasSentDrawRequestThisFrame() const { | |
brianderson
2014/05/08 02:24:13
HasRequestedDrawThisFrame?
simonhong
2014/05/08 03:13:31
Done.
| |
307 return current_frame_number_ == last_frame_number_draw_request_sent_; | |
308 } | |
309 | |
295 bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const { | 310 bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const { |
296 // These are all the cases where we normally cannot or do not want to draw | 311 // These are all the cases where we normally cannot or do not want to draw |
297 // but, if needs_redraw_ is true and we do not draw to make forward progress, | 312 // but, if needs_redraw_ is true and we do not draw to make forward progress, |
298 // we might deadlock with the main thread. | 313 // we might deadlock with the main thread. |
299 // This should be a superset of PendingActivationsShouldBeForced() since | 314 // This should be a superset of PendingActivationsShouldBeForced() since |
300 // activation of the pending tree is blocked by drawing of the active tree and | 315 // activation of the pending tree is blocked by drawing of the active tree and |
301 // the main thread might be blocked on activation of the most recent commit. | 316 // the main thread might be blocked on activation of the most recent commit. |
302 if (PendingActivationsShouldBeForced()) | 317 if (PendingActivationsShouldBeForced()) |
303 return true; | 318 return true; |
304 | 319 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
363 return true; | 378 return true; |
364 | 379 |
365 // If we need to abort draws, we should do so ASAP since the draw could | 380 // If we need to abort draws, we should do so ASAP since the draw could |
366 // be blocking other important actions (like output surface initialization), | 381 // be blocking other important actions (like output surface initialization), |
367 // from occuring. If we are waiting for the first draw, then perfom the | 382 // from occuring. If we are waiting for the first draw, then perfom the |
368 // aborted draw to keep things moving. If we are not waiting for the first | 383 // aborted draw to keep things moving. If we are not waiting for the first |
369 // draw however, we don't want to abort for no reason. | 384 // draw however, we don't want to abort for no reason. |
370 if (PendingDrawsShouldBeAborted()) | 385 if (PendingDrawsShouldBeAborted()) |
371 return active_tree_needs_first_draw_; | 386 return active_tree_needs_first_draw_; |
372 | 387 |
373 // After this line, we only want to swap once per frame. | 388 // After this line, we only want to send draw & swap request once per frame. |
374 if (HasSwappedThisFrame()) | 389 if (HasSentDrawRequestThisFrame() && HasSentSwapRequestThisFrame()) |
brianderson
2014/05/08 02:24:13
HasSentSwapRequestThisFrame should be good enough
simonhong
2014/05/08 03:13:31
Yep, you're right.
Using it alone is enough.
| |
375 return false; | 390 return false; |
376 | 391 |
377 // Do not queue too many swaps. | 392 // Do not queue too many swaps. |
378 if (pending_swaps_ >= max_pending_swaps_) | 393 if (pending_swaps_ >= max_pending_swaps_) |
379 return false; | 394 return false; |
380 | 395 |
381 // Except for the cases above, do not draw outside of the BeginImplFrame | 396 // Except for the cases above, do not draw outside of the BeginImplFrame |
382 // deadline. | 397 // deadline. |
383 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) | 398 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) |
384 return false; | 399 return false; |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
621 UpdateStateOnCommit(commit_was_aborted); | 636 UpdateStateOnCommit(commit_was_aborted); |
622 return; | 637 return; |
623 } | 638 } |
624 | 639 |
625 case ACTION_DRAW_AND_SWAP_FORCED: | 640 case ACTION_DRAW_AND_SWAP_FORCED: |
626 case ACTION_DRAW_AND_SWAP_IF_POSSIBLE: { | 641 case ACTION_DRAW_AND_SWAP_IF_POSSIBLE: { |
627 bool did_request_swap = true; | 642 bool did_request_swap = true; |
628 UpdateStateOnDraw(did_request_swap); | 643 UpdateStateOnDraw(did_request_swap); |
629 return; | 644 return; |
630 } | 645 } |
631 | |
brianderson
2014/05/08 02:24:13
Accident?
simonhong
2014/05/08 03:13:31
Oops!
blank line restored.
| |
632 case ACTION_DRAW_AND_SWAP_ABORT: | 646 case ACTION_DRAW_AND_SWAP_ABORT: |
633 case ACTION_DRAW_AND_READBACK: { | 647 case ACTION_DRAW_AND_READBACK: { |
634 bool did_request_swap = false; | 648 bool did_request_swap = false; |
635 UpdateStateOnDraw(did_request_swap); | 649 UpdateStateOnDraw(did_request_swap); |
636 return; | 650 return; |
637 } | 651 } |
638 | 652 |
639 case ACTION_BEGIN_OUTPUT_SURFACE_CREATION: | 653 case ACTION_BEGIN_OUTPUT_SURFACE_CREATION: |
640 DCHECK_EQ(output_surface_state_, OUTPUT_SURFACE_LOST); | 654 DCHECK_EQ(output_surface_state_, OUTPUT_SURFACE_LOST); |
641 output_surface_state_ = OUTPUT_SURFACE_CREATING; | 655 output_surface_state_ = OUTPUT_SURFACE_CREATING; |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
782 readback_state_ = READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT; | 796 readback_state_ = READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT; |
783 } else if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) { | 797 } else if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) { |
784 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; | 798 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; |
785 } | 799 } |
786 | 800 |
787 if (commit_state_ == COMMIT_STATE_WAITING_FOR_FIRST_DRAW) | 801 if (commit_state_ == COMMIT_STATE_WAITING_FOR_FIRST_DRAW) |
788 commit_state_ = COMMIT_STATE_IDLE; | 802 commit_state_ = COMMIT_STATE_IDLE; |
789 | 803 |
790 needs_redraw_ = false; | 804 needs_redraw_ = false; |
791 active_tree_needs_first_draw_ = false; | 805 active_tree_needs_first_draw_ = false; |
806 last_frame_number_draw_request_sent_ = current_frame_number_; | |
792 | 807 |
793 if (did_request_swap) | 808 if (did_request_swap) |
794 last_frame_number_swap_performed_ = current_frame_number_; | 809 last_frame_number_swap_request_sent_ = current_frame_number_; |
795 } | 810 } |
796 | 811 |
797 void SchedulerStateMachine::UpdateStateOnManageTiles() { | 812 void SchedulerStateMachine::UpdateStateOnManageTiles() { |
798 needs_manage_tiles_ = false; | 813 needs_manage_tiles_ = false; |
799 } | 814 } |
800 | 815 |
801 void SchedulerStateMachine::SetSkipNextBeginMainFrameToReduceLatency() { | 816 void SchedulerStateMachine::SetSkipNextBeginMainFrameToReduceLatency() { |
802 skip_next_begin_main_frame_to_reduce_latency_ = true; | 817 skip_next_begin_main_frame_to_reduce_latency_ = true; |
803 } | 818 } |
804 | 819 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
892 // If the pending tree activates quickly, we'll want a BeginImplFrame soon | 907 // If the pending tree activates quickly, we'll want a BeginImplFrame soon |
893 // to draw the new active tree. | 908 // to draw the new active tree. |
894 if (has_pending_tree_) | 909 if (has_pending_tree_) |
895 return true; | 910 return true; |
896 | 911 |
897 // Changing priorities may allow us to activate (given the new priorities), | 912 // Changing priorities may allow us to activate (given the new priorities), |
898 // which may result in a new frame. | 913 // which may result in a new frame. |
899 if (needs_manage_tiles_) | 914 if (needs_manage_tiles_) |
900 return true; | 915 return true; |
901 | 916 |
902 // If we just swapped, it's likely that we are going to produce another | 917 // If we just sent draw request, it's likely that we are going to produce |
903 // frame soon. This helps avoid negative glitches in our | 918 // another frame soon. This helps avoid negative glitches in our |
904 // SetNeedsBeginFrame requests, which may propagate to the BeginImplFrame | 919 // SetNeedsBeginFrame requests, which may propagate to the BeginImplFrame |
905 // provider and get sampled at an inopportune time, delaying the next | 920 // provider and get sampled at an inopportune time, delaying the next |
906 // BeginImplFrame. | 921 // BeginImplFrame. |
907 if (last_frame_number_swap_performed_ == current_frame_number_) | 922 if (HasSentDrawRequestThisFrame()) |
908 return true; | 923 return true; |
909 | 924 |
910 return false; | 925 return false; |
911 } | 926 } |
912 | 927 |
913 void SchedulerStateMachine::OnBeginImplFrame(const BeginFrameArgs& args) { | 928 void SchedulerStateMachine::OnBeginImplFrame(const BeginFrameArgs& args) { |
914 AdvanceCurrentFrameNumber(); | 929 AdvanceCurrentFrameNumber(); |
915 begin_impl_frame_args_ = args; | 930 begin_impl_frame_args_ = args; |
916 DCHECK_EQ(begin_impl_frame_state_, BEGIN_IMPL_FRAME_STATE_IDLE) << *AsValue(); | 931 DCHECK_EQ(begin_impl_frame_state_, BEGIN_IMPL_FRAME_STATE_IDLE) << *AsValue(); |
917 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING; | 932 begin_impl_frame_state_ = BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
978 } | 993 } |
979 | 994 |
980 bool SchedulerStateMachine::MainThreadIsInHighLatencyMode() const { | 995 bool SchedulerStateMachine::MainThreadIsInHighLatencyMode() const { |
981 // If a commit is pending before the previous commit has been drawn, we | 996 // If a commit is pending before the previous commit has been drawn, we |
982 // are definitely in a high latency mode. | 997 // are definitely in a high latency mode. |
983 if (CommitPending() && (active_tree_needs_first_draw_ || has_pending_tree_)) | 998 if (CommitPending() && (active_tree_needs_first_draw_ || has_pending_tree_)) |
984 return true; | 999 return true; |
985 | 1000 |
986 // If we just sent a BeginMainFrame and haven't hit the deadline yet, the main | 1001 // If we just sent a BeginMainFrame and haven't hit the deadline yet, the main |
987 // thread is in a low latency mode. | 1002 // thread is in a low latency mode. |
988 if (last_frame_number_begin_main_frame_sent_ == current_frame_number_ && | 1003 if (HasSentBeginMainFrameThisFrame() && |
989 (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING || | 1004 (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_BEGIN_FRAME_STARTING || |
990 begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME)) | 1005 begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_BEGIN_FRAME)) |
991 return false; | 1006 return false; |
992 | 1007 |
993 // If there's a commit in progress it must either be from the previous frame | 1008 // If there's a commit in progress it must either be from the previous frame |
994 // or it started after the impl thread's deadline. In either case the main | 1009 // or it started after the impl thread's deadline. In either case the main |
995 // thread is in high latency mode. | 1010 // thread is in high latency mode. |
996 if (commit_state_ == COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || | 1011 if (CommitPending()) |
997 commit_state_ == COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED || | |
998 commit_state_ == COMMIT_STATE_READY_TO_COMMIT) | |
999 return true; | 1012 return true; |
1000 | 1013 |
1001 // Similarly, if there's a pending tree the main thread is in high latency | 1014 // Similarly, if there's a pending tree the main thread is in high latency |
1002 // mode, because either | 1015 // mode, because either |
1003 // it's from the previous frame | 1016 // it's from the previous frame |
1004 // or | 1017 // or |
1005 // we're currently drawing the active tree and the pending tree will thus | 1018 // we're currently drawing the active tree and the pending tree will thus |
1006 // only be drawn in the next frame. | 1019 // only be drawn in the next frame. |
1007 if (has_pending_tree_) | 1020 if (has_pending_tree_) |
1008 return true; | 1021 return true; |
1009 | 1022 |
1010 if (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) { | 1023 if (begin_impl_frame_state_ == BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) { |
1011 // Even if there's a new active tree to draw at the deadline or we've just | 1024 // Even if we've just drawn it, it may have been triggered by a previous |
1012 // drawn it, it may have been triggered by a previous BeginImplFrame, in | 1025 // BeginImplFrame, in which case the main thread is in a high latency mode. |
1013 // which case the main thread is in a high latency mode. | 1026 return HasSwappedThisFrame() && !HasSentBeginMainFrameThisFrame(); |
brianderson
2014/05/08 02:24:13
Why was the active_tree_needs_first_draw_ conditio
simonhong
2014/05/08 03:13:31
My mistake. restored!
| |
1014 return (active_tree_needs_first_draw_ || | |
1015 last_frame_number_swap_performed_ == current_frame_number_) && | |
1016 last_frame_number_begin_main_frame_sent_ != current_frame_number_; | |
1017 } | 1027 } |
1018 | 1028 |
1019 // If the active tree needs its first draw in any other state, we know the | 1029 // If the active tree needs its first draw in any other state, we know the |
1020 // main thread is in a high latency mode. | 1030 // main thread is in a high latency mode. |
1021 return active_tree_needs_first_draw_; | 1031 return active_tree_needs_first_draw_; |
1022 } | 1032 } |
1023 | 1033 |
1024 void SchedulerStateMachine::DidEnterPollForAnticipatedDrawTriggers() { | 1034 void SchedulerStateMachine::DidEnterPollForAnticipatedDrawTriggers() { |
1025 AdvanceCurrentFrameNumber(); | 1035 AdvanceCurrentFrameNumber(); |
1026 inside_poll_for_anticipated_draw_triggers_ = true; | 1036 inside_poll_for_anticipated_draw_triggers_ = true; |
(...skipping 21 matching lines...) Expand all Loading... | |
1048 } | 1058 } |
1049 } | 1059 } |
1050 | 1060 |
1051 void SchedulerStateMachine::SetMaxSwapsPending(int max) { | 1061 void SchedulerStateMachine::SetMaxSwapsPending(int max) { |
1052 max_pending_swaps_ = max; | 1062 max_pending_swaps_ = max; |
1053 } | 1063 } |
1054 | 1064 |
1055 void SchedulerStateMachine::DidSwapBuffers() { | 1065 void SchedulerStateMachine::DidSwapBuffers() { |
1056 pending_swaps_++; | 1066 pending_swaps_++; |
1057 DCHECK_LE(pending_swaps_, max_pending_swaps_); | 1067 DCHECK_LE(pending_swaps_, max_pending_swaps_); |
1068 | |
1069 last_frame_number_swap_performed_ = current_frame_number_; | |
1058 } | 1070 } |
1059 | 1071 |
1060 void SchedulerStateMachine::SetSwapUsedIncompleteTile( | 1072 void SchedulerStateMachine::SetSwapUsedIncompleteTile( |
1061 bool used_incomplete_tile) { | 1073 bool used_incomplete_tile) { |
1062 swap_used_incomplete_tile_ = used_incomplete_tile; | 1074 swap_used_incomplete_tile_ = used_incomplete_tile; |
1063 } | 1075 } |
1064 | 1076 |
1065 void SchedulerStateMachine::DidSwapBuffersComplete() { | 1077 void SchedulerStateMachine::DidSwapBuffersComplete() { |
1066 DCHECK_GT(pending_swaps_, 0); | 1078 DCHECK_GT(pending_swaps_, 0); |
1067 pending_swaps_--; | 1079 pending_swaps_--; |
1068 } | 1080 } |
1069 | 1081 |
1070 void SchedulerStateMachine::SetSmoothnessTakesPriority( | 1082 void SchedulerStateMachine::SetSmoothnessTakesPriority( |
1071 bool smoothness_takes_priority) { | 1083 bool smoothness_takes_priority) { |
1072 smoothness_takes_priority_ = smoothness_takes_priority; | 1084 smoothness_takes_priority_ = smoothness_takes_priority; |
1073 } | 1085 } |
1074 | 1086 |
1075 void SchedulerStateMachine::DidDrawIfPossibleCompleted( | 1087 void SchedulerStateMachine::DidDrawIfPossibleCompleted(DrawResult result) { |
1076 DrawSwapReadbackResult::DrawResult result) { | |
1077 switch (result) { | 1088 switch (result) { |
1078 case DrawSwapReadbackResult::INVALID_RESULT: | 1089 case INVALID_RESULT: |
1079 NOTREACHED() << "Uninitialized DrawSwapReadbackResult."; | 1090 NOTREACHED() << "Uninitialized DrawResult."; |
1080 break; | 1091 break; |
1081 case DrawSwapReadbackResult::DRAW_ABORTED_CANT_DRAW: | 1092 case DRAW_ABORTED_CANT_DRAW: |
1082 case DrawSwapReadbackResult::DRAW_ABORTED_CANT_READBACK: | 1093 case DRAW_ABORTED_CANT_READBACK: |
1083 case DrawSwapReadbackResult::DRAW_ABORTED_CONTEXT_LOST: | 1094 case DRAW_ABORTED_CONTEXT_LOST: |
1084 NOTREACHED() << "Invalid return value from DrawAndSwapIfPossible:" | 1095 NOTREACHED() << "Invalid return value from DrawAndSwapIfPossible:" |
1085 << result; | 1096 << result; |
1086 break; | 1097 break; |
1087 case DrawSwapReadbackResult::DRAW_SUCCESS: | 1098 case DRAW_SUCCESS: |
1088 consecutive_checkerboard_animations_ = 0; | 1099 consecutive_checkerboard_animations_ = 0; |
1089 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; | 1100 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; |
1090 break; | 1101 break; |
1091 case DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS: | 1102 case DRAW_ABORTED_CHECKERBOARD_ANIMATIONS: |
1092 needs_redraw_ = true; | 1103 needs_redraw_ = true; |
1093 | 1104 |
1094 // If we're already in the middle of a redraw, we don't need to | 1105 // If we're already in the middle of a redraw, we don't need to |
1095 // restart it. | 1106 // restart it. |
1096 if (forced_redraw_state_ != FORCED_REDRAW_STATE_IDLE) | 1107 if (forced_redraw_state_ != FORCED_REDRAW_STATE_IDLE) |
1097 return; | 1108 return; |
1098 | 1109 |
1099 needs_commit_ = true; | 1110 needs_commit_ = true; |
1100 consecutive_checkerboard_animations_++; | 1111 consecutive_checkerboard_animations_++; |
1101 if (settings_.timeout_and_draw_when_animation_checkerboards && | 1112 if (settings_.timeout_and_draw_when_animation_checkerboards && |
1102 consecutive_checkerboard_animations_ >= | 1113 consecutive_checkerboard_animations_ >= |
1103 settings_.maximum_number_of_failed_draws_before_draw_is_forced_) { | 1114 settings_.maximum_number_of_failed_draws_before_draw_is_forced_) { |
1104 consecutive_checkerboard_animations_ = 0; | 1115 consecutive_checkerboard_animations_ = 0; |
1105 // We need to force a draw, but it doesn't make sense to do this until | 1116 // We need to force a draw, but it doesn't make sense to do this until |
1106 // we've committed and have new textures. | 1117 // we've committed and have new textures. |
1107 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_COMMIT; | 1118 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_COMMIT; |
1108 } | 1119 } |
1109 break; | 1120 break; |
1110 case DrawSwapReadbackResult::DRAW_ABORTED_MISSING_HIGH_RES_CONTENT: | 1121 case DRAW_ABORTED_MISSING_HIGH_RES_CONTENT: |
1111 // It's not clear whether this missing content is because of missing | 1122 // It's not clear whether this missing content is because of missing |
1112 // pictures (which requires a commit) or because of memory pressure | 1123 // pictures (which requires a commit) or because of memory pressure |
1113 // removing textures (which might not). To be safe, request a commit | 1124 // removing textures (which might not). To be safe, request a commit |
1114 // anyway. | 1125 // anyway. |
1115 needs_commit_ = true; | 1126 needs_commit_ = true; |
1116 break; | 1127 break; |
1117 } | 1128 } |
1118 } | 1129 } |
1119 | 1130 |
1120 void SchedulerStateMachine::SetNeedsCommit() { needs_commit_ = true; } | 1131 void SchedulerStateMachine::SetNeedsCommit() { needs_commit_ = true; } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1220 case OUTPUT_SURFACE_ACTIVE: | 1231 case OUTPUT_SURFACE_ACTIVE: |
1221 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: | 1232 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: |
1222 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: | 1233 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: |
1223 return true; | 1234 return true; |
1224 } | 1235 } |
1225 NOTREACHED(); | 1236 NOTREACHED(); |
1226 return false; | 1237 return false; |
1227 } | 1238 } |
1228 | 1239 |
1229 } // namespace cc | 1240 } // namespace cc |
OLD | NEW |