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

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

Issue 184063002: cc: Change texture locking check point (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add invariant condition of texture acquisition state Created 6 years, 9 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
« no previous file with comments | « no previous file | cc/scheduler/scheduler_state_machine_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const { 296 bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const {
297 // These are all the cases where we normally cannot or do not want to draw 297 // These are all the cases where we normally cannot or do not want to draw
298 // but, if needs_redraw_ is true and we do not draw to make forward progress, 298 // but, if needs_redraw_ is true and we do not draw to make forward progress,
299 // we might deadlock with the main thread. 299 // we might deadlock with the main thread.
300 // This should be a superset of PendingActivationsShouldBeForced() since 300 // This should be a superset of PendingActivationsShouldBeForced() since
301 // activation of the pending tree is blocked by drawing of the active tree and 301 // activation of the pending tree is blocked by drawing of the active tree and
302 // the main thread might be blocked on activation of the most recent commit. 302 // the main thread might be blocked on activation of the most recent commit.
303 if (PendingActivationsShouldBeForced()) 303 if (PendingActivationsShouldBeForced())
304 return true; 304 return true;
305 305
306 // Impl thread should not draw anymore when texture is acquired by main thread
307 // because texture is controlled under main thread.
308 if (texture_state_ == LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD)
309 return true;
310
306 // Additional states where we should abort draws. 311 // Additional states where we should abort draws.
307 // Note: We don't force activation in these cases because doing so would 312 // Note: We don't force activation in these cases because doing so would
308 // result in checkerboarding on resize, becoming visible, etc. 313 // result in checkerboarding on resize, becoming visible, etc.
309 if (!can_draw_) 314 if (!can_draw_)
310 return true; 315 return true;
311 if (!visible_) 316 if (!visible_)
312 return true; 317 return true;
313 return false; 318 return false;
314 } 319 }
315 320
316 bool SchedulerStateMachine::PendingActivationsShouldBeForced() const { 321 bool SchedulerStateMachine::PendingActivationsShouldBeForced() const {
317 // These are all the cases where, if we do not force activations to make 322 // These are all the cases where, if we do not force activations to make
318 // forward progress, we might deadlock with the main thread. 323 // forward progress, we might deadlock with the main thread.
319 324
320 // The impl thread cannot lock layer textures unless the pending
321 // tree can be activated to unblock the commit.
322 if (texture_state_ == LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD)
323 return true;
324
325 // There is no output surface to trigger our activations. 325 // There is no output surface to trigger our activations.
326 if (output_surface_state_ == OUTPUT_SURFACE_LOST) 326 if (output_surface_state_ == OUTPUT_SURFACE_LOST)
327 return true; 327 return true;
328 328
329 return false; 329 return false;
330 } 330 }
331 331
332 bool SchedulerStateMachine::ShouldBeginOutputSurfaceCreation() const { 332 bool SchedulerStateMachine::ShouldBeginOutputSurfaceCreation() const {
333 // Don't try to initialize too early. 333 // Don't try to initialize too early.
334 if (!can_start_) 334 if (!can_start_)
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 if (ShouldBeginOutputSurfaceCreation()) 554 if (ShouldBeginOutputSurfaceCreation())
555 return ACTION_BEGIN_OUTPUT_SURFACE_CREATION; 555 return ACTION_BEGIN_OUTPUT_SURFACE_CREATION;
556 return ACTION_NONE; 556 return ACTION_NONE;
557 } 557 }
558 558
559 void SchedulerStateMachine::CheckInvariants() { 559 void SchedulerStateMachine::CheckInvariants() {
560 // We should never try to perform a draw for readback and forced draw due to 560 // We should never try to perform a draw for readback and forced draw due to
561 // timeout simultaneously. 561 // timeout simultaneously.
562 DCHECK(!(forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW && 562 DCHECK(!(forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW &&
563 readback_state_ == READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK)); 563 readback_state_ == READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK));
564 // Main thread should never have the texture locked when there is a pending
brianderson 2014/03/06 17:56:25 nit: line break above comment.
simonhong 2014/03/06 21:04:48 Done.
565 // tree.
566 if (has_pending_tree_)
brianderson 2014/03/06 17:56:25 Can you change this to: if (has_pending_tree_ || a
simonhong 2014/03/06 21:04:48 Done.
567 DCHECK(texture_state_ != LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD);
564 } 568 }
565 569
566 void SchedulerStateMachine::UpdateState(Action action) { 570 void SchedulerStateMachine::UpdateState(Action action) {
567 switch (action) { 571 switch (action) {
568 case ACTION_NONE: 572 case ACTION_NONE:
569 return; 573 return;
570 574
571 case ACTION_UPDATE_VISIBLE_TILES: 575 case ACTION_UPDATE_VISIBLE_TILES:
572 last_frame_number_update_visible_tiles_was_called_ = 576 last_frame_number_update_visible_tiles_was_called_ =
573 current_frame_number_; 577 current_frame_number_;
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 case OUTPUT_SURFACE_ACTIVE: 1154 case OUTPUT_SURFACE_ACTIVE:
1151 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: 1155 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT:
1152 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: 1156 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION:
1153 return true; 1157 return true;
1154 } 1158 }
1155 NOTREACHED(); 1159 NOTREACHED();
1156 return false; 1160 return false;
1157 } 1161 }
1158 1162
1159 } // namespace cc 1163 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/scheduler/scheduler_state_machine_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698