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

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

Issue 1127963003: Revert of cc: Adding DidFinishImplFrame to LTHI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « cc/trees/single_thread_proxy.h ('k') | cc/trees/thread_proxy.h » ('j') | 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/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 27 matching lines...) Expand all
38 SingleThreadProxy::SingleThreadProxy( 38 SingleThreadProxy::SingleThreadProxy(
39 LayerTreeHost* layer_tree_host, 39 LayerTreeHost* layer_tree_host,
40 LayerTreeHostSingleThreadClient* client, 40 LayerTreeHostSingleThreadClient* client,
41 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 41 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
42 scoped_ptr<BeginFrameSource> external_begin_frame_source) 42 scoped_ptr<BeginFrameSource> external_begin_frame_source)
43 : Proxy(main_task_runner, NULL), 43 : Proxy(main_task_runner, NULL),
44 layer_tree_host_(layer_tree_host), 44 layer_tree_host_(layer_tree_host),
45 client_(client), 45 client_(client),
46 timing_history_(layer_tree_host->rendering_stats_instrumentation()), 46 timing_history_(layer_tree_host->rendering_stats_instrumentation()),
47 next_frame_is_newly_committed_frame_(false), 47 next_frame_is_newly_committed_frame_(false),
48 #if DCHECK_IS_ON()
49 inside_impl_frame_(false), 48 inside_impl_frame_(false),
50 #endif
51 inside_draw_(false), 49 inside_draw_(false),
52 defer_commits_(false), 50 defer_commits_(false),
53 animate_requested_(false), 51 animate_requested_(false),
54 commit_requested_(false), 52 commit_requested_(false),
55 inside_synchronous_composite_(false), 53 inside_synchronous_composite_(false),
56 output_surface_creation_requested_(false), 54 output_surface_creation_requested_(false),
57 weak_factory_(this) { 55 weak_factory_(this) {
58 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); 56 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy");
59 DCHECK(Proxy::IsMainThread()); 57 DCHECK(Proxy::IsMainThread());
60 DCHECK(layer_tree_host); 58 DCHECK(layer_tree_host);
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 layer_tree_host_->DidCompleteSwapBuffers(); 580 layer_tree_host_->DidCompleteSwapBuffers();
583 } 581 }
584 582
585 void SingleThreadProxy::OnDrawForOutputSurface() { 583 void SingleThreadProxy::OnDrawForOutputSurface() {
586 NOTREACHED() << "Implemented by ThreadProxy for synchronous compositor."; 584 NOTREACHED() << "Implemented by ThreadProxy for synchronous compositor.";
587 } 585 }
588 586
589 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) { 587 void SingleThreadProxy::CompositeImmediately(base::TimeTicks frame_begin_time) {
590 TRACE_EVENT0("cc,benchmark", "SingleThreadProxy::CompositeImmediately"); 588 TRACE_EVENT0("cc,benchmark", "SingleThreadProxy::CompositeImmediately");
591 DCHECK(Proxy::IsMainThread()); 589 DCHECK(Proxy::IsMainThread());
592 #if DCHECK_IS_ON()
593 DCHECK(!inside_impl_frame_); 590 DCHECK(!inside_impl_frame_);
594 #endif
595 base::AutoReset<bool> inside_composite(&inside_synchronous_composite_, true); 591 base::AutoReset<bool> inside_composite(&inside_synchronous_composite_, true);
596 592
597 if (layer_tree_host_->output_surface_lost()) { 593 if (layer_tree_host_->output_surface_lost()) {
598 RequestNewOutputSurface(); 594 RequestNewOutputSurface();
599 // RequestNewOutputSurface could have synchronously created an output 595 // RequestNewOutputSurface could have synchronously created an output
600 // surface, so check again before returning. 596 // surface, so check again before returning.
601 if (layer_tree_host_->output_surface_lost()) 597 if (layer_tree_host_->output_surface_lost())
602 return; 598 return;
603 } 599 }
604 600
605 BeginFrameArgs begin_frame_args(BeginFrameArgs::Create( 601 BeginFrameArgs begin_frame_args(BeginFrameArgs::Create(
606 BEGINFRAME_FROM_HERE, frame_begin_time, base::TimeTicks(), 602 BEGINFRAME_FROM_HERE, frame_begin_time, base::TimeTicks(),
607 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL)); 603 BeginFrameArgs::DefaultInterval(), BeginFrameArgs::NORMAL));
608 604
609 // Start the impl frame. 605 // Start the impl frame.
610 { 606 {
611 DebugScopedSetImplThread impl(this); 607 DebugScopedSetImplThread impl(this);
612 WillBeginImplFrame(begin_frame_args); 608 WillBeginImplFrame(begin_frame_args);
613 } 609 }
614 610
615 // Run the "main thread" and get it to commit. 611 // Run the "main thread" and get it to commit.
616 { 612 {
617 #if DCHECK_IS_ON()
618 DCHECK(inside_impl_frame_); 613 DCHECK(inside_impl_frame_);
619 #endif
620 DoBeginMainFrame(begin_frame_args); 614 DoBeginMainFrame(begin_frame_args);
621 DoCommit(); 615 DoCommit();
622 616
623 DCHECK_EQ(0u, layer_tree_host_->num_queued_swap_promises()) 617 DCHECK_EQ(0u, layer_tree_host_->num_queued_swap_promises())
624 << "Commit should always succeed and transfer promises."; 618 << "Commit should always succeed and transfer promises.";
625 } 619 }
626 620
627 // Finish the impl frame. 621 // Finish the impl frame.
628 { 622 {
629 DebugScopedSetImplThread impl(this); 623 DebugScopedSetImplThread impl(this);
630 if (layer_tree_host_impl_->settings().impl_side_painting) { 624 if (layer_tree_host_impl_->settings().impl_side_painting) {
631 layer_tree_host_impl_->ActivateSyncTree(); 625 layer_tree_host_impl_->ActivateSyncTree();
632 DCHECK(!layer_tree_host_impl_->active_tree() 626 DCHECK(!layer_tree_host_impl_->active_tree()
633 ->needs_update_draw_properties()); 627 ->needs_update_draw_properties());
634 layer_tree_host_impl_->PrepareTiles(); 628 layer_tree_host_impl_->PrepareTiles();
635 layer_tree_host_impl_->SynchronouslyInitializeAllTiles(); 629 layer_tree_host_impl_->SynchronouslyInitializeAllTiles();
636 } 630 }
637 631
638 DoAnimate(); 632 DoAnimate();
639 633
640 LayerTreeHostImpl::FrameData frame; 634 LayerTreeHostImpl::FrameData frame;
641 DoComposite(&frame); 635 DoComposite(&frame);
642 636
643 // DoComposite could abort, but because this is a synchronous composite 637 // DoComposite could abort, but because this is a synchronous composite
644 // another draw will never be scheduled, so break remaining promises. 638 // another draw will never be scheduled, so break remaining promises.
645 layer_tree_host_impl_->active_tree()->BreakSwapPromises( 639 layer_tree_host_impl_->active_tree()->BreakSwapPromises(
646 SwapPromise::SWAP_FAILS); 640 SwapPromise::SWAP_FAILS);
647 641
648 DidFinishImplFrame(); 642 DidBeginImplFrameDeadline();
649 } 643 }
650 } 644 }
651 645
652 void SingleThreadProxy::ForceSerializeOnSwapBuffers() { 646 void SingleThreadProxy::ForceSerializeOnSwapBuffers() {
653 { 647 {
654 DebugScopedSetImplThread impl(this); 648 DebugScopedSetImplThread impl(this);
655 if (layer_tree_host_impl_->renderer()) { 649 if (layer_tree_host_impl_->renderer()) {
656 DCHECK(!layer_tree_host_->output_surface_lost()); 650 DCHECK(!layer_tree_host_->output_surface_lost());
657 layer_tree_host_impl_->renderer()->DoNoOp(); 651 layer_tree_host_impl_->renderer()->DoNoOp();
658 } 652 }
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 scheduler_on_impl_thread_->SetChildrenNeedBeginFrames( 791 scheduler_on_impl_thread_->SetChildrenNeedBeginFrames(
798 children_need_begin_frames); 792 children_need_begin_frames);
799 } 793 }
800 794
801 void SingleThreadProxy::SetAuthoritativeVSyncInterval( 795 void SingleThreadProxy::SetAuthoritativeVSyncInterval(
802 const base::TimeDelta& interval) { 796 const base::TimeDelta& interval) {
803 scheduler_on_impl_thread_->SetAuthoritativeVSyncInterval(interval); 797 scheduler_on_impl_thread_->SetAuthoritativeVSyncInterval(interval);
804 } 798 }
805 799
806 void SingleThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { 800 void SingleThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) {
807 #if DCHECK_IS_ON()
808 DCHECK(!inside_impl_frame_) 801 DCHECK(!inside_impl_frame_)
809 << "WillBeginImplFrame called while already inside an impl frame!"; 802 << "WillBeginImplFrame called while already inside an impl frame!";
810 inside_impl_frame_ = true; 803 inside_impl_frame_ = true;
811 #endif
812 layer_tree_host_impl_->WillBeginImplFrame(args); 804 layer_tree_host_impl_->WillBeginImplFrame(args);
813 } 805 }
814 806
815 void SingleThreadProxy::ScheduledActionSendBeginMainFrame() { 807 void SingleThreadProxy::ScheduledActionSendBeginMainFrame() {
816 TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionSendBeginMainFrame"); 808 TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionSendBeginMainFrame");
817 // Although this proxy is single-threaded, it's problematic to synchronously 809 // Although this proxy is single-threaded, it's problematic to synchronously
818 // have BeginMainFrame happen after ScheduledActionSendBeginMainFrame. This 810 // have BeginMainFrame happen after ScheduledActionSendBeginMainFrame. This
819 // could cause a commit to occur in between a series of SetNeedsCommit calls 811 // could cause a commit to occur in between a series of SetNeedsCommit calls
820 // (i.e. property modifications) causing some to fall on one frame and some to 812 // (i.e. property modifications) causing some to fall on one frame and some to
821 // fall on the next. Doing it asynchronously instead matches the semantics of 813 // fall on the next. Doing it asynchronously instead matches the semantics of
822 // ThreadProxy::SetNeedsCommit where SetNeedsCommit will not cause a 814 // ThreadProxy::SetNeedsCommit where SetNeedsCommit will not cause a
823 // synchronous commit. 815 // synchronous commit.
824 #if DCHECK_IS_ON()
825 DCHECK(inside_impl_frame_) 816 DCHECK(inside_impl_frame_)
826 << "BeginMainFrame should only be sent inside a BeginImplFrame"; 817 << "BeginMainFrame should only be sent inside a BeginImplFrame";
827 #endif
828 const BeginFrameArgs& begin_frame_args = 818 const BeginFrameArgs& begin_frame_args =
829 layer_tree_host_impl_->CurrentBeginFrameArgs(); 819 layer_tree_host_impl_->CurrentBeginFrameArgs();
830 820
831 MainThreadTaskRunner()->PostTask( 821 MainThreadTaskRunner()->PostTask(
832 FROM_HERE, base::Bind(&SingleThreadProxy::BeginMainFrame, 822 FROM_HERE, base::Bind(&SingleThreadProxy::BeginMainFrame,
833 weak_factory_.GetWeakPtr(), begin_frame_args)); 823 weak_factory_.GetWeakPtr(), begin_frame_args));
834 } 824 }
835 825
836 void SingleThreadProxy::SendBeginMainFrameNotExpectedSoon() { 826 void SingleThreadProxy::SendBeginMainFrameNotExpectedSoon() {
837 layer_tree_host_->BeginMainFrameNotExpectedSoon(); 827 layer_tree_host_->BeginMainFrameNotExpectedSoon();
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 } 971 }
982 972
983 base::TimeDelta SingleThreadProxy::BeginMainFrameToCommitDurationEstimate() { 973 base::TimeDelta SingleThreadProxy::BeginMainFrameToCommitDurationEstimate() {
984 return timing_history_.BeginMainFrameToCommitDurationEstimate(); 974 return timing_history_.BeginMainFrameToCommitDurationEstimate();
985 } 975 }
986 976
987 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { 977 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() {
988 return timing_history_.CommitToActivateDurationEstimate(); 978 return timing_history_.CommitToActivateDurationEstimate();
989 } 979 }
990 980
991 void SingleThreadProxy::DidFinishImplFrame() { 981 void SingleThreadProxy::DidBeginImplFrameDeadline() {
992 layer_tree_host_impl_->DidFinishImplFrame(); 982 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame();
993 #if DCHECK_IS_ON()
994 DCHECK(inside_impl_frame_) 983 DCHECK(inside_impl_frame_)
995 << "DidBeginImplFrameDeadline called while not inside an impl frame!"; 984 << "DidBeginImplFrameDeadline called while not inside an impl frame!";
996 inside_impl_frame_ = false; 985 inside_impl_frame_ = false;
997 #endif
998 } 986 }
999 987
1000 void SingleThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) { 988 void SingleThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) {
1001 layer_tree_host_->SendBeginFramesToChildren(args); 989 layer_tree_host_->SendBeginFramesToChildren(args);
1002 } 990 }
1003 991
1004 } // namespace cc 992 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/single_thread_proxy.h ('k') | cc/trees/thread_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698