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

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

Issue 227413011: Remove old texture path in TextureLayer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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 texture_state_(LAYER_TEXTURE_STATE_UNLOCKED),
22 forced_redraw_state_(FORCED_REDRAW_STATE_IDLE), 21 forced_redraw_state_(FORCED_REDRAW_STATE_IDLE),
23 readback_state_(READBACK_STATE_IDLE), 22 readback_state_(READBACK_STATE_IDLE),
24 commit_count_(0), 23 commit_count_(0),
25 current_frame_number_(0), 24 current_frame_number_(0),
26 last_frame_number_swap_performed_(-1), 25 last_frame_number_swap_performed_(-1),
27 last_frame_number_begin_main_frame_sent_(-1), 26 last_frame_number_begin_main_frame_sent_(-1),
28 last_frame_number_update_visible_tiles_was_called_(-1), 27 last_frame_number_update_visible_tiles_was_called_(-1),
29 manage_tiles_funnel_(0), 28 manage_tiles_funnel_(0),
30 consecutive_checkerboard_animations_(0), 29 consecutive_checkerboard_animations_(0),
31 needs_redraw_(false), 30 needs_redraw_(false),
32 needs_manage_tiles_(false), 31 needs_manage_tiles_(false),
33 swap_used_incomplete_tile_(false), 32 swap_used_incomplete_tile_(false),
34 needs_commit_(false), 33 needs_commit_(false),
35 main_thread_needs_layer_textures_(false),
36 inside_poll_for_anticipated_draw_triggers_(false), 34 inside_poll_for_anticipated_draw_triggers_(false),
37 visible_(false), 35 visible_(false),
38 can_start_(false), 36 can_start_(false),
39 can_draw_(false), 37 can_draw_(false),
40 has_pending_tree_(false), 38 has_pending_tree_(false),
41 pending_tree_is_ready_for_activation_(false), 39 pending_tree_is_ready_for_activation_(false),
42 active_tree_needs_first_draw_(false), 40 active_tree_needs_first_draw_(false),
43 draw_if_possible_failed_(false), 41 draw_if_possible_failed_(false),
44 did_create_and_initialize_first_output_surface_(false), 42 did_create_and_initialize_first_output_surface_(false),
45 smoothness_takes_priority_(false), 43 smoothness_takes_priority_(false),
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 return "COMMIT_STATE_READY_TO_COMMIT"; 92 return "COMMIT_STATE_READY_TO_COMMIT";
95 case COMMIT_STATE_WAITING_FOR_ACTIVATION: 93 case COMMIT_STATE_WAITING_FOR_ACTIVATION:
96 return "COMMIT_STATE_WAITING_FOR_ACTIVATION"; 94 return "COMMIT_STATE_WAITING_FOR_ACTIVATION";
97 case COMMIT_STATE_WAITING_FOR_FIRST_DRAW: 95 case COMMIT_STATE_WAITING_FOR_FIRST_DRAW:
98 return "COMMIT_STATE_WAITING_FOR_FIRST_DRAW"; 96 return "COMMIT_STATE_WAITING_FOR_FIRST_DRAW";
99 } 97 }
100 NOTREACHED(); 98 NOTREACHED();
101 return "???"; 99 return "???";
102 } 100 }
103 101
104 const char* SchedulerStateMachine::TextureStateToString(TextureState state) {
105 switch (state) {
106 case LAYER_TEXTURE_STATE_UNLOCKED:
107 return "LAYER_TEXTURE_STATE_UNLOCKED";
108 case LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD:
109 return "LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD";
110 case LAYER_TEXTURE_STATE_ACQUIRED_BY_IMPL_THREAD:
111 return "LAYER_TEXTURE_STATE_ACQUIRED_BY_IMPL_THREAD";
112 }
113 NOTREACHED();
114 return "???";
115 }
116
117 const char* SchedulerStateMachine::SynchronousReadbackStateToString( 102 const char* SchedulerStateMachine::SynchronousReadbackStateToString(
118 SynchronousReadbackState state) { 103 SynchronousReadbackState state) {
119 switch (state) { 104 switch (state) {
120 case READBACK_STATE_IDLE: 105 case READBACK_STATE_IDLE:
121 return "READBACK_STATE_IDLE"; 106 return "READBACK_STATE_IDLE";
122 case READBACK_STATE_NEEDS_BEGIN_MAIN_FRAME: 107 case READBACK_STATE_NEEDS_BEGIN_MAIN_FRAME:
123 return "READBACK_STATE_NEEDS_BEGIN_MAIN_FRAME"; 108 return "READBACK_STATE_NEEDS_BEGIN_MAIN_FRAME";
124 case READBACK_STATE_WAITING_FOR_COMMIT: 109 case READBACK_STATE_WAITING_FOR_COMMIT:
125 return "READBACK_STATE_WAITING_FOR_COMMIT"; 110 return "READBACK_STATE_WAITING_FOR_COMMIT";
126 case READBACK_STATE_WAITING_FOR_ACTIVATION: 111 case READBACK_STATE_WAITING_FOR_ACTIVATION:
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 case ACTION_DRAW_AND_SWAP_IF_POSSIBLE: 152 case ACTION_DRAW_AND_SWAP_IF_POSSIBLE:
168 return "ACTION_DRAW_AND_SWAP_IF_POSSIBLE"; 153 return "ACTION_DRAW_AND_SWAP_IF_POSSIBLE";
169 case ACTION_DRAW_AND_SWAP_FORCED: 154 case ACTION_DRAW_AND_SWAP_FORCED:
170 return "ACTION_DRAW_AND_SWAP_FORCED"; 155 return "ACTION_DRAW_AND_SWAP_FORCED";
171 case ACTION_DRAW_AND_SWAP_ABORT: 156 case ACTION_DRAW_AND_SWAP_ABORT:
172 return "ACTION_DRAW_AND_SWAP_ABORT"; 157 return "ACTION_DRAW_AND_SWAP_ABORT";
173 case ACTION_DRAW_AND_READBACK: 158 case ACTION_DRAW_AND_READBACK:
174 return "ACTION_DRAW_AND_READBACK"; 159 return "ACTION_DRAW_AND_READBACK";
175 case ACTION_BEGIN_OUTPUT_SURFACE_CREATION: 160 case ACTION_BEGIN_OUTPUT_SURFACE_CREATION:
176 return "ACTION_BEGIN_OUTPUT_SURFACE_CREATION"; 161 return "ACTION_BEGIN_OUTPUT_SURFACE_CREATION";
177 case ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD:
178 return "ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD";
179 case ACTION_MANAGE_TILES: 162 case ACTION_MANAGE_TILES:
180 return "ACTION_MANAGE_TILES"; 163 return "ACTION_MANAGE_TILES";
181 } 164 }
182 NOTREACHED(); 165 NOTREACHED();
183 return "???"; 166 return "???";
184 } 167 }
185 168
186 scoped_ptr<base::Value> SchedulerStateMachine::AsValue() const { 169 scoped_ptr<base::Value> SchedulerStateMachine::AsValue() const {
187 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue); 170 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue);
188 171
189 scoped_ptr<base::DictionaryValue> major_state(new base::DictionaryValue); 172 scoped_ptr<base::DictionaryValue> major_state(new base::DictionaryValue);
190 major_state->SetString("next_action", ActionToString(NextAction())); 173 major_state->SetString("next_action", ActionToString(NextAction()));
191 major_state->SetString("begin_impl_frame_state", 174 major_state->SetString("begin_impl_frame_state",
192 BeginImplFrameStateToString(begin_impl_frame_state_)); 175 BeginImplFrameStateToString(begin_impl_frame_state_));
193 major_state->SetString("commit_state", CommitStateToString(commit_state_)); 176 major_state->SetString("commit_state", CommitStateToString(commit_state_));
194 major_state->SetString("texture_state_",
195 TextureStateToString(texture_state_));
196 major_state->SetString("output_surface_state_", 177 major_state->SetString("output_surface_state_",
197 OutputSurfaceStateToString(output_surface_state_)); 178 OutputSurfaceStateToString(output_surface_state_));
198 major_state->SetString( 179 major_state->SetString(
199 "forced_redraw_state", 180 "forced_redraw_state",
200 ForcedRedrawOnTimeoutStateToString(forced_redraw_state_)); 181 ForcedRedrawOnTimeoutStateToString(forced_redraw_state_));
201 major_state->SetString("readback_state", 182 major_state->SetString("readback_state",
202 SynchronousReadbackStateToString(readback_state_)); 183 SynchronousReadbackStateToString(readback_state_));
203 state->Set("major_state", major_state.release()); 184 state->Set("major_state", major_state.release());
204 185
205 scoped_ptr<base::DictionaryValue> timestamps_state(new base::DictionaryValue); 186 scoped_ptr<base::DictionaryValue> timestamps_state(new base::DictionaryValue);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 last_frame_number_update_visible_tiles_was_called_); 228 last_frame_number_update_visible_tiles_was_called_);
248 229
249 minor_state->SetInteger("manage_tiles_funnel", manage_tiles_funnel_); 230 minor_state->SetInteger("manage_tiles_funnel", manage_tiles_funnel_);
250 minor_state->SetInteger("consecutive_checkerboard_animations", 231 minor_state->SetInteger("consecutive_checkerboard_animations",
251 consecutive_checkerboard_animations_); 232 consecutive_checkerboard_animations_);
252 minor_state->SetBoolean("needs_redraw", needs_redraw_); 233 minor_state->SetBoolean("needs_redraw", needs_redraw_);
253 minor_state->SetBoolean("needs_manage_tiles", needs_manage_tiles_); 234 minor_state->SetBoolean("needs_manage_tiles", needs_manage_tiles_);
254 minor_state->SetBoolean("swap_used_incomplete_tile", 235 minor_state->SetBoolean("swap_used_incomplete_tile",
255 swap_used_incomplete_tile_); 236 swap_used_incomplete_tile_);
256 minor_state->SetBoolean("needs_commit", needs_commit_); 237 minor_state->SetBoolean("needs_commit", needs_commit_);
257 minor_state->SetBoolean("main_thread_needs_layer_textures",
258 main_thread_needs_layer_textures_);
259 minor_state->SetBoolean("visible", visible_); 238 minor_state->SetBoolean("visible", visible_);
260 minor_state->SetBoolean("can_start", can_start_); 239 minor_state->SetBoolean("can_start", can_start_);
261 minor_state->SetBoolean("can_draw", can_draw_); 240 minor_state->SetBoolean("can_draw", can_draw_);
262 minor_state->SetBoolean("has_pending_tree", has_pending_tree_); 241 minor_state->SetBoolean("has_pending_tree", has_pending_tree_);
263 minor_state->SetBoolean("pending_tree_is_ready_for_activation", 242 minor_state->SetBoolean("pending_tree_is_ready_for_activation",
264 pending_tree_is_ready_for_activation_); 243 pending_tree_is_ready_for_activation_);
265 minor_state->SetBoolean("active_tree_needs_first_draw", 244 minor_state->SetBoolean("active_tree_needs_first_draw",
266 active_tree_needs_first_draw_); 245 active_tree_needs_first_draw_);
267 minor_state->SetBoolean("draw_if_possible_failed", draw_if_possible_failed_); 246 minor_state->SetBoolean("draw_if_possible_failed", draw_if_possible_failed_);
268 minor_state->SetBoolean("did_create_and_initialize_first_output_surface", 247 minor_state->SetBoolean("did_create_and_initialize_first_output_surface",
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const { 289 bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const {
311 // These are all the cases where we normally cannot or do not want to draw 290 // These are all the cases where we normally cannot or do not want to draw
312 // but, if needs_redraw_ is true and we do not draw to make forward progress, 291 // but, if needs_redraw_ is true and we do not draw to make forward progress,
313 // we might deadlock with the main thread. 292 // we might deadlock with the main thread.
314 // This should be a superset of PendingActivationsShouldBeForced() since 293 // This should be a superset of PendingActivationsShouldBeForced() since
315 // activation of the pending tree is blocked by drawing of the active tree and 294 // activation of the pending tree is blocked by drawing of the active tree and
316 // the main thread might be blocked on activation of the most recent commit. 295 // the main thread might be blocked on activation of the most recent commit.
317 if (PendingActivationsShouldBeForced()) 296 if (PendingActivationsShouldBeForced())
318 return true; 297 return true;
319 298
320 // Impl thread should not draw anymore when texture is acquired by main thread
321 // because texture is controlled under main thread.
322 if (texture_state_ == LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD)
323 return true;
324
325 // Additional states where we should abort draws. 299 // Additional states where we should abort draws.
326 // Note: We don't force activation in these cases because doing so would 300 // Note: We don't force activation in these cases because doing so would
327 // result in checkerboarding on resize, becoming visible, etc. 301 // result in checkerboarding on resize, becoming visible, etc.
328 if (!can_draw_) 302 if (!can_draw_)
329 return true; 303 return true;
330 if (!visible_) 304 if (!visible_)
331 return true; 305 return true;
332 return false; 306 return false;
333 } 307 }
334 308
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE) 373 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE)
400 return false; 374 return false;
401 375
402 // Only handle forced redraws due to timeouts on the regular deadline. 376 // Only handle forced redraws due to timeouts on the regular deadline.
403 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) 377 if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW)
404 return true; 378 return true;
405 379
406 return needs_redraw_; 380 return needs_redraw_;
407 } 381 }
408 382
409 bool SchedulerStateMachine::ShouldAcquireLayerTexturesForMainThread() const {
410 if (!main_thread_needs_layer_textures_)
411 return false;
412 if (texture_state_ == LAYER_TEXTURE_STATE_UNLOCKED)
413 return true;
414 DCHECK_EQ(texture_state_, LAYER_TEXTURE_STATE_ACQUIRED_BY_IMPL_THREAD);
415 return false;
416 }
417
418 bool SchedulerStateMachine::ShouldActivatePendingTree() const { 383 bool SchedulerStateMachine::ShouldActivatePendingTree() const {
419 // There is nothing to activate. 384 // There is nothing to activate.
420 if (!has_pending_tree_) 385 if (!has_pending_tree_)
421 return false; 386 return false;
422 387
423 // We should not activate a second tree before drawing the first one. 388 // We should not activate a second tree before drawing the first one.
424 // Even if we need to force activation of the pending tree, we should abort 389 // Even if we need to force activation of the pending tree, we should abort
425 // drawing the active tree first. 390 // drawing the active tree first.
426 if (active_tree_needs_first_draw_) 391 if (active_tree_needs_first_draw_)
427 return false; 392 return false;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 // Limiting to once per-frame is not enough, since we only want to 509 // Limiting to once per-frame is not enough, since we only want to
545 // manage tiles _after_ draws. Polling for draw triggers and 510 // manage tiles _after_ draws. Polling for draw triggers and
546 // begin-frame are mutually exclusive, so we limit to these two cases. 511 // begin-frame are mutually exclusive, so we limit to these two cases.
547 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE && 512 if (begin_impl_frame_state_ != BEGIN_IMPL_FRAME_STATE_INSIDE_DEADLINE &&
548 !inside_poll_for_anticipated_draw_triggers_) 513 !inside_poll_for_anticipated_draw_triggers_)
549 return false; 514 return false;
550 return needs_manage_tiles_; 515 return needs_manage_tiles_;
551 } 516 }
552 517
553 SchedulerStateMachine::Action SchedulerStateMachine::NextAction() const { 518 SchedulerStateMachine::Action SchedulerStateMachine::NextAction() const {
554 if (ShouldAcquireLayerTexturesForMainThread())
555 return ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD;
556 if (ShouldUpdateVisibleTiles()) 519 if (ShouldUpdateVisibleTiles())
557 return ACTION_UPDATE_VISIBLE_TILES; 520 return ACTION_UPDATE_VISIBLE_TILES;
558 if (ShouldActivatePendingTree()) 521 if (ShouldActivatePendingTree())
559 return ACTION_ACTIVATE_PENDING_TREE; 522 return ACTION_ACTIVATE_PENDING_TREE;
560 if (ShouldCommit()) 523 if (ShouldCommit())
561 return ACTION_COMMIT; 524 return ACTION_COMMIT;
562 if (ShouldDraw()) { 525 if (ShouldDraw()) {
563 if (readback_state_ == READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK) 526 if (readback_state_ == READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK)
564 return ACTION_DRAW_AND_READBACK; 527 return ACTION_DRAW_AND_READBACK;
565 else if (PendingDrawsShouldBeAborted()) 528 else if (PendingDrawsShouldBeAborted())
(...skipping 10 matching lines...) Expand all
576 if (ShouldBeginOutputSurfaceCreation()) 539 if (ShouldBeginOutputSurfaceCreation())
577 return ACTION_BEGIN_OUTPUT_SURFACE_CREATION; 540 return ACTION_BEGIN_OUTPUT_SURFACE_CREATION;
578 return ACTION_NONE; 541 return ACTION_NONE;
579 } 542 }
580 543
581 void SchedulerStateMachine::CheckInvariants() { 544 void SchedulerStateMachine::CheckInvariants() {
582 // We should never try to perform a draw for readback and forced draw due to 545 // We should never try to perform a draw for readback and forced draw due to
583 // timeout simultaneously. 546 // timeout simultaneously.
584 DCHECK(!(forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW && 547 DCHECK(!(forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW &&
585 readback_state_ == READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK)); 548 readback_state_ == READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK));
586
587 // Main thread should never have the texture locked when there is a pending
588 // tree or active tree is not drawn for the first time.
589 if (has_pending_tree_ || active_tree_needs_first_draw_)
590 DCHECK(texture_state_ != LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD);
591 } 549 }
592 550
593 void SchedulerStateMachine::UpdateState(Action action) { 551 void SchedulerStateMachine::UpdateState(Action action) {
594 switch (action) { 552 switch (action) {
595 case ACTION_NONE: 553 case ACTION_NONE:
596 return; 554 return;
597 555
598 case ACTION_UPDATE_VISIBLE_TILES: 556 case ACTION_UPDATE_VISIBLE_TILES:
599 last_frame_number_update_visible_tiles_was_called_ = 557 last_frame_number_update_visible_tiles_was_called_ =
600 current_frame_number_; 558 current_frame_number_;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 output_surface_state_ = OUTPUT_SURFACE_CREATING; 602 output_surface_state_ = OUTPUT_SURFACE_CREATING;
645 603
646 // The following DCHECKs make sure we are in the proper quiescent state. 604 // The following DCHECKs make sure we are in the proper quiescent state.
647 // The pipeline should be flushed entirely before we start output 605 // The pipeline should be flushed entirely before we start output
648 // surface creation to avoid complicated corner cases. 606 // surface creation to avoid complicated corner cases.
649 DCHECK_EQ(commit_state_, COMMIT_STATE_IDLE); 607 DCHECK_EQ(commit_state_, COMMIT_STATE_IDLE);
650 DCHECK(!has_pending_tree_); 608 DCHECK(!has_pending_tree_);
651 DCHECK(!active_tree_needs_first_draw_); 609 DCHECK(!active_tree_needs_first_draw_);
652 return; 610 return;
653 611
654 case ACTION_ACQUIRE_LAYER_TEXTURES_FOR_MAIN_THREAD:
655 texture_state_ = LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD;
656 main_thread_needs_layer_textures_ = false;
657 return;
658
659 case ACTION_MANAGE_TILES: 612 case ACTION_MANAGE_TILES:
660 UpdateStateOnManageTiles(); 613 UpdateStateOnManageTiles();
661 return; 614 return;
662 } 615 }
663 } 616 }
664 617
665 void SchedulerStateMachine::UpdateStateOnCommit(bool commit_was_aborted) { 618 void SchedulerStateMachine::UpdateStateOnCommit(bool commit_was_aborted) {
666 commit_count_++; 619 commit_count_++;
667 620
668 if (commit_was_aborted || settings_.main_frame_before_activation_enabled) { 621 if (commit_was_aborted || settings_.main_frame_before_activation_enabled) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 needs_redraw_ = true; 682 needs_redraw_ = true;
730 active_tree_needs_first_draw_ = true; 683 active_tree_needs_first_draw_ = true;
731 } 684 }
732 685
733 // This post-commit work is common to both completed and aborted commits. 686 // This post-commit work is common to both completed and aborted commits.
734 pending_tree_is_ready_for_activation_ = false; 687 pending_tree_is_ready_for_activation_ = false;
735 688
736 if (draw_if_possible_failed_) 689 if (draw_if_possible_failed_)
737 last_frame_number_swap_performed_ = -1; 690 last_frame_number_swap_performed_ = -1;
738 691
739 // If we are planing to draw with the new commit, lock the layer textures for
740 // use on the impl thread. Otherwise, leave them unlocked.
741 if (has_pending_tree_ || needs_redraw_)
742 texture_state_ = LAYER_TEXTURE_STATE_ACQUIRED_BY_IMPL_THREAD;
743 else
744 texture_state_ = LAYER_TEXTURE_STATE_UNLOCKED;
745
746 if (continuous_painting_) 692 if (continuous_painting_)
747 needs_commit_ = true; 693 needs_commit_ = true;
748 } 694 }
749 695
750 void SchedulerStateMachine::UpdateStateOnActivation() { 696 void SchedulerStateMachine::UpdateStateOnActivation() {
751 if (commit_state_ == COMMIT_STATE_WAITING_FOR_ACTIVATION) 697 if (commit_state_ == COMMIT_STATE_WAITING_FOR_ACTIVATION)
752 commit_state_ = COMMIT_STATE_IDLE; 698 commit_state_ = COMMIT_STATE_IDLE;
753 699
754 if (output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION) 700 if (output_surface_state_ == OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION)
755 output_surface_state_ = OUTPUT_SURFACE_ACTIVE; 701 output_surface_state_ = OUTPUT_SURFACE_ACTIVE;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 // pending BeginMainFrame behind the readback request. 744 // pending BeginMainFrame behind the readback request.
799 commit_state_ = COMMIT_STATE_BEGIN_MAIN_FRAME_SENT; 745 commit_state_ = COMMIT_STATE_BEGIN_MAIN_FRAME_SENT;
800 readback_state_ = READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT; 746 readback_state_ = READBACK_STATE_WAITING_FOR_REPLACEMENT_COMMIT;
801 } else if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) { 747 } else if (forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW) {
802 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE; 748 forced_redraw_state_ = FORCED_REDRAW_STATE_IDLE;
803 } 749 }
804 750
805 if (commit_state_ == COMMIT_STATE_WAITING_FOR_FIRST_DRAW) 751 if (commit_state_ == COMMIT_STATE_WAITING_FOR_FIRST_DRAW)
806 commit_state_ = COMMIT_STATE_IDLE; 752 commit_state_ = COMMIT_STATE_IDLE;
807 753
808 if (texture_state_ == LAYER_TEXTURE_STATE_ACQUIRED_BY_IMPL_THREAD)
809 texture_state_ = LAYER_TEXTURE_STATE_UNLOCKED;
810
811 needs_redraw_ = false; 754 needs_redraw_ = false;
812 draw_if_possible_failed_ = false; 755 draw_if_possible_failed_ = false;
813 active_tree_needs_first_draw_ = false; 756 active_tree_needs_first_draw_ = false;
814 757
815 if (did_swap) 758 if (did_swap)
816 last_frame_number_swap_performed_ = current_frame_number_; 759 last_frame_number_swap_performed_ = current_frame_number_;
817 } 760 }
818 761
819 void SchedulerStateMachine::UpdateStateOnManageTiles() { 762 void SchedulerStateMachine::UpdateStateOnManageTiles() {
820 needs_manage_tiles_ = false; 763 needs_manage_tiles_ = false;
821 } 764 }
822 765
823 void SchedulerStateMachine::SetMainThreadNeedsLayerTextures() {
824 DCHECK(!main_thread_needs_layer_textures_);
825 DCHECK_NE(texture_state_, LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD);
826 main_thread_needs_layer_textures_ = true;
827 }
828
829 void SchedulerStateMachine::SetSkipNextBeginMainFrameToReduceLatency() { 766 void SchedulerStateMachine::SetSkipNextBeginMainFrameToReduceLatency() {
830 skip_next_begin_main_frame_to_reduce_latency_ = true; 767 skip_next_begin_main_frame_to_reduce_latency_ = true;
831 } 768 }
832 769
833 bool SchedulerStateMachine::BeginImplFrameNeeded() const { 770 bool SchedulerStateMachine::BeginImplFrameNeeded() const {
834 // Proactive BeginImplFrames are bad for the synchronous compositor because we 771 // Proactive BeginImplFrames are bad for the synchronous compositor because we
835 // have to draw when we get the BeginImplFrame and could end up drawing many 772 // have to draw when we get the BeginImplFrame and could end up drawing many
836 // duplicate frames if our new frame isn't ready in time. 773 // duplicate frames if our new frame isn't ready in time.
837 // To poll for state with the synchronous compositor without having to draw, 774 // To poll for state with the synchronous compositor without having to draw,
838 // we rely on ShouldPollForAnticipatedDrawTriggers instead. 775 // we rely on ShouldPollForAnticipatedDrawTriggers instead.
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 case OUTPUT_SURFACE_ACTIVE: 1159 case OUTPUT_SURFACE_ACTIVE:
1223 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: 1160 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT:
1224 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: 1161 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION:
1225 return true; 1162 return true;
1226 } 1163 }
1227 NOTREACHED(); 1164 NOTREACHED();
1228 return false; 1165 return false;
1229 } 1166 }
1230 1167
1231 } // namespace cc 1168 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler_state_machine.h ('k') | cc/scheduler/scheduler_state_machine_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698