| 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 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 | 283 |
| 284 // Trace this begin frame time through the Chrome stack | 284 // Trace this begin frame time through the Chrome stack |
| 285 TRACE_EVENT_FLOW_BEGIN0( | 285 TRACE_EVENT_FLOW_BEGIN0( |
| 286 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), "BeginFrameArgs", | 286 TRACE_DISABLED_BY_DEFAULT("cc.debug.scheduler.frames"), "BeginFrameArgs", |
| 287 args.frame_time.ToInternalValue()); | 287 args.frame_time.ToInternalValue()); |
| 288 | 288 |
| 289 // TODO(brianderson): Adjust deadline in the DisplayScheduler. | 289 // TODO(brianderson): Adjust deadline in the DisplayScheduler. |
| 290 BeginFrameArgs adjusted_args(args); | 290 BeginFrameArgs adjusted_args(args); |
| 291 adjusted_args.deadline -= EstimatedParentDrawTime(); | 291 adjusted_args.deadline -= EstimatedParentDrawTime(); |
| 292 | 292 |
| 293 // Deliver BeginFrames to children. | |
| 294 // TODO(brianderson): Move this responsibility to the DisplayScheduler. | |
| 295 if (state_machine_.children_need_begin_frames()) | |
| 296 client_->SendBeginFramesToChildren(adjusted_args); | |
| 297 | |
| 298 if (settings_.using_synchronous_renderer_compositor) { | 293 if (settings_.using_synchronous_renderer_compositor) { |
| 299 BeginImplFrameSynchronous(adjusted_args); | 294 BeginImplFrameSynchronous(adjusted_args); |
| 300 return true; | 295 return true; |
| 301 } | 296 } |
| 302 | 297 |
| 303 // We have just called SetNeedsBeginFrame(true) and the BeginFrameSource has | 298 // We have just called SetNeedsBeginFrame(true) and the BeginFrameSource has |
| 304 // sent us the last BeginFrame we have missed. As we might not be able to | 299 // sent us the last BeginFrame we have missed. As we might not be able to |
| 305 // actually make rendering for this call, handle it like a "retro frame". | 300 // actually make rendering for this call, handle it like a "retro frame". |
| 306 // TODO(brainderson): Add a test for this functionality ASAP! | 301 // TODO(brainderson): Add a test for this functionality ASAP! |
| 307 if (adjusted_args.type == BeginFrameArgs::MISSED) { | 302 if (adjusted_args.type == BeginFrameArgs::MISSED) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 321 begin_retro_frame_args_.push_back(adjusted_args); | 316 begin_retro_frame_args_.push_back(adjusted_args); |
| 322 TRACE_EVENT_INSTANT0( | 317 TRACE_EVENT_INSTANT0( |
| 323 "cc", "Scheduler::BeginFrame deferred", TRACE_EVENT_SCOPE_THREAD); | 318 "cc", "Scheduler::BeginFrame deferred", TRACE_EVENT_SCOPE_THREAD); |
| 324 // Queuing the frame counts as "using it", so we need to return true. | 319 // Queuing the frame counts as "using it", so we need to return true. |
| 325 } else { | 320 } else { |
| 326 BeginImplFrameWithDeadline(adjusted_args); | 321 BeginImplFrameWithDeadline(adjusted_args); |
| 327 } | 322 } |
| 328 return true; | 323 return true; |
| 329 } | 324 } |
| 330 | 325 |
| 331 void Scheduler::SetChildrenNeedBeginFrames(bool children_need_begin_frames) { | |
| 332 state_machine_.SetChildrenNeedBeginFrames(children_need_begin_frames); | |
| 333 ProcessScheduledActions(); | |
| 334 } | |
| 335 | |
| 336 void Scheduler::SetVideoNeedsBeginFrames(bool video_needs_begin_frames) { | 326 void Scheduler::SetVideoNeedsBeginFrames(bool video_needs_begin_frames) { |
| 337 state_machine_.SetVideoNeedsBeginFrames(video_needs_begin_frames); | 327 state_machine_.SetVideoNeedsBeginFrames(video_needs_begin_frames); |
| 338 ProcessScheduledActions(); | 328 ProcessScheduledActions(); |
| 339 } | 329 } |
| 340 | 330 |
| 341 void Scheduler::OnDrawForOutputSurface(bool resourceless_software_draw) { | 331 void Scheduler::OnDrawForOutputSurface(bool resourceless_software_draw) { |
| 342 DCHECK(settings_.using_synchronous_renderer_compositor); | 332 DCHECK(settings_.using_synchronous_renderer_compositor); |
| 343 DCHECK_EQ(state_machine_.begin_impl_frame_state(), | 333 DCHECK_EQ(state_machine_.begin_impl_frame_state(), |
| 344 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); | 334 SchedulerStateMachine::BEGIN_IMPL_FRAME_STATE_IDLE); |
| 345 DCHECK(!BeginImplFrameDeadlinePending()); | 335 DCHECK(!BeginImplFrameDeadlinePending()); |
| (...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 } | 859 } |
| 870 | 860 |
| 871 bool Scheduler::IsBeginMainFrameSentOrStarted() const { | 861 bool Scheduler::IsBeginMainFrameSentOrStarted() const { |
| 872 return (state_machine_.begin_main_frame_state() == | 862 return (state_machine_.begin_main_frame_state() == |
| 873 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT || | 863 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_SENT || |
| 874 state_machine_.begin_main_frame_state() == | 864 state_machine_.begin_main_frame_state() == |
| 875 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED); | 865 SchedulerStateMachine::BEGIN_MAIN_FRAME_STATE_STARTED); |
| 876 } | 866 } |
| 877 | 867 |
| 878 } // namespace cc | 868 } // namespace cc |
| OLD | NEW |