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/trees/single_thread_proxy.h" | 5 #include "cc/trees/single_thread_proxy.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "cc/debug/benchmark_instrumentation.h" | 9 #include "cc/debug/benchmark_instrumentation.h" |
10 #include "cc/output/context_provider.h" | 10 #include "cc/output/context_provider.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 client_->ScheduleAnimation(); | 152 client_->ScheduleAnimation(); |
153 SetNeedsCommit(); | 153 SetNeedsCommit(); |
154 } | 154 } |
155 | 155 |
156 void SingleThreadProxy::SetNeedsUpdateLayers() { | 156 void SingleThreadProxy::SetNeedsUpdateLayers() { |
157 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsUpdateLayers"); | 157 TRACE_EVENT0("cc", "SingleThreadProxy::SetNeedsUpdateLayers"); |
158 DCHECK(Proxy::IsMainThread()); | 158 DCHECK(Proxy::IsMainThread()); |
159 SetNeedsCommit(); | 159 SetNeedsCommit(); |
160 } | 160 } |
161 | 161 |
162 void SingleThreadProxy::DoCommit(base::TimeTicks frame_begin_time) { | 162 void SingleThreadProxy::DoCommit(const BeginFrameArgs& begin_frame_args) { |
163 TRACE_EVENT0("cc", "SingleThreadProxy::DoCommit"); | 163 TRACE_EVENT0("cc", "SingleThreadProxy::DoCommit"); |
164 DCHECK(Proxy::IsMainThread()); | 164 DCHECK(Proxy::IsMainThread()); |
165 layer_tree_host_->WillBeginMainFrame(); | 165 layer_tree_host_->WillBeginMainFrame(); |
166 layer_tree_host_->UpdateClientAnimations(frame_begin_time); | 166 layer_tree_host_->BeginMainFrame(begin_frame_args); |
167 layer_tree_host_->AnimateLayers(frame_begin_time); | 167 layer_tree_host_->AnimateLayers(begin_frame_args.frame_time); |
168 layer_tree_host_->Layout(); | 168 layer_tree_host_->Layout(); |
169 commit_requested_ = false; | 169 commit_requested_ = false; |
170 | 170 |
171 if (PrioritizedResourceManager* contents_texture_manager = | 171 if (PrioritizedResourceManager* contents_texture_manager = |
172 layer_tree_host_->contents_texture_manager()) { | 172 layer_tree_host_->contents_texture_manager()) { |
173 contents_texture_manager->UnlinkAndClearEvictedBackings(); | 173 contents_texture_manager->UnlinkAndClearEvictedBackings(); |
174 contents_texture_manager->SetMaxMemoryLimitBytes( | 174 contents_texture_manager->SetMaxMemoryLimitBytes( |
175 layer_tree_host_impl_->memory_allocation_limit_bytes()); | 175 layer_tree_host_impl_->memory_allocation_limit_bytes()); |
176 contents_texture_manager->SetExternalPriorityCutoff( | 176 contents_texture_manager->SetExternalPriorityCutoff( |
177 layer_tree_host_impl_->memory_allocation_priority_cutoff()); | 177 layer_tree_host_impl_->memory_allocation_priority_cutoff()); |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 TRACE_EVENT0("cc", "SingleThreadProxy::BeginFrame"); | 429 TRACE_EVENT0("cc", "SingleThreadProxy::BeginFrame"); |
430 if (scheduler_on_impl_thread_) | 430 if (scheduler_on_impl_thread_) |
431 scheduler_on_impl_thread_->BeginImplFrame(args); | 431 scheduler_on_impl_thread_->BeginImplFrame(args); |
432 } | 432 } |
433 | 433 |
434 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { | 434 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { |
435 TRACE_EVENT0("cc", "SingleThreadProxy::CompositeImmediately"); | 435 TRACE_EVENT0("cc", "SingleThreadProxy::CompositeImmediately"); |
436 DCHECK(Proxy::IsMainThread()); | 436 DCHECK(Proxy::IsMainThread()); |
437 DCHECK(!layer_tree_host_->output_surface_lost()); | 437 DCHECK(!layer_tree_host_->output_surface_lost()); |
438 | 438 |
439 DoCommit(frame_begin_time); | 439 DoCommit(BeginFrameArgs::Create( |
| 440 frame_begin_time, base::TimeTicks(), BeginFrameArgs::DefaultInterval())); |
440 | 441 |
441 LayerTreeHostImpl::FrameData frame; | 442 LayerTreeHostImpl::FrameData frame; |
442 DoComposite(frame_begin_time, &frame); | 443 DoComposite(frame_begin_time, &frame); |
443 } | 444 } |
444 | 445 |
445 void SingleThreadProxy::AsValueInto(base::debug::TracedValue* state) const { | 446 void SingleThreadProxy::AsValueInto(base::debug::TracedValue* state) const { |
446 // The following line casts away const modifiers because it is just | 447 // The following line casts away const modifiers because it is just |
447 // setting debug state. We still want the AsValue() function and its | 448 // setting debug state. We still want the AsValue() function and its |
448 // call chain to be const throughout. | 449 // call chain to be const throughout. |
449 DebugScopedSetImplThread impl(const_cast<SingleThreadProxy*>(this)); | 450 DebugScopedSetImplThread impl(const_cast<SingleThreadProxy*>(this)); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on | 494 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on |
494 // CanDraw() as well. | 495 // CanDraw() as well. |
495 if (!ShouldComposite()) { | 496 if (!ShouldComposite()) { |
496 UpdateBackgroundAnimateTicking(); | 497 UpdateBackgroundAnimateTicking(); |
497 return DRAW_ABORTED_CANT_DRAW; | 498 return DRAW_ABORTED_CANT_DRAW; |
498 } | 499 } |
499 | 500 |
500 timing_history_.DidStartDrawing(); | 501 timing_history_.DidStartDrawing(); |
501 | 502 |
502 layer_tree_host_impl_->Animate( | 503 layer_tree_host_impl_->Animate( |
503 layer_tree_host_impl_->CurrentFrameTimeTicks()); | 504 layer_tree_host_impl_->CurrentBeginFrameArgs().frame_time); |
504 UpdateBackgroundAnimateTicking(); | 505 UpdateBackgroundAnimateTicking(); |
505 | 506 |
506 if (!layer_tree_host_impl_->IsContextLost()) { | 507 if (!layer_tree_host_impl_->IsContextLost()) { |
507 layer_tree_host_impl_->PrepareToDraw(frame); | 508 layer_tree_host_impl_->PrepareToDraw(frame); |
508 layer_tree_host_impl_->DrawLayers(frame, frame_begin_time); | 509 layer_tree_host_impl_->DrawLayers(frame, frame_begin_time); |
509 layer_tree_host_impl_->DidDrawAllLayers(*frame); | 510 layer_tree_host_impl_->DidDrawAllLayers(*frame); |
510 } | 511 } |
511 | 512 |
512 bool start_ready_animations = true; | 513 bool start_ready_animations = true; |
513 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); | 514 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); |
514 | 515 |
515 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); | 516 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); |
516 | 517 |
517 timing_history_.DidFinishDrawing(); | 518 timing_history_.DidFinishDrawing(); |
518 } | 519 } |
519 | 520 |
520 { | 521 { |
521 DebugScopedSetImplThread impl(this); | 522 DebugScopedSetImplThread impl(this); |
522 | 523 |
523 if (layer_tree_host_impl_->IsContextLost()) { | 524 if (layer_tree_host_impl_->IsContextLost()) { |
524 DidLoseOutputSurfaceOnImplThread(); | 525 DidLoseOutputSurfaceOnImplThread(); |
525 } else { | 526 } else { |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 } | 622 } |
622 | 623 |
623 DrawResult SingleThreadProxy::ScheduledActionDrawAndSwapIfPossible() { | 624 DrawResult SingleThreadProxy::ScheduledActionDrawAndSwapIfPossible() { |
624 DebugScopedSetImplThread impl(this); | 625 DebugScopedSetImplThread impl(this); |
625 if (layer_tree_host_impl_->IsContextLost()) { | 626 if (layer_tree_host_impl_->IsContextLost()) { |
626 DidCommitAndDrawFrame(); | 627 DidCommitAndDrawFrame(); |
627 return DRAW_SUCCESS; | 628 return DRAW_SUCCESS; |
628 } | 629 } |
629 | 630 |
630 LayerTreeHostImpl::FrameData frame; | 631 LayerTreeHostImpl::FrameData frame; |
631 return DoComposite(layer_tree_host_impl_->CurrentFrameTimeTicks(), &frame); | 632 return DoComposite(layer_tree_host_impl_->CurrentBeginFrameArgs().frame_time, |
| 633 &frame); |
632 } | 634 } |
633 | 635 |
634 DrawResult SingleThreadProxy::ScheduledActionDrawAndSwapForced() { | 636 DrawResult SingleThreadProxy::ScheduledActionDrawAndSwapForced() { |
635 NOTREACHED(); | 637 NOTREACHED(); |
636 return INVALID_RESULT; | 638 return INVALID_RESULT; |
637 } | 639 } |
638 | 640 |
639 void SingleThreadProxy::ScheduledActionCommit() { | 641 void SingleThreadProxy::ScheduledActionCommit() { |
640 DebugScopedSetMainThread main(this); | 642 DebugScopedSetMainThread main(this); |
641 DoCommit(layer_tree_host_impl_->CurrentFrameTimeTicks()); | 643 DoCommit(layer_tree_host_impl_->CurrentBeginFrameArgs()); |
642 } | 644 } |
643 | 645 |
644 void SingleThreadProxy::ScheduledActionAnimate() { | 646 void SingleThreadProxy::ScheduledActionAnimate() { |
645 TRACE_EVENT0("cc", "ScheduledActionAnimate"); | 647 TRACE_EVENT0("cc", "ScheduledActionAnimate"); |
646 layer_tree_host_impl_->Animate( | 648 layer_tree_host_impl_->Animate( |
647 layer_tree_host_impl_->CurrentFrameTimeTicks()); | 649 layer_tree_host_impl_->CurrentBeginFrameArgs().frame_time); |
648 } | 650 } |
649 | 651 |
650 void SingleThreadProxy::ScheduledActionUpdateVisibleTiles() { | 652 void SingleThreadProxy::ScheduledActionUpdateVisibleTiles() { |
651 // Impl-side painting only. | 653 // Impl-side painting only. |
652 NOTREACHED(); | 654 NOTREACHED(); |
653 } | 655 } |
654 | 656 |
655 void SingleThreadProxy::ScheduledActionActivateSyncTree() { | 657 void SingleThreadProxy::ScheduledActionActivateSyncTree() { |
656 } | 658 } |
657 | 659 |
(...skipping 28 matching lines...) Expand all Loading... |
686 | 688 |
687 base::TimeDelta SingleThreadProxy::BeginMainFrameToCommitDurationEstimate() { | 689 base::TimeDelta SingleThreadProxy::BeginMainFrameToCommitDurationEstimate() { |
688 return timing_history_.BeginMainFrameToCommitDurationEstimate(); | 690 return timing_history_.BeginMainFrameToCommitDurationEstimate(); |
689 } | 691 } |
690 | 692 |
691 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { | 693 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { |
692 return timing_history_.CommitToActivateDurationEstimate(); | 694 return timing_history_.CommitToActivateDurationEstimate(); |
693 } | 695 } |
694 | 696 |
695 void SingleThreadProxy::DidBeginImplFrameDeadline() { | 697 void SingleThreadProxy::DidBeginImplFrameDeadline() { |
696 layer_tree_host_impl_->ResetCurrentFrameTimeForNextFrame(); | 698 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); |
697 } | 699 } |
698 | 700 |
699 } // namespace cc | 701 } // namespace cc |
OLD | NEW |