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

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

Issue 987563002: cc: Simplify SetNeedsBeginFrames code in scheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_retro_frame
Patch Set: Created 5 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
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.h" 5 #include "cc/scheduler/scheduler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 base::TimeTicks timebase = std::max(begin_impl_frame_args_.frame_time, 318 base::TimeTicks timebase = std::max(begin_impl_frame_args_.frame_time,
319 begin_impl_frame_args_.deadline); 319 begin_impl_frame_args_.deadline);
320 int64 intervals = 1 + ((now - timebase) / begin_impl_frame_args_.interval); 320 int64 intervals = 1 + ((now - timebase) / begin_impl_frame_args_.interval);
321 return timebase + (begin_impl_frame_args_.interval * intervals); 321 return timebase + (begin_impl_frame_args_.interval * intervals);
322 } 322 }
323 323
324 base::TimeTicks Scheduler::LastBeginImplFrameTime() { 324 base::TimeTicks Scheduler::LastBeginImplFrameTime() {
325 return begin_impl_frame_args_.frame_time; 325 return begin_impl_frame_args_.frame_time;
326 } 326 }
327 327
328 void Scheduler::SetupNextBeginFrameIfNeeded() { 328 void Scheduler::SetNeedsBeginFrameIfNeeded() {
329 if (!task_runner_.get()) 329 // Never call SetNeedsBeginFrames if the frame source already has the right
330 // value.
331 if (frame_source_->NeedsBeginFrames() == state_machine_.BeginFrameNeeded())
330 return; 332 return;
331 333
332 if (state_machine_.ShouldSetNeedsBeginFrames( 334 // Always call SetNeedsBeginFrames(true). Only call SetNeedsBeginFrames(false)
333 frame_source_->NeedsBeginFrames())) { 335 // in between BeginFrames i.e. when begin_impl_frame_state is IDLE.
334 frame_source_->SetNeedsBeginFrames(state_machine_.BeginFrameNeeded()); 336 if (state_machine_.BeginFrameNeeded()) {
335 if (!frame_source_->NeedsBeginFrames()) { 337 frame_source_->SetNeedsBeginFrames(true);
336 client_->SendBeginMainFrameNotExpectedSoon(); 338 } else if (state_machine_.begin_impl_frame_state() ==
337 } 339 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE) {
340 frame_source_->SetNeedsBeginFrames(false);
341 client_->SendBeginMainFrameNotExpectedSoon();
338 } 342 }
339
340 SetupPollingMechanisms();
341 } 343 }
342 344
343 // We may need to poll when we can't rely on BeginFrame to advance certain 345 // We may need to poll when we can't rely on BeginFrame to advance certain
344 // state or to avoid deadlock. 346 // state or to avoid deadlock.
345 void Scheduler::SetupPollingMechanisms() { 347 void Scheduler::SetupPollingMechanisms() {
346 bool needs_advance_commit_state_timer = false; 348 bool needs_advance_commit_state_timer = false;
347 // Setup PollForAnticipatedDrawTriggers if we need to monitor state but 349 // Setup PollForAnticipatedDrawTriggers if we need to monitor state but
348 // aren't expecting any more BeginFrames. This should only be needed by 350 // aren't expecting any more BeginFrames. This should only be needed by
349 // the synchronous compositor when BeginFrameNeeded is false. 351 // the synchronous compositor when BeginFrameNeeded is false.
350 if (state_machine_.ShouldPollForAnticipatedDrawTriggers()) { 352 if (state_machine_.ShouldPollForAnticipatedDrawTriggers()) {
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 client_->ScheduledActionPrepareTiles(); 710 client_->ScheduledActionPrepareTiles();
709 break; 711 break;
710 } 712 }
711 } 713 }
712 } while (action != SchedulerStateMachine::ACTION_NONE); 714 } while (action != SchedulerStateMachine::ACTION_NONE);
713 715
714 // TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is fixed. 716 // TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is fixed.
715 tracked_objects::ScopedTracker tracking_profile10( 717 tracked_objects::ScopedTracker tracking_profile10(
716 FROM_HERE_WITH_EXPLICIT_FUNCTION( 718 FROM_HERE_WITH_EXPLICIT_FUNCTION(
717 "461509 Scheduler::ProcessScheduledActions10")); 719 "461509 Scheduler::ProcessScheduledActions10"));
718 SetupNextBeginFrameIfNeeded(); 720
721 SetupPollingMechanisms();
722
719 client_->DidAnticipatedDrawTimeChange(AnticipatedDrawTime()); 723 client_->DidAnticipatedDrawTimeChange(AnticipatedDrawTime());
720 724
721 // TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is fixed. 725 // TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is fixed.
722 tracked_objects::ScopedTracker tracking_profile11( 726 tracked_objects::ScopedTracker tracking_profile11(
723 FROM_HERE_WITH_EXPLICIT_FUNCTION( 727 FROM_HERE_WITH_EXPLICIT_FUNCTION(
724 "461509 Scheduler::ProcessScheduledActions11")); 728 "461509 Scheduler::ProcessScheduledActions11"));
729
725 RescheduleBeginImplFrameDeadlineIfNeeded(); 730 RescheduleBeginImplFrameDeadlineIfNeeded();
731
732 SetNeedsBeginFrameIfNeeded();
726 } 733 }
727 734
728 scoped_refptr<base::trace_event::ConvertableToTraceFormat> Scheduler::AsValue() 735 scoped_refptr<base::trace_event::ConvertableToTraceFormat> Scheduler::AsValue()
729 const { 736 const {
730 scoped_refptr<base::trace_event::TracedValue> state = 737 scoped_refptr<base::trace_event::TracedValue> state =
731 new base::trace_event::TracedValue(); 738 new base::trace_event::TracedValue();
732 AsValueInto(state.get()); 739 AsValueInto(state.get());
733 return state; 740 return state;
734 } 741 }
735 742
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 } 807 }
801 808
802 bool Scheduler::IsBeginMainFrameSentOrStarted() const { 809 bool Scheduler::IsBeginMainFrameSentOrStarted() const {
803 return (state_machine_.commit_state() == 810 return (state_machine_.commit_state() ==
804 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || 811 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT ||
805 state_machine_.commit_state() == 812 state_machine_.commit_state() ==
806 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); 813 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED);
807 } 814 }
808 815
809 } // namespace cc 816 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698