| 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/profiler/scoped_tracker.h" | 8 #include "base/profiler/scoped_tracker.h" |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "cc/debug/benchmark_instrumentation.h" | 10 #include "cc/debug/benchmark_instrumentation.h" |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 layer_tree_host_->DidCompleteSwapBuffers(); | 580 layer_tree_host_->DidCompleteSwapBuffers(); |
| 581 } | 581 } |
| 582 | 582 |
| 583 void SingleThreadProxy::OnDrawForOutputSurface() { | 583 void SingleThreadProxy::OnDrawForOutputSurface() { |
| 584 NOTREACHED() << "Implemented by ThreadProxy for synchronous compositor."; | 584 NOTREACHED() << "Implemented by ThreadProxy for synchronous compositor."; |
| 585 } | 585 } |
| 586 | 586 |
| 587 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { | 587 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { |
| 588 TRACE_EVENT0("cc,benchmark", "SingleThreadProxy::CompositeImmediately"); | 588 TRACE_EVENT0("cc,benchmark", "SingleThreadProxy::CompositeImmediately"); |
| 589 DCHECK(Proxy::IsMainThread()); | 589 DCHECK(Proxy::IsMainThread()); |
| 590 DCHECK(!inside_impl_frame_); |
| 590 base::AutoReset<bool> inside_composite(&inside_synchronous_composite_, true); | 591 base::AutoReset<bool> inside_composite(&inside_synchronous_composite_, true); |
| 591 | 592 |
| 592 if (layer_tree_host_->output_surface_lost()) { | 593 if (layer_tree_host_->output_surface_lost()) { |
| 593 RequestNewOutputSurface(); | 594 RequestNewOutputSurface(); |
| 594 // RequestNewOutputSurface could have synchronously created an output | 595 // RequestNewOutputSurface could have synchronously created an output |
| 595 // surface, so check again before returning. | 596 // surface, so check again before returning. |
| 596 if (layer_tree_host_->output_surface_lost()) | 597 if (layer_tree_host_->output_surface_lost()) |
| 597 return; | 598 return; |
| 598 } | 599 } |
| 599 | 600 |
| 601 BeginFrameArgs begin_frame_args(BeginFrameArgs::Create( |
| 602 BEGINFRAME_FROM_HERE, frame_begin_time, base::TimeTicks(), |
| 603 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL)); |
| 604 |
| 605 // Start the impl frame. |
| 600 { | 606 { |
| 601 BeginFrameArgs begin_frame_args(BeginFrameArgs::Create( | 607 DebugScopedSetImplThread impl(this); |
| 602 BEGINFRAME_FROM_HERE, frame_begin_time, base::TimeTicks(), | 608 WillBeginImplFrame(begin_frame_args); |
| 603 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL)); | 609 } |
| 610 |
| 611 // Run the "main thread" and get it to commit. |
| 612 { |
| 613 DCHECK(inside_impl_frame_); |
| 604 DoBeginMainFrame(begin_frame_args); | 614 DoBeginMainFrame(begin_frame_args); |
| 605 DoCommit(); | 615 DoCommit(); |
| 606 | 616 |
| 607 DCHECK_EQ(0u, layer_tree_host_->num_queued_swap_promises()) | 617 DCHECK_EQ(0u, layer_tree_host_->num_queued_swap_promises()) |
| 608 << "Commit should always succeed and transfer promises."; | 618 << "Commit should always succeed and transfer promises."; |
| 609 } | 619 } |
| 610 | 620 |
| 621 // Finish the impl frame. |
| 611 { | 622 { |
| 612 DebugScopedSetImplThread impl(const_cast<SingleThreadProxy*>(this)); | 623 DebugScopedSetImplThread impl(this); |
| 613 if (layer_tree_host_impl_->settings().impl_side_painting) { | 624 if (layer_tree_host_impl_->settings().impl_side_painting) { |
| 614 layer_tree_host_impl_->ActivateSyncTree(); | 625 layer_tree_host_impl_->ActivateSyncTree(); |
| 615 DCHECK(!layer_tree_host_impl_->active_tree() | 626 DCHECK(!layer_tree_host_impl_->active_tree() |
| 616 ->needs_update_draw_properties()); | 627 ->needs_update_draw_properties()); |
| 617 layer_tree_host_impl_->PrepareTiles(); | 628 layer_tree_host_impl_->PrepareTiles(); |
| 618 layer_tree_host_impl_->SynchronouslyInitializeAllTiles(); | 629 layer_tree_host_impl_->SynchronouslyInitializeAllTiles(); |
| 619 } | 630 } |
| 620 | 631 |
| 621 DoAnimate(); | 632 DoAnimate(); |
| 622 | 633 |
| 623 LayerTreeHostImpl::FrameData frame; | 634 LayerTreeHostImpl::FrameData frame; |
| 624 DoComposite(frame_begin_time, &frame); | 635 DoComposite(frame_begin_time, &frame); |
| 625 | 636 |
| 626 // DoComposite could abort, but because this is a synchronous composite | 637 // DoComposite could abort, but because this is a synchronous composite |
| 627 // another draw will never be scheduled, so break remaining promises. | 638 // another draw will never be scheduled, so break remaining promises. |
| 628 layer_tree_host_impl_->active_tree()->BreakSwapPromises( | 639 layer_tree_host_impl_->active_tree()->BreakSwapPromises( |
| 629 SwapPromise::SWAP_FAILS); | 640 SwapPromise::SWAP_FAILS); |
| 641 |
| 642 DidBeginImplFrameDeadline(); |
| 630 } | 643 } |
| 631 } | 644 } |
| 632 | 645 |
| 633 void SingleThreadProxy::ForceSerializeOnSwapBuffers() { | 646 void SingleThreadProxy::ForceSerializeOnSwapBuffers() { |
| 634 { | 647 { |
| 635 DebugScopedSetImplThread impl(this); | 648 DebugScopedSetImplThread impl(this); |
| 636 if (layer_tree_host_impl_->renderer()) { | 649 if (layer_tree_host_impl_->renderer()) { |
| 637 DCHECK(!layer_tree_host_->output_surface_lost()); | 650 DCHECK(!layer_tree_host_->output_surface_lost()); |
| 638 layer_tree_host_impl_->renderer()->DoNoOp(); | 651 layer_tree_host_impl_->renderer()->DoNoOp(); |
| 639 } | 652 } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 "461509 SingleThreadProxy::DoComposite4")); | 723 "461509 SingleThreadProxy::DoComposite4")); |
| 711 layer_tree_host_impl_->DidDrawAllLayers(*frame); | 724 layer_tree_host_impl_->DidDrawAllLayers(*frame); |
| 712 | 725 |
| 713 bool start_ready_animations = draw_frame; | 726 bool start_ready_animations = draw_frame; |
| 714 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 | 727 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 |
| 715 // is fixed. | 728 // is fixed. |
| 716 tracked_objects::ScopedTracker tracking_profile5( | 729 tracked_objects::ScopedTracker tracking_profile5( |
| 717 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 730 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 718 "461509 SingleThreadProxy::DoComposite5")); | 731 "461509 SingleThreadProxy::DoComposite5")); |
| 719 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); | 732 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); |
| 720 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 | |
| 721 // is fixed. | |
| 722 tracked_objects::ScopedTracker tracking_profile6( | |
| 723 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
| 724 "461509 SingleThreadProxy::DoComposite6")); | |
| 725 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); | |
| 726 | 733 |
| 727 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 | 734 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 |
| 728 // is fixed. | 735 // is fixed. |
| 729 tracked_objects::ScopedTracker tracking_profile7( | 736 tracked_objects::ScopedTracker tracking_profile7( |
| 730 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 737 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 731 "461509 SingleThreadProxy::DoComposite7")); | 738 "461509 SingleThreadProxy::DoComposite7")); |
| 732 timing_history_.DidFinishDrawing(); | 739 timing_history_.DidFinishDrawing(); |
| 733 } | 740 } |
| 734 | 741 |
| 735 if (draw_frame) { | 742 if (draw_frame) { |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 DCHECK(inside_impl_frame_) | 985 DCHECK(inside_impl_frame_) |
| 979 << "DidBeginImplFrameDeadline called while not inside an impl frame!"; | 986 << "DidBeginImplFrameDeadline called while not inside an impl frame!"; |
| 980 inside_impl_frame_ = false; | 987 inside_impl_frame_ = false; |
| 981 } | 988 } |
| 982 | 989 |
| 983 void SingleThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) { | 990 void SingleThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) { |
| 984 layer_tree_host_->SendBeginFramesToChildren(args); | 991 layer_tree_host_->SendBeginFramesToChildren(args); |
| 985 } | 992 } |
| 986 | 993 |
| 987 } // namespace cc | 994 } // namespace cc |
| OLD | NEW |