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

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

Issue 1192663005: cc: Measure compositor timing with finer granularity (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@modeTimingHistory3
Patch Set: fixes Created 5 years, 6 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
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 24 matching lines...) Expand all
35 } 35 }
36 36
37 SingleThreadProxy::SingleThreadProxy( 37 SingleThreadProxy::SingleThreadProxy(
38 LayerTreeHost* layer_tree_host, 38 LayerTreeHost* layer_tree_host,
39 LayerTreeHostSingleThreadClient* client, 39 LayerTreeHostSingleThreadClient* client,
40 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 40 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
41 scoped_ptr<BeginFrameSource> external_begin_frame_source) 41 scoped_ptr<BeginFrameSource> external_begin_frame_source)
42 : Proxy(main_task_runner, NULL), 42 : Proxy(main_task_runner, NULL),
43 layer_tree_host_(layer_tree_host), 43 layer_tree_host_(layer_tree_host),
44 client_(client), 44 client_(client),
45 timing_history_(layer_tree_host->rendering_stats_instrumentation()),
46 next_frame_is_newly_committed_frame_(false), 45 next_frame_is_newly_committed_frame_(false),
47 #if DCHECK_IS_ON() 46 #if DCHECK_IS_ON()
48 inside_impl_frame_(false), 47 inside_impl_frame_(false),
49 #endif 48 #endif
50 inside_draw_(false), 49 inside_draw_(false),
51 defer_commits_(false), 50 defer_commits_(false),
52 animate_requested_(false), 51 animate_requested_(false),
53 commit_requested_(false), 52 commit_requested_(false),
54 inside_synchronous_composite_(false), 53 inside_synchronous_composite_(false),
55 output_surface_creation_requested_(false), 54 output_surface_creation_requested_(false),
56 weak_factory_(this) { 55 weak_factory_(this) {
57 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy"); 56 TRACE_EVENT0("cc", "SingleThreadProxy::SingleThreadProxy");
58 DCHECK(Proxy::IsMainThread()); 57 DCHECK(Proxy::IsMainThread());
59 DCHECK(layer_tree_host); 58 DCHECK(layer_tree_host);
60 59
61 if (layer_tree_host->settings().single_thread_proxy_scheduler && 60 if (layer_tree_host->settings().single_thread_proxy_scheduler &&
62 !scheduler_on_impl_thread_) { 61 !scheduler_on_impl_thread_) {
63 SchedulerSettings scheduler_settings( 62 SchedulerSettings scheduler_settings(
64 layer_tree_host->settings().ToSchedulerSettings()); 63 layer_tree_host->settings().ToSchedulerSettings());
65 // SingleThreadProxy should run in main thread low latency mode. 64 // SingleThreadProxy should run in main thread low latency mode.
66 scheduler_settings.main_thread_should_always_be_low_latency = true; 65 scheduler_settings.main_thread_should_always_be_low_latency = true;
67 scheduler_on_impl_thread_ = Scheduler::Create( 66 scheduler_on_impl_thread_ = Scheduler::Create(
68 this, scheduler_settings, layer_tree_host_->id(), 67 this, scheduler_settings, layer_tree_host_->id(),
69 MainThreadTaskRunner(), external_begin_frame_source.Pass()); 68 MainThreadTaskRunner(), external_begin_frame_source.Pass(),
69 layer_tree_host->rendering_stats_instrumentation());
70 } 70 }
71 } 71 }
72 72
73 void SingleThreadProxy::Start() { 73 void SingleThreadProxy::Start() {
74 DebugScopedSetImplThread impl(this); 74 DebugScopedSetImplThread impl(this);
75 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); 75 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this);
76 } 76 }
77 77
78 SingleThreadProxy::~SingleThreadProxy() { 78 SingleThreadProxy::~SingleThreadProxy() {
79 TRACE_EVENT0("cc", "SingleThreadProxy::~SingleThreadProxy"); 79 TRACE_EVENT0("cc", "SingleThreadProxy::~SingleThreadProxy");
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 CommitComplete(); 318 CommitComplete();
319 } 319 }
320 } 320 }
321 } 321 }
322 322
323 void SingleThreadProxy::CommitComplete() { 323 void SingleThreadProxy::CommitComplete() {
324 DCHECK(!layer_tree_host_impl_->pending_tree()) 324 DCHECK(!layer_tree_host_impl_->pending_tree())
325 << "Activation is expected to have synchronously occurred by now."; 325 << "Activation is expected to have synchronously occurred by now.";
326 DCHECK(commit_blocking_task_runner_); 326 DCHECK(commit_blocking_task_runner_);
327 327
328 if (scheduler_on_impl_thread_)
329 scheduler_on_impl_thread_->DidCommit();
330
328 // Notify commit complete on the impl side after activate to satisfy any 331 // Notify commit complete on the impl side after activate to satisfy any
329 // SetNextCommitWaitsForActivation calls. 332 // SetNextCommitWaitsForActivation calls.
330 layer_tree_host_impl_->CommitComplete(); 333 layer_tree_host_impl_->CommitComplete();
331 334
332 DebugScopedSetMainThread main(this); 335 DebugScopedSetMainThread main(this);
333 commit_blocking_task_runner_.reset(); 336 commit_blocking_task_runner_.reset();
334 layer_tree_host_->CommitComplete(); 337 layer_tree_host_->CommitComplete();
335 layer_tree_host_->DidBeginMainFrame(); 338 layer_tree_host_->DidBeginMainFrame();
336 timing_history_.DidCommit();
337 339
338 next_frame_is_newly_committed_frame_ = true; 340 next_frame_is_newly_committed_frame_ = true;
339 } 341 }
340 342
341 void SingleThreadProxy::SetNeedsCommit() { 343 void SingleThreadProxy::SetNeedsCommit() {
342 DCHECK(Proxy::IsMainThread()); 344 DCHECK(Proxy::IsMainThread());
343 client_->ScheduleComposite(); 345 client_->ScheduleComposite();
344 if (commit_requested_) 346 if (commit_requested_)
345 return; 347 return;
346 commit_requested_ = true; 348 commit_requested_ = true;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 // This is required because NotifyReadyToActivate gets called immediately 511 // This is required because NotifyReadyToActivate gets called immediately
510 // after commit since single thread commits directly to the active tree. 512 // after commit since single thread commits directly to the active tree.
511 if (scheduler_on_impl_thread_) 513 if (scheduler_on_impl_thread_)
512 scheduler_on_impl_thread_->SetWaitForReadyToDraw(); 514 scheduler_on_impl_thread_->SetWaitForReadyToDraw();
513 515
514 // Synchronously call to CommitComplete. Resetting 516 // Synchronously call to CommitComplete. Resetting
515 // |commit_blocking_task_runner| would make sure all tasks posted during 517 // |commit_blocking_task_runner| would make sure all tasks posted during
516 // commit/activation before CommitComplete. 518 // commit/activation before CommitComplete.
517 CommitComplete(); 519 CommitComplete();
518 } 520 }
521 }
519 522
520 timing_history_.DidActivateSyncTree(); 523 void SingleThreadProxy::WillPrepareTiles() {
524 DCHECK(layer_tree_host_impl_->settings().impl_side_painting);
525 DCHECK(Proxy::IsImplThread());
526 if (scheduler_on_impl_thread_)
527 scheduler_on_impl_thread_->WillPrepareTiles();
521 } 528 }
522 529
523 void SingleThreadProxy::DidPrepareTiles() { 530 void SingleThreadProxy::DidPrepareTiles() {
524 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); 531 DCHECK(layer_tree_host_impl_->settings().impl_side_painting);
525 DCHECK(Proxy::IsImplThread()); 532 DCHECK(Proxy::IsImplThread());
526 if (scheduler_on_impl_thread_) 533 if (scheduler_on_impl_thread_)
527 scheduler_on_impl_thread_->DidPrepareTiles(); 534 scheduler_on_impl_thread_->DidPrepareTiles();
528 } 535 }
529 536
530 void SingleThreadProxy::DidCompletePageScaleAnimationOnImplThread() { 537 void SingleThreadProxy::DidCompletePageScaleAnimationOnImplThread() {
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 "461509 SingleThreadProxy::DoComposite1")); 710 "461509 SingleThreadProxy::DoComposite1"));
704 711
705 // We guard PrepareToDraw() with CanDraw() because it always returns a valid 712 // We guard PrepareToDraw() with CanDraw() because it always returns a valid
706 // frame, so can only be used when such a frame is possible. Since 713 // frame, so can only be used when such a frame is possible. Since
707 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on 714 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on
708 // CanDraw() as well. 715 // CanDraw() as well.
709 if (!ShouldComposite()) { 716 if (!ShouldComposite()) {
710 return DRAW_ABORTED_CANT_DRAW; 717 return DRAW_ABORTED_CANT_DRAW;
711 } 718 }
712 719
713 timing_history_.DidStartDrawing();
714
715 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 720 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509
716 // is fixed. 721 // is fixed.
717 tracked_objects::ScopedTracker tracking_profile2( 722 tracked_objects::ScopedTracker tracking_profile2(
718 FROM_HERE_WITH_EXPLICIT_FUNCTION( 723 FROM_HERE_WITH_EXPLICIT_FUNCTION(
719 "461509 SingleThreadProxy::DoComposite2")); 724 "461509 SingleThreadProxy::DoComposite2"));
720 draw_result = layer_tree_host_impl_->PrepareToDraw(frame); 725 draw_result = layer_tree_host_impl_->PrepareToDraw(frame);
721 draw_frame = draw_result == DRAW_SUCCESS; 726 draw_frame = draw_result == DRAW_SUCCESS;
722 if (draw_frame) { 727 if (draw_frame) {
723 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 728 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509
724 // is fixed. 729 // is fixed.
(...skipping 15 matching lines...) Expand all
740 tracked_objects::ScopedTracker tracking_profile5( 745 tracked_objects::ScopedTracker tracking_profile5(
741 FROM_HERE_WITH_EXPLICIT_FUNCTION( 746 FROM_HERE_WITH_EXPLICIT_FUNCTION(
742 "461509 SingleThreadProxy::DoComposite5")); 747 "461509 SingleThreadProxy::DoComposite5"));
743 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations); 748 layer_tree_host_impl_->UpdateAnimationState(start_ready_animations);
744 749
745 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 750 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509
746 // is fixed. 751 // is fixed.
747 tracked_objects::ScopedTracker tracking_profile7( 752 tracked_objects::ScopedTracker tracking_profile7(
748 FROM_HERE_WITH_EXPLICIT_FUNCTION( 753 FROM_HERE_WITH_EXPLICIT_FUNCTION(
749 "461509 SingleThreadProxy::DoComposite7")); 754 "461509 SingleThreadProxy::DoComposite7"));
750 timing_history_.DidFinishDrawing();
751 } 755 }
752 756
753 if (draw_frame) { 757 if (draw_frame) {
754 DebugScopedSetImplThread impl(this); 758 DebugScopedSetImplThread impl(this);
755 759
756 // This CapturePostTasks should be destroyed before 760 // This CapturePostTasks should be destroyed before
757 // DidCommitAndDrawFrame() is called since that goes out to the 761 // DidCommitAndDrawFrame() is called since that goes out to the
758 // embedder, 762 // embedder,
759 // and we want the embedder to receive its callbacks before that. 763 // and we want the embedder to receive its callbacks before that.
760 // NOTE: This maintains consistent ordering with the ThreadProxy since 764 // NOTE: This maintains consistent ordering with the ThreadProxy since
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 } 903 }
900 904
901 DCHECK(!queue_for_commit_); 905 DCHECK(!queue_for_commit_);
902 queue_for_commit_ = make_scoped_ptr(new ResourceUpdateQueue); 906 queue_for_commit_ = make_scoped_ptr(new ResourceUpdateQueue);
903 907
904 // New commits requested inside UpdateLayers should be respected. 908 // New commits requested inside UpdateLayers should be respected.
905 commit_requested_ = false; 909 commit_requested_ = false;
906 910
907 layer_tree_host_->UpdateLayers(queue_for_commit_.get()); 911 layer_tree_host_->UpdateLayers(queue_for_commit_.get());
908 912
909 timing_history_.DidBeginMainFrame();
910
911 // TODO(enne): SingleThreadProxy does not support cancelling commits yet, 913 // TODO(enne): SingleThreadProxy does not support cancelling commits yet,
912 // search for CommitEarlyOutReason::FINISHED_NO_UPDATES inside 914 // search for CommitEarlyOutReason::FINISHED_NO_UPDATES inside
913 // thread_proxy.cc 915 // thread_proxy.cc
914 if (scheduler_on_impl_thread_) { 916 if (scheduler_on_impl_thread_) {
915 scheduler_on_impl_thread_->NotifyBeginMainFrameStarted(); 917 scheduler_on_impl_thread_->NotifyBeginMainFrameStarted();
916 scheduler_on_impl_thread_->NotifyReadyToCommit(); 918 scheduler_on_impl_thread_->NotifyReadyToCommit();
917 } 919 }
918 } 920 }
919 921
920 void SingleThreadProxy::BeginMainFrameAbortedOnImplThread( 922 void SingleThreadProxy::BeginMainFrameAbortedOnImplThread(
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 layer_tree_host_impl_->PrepareTiles(); 977 layer_tree_host_impl_->PrepareTiles();
976 } 978 }
977 979
978 void SingleThreadProxy::ScheduledActionInvalidateOutputSurface() { 980 void SingleThreadProxy::ScheduledActionInvalidateOutputSurface() {
979 NOTREACHED(); 981 NOTREACHED();
980 } 982 }
981 983
982 void SingleThreadProxy::DidAnticipatedDrawTimeChange(base::TimeTicks time) { 984 void SingleThreadProxy::DidAnticipatedDrawTimeChange(base::TimeTicks time) {
983 } 985 }
984 986
985 base::TimeDelta SingleThreadProxy::DrawDurationEstimate() {
986 return timing_history_.DrawDurationEstimate();
987 }
988
989 base::TimeDelta SingleThreadProxy::BeginMainFrameToCommitDurationEstimate() {
990 return timing_history_.BeginMainFrameToCommitDurationEstimate();
991 }
992
993 base::TimeDelta SingleThreadProxy::CommitToActivateDurationEstimate() {
994 return timing_history_.CommitToActivateDurationEstimate();
995 }
996
997 void SingleThreadProxy::DidFinishImplFrame() { 987 void SingleThreadProxy::DidFinishImplFrame() {
998 layer_tree_host_impl_->DidFinishImplFrame(); 988 layer_tree_host_impl_->DidFinishImplFrame();
999 #if DCHECK_IS_ON() 989 #if DCHECK_IS_ON()
1000 DCHECK(inside_impl_frame_) 990 DCHECK(inside_impl_frame_)
1001 << "DidFinishImplFrame called while not inside an impl frame!"; 991 << "DidFinishImplFrame called while not inside an impl frame!";
1002 inside_impl_frame_ = false; 992 inside_impl_frame_ = false;
1003 #endif 993 #endif
1004 } 994 }
1005 995
1006 void SingleThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) { 996 void SingleThreadProxy::SendBeginFramesToChildren(const BeginFrameArgs& args) {
1007 layer_tree_host_->SendBeginFramesToChildren(args); 997 layer_tree_host_->SendBeginFramesToChildren(args);
1008 } 998 }
1009 999
1010 } // namespace cc 1000 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698