Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: cc/trees/single_thread_proxy.cc

Issue 2317493003: cc: Toward merging DrawFrame and SwapBuffers in DelegatingRenderer. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« cc/trees/layer_tree_host_impl.cc ('K') | « cc/trees/proxy_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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);
618 } 629 }
630
631 if (draw_frame) {
632 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509
633 // is fixed.
634 tracked_objects::ScopedTracker tracking_profile8(
635 FROM_HERE_WITH_EXPLICIT_FUNCTION(
636 "461509 SingleThreadProxy::DoComposite8"));
637 if (layer_tree_host_impl_->SwapBuffers(*frame)) {
638 if (scheduler_on_impl_thread_)
639 scheduler_on_impl_thread_->DidSwapBuffers();
640 client_->DidPostSwapBuffers();
641 }
642 }
643
619 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 644 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509
620 // is fixed. 645 // is fixed.
621 tracked_objects::ScopedTracker tracking_profile4( 646 tracked_objects::ScopedTracker tracking_profile4(
622 FROM_HERE_WITH_EXPLICIT_FUNCTION( 647 FROM_HERE_WITH_EXPLICIT_FUNCTION(
623 "461509 SingleThreadProxy::DoComposite4")); 648 "461509 SingleThreadProxy::DoComposite4"));
624 layer_tree_host_impl_->DidDrawAllLayers(*frame); 649 layer_tree_host_impl_->DidDrawAllLayers(*frame);
625 650
626 bool start_ready_animations = draw_frame;
627 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 651 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509
628 // is fixed. 652 // is fixed.
629 tracked_objects::ScopedTracker tracking_profile5( 653 tracked_objects::ScopedTracker tracking_profile5(
630 FROM_HERE_WITH_EXPLICIT_FUNCTION( 654 FROM_HERE_WITH_EXPLICIT_FUNCTION(
631 "461509 SingleThreadProxy::DoComposite5")); 655 "461509 SingleThreadProxy::DoComposite5"));
656 bool start_ready_animations = draw_frame;
632 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); 657 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 } 658 }
667 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 is 659 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 is
668 // fixed. 660 // fixed.
669 tracked_objects::ScopedTracker tracking_profile9( 661 tracked_objects::ScopedTracker tracking_profile9(
670 FROM_HERE_WITH_EXPLICIT_FUNCTION( 662 FROM_HERE_WITH_EXPLICIT_FUNCTION(
671 "461509 SingleThreadProxy::DoComposite9")); 663 "461509 SingleThreadProxy::DoComposite9"));
672 DidCommitAndDrawFrame(); 664 DidCommitAndDrawFrame();
673 665
674 return draw_result; 666 return draw_result;
675 } 667 }
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 void SingleThreadProxy::DidFinishImplFrame() { 843 void SingleThreadProxy::DidFinishImplFrame() {
852 layer_tree_host_impl_->DidFinishImplFrame(); 844 layer_tree_host_impl_->DidFinishImplFrame();
853 #if DCHECK_IS_ON() 845 #if DCHECK_IS_ON()
854 DCHECK(inside_impl_frame_) 846 DCHECK(inside_impl_frame_)
855 << "DidFinishImplFrame called while not inside an impl frame!"; 847 << "DidFinishImplFrame called while not inside an impl frame!";
856 inside_impl_frame_ = false; 848 inside_impl_frame_ = false;
857 #endif 849 #endif
858 } 850 }
859 851
860 } // namespace cc 852 } // namespace cc
OLDNEW
« cc/trees/layer_tree_host_impl.cc ('K') | « cc/trees/proxy_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698