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

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: Modify invariant condition 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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const { 303 bool SchedulerStateMachine::PendingDrawsShouldBeAborted() const {
304 // These are all the cases where we normally cannot or do not want to draw 304 // These are all the cases where we normally cannot or do not want to draw
305 // but, if needs_redraw_ is true and we do not draw to make forward progress, 305 // but, if needs_redraw_ is true and we do not draw to make forward progress,
306 // we might deadlock with the main thread. 306 // we might deadlock with the main thread.
307 // This should be a superset of PendingActivationsShouldBeForced() since 307 // This should be a superset of PendingActivationsShouldBeForced() since
308 // activation of the pending tree is blocked by drawing of the active tree and 308 // activation of the pending tree is blocked by drawing of the active tree and
309 // the main thread might be blocked on activation of the most recent commit. 309 // the main thread might be blocked on activation of the most recent commit.
310 if (PendingActivationsShouldBeForced()) 310 if (PendingActivationsShouldBeForced())
311 return true; 311 return true;
312 312
313 // Impl thread should not draw anymore when texture is acquired by main thread
314 // because texture is controlled under main thread.
315 if (texture_state_ == LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD)
316 return true;
317
313 // Additional states where we should abort draws. 318 // Additional states where we should abort draws.
314 // Note: We don't force activation in these cases because doing so would 319 // Note: We don't force activation in these cases because doing so would
315 // result in checkerboarding on resize, becoming visible, etc. 320 // result in checkerboarding on resize, becoming visible, etc.
316 if (!can_draw_) 321 if (!can_draw_)
317 return true; 322 return true;
318 if (!visible_) 323 if (!visible_)
319 return true; 324 return true;
320 return false; 325 return false;
321 } 326 }
322 327
323 bool SchedulerStateMachine::PendingActivationsShouldBeForced() const { 328 bool SchedulerStateMachine::PendingActivationsShouldBeForced() const {
324 // These are all the cases where, if we do not force activations to make 329 // These are all the cases where, if we do not force activations to make
325 // forward progress, we might deadlock with the main thread. 330 // forward progress, we might deadlock with the main thread.
326 331
327 // The impl thread cannot lock layer textures unless the pending
328 // tree can be activated to unblock the commit.
329 if (texture_state_ == LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD)
330 return true;
331
332 // There is no output surface to trigger our activations. 332 // There is no output surface to trigger our activations.
333 if (output_surface_state_ == OUTPUT_SURFACE_LOST) 333 if (output_surface_state_ == OUTPUT_SURFACE_LOST)
334 return true; 334 return true;
335 335
336 return false; 336 return false;
337 } 337 }
338 338
339 bool SchedulerStateMachine::ShouldBeginOutputSurfaceCreation() const { 339 bool SchedulerStateMachine::ShouldBeginOutputSurfaceCreation() const {
340 // Don't try to initialize too early. 340 // Don't try to initialize too early.
341 if (!can_start_) 341 if (!can_start_)
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 if (ShouldBeginOutputSurfaceCreation()) 561 if (ShouldBeginOutputSurfaceCreation())
562 return ACTION_BEGIN_OUTPUT_SURFACE_CREATION; 562 return ACTION_BEGIN_OUTPUT_SURFACE_CREATION;
563 return ACTION_NONE; 563 return ACTION_NONE;
564 } 564 }
565 565
566 void SchedulerStateMachine::CheckInvariants() { 566 void SchedulerStateMachine::CheckInvariants() {
567 // We should never try to perform a draw for readback and forced draw due to 567 // We should never try to perform a draw for readback and forced draw due to
568 // timeout simultaneously. 568 // timeout simultaneously.
569 DCHECK(!(forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW && 569 DCHECK(!(forced_redraw_state_ == FORCED_REDRAW_STATE_WAITING_FOR_DRAW &&
570 readback_state_ == READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK)); 570 readback_state_ == READBACK_STATE_WAITING_FOR_DRAW_AND_READBACK));
571
572 // Main thread should never have the texture locked when there is a pending
573 // tree or active tree is not drawn for the first time.
574 if (has_pending_tree_ || active_tree_needs_first_draw_)
575 DCHECK(texture_state_ != LAYER_TEXTURE_STATE_ACQUIRED_BY_MAIN_THREAD);
571 } 576 }
572 577
573 void SchedulerStateMachine::UpdateState(Action action) { 578 void SchedulerStateMachine::UpdateState(Action action) {
574 switch (action) { 579 switch (action) {
575 case ACTION_NONE: 580 case ACTION_NONE:
576 return; 581 return;
577 582
578 case ACTION_UPDATE_VISIBLE_TILES: 583 case ACTION_UPDATE_VISIBLE_TILES:
579 last_frame_number_update_visible_tiles_was_called_ = 584 last_frame_number_update_visible_tiles_was_called_ =
580 current_frame_number_; 585 current_frame_number_;
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 case OUTPUT_SURFACE_ACTIVE: 1162 case OUTPUT_SURFACE_ACTIVE:
1158 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT: 1163 case OUTPUT_SURFACE_WAITING_FOR_FIRST_COMMIT:
1159 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION: 1164 case OUTPUT_SURFACE_WAITING_FOR_FIRST_ACTIVATION:
1160 return true; 1165 return true;
1161 } 1166 }
1162 NOTREACHED(); 1167 NOTREACHED();
1163 return false; 1168 return false;
1164 } 1169 }
1165 1170
1166 } // namespace cc 1171 } // 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