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

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

Issue 1053653008: cc: Get BeginFrameArgs for BeginMainFrame while inside an impl frame. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing timing around reading BFAs in scheduler flow. Created 5 years, 8 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') | 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/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 inside_impl_frame_(false),
48 inside_draw_(false), 49 inside_draw_(false),
49 defer_commits_(false), 50 defer_commits_(false),
50 commit_requested_(false), 51 commit_requested_(false),
51 inside_synchronous_composite_(false), 52 inside_synchronous_composite_(false),
52 output_surface_creation_requested_(false), 53 output_surface_creation_requested_(false),
53 weak_factory_(this) { 54 weak_factory_(this) {
54 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); 55 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy");
55 DCHECK(Proxy::IsMainThread()); 56 DCHECK(Proxy::IsMainThread());
56 DCHECK(layer_tree_host); 57 DCHECK(layer_tree_host);
57 58
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 scheduler_on_impl_thread_->SetChildrenNeedBeginFrames( 779 scheduler_on_impl_thread_->SetChildrenNeedBeginFrames(
779 children_need_begin_frames); 780 children_need_begin_frames);
780 } 781 }
781 782
782 void SingleThreadProxy::SetAuthoritativeVSyncInterval( 783 void SingleThreadProxy::SetAuthoritativeVSyncInterval(
783 const base::TimeDelta& interval) { 784 const base::TimeDelta& interval) {
784 scheduler_on_impl_thread_->SetAuthoritativeVSyncInterval(interval); 785 scheduler_on_impl_thread_->SetAuthoritativeVSyncInterval(interval);
785 } 786 }
786 787
787 void SingleThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { 788 void SingleThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) {
789 DCHECK(!inside_impl_frame_)
790 << "WillBeginImplFrame called while already inside an impl frame!";
791 inside_impl_frame_ = true;
788 layer_tree_host_impl_->WillBeginImplFrame(args); 792 layer_tree_host_impl_->WillBeginImplFrame(args);
789 } 793 }
790 794
791 void SingleThreadProxy::ScheduledActionSendBeginMainFrame() { 795 void SingleThreadProxy::ScheduledActionSendBeginMainFrame() {
792 TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionSendBeginMainFrame"); 796 TRACE_EVENT0("cc", "SingleThreadProxy::ScheduledActionSendBeginMainFrame");
793 // Although this proxy is single-threaded, it's problematic to synchronously 797 // Although this proxy is single-threaded, it's problematic to synchronously
794 // have BeginMainFrame happen after ScheduledActionSendBeginMainFrame. This 798 // have BeginMainFrame happen after ScheduledActionSendBeginMainFrame. This
795 // could cause a commit to occur in between a series of SetNeedsCommit calls 799 // could cause a commit to occur in between a series of SetNeedsCommit calls
796 // (i.e. property modifications) causing some to fall on one frame and some to 800 // (i.e. property modifications) causing some to fall on one frame and some to
797 // fall on the next. Doing it asynchronously instead matches the semantics of 801 // fall on the next. Doing it asynchronously instead matches the semantics of
798 // ThreadProxy::SetNeedsCommit where SetNeedsCommit will not cause a 802 // ThreadProxy::SetNeedsCommit where SetNeedsCommit will not cause a
799 // synchronous commit. 803 // synchronous commit.
804 DCHECK(inside_impl_frame_)
805 << "BeginMainFrame should only be sent inside a BeginImplFrame";
806 const BeginFrameArgs& begin_frame_args =
807 layer_tree_host_impl_->CurrentBeginFrameArgs();
808
800 MainThreadTaskRunner()->PostTask( 809 MainThreadTaskRunner()->PostTask(
801 FROM_HERE, 810 FROM_HERE, base::Bind(&SingleThreadProxy::BeginMainFrame,
802 base::Bind(&SingleThreadProxy::BeginMainFrame, 811 weak_factory_.GetWeakPtr(), begin_frame_args));
803 weak_factory_.GetWeakPtr()));
804 } 812 }
805 813
806 void SingleThreadProxy::SendBeginMainFrameNotExpectedSoon() { 814 void SingleThreadProxy::SendBeginMainFrameNotExpectedSoon() {
807 layer_tree_host_->BeginMainFrameNotExpectedSoon(); 815 layer_tree_host_->BeginMainFrameNotExpectedSoon();
808 } 816 }
809 817
810 void SingleThreadProxy::BeginMainFrame() { 818 void SingleThreadProxy::BeginMainFrame(const BeginFrameArgs& begin_frame_args) {
811 commit_requested_ = false; 819 commit_requested_ = false;
812 820
813 if (defer_commits_) { 821 if (defer_commits_) {
814 TRACE_EVENT_INSTANT0("cc", "EarlyOut_DeferCommit", 822 TRACE_EVENT_INSTANT0("cc", "EarlyOut_DeferCommit",
815 TRACE_EVENT_SCOPE_THREAD); 823 TRACE_EVENT_SCOPE_THREAD);
816 BeginMainFrameAbortedOnImplThread( 824 BeginMainFrameAbortedOnImplThread(
817 CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT); 825 CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT);
818 return; 826 return;
819 } 827 }
820 828
(...skipping 12 matching lines...) Expand all
833 TRACE_EVENT_INSTANT0( 841 TRACE_EVENT_INSTANT0(
834 "cc", "EarlyOut_OutputSurfaceLost", TRACE_EVENT_SCOPE_THREAD); 842 "cc", "EarlyOut_OutputSurfaceLost", TRACE_EVENT_SCOPE_THREAD);
835 BeginMainFrameAbortedOnImplThread( 843 BeginMainFrameAbortedOnImplThread(
836 CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST); 844 CommitEarlyOutReason::ABORTED_OUTPUT_SURFACE_LOST);
837 return; 845 return;
838 } 846 }
839 847
840 // Prevent new commits from being requested inside DoBeginMainFrame. 848 // Prevent new commits from being requested inside DoBeginMainFrame.
841 commit_requested_ = true; 849 commit_requested_ = true;
842 850
843 const BeginFrameArgs& begin_frame_args =
844 layer_tree_host_impl_->CurrentBeginFrameArgs();
845 DoBeginMainFrame(begin_frame_args); 851 DoBeginMainFrame(begin_frame_args);
846 } 852 }
847 853
848 void SingleThreadProxy::DoBeginMainFrame( 854 void SingleThreadProxy::DoBeginMainFrame(
849 const BeginFrameArgs& begin_frame_args) { 855 const BeginFrameArgs& begin_frame_args) {
850 layer_tree_host_->WillBeginMainFrame(); 856 layer_tree_host_->WillBeginMainFrame();
851 layer_tree_host_->BeginMainFrame(begin_frame_args); 857 layer_tree_host_->BeginMainFrame(begin_frame_args);
852 layer_tree_host_->AnimateLayers(begin_frame_args.frame_time); 858 layer_tree_host_->AnimateLayers(begin_frame_args.frame_time);
853 layer_tree_host_->Layout(); 859 layer_tree_host_->Layout();
854 860
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 base::TimeDelta SingleThreadProxy::BeginMainFrameToCommitDurationEstimate() { 959 base::TimeDelta SingleThreadProxy::BeginMainFrameToCommitDurationEstimate() {
954 return timing_history_.BeginMainFrameToCommitDurationEstimate(); 960 return timing_history_.BeginMainFrameToCommitDurationEstimate();
955 } 961 }
956 962
957 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() { 963 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() {
958 return timing_history_.CommitToActivateDurationEstimate(); 964 return timing_history_.CommitToActivateDurationEstimate();
959 } 965 }
960 966
961 void SingleThreadProxy::DidBeginImplFrameDeadline() { 967 void SingleThreadProxy::DidBeginImplFrameDeadline() {
962 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame(); 968 layer_tree_host_impl_->ResetCurrentBeginFrameArgsForNextFrame();
969 DCHECK(inside_impl_frame_)
970 << "DidBeginImplFrameDeadline called while not inside an impl frame!";
971 inside_impl_frame_ = false;
963 } 972 }
964 973
965 void SingleThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) { 974 void SingleThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) {
966 layer_tree_host_->SendBeginFramesToChildren(args); 975 layer_tree_host_->SendBeginFramesToChildren(args);
967 } 976 }
968 977
969 } // namespace cc 978 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/single_thread_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698