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

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: Address comments. 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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 base::TimeTicks timebase = std::max(begin_impl_frame_args_.frame_time, 292 base::TimeTicks timebase = std::max(begin_impl_frame_args_.frame_time,
293 begin_impl_frame_args_.deadline); 293 begin_impl_frame_args_.deadline);
294 int64 intervals = 1 + ((now - timebase) / begin_impl_frame_args_.interval); 294 int64 intervals = 1 + ((now - timebase) / begin_impl_frame_args_.interval);
295 return timebase + (begin_impl_frame_args_.interval * intervals); 295 return timebase + (begin_impl_frame_args_.interval * intervals);
296 } 296 }
297 297
298 base::TimeTicks Scheduler::LastBeginImplFrameTime() { 298 base::TimeTicks Scheduler::LastBeginImplFrameTime() {
299 return begin_impl_frame_args_.frame_time; 299 return begin_impl_frame_args_.frame_time;
300 } 300 }
301 301
302 void Scheduler::SetupNextBeginFrameIfNeeded() { 302 void Scheduler::SetNeedsBeginFrameIfNeeded() {
303 if (!task_runner_.get()) 303 // Never call SetNeedsBeginFrames if the frame source already has the right
304 // value.
305 if (frame_source_->NeedsBeginFrames() == state_machine_.BeginFrameNeeded())
304 return; 306 return;
305 307
306 if (state_machine_.ShouldSetNeedsBeginFrames( 308 // Always call SetNeedsBeginFrames(true). Only call SetNeedsBeginFrames(false)
307 frame_source_->NeedsBeginFrames())) { 309 // in between BeginFrames i.e. when begin_impl_frame_state is IDLE.
308 frame_source_->SetNeedsBeginFrames(state_machine_.BeginFrameNeeded()); 310 if (state_machine_.BeginFrameNeeded()) {
309 if (!frame_source_->NeedsBeginFrames()) { 311 frame_source_->SetNeedsBeginFrames(true);
310 client_->SendBeginMainFrameNotExpectedSoon(); 312 } else if (state_machine_.begin_impl_frame_state() ==
311 } 313 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE) {
314 frame_source_->SetNeedsBeginFrames(false);
315 client_->SendBeginMainFrameNotExpectedSoon();
312 } 316 }
313
314 SetupPollingMechanisms();
315 } 317 }
316 318
317 // We may need to poll when we can't rely on BeginFrame to advance certain 319 // We may need to poll when we can't rely on BeginFrame to advance certain
318 // state or to avoid deadlock. 320 // state or to avoid deadlock.
319 void Scheduler::SetupPollingMechanisms() { 321 void Scheduler::SetupPollingMechanisms() {
320 bool needs_advance_commit_state_timer = false; 322 bool needs_advance_commit_state_timer = false;
321 // Setup PollForAnticipatedDrawTriggers if we need to monitor state but 323 // Setup PollForAnticipatedDrawTriggers if we need to monitor state but
322 // aren't expecting any more BeginFrames. This should only be needed by 324 // aren't expecting any more BeginFrames. This should only be needed by
323 // the synchronous compositor when BeginFrameNeeded is false. 325 // the synchronous compositor when BeginFrameNeeded is false.
324 if (state_machine_.ShouldPollForAnticipatedDrawTriggers()) { 326 if (state_machine_.ShouldPollForAnticipatedDrawTriggers()) {
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 client_->ScheduledActionPrepareTiles(); 681 client_->ScheduledActionPrepareTiles();
680 break; 682 break;
681 } 683 }
682 } 684 }
683 } while (action != SchedulerStateMachine::ACTION_NONE); 685 } while (action != SchedulerStateMachine::ACTION_NONE);
684 686
685 // TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is fixed. 687 // TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is fixed.
686 tracked_objects::ScopedTracker tracking_profile10( 688 tracked_objects::ScopedTracker tracking_profile10(
687 FROM_HERE_WITH_EXPLICIT_FUNCTION( 689 FROM_HERE_WITH_EXPLICIT_FUNCTION(
688 "461509 Scheduler::ProcessScheduledActions10")); 690 "461509 Scheduler::ProcessScheduledActions10"));
689 SetupNextBeginFrameIfNeeded(); 691
692 SetupPollingMechanisms();
693
690 client_->DidAnticipatedDrawTimeChange(AnticipatedDrawTime()); 694 client_->DidAnticipatedDrawTimeChange(AnticipatedDrawTime());
691 695
692 // TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is fixed. 696 // TODO(robliao): Remove ScopedTracker below once crbug.com/461509 is fixed.
693 tracked_objects::ScopedTracker tracking_profile11( 697 tracked_objects::ScopedTracker tracking_profile11(
694 FROM_HERE_WITH_EXPLICIT_FUNCTION( 698 FROM_HERE_WITH_EXPLICIT_FUNCTION(
695 "461509 Scheduler::ProcessScheduledActions11")); 699 "461509 Scheduler::ProcessScheduledActions11"));
700
696 RescheduleBeginImplFrameDeadlineIfNeeded(); 701 RescheduleBeginImplFrameDeadlineIfNeeded();
702
703 SetNeedsBeginFrameIfNeeded();
697 } 704 }
698 705
699 scoped_refptr<base::trace_event::ConvertableToTraceFormat> Scheduler::AsValue() 706 scoped_refptr<base::trace_event::ConvertableToTraceFormat> Scheduler::AsValue()
700 const { 707 const {
701 scoped_refptr<base::trace_event::TracedValue> state = 708 scoped_refptr<base::trace_event::TracedValue> state =
702 new base::trace_event::TracedValue(); 709 new base::trace_event::TracedValue();
703 AsValueInto(state.get()); 710 AsValueInto(state.get());
704 return state; 711 return state;
705 } 712 }
706 713
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 } 778 }
772 779
773 bool Scheduler::IsBeginMainFrameSentOrStarted() const { 780 bool Scheduler::IsBeginMainFrameSentOrStarted() const {
774 return (state_machine_.commit_state() == 781 return (state_machine_.commit_state() ==
775 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT || 782 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_SENT ||
776 state_machine_.commit_state() == 783 state_machine_.commit_state() ==
777 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED); 784 SchedulerStateMachine::COMMIT_STATE_BEGIN_MAIN_FRAME_STARTED);
778 } 785 }
779 786
780 } // namespace cc 787 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698