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