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/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/profiler/scoped_tracker.h" | 9 #include "base/profiler/scoped_tracker.h" |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 "461509 SingleThreadProxy::DoComposite1")); | 594 "461509 SingleThreadProxy::DoComposite1")); |
595 | 595 |
596 // We guard PrepareToDraw() with CanDraw() because it always returns a valid | 596 // We guard PrepareToDraw() with CanDraw() because it always returns a valid |
597 // frame, so can only be used when such a frame is possible. Since | 597 // frame, so can only be used when such a frame is possible. Since |
598 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on | 598 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on |
599 // CanDraw() as well. | 599 // CanDraw() as well. |
600 if (!ShouldComposite()) { | 600 if (!ShouldComposite()) { |
601 return DRAW_ABORTED_CANT_DRAW; | 601 return DRAW_ABORTED_CANT_DRAW; |
602 } | 602 } |
603 | 603 |
| 604 // This CapturePostTasks should be destroyed before |
| 605 // DidCommitAndDrawFrame() is called since that goes out to the |
| 606 // embedder, and we want the embedder to receive its callbacks before that. |
| 607 // NOTE: This maintains consistent ordering with the ThreadProxy since |
| 608 // the DidCommitAndDrawFrame() must be post-tasked from the impl thread |
| 609 // there as the main thread is not blocked, so any posted tasks inside |
| 610 // the swap buffers will execute first. |
| 611 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); |
| 612 BlockingTaskRunner::CapturePostTasks blocked( |
| 613 task_runner_provider_->blocking_main_thread_task_runner()); |
| 614 |
604 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 | 615 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 |
605 // is fixed. | 616 // is fixed. |
606 tracked_objects::ScopedTracker tracking_profile2( | 617 tracked_objects::ScopedTracker tracking_profile2( |
607 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 618 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
608 "461509 SingleThreadProxy::DoComposite2")); | 619 "461509 SingleThreadProxy::DoComposite2")); |
609 draw_result = layer_tree_host_impl_->PrepareToDraw(frame); | 620 draw_result = layer_tree_host_impl_->PrepareToDraw(frame); |
610 draw_frame = draw_result == DRAW_SUCCESS; | 621 draw_frame = draw_result == DRAW_SUCCESS; |
611 if (draw_frame) { | 622 if (draw_frame) { |
612 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 | 623 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 |
613 // is fixed. | 624 // is fixed. |
614 tracked_objects::ScopedTracker tracking_profile3( | 625 tracked_objects::ScopedTracker tracking_profile3( |
615 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 626 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
616 "461509 SingleThreadProxy::DoComposite3")); | 627 "461509 SingleThreadProxy::DoComposite3")); |
617 layer_tree_host_impl_->DrawLayers(frame); | 628 layer_tree_host_impl_->DrawLayers(frame); |
| 629 |
| 630 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 |
| 631 // is fixed. |
| 632 tracked_objects::ScopedTracker tracking_profile8( |
| 633 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 634 "461509 SingleThreadProxy::DoComposite8")); |
| 635 if (layer_tree_host_impl_->SwapBuffers(*frame)) { |
| 636 if (scheduler_on_impl_thread_) |
| 637 scheduler_on_impl_thread_->DidSwapBuffers(); |
| 638 client_->DidPostSwapBuffers(); |
| 639 } |
618 } | 640 } |
| 641 |
619 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 | 642 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 |
620 // is fixed. | 643 // is fixed. |
621 tracked_objects::ScopedTracker tracking_profile4( | 644 tracked_objects::ScopedTracker tracking_profile4( |
622 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 645 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
623 "461509 SingleThreadProxy::DoComposite4")); | 646 "461509 SingleThreadProxy::DoComposite4")); |
624 layer_tree_host_impl_->DidDrawAllLayers(*frame); | 647 layer_tree_host_impl_->DidDrawAllLayers(*frame); |
625 | 648 |
626 bool start_ready_animations = draw_frame; | |
627 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 | 649 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 |
628 // is fixed. | 650 // is fixed. |
629 tracked_objects::ScopedTracker tracking_profile5( | 651 tracked_objects::ScopedTracker tracking_profile5( |
630 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 652 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
631 "461509 SingleThreadProxy::DoComposite5")); | 653 "461509 SingleThreadProxy::DoComposite5")); |
| 654 bool start_ready_animations = draw_frame; |
632 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); | 655 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); |
633 | |
634 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 | |
635 // is fixed. | |
636 tracked_objects::ScopedTracker tracking_profile7( | |
637 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
638 "461509 SingleThreadProxy::DoComposite7")); | |
639 } | |
640 | |
641 if (draw_frame) { | |
642 DebugScopedSetImplThread impl(task_runner_provider_); | |
643 | |
644 // This CapturePostTasks should be destroyed before | |
645 // DidCommitAndDrawFrame() is called since that goes out to the | |
646 // embedder, | |
647 // and we want the embedder to receive its callbacks before that. | |
648 // NOTE: This maintains consistent ordering with the ThreadProxy since | |
649 // the DidCommitAndDrawFrame() must be post-tasked from the impl thread | |
650 // there as the main thread is not blocked, so any posted tasks inside | |
651 // the swap buffers will execute first. | |
652 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); | |
653 | |
654 BlockingTaskRunner::CapturePostTasks blocked( | |
655 task_runner_provider_->blocking_main_thread_task_runner()); | |
656 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 | |
657 // is fixed. | |
658 tracked_objects::ScopedTracker tracking_profile8( | |
659 FROM_HERE_WITH_EXPLICIT_FUNCTION( | |
660 "461509 SingleThreadProxy::DoComposite8")); | |
661 if (layer_tree_host_impl_->SwapBuffers(*frame)) { | |
662 if (scheduler_on_impl_thread_) | |
663 scheduler_on_impl_thread_->DidSwapBuffers(); | |
664 client_->DidPostSwapBuffers(); | |
665 } | |
666 } | 656 } |
667 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 is | 657 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 is |
668 // fixed. | 658 // fixed. |
669 tracked_objects::ScopedTracker tracking_profile9( | 659 tracked_objects::ScopedTracker tracking_profile9( |
670 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 660 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
671 "461509 SingleThreadProxy::DoComposite9")); | 661 "461509 SingleThreadProxy::DoComposite9")); |
672 DidCommitAndDrawFrame(); | 662 DidCommitAndDrawFrame(); |
673 | 663 |
674 return draw_result; | 664 return draw_result; |
675 } | 665 } |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 void SingleThreadProxy::DidFinishImplFrame() { | 841 void SingleThreadProxy::DidFinishImplFrame() { |
852 layer_tree_host_impl_->DidFinishImplFrame(); | 842 layer_tree_host_impl_->DidFinishImplFrame(); |
853 #if DCHECK_IS_ON() | 843 #if DCHECK_IS_ON() |
854 DCHECK(inside_impl_frame_) | 844 DCHECK(inside_impl_frame_) |
855 << "DidFinishImplFrame called while not inside an impl frame!"; | 845 << "DidFinishImplFrame called while not inside an impl frame!"; |
856 inside_impl_frame_ = false; | 846 inside_impl_frame_ = false; |
857 #endif | 847 #endif |
858 } | 848 } |
859 | 849 |
860 } // namespace cc | 850 } // namespace cc |
OLD | NEW |