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

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

Issue 131683005: cc: Make PrepareToDraw return an enum for why it aborts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 texture_state_(LAYER_TEXTURE_STATE_UNLOCKED), 21 texture_state_(LAYER_TEXTURE_STATE_UNLOCKED),
22 forced_redraw_state_(FORCED_REDRAW_STATE_IDLE), 22 forced_redraw_state_(FORCED_REDRAW_STATE_IDLE),
23 readback_state_(READBACK_STATE_IDLE), 23 readback_state_(READBACK_STATE_IDLE),
24 commit_count_(0), 24 commit_count_(0),
25 current_frame_number_(0), 25 current_frame_number_(0),
26 last_frame_number_swap_performed_(-1), 26 last_frame_number_swap_performed_(-1),
27 last_frame_number_begin_main_frame_sent_(-1), 27 last_frame_number_begin_main_frame_sent_(-1),
28 last_frame_number_update_visible_tiles_was_called_(-1), 28 last_frame_number_update_visible_tiles_was_called_(-1),
29 manage_tiles_funnel_(0), 29 manage_tiles_funnel_(0),
30 consecutive_failed_draws_(0), 30 consecutive_checkerboard_animations_(0),
31 needs_redraw_(false), 31 needs_redraw_(false),
32 needs_manage_tiles_(false), 32 needs_manage_tiles_(false),
33 swap_used_incomplete_tile_(false), 33 swap_used_incomplete_tile_(false),
34 needs_commit_(false), 34 needs_commit_(false),
35 main_thread_needs_layer_textures_(false), 35 main_thread_needs_layer_textures_(false),
36 inside_poll_for_anticipated_draw_triggers_(false), 36 inside_poll_for_anticipated_draw_triggers_(false),
37 visible_(false), 37 visible_(false),
38 can_start_(false), 38 can_start_(false),
39 can_draw_(false), 39 can_draw_(false),
40 has_pending_tree_(false), 40 has_pending_tree_(false),
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 minor_state->SetInteger("last_frame_number_swap_performed", 233 minor_state->SetInteger("last_frame_number_swap_performed",
234 last_frame_number_swap_performed_); 234 last_frame_number_swap_performed_);
235 minor_state->SetInteger( 235 minor_state->SetInteger(
236 "last_frame_number_begin_main_frame_sent", 236 "last_frame_number_begin_main_frame_sent",
237 last_frame_number_begin_main_frame_sent_); 237 last_frame_number_begin_main_frame_sent_);
238 minor_state->SetInteger( 238 minor_state->SetInteger(
239 "last_frame_number_update_visible_tiles_was_called", 239 "last_frame_number_update_visible_tiles_was_called",
240 last_frame_number_update_visible_tiles_was_called_); 240 last_frame_number_update_visible_tiles_was_called_);
241 241
242 minor_state->SetInteger("manage_tiles_funnel", manage_tiles_funnel_); 242 minor_state->SetInteger("manage_tiles_funnel", manage_tiles_funnel_);
243 minor_state->SetInteger("consecutive_failed_draws", 243 minor_state->SetInteger("consecutive_checkerboard_animations",
244 consecutive_failed_draws_); 244 consecutive_checkerboard_animations_);
245 minor_state->SetBoolean("needs_redraw", needs_redraw_); 245 minor_state->SetBoolean("needs_redraw", needs_redraw_);
246 minor_state->SetBoolean("needs_manage_tiles", needs_manage_tiles_); 246 minor_state->SetBoolean("needs_manage_tiles", needs_manage_tiles_);
247 minor_state->SetBoolean("swap_used_incomplete_tile", 247 minor_state->SetBoolean("swap_used_incomplete_tile",
248 swap_used_incomplete_tile_); 248 swap_used_incomplete_tile_);
249 minor_state->SetBoolean("needs_commit", needs_commit_); 249 minor_state->SetBoolean("needs_commit", needs_commit_);
250 minor_state->SetBoolean("main_thread_needs_layer_textures", 250 minor_state->SetBoolean("main_thread_needs_layer_textures",
251 main_thread_needs_layer_textures_); 251 main_thread_needs_layer_textures_);
252 minor_state->SetBoolean("visible", visible_); 252 minor_state->SetBoolean("visible", visible_);
253 minor_state->SetBoolean("can_start", can_start_); 253 minor_state->SetBoolean("can_start", can_start_);
254 minor_state->SetBoolean("can_draw", can_draw_); 254 minor_state->SetBoolean("can_draw", can_draw_);
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 void SchedulerStateMachine::SetSwapUsedIncompleteTile( 1015 void SchedulerStateMachine::SetSwapUsedIncompleteTile(
1016 bool used_incomplete_tile) { 1016 bool used_incomplete_tile) {
1017 swap_used_incomplete_tile_ = used_incomplete_tile; 1017 swap_used_incomplete_tile_ = used_incomplete_tile;
1018 } 1018 }
1019 1019
1020 void SchedulerStateMachine::SetSmoothnessTakesPriority( 1020 void SchedulerStateMachine::SetSmoothnessTakesPriority(
1021 bool smoothness_takes_priority) { 1021 bool smoothness_takes_priority) {
1022 smoothness_takes_priority_ = smoothness_takes_priority; 1022 smoothness_takes_priority_ = smoothness_takes_priority;
1023 } 1023 }
1024 1024
1025 void SchedulerStateMachine::DidDrawIfPossibleCompleted(bool success) { 1025 void SchedulerStateMachine::DidDrawIfPossibleCompleted(
1026 draw_if_possible_failed_ = !success; 1026 DrawSwapReadbackResult::DrawResult result) {
1027 if (draw_if_possible_failed_) { 1027 switch (result) {
1028 needs_redraw_ = true; 1028 case DrawSwapReadbackResult::INVALID_RESULT:
1029 // Uninitialized DrawSwapReadbackResult.
1030 NOTREACHED();
1031 break;
1032 case DrawSwapReadbackResult::DID_DRAW:
1033 consecutive_checkerboard_animations_ = 0;
1034 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE;
1035 break;
1036 case DrawSwapReadbackResult::DRAW_ABORTED_CANT_DRAW:
1037 case DrawSwapReadbackResult::DRAW_ABORTED_NO_TREE:
1038 case DrawSwapReadbackResult::DRAW_ABORTED_NO_RENDERER:
1039 // Nothing to do in these cases. External state needs to change first.
brianderson 2014/01/29 01:31:22 I suppose this is one of the few logic changes, bu
1040 break;
1041 case DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS:
1042 needs_redraw_ = true;
1029 1043
1030 // If we're already in the middle of a redraw, we don't need to 1044 // If we're already in the middle of a redraw, we don't need to
1031 // restart it. 1045 // restart it.
1032 if (forced_redraw_state_ != FORCED_REDRAW_STATE_IDLE) 1046 if (forced_redraw_state_ != FORCED_REDRAW_STATE_IDLE)
1033 return; 1047 return;
1034 1048
1035 needs_commit_ = true; 1049 needs_commit_ = true;
1036 consecutive_failed_draws_++; 1050 consecutive_checkerboard_animations_++;
1037 if (settings_.timeout_and_draw_when_animation_checkerboards && 1051 if (settings_.timeout_and_draw_when_animation_checkerboards &&
1038 consecutive_failed_draws_ >= 1052 consecutive_checkerboard_animations_ >=
1039 settings_.maximum_number_of_failed_draws_before_draw_is_forced_) { 1053 settings_.maximum_number_of_failed_draws_before_draw_is_forced_) {
brianderson 2014/01/29 01:31:22 Should we change the name of this setting? Doesn't
1040 consecutive_failed_draws_ = 0; 1054 consecutive_checkerboard_animations_ = 0;
1041 // We need to force a draw, but it doesn't make sense to do this until 1055 // We need to force a draw, but it doesn't make sense to do this until
1042 // we've committed and have new textures. 1056 // we've committed and have new textures.
1043 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_COMMIT; 1057 forced_redraw_state_ = FORCED_REDRAW_STATE_WAITING_FOR_COMMIT;
1044 } 1058 }
1045 } else { 1059 break;
1046 consecutive_failed_draws_ = 0;
1047 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE;
1048 } 1060 }
1049 } 1061 }
1050 1062
1051 void SchedulerStateMachine::SetNeedsCommit() { needs_commit_ = true; } 1063 void SchedulerStateMachine::SetNeedsCommit() { needs_commit_ = true; }
1052 1064
1053 void SchedulerStateMachine::SetNeedsForcedCommitForReadback() { 1065 void SchedulerStateMachine::SetNeedsForcedCommitForReadback() {
1054 // If this is called in READBACK_STATE_IDLE, this is a "first" readback 1066 // If this is called in READBACK_STATE_IDLE, this is a "first" readback
1055 // request. 1067 // request.
1056 // If this is called in READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT, this 1068 // If this is called in READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT, this
1057 // is a back-to-back readback request that started before the replacement 1069 // is a back-to-back readback request that started before the replacement
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 case OUTPUT_SURFACE_ACTIVE: 1141 case OUTPUT_SURFACE_ACTIVE:
1130 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: 1142 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT:
1131 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: 1143 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION:
1132 return true; 1144 return true;
1133 } 1145 }
1134 NOTREACHED(); 1146 NOTREACHED();
1135 return false; 1147 return false;
1136 } 1148 }
1137 1149
1138 } // namespace cc 1150 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698