| OLD | NEW |
| 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 #include "base/auto_reset.h" | 8 #include "base/auto_reset.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 } | 177 } |
| 178 | 178 |
| 179 void Scheduler::BeginImplFrame(const BeginFrameArgs& args) { | 179 void Scheduler::BeginImplFrame(const BeginFrameArgs& args) { |
| 180 TRACE_EVENT0("cc", "Scheduler::BeginImplFrame"); | 180 TRACE_EVENT0("cc", "Scheduler::BeginImplFrame"); |
| 181 DCHECK(state_machine_.begin_impl_frame_state() == | 181 DCHECK(state_machine_.begin_impl_frame_state() == |
| 182 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); | 182 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); |
| 183 DCHECK(state_machine_.HasInitializedOutputSurface()); | 183 DCHECK(state_machine_.HasInitializedOutputSurface()); |
| 184 last_begin_impl_frame_args_ = args; | 184 last_begin_impl_frame_args_ = args; |
| 185 last_begin_impl_frame_args_.deadline -= client_->DrawDurationEstimate(); | 185 last_begin_impl_frame_args_.deadline -= client_->DrawDurationEstimate(); |
| 186 state_machine_.OnBeginImplFrame(last_begin_impl_frame_args_); | 186 state_machine_.OnBeginImplFrame(last_begin_impl_frame_args_); |
| 187 |
| 188 if (settings_.switch_to_low_latency_if_possible) { |
| 189 state_machine_.SetSkipBeginMainFrameToReduceLatency( |
| 190 state_machine_.MainThreadIsInHighLatencyMode() && |
| 191 CanPaintAndCommitBeforeDeadline()); |
| 192 } |
| 193 |
| 187 ProcessScheduledActions(); | 194 ProcessScheduledActions(); |
| 188 | 195 |
| 189 if (!state_machine_.HasInitializedOutputSurface()) | 196 if (!state_machine_.HasInitializedOutputSurface()) |
| 190 return; | 197 return; |
| 191 | 198 |
| 192 state_machine_.OnBeginImplFrameDeadlinePending(); | 199 state_machine_.OnBeginImplFrameDeadlinePending(); |
| 193 | 200 |
| 194 if (settings_.using_synchronous_renderer_compositor) { | 201 if (settings_.using_synchronous_renderer_compositor) { |
| 195 // The synchronous renderer compositor has to make its GL calls | 202 // The synchronous renderer compositor has to make its GL calls |
| 196 // within this call to BeginImplFrame. | 203 // within this call to BeginImplFrame. |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 client_->DidAnticipatedDrawTimeChange(AnticipatedDrawTime()); | 344 client_->DidAnticipatedDrawTimeChange(AnticipatedDrawTime()); |
| 338 | 345 |
| 339 if (state_machine_.ShouldTriggerBeginImplFrameDeadlineEarly()) | 346 if (state_machine_.ShouldTriggerBeginImplFrameDeadlineEarly()) |
| 340 PostBeginImplFrameDeadline(base::TimeTicks()); | 347 PostBeginImplFrameDeadline(base::TimeTicks()); |
| 341 } | 348 } |
| 342 | 349 |
| 343 bool Scheduler::WillDrawIfNeeded() const { | 350 bool Scheduler::WillDrawIfNeeded() const { |
| 344 return !state_machine_.PendingDrawsShouldBeAborted(); | 351 return !state_machine_.PendingDrawsShouldBeAborted(); |
| 345 } | 352 } |
| 346 | 353 |
| 354 bool Scheduler::CanPaintAndCommitBeforeDeadline() const { |
| 355 // Check if the main thread computation and commit can be finished before the |
| 356 // impl thread's deadline. |
| 357 base::TimeTicks estimated_draw_time = |
| 358 last_begin_impl_frame_args_.frame_time + |
| 359 client_->BeginMainFrameToCommitDurationEstimate() + |
| 360 client_->CommitToActivateDurationEstimate(); |
| 361 |
| 362 return estimated_draw_time < last_begin_impl_frame_args_.deadline; |
| 363 } |
| 364 |
| 347 } // namespace cc | 365 } // namespace cc |
| OLD | NEW |