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

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

Issue 2317753002: cc: Abstract the LayerTreeHost. (Closed)
Patch Set: Rebase 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
« no previous file with comments | « cc/trees/proxy_main.cc ('k') | cc/trees/swap_promise_monitor.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/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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 DCHECK(task_runner_provider_); 56 DCHECK(task_runner_provider_);
57 DCHECK(task_runner_provider_->IsMainThread()); 57 DCHECK(task_runner_provider_->IsMainThread());
58 DCHECK(layer_tree_host); 58 DCHECK(layer_tree_host);
59 } 59 }
60 60
61 void SingleThreadProxy::Start( 61 void SingleThreadProxy::Start(
62 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { 62 std::unique_ptr<BeginFrameSource> external_begin_frame_source) {
63 DebugScopedSetImplThread impl(task_runner_provider_); 63 DebugScopedSetImplThread impl(task_runner_provider_);
64 external_begin_frame_source_ = std::move(external_begin_frame_source); 64 external_begin_frame_source_ = std::move(external_begin_frame_source);
65 65
66 if (layer_tree_host_->settings().single_thread_proxy_scheduler && 66 const LayerTreeSettings& settings = layer_tree_host_->GetSettings();
67 !scheduler_on_impl_thread_) { 67 if (settings.single_thread_proxy_scheduler && !scheduler_on_impl_thread_) {
68 SchedulerSettings scheduler_settings( 68 SchedulerSettings scheduler_settings(settings.ToSchedulerSettings());
69 layer_tree_host_->settings().ToSchedulerSettings());
70 scheduler_settings.commit_to_active_tree = CommitToActiveTree(); 69 scheduler_settings.commit_to_active_tree = CommitToActiveTree();
71 70
72 std::unique_ptr<CompositorTimingHistory> compositor_timing_history( 71 std::unique_ptr<CompositorTimingHistory> compositor_timing_history(
73 new CompositorTimingHistory( 72 new CompositorTimingHistory(
74 scheduler_settings.using_synchronous_renderer_compositor, 73 scheduler_settings.using_synchronous_renderer_compositor,
75 CompositorTimingHistory::BROWSER_UMA, 74 CompositorTimingHistory::BROWSER_UMA,
76 layer_tree_host_->rendering_stats_instrumentation())); 75 layer_tree_host_->rendering_stats_instrumentation()));
77 76
78 // BFS must either be external or come from the output surface. If 77 // BFS must either be external or come from the output surface. If
79 // external, it must be provided. If from the output surface, it must 78 // external, it must be provided. If from the output surface, it must
80 // not be provided. 79 // not be provided.
81 // TODO(enne): Make all BFS come from the output surface. 80 // TODO(enne): Make all BFS come from the output surface.
82 DCHECK(layer_tree_host_->settings().use_external_begin_frame_source ^ 81 DCHECK(settings.use_external_begin_frame_source ^
83 layer_tree_host_->settings().use_output_surface_begin_frame_source); 82 settings.use_output_surface_begin_frame_source);
84 DCHECK(!layer_tree_host_->settings().use_external_begin_frame_source || 83 DCHECK(!settings.use_external_begin_frame_source ||
85 external_begin_frame_source_); 84 external_begin_frame_source_);
86 DCHECK( 85 DCHECK(!settings.use_output_surface_begin_frame_source ||
87 !layer_tree_host_->settings().use_output_surface_begin_frame_source || 86 !external_begin_frame_source_);
88 !external_begin_frame_source_);
89 scheduler_on_impl_thread_ = 87 scheduler_on_impl_thread_ =
90 Scheduler::Create(this, scheduler_settings, layer_tree_host_->id(), 88 Scheduler::Create(this, scheduler_settings, layer_tree_host_->GetId(),
91 task_runner_provider_->MainThreadTaskRunner(), 89 task_runner_provider_->MainThreadTaskRunner(),
92 external_begin_frame_source_.get(), 90 external_begin_frame_source_.get(),
93 std::move(compositor_timing_history)); 91 std::move(compositor_timing_history));
94 } 92 }
95 93
96 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); 94 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this);
97 } 95 }
98 96
99 SingleThreadProxy::~SingleThreadProxy() { 97 SingleThreadProxy::~SingleThreadProxy() {
100 TRACE_EVENT0("cc", "SingleThreadProxy::~SingleThreadProxy"); 98 TRACE_EVENT0("cc", "SingleThreadProxy::~SingleThreadProxy");
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 void SingleThreadProxy::DoCommit() { 185 void SingleThreadProxy::DoCommit() {
188 TRACE_EVENT0("cc", "SingleThreadProxy::DoCommit"); 186 TRACE_EVENT0("cc", "SingleThreadProxy::DoCommit");
189 DCHECK(task_runner_provider_->IsMainThread()); 187 DCHECK(task_runner_provider_->IsMainThread());
190 188
191 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 is 189 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 is
192 // fixed. 190 // fixed.
193 tracked_objects::ScopedTracker tracking_profile1( 191 tracked_objects::ScopedTracker tracking_profile1(
194 FROM_HERE_WITH_EXPLICIT_FUNCTION("461509 SingleThreadProxy::DoCommit1")); 192 FROM_HERE_WITH_EXPLICIT_FUNCTION("461509 SingleThreadProxy::DoCommit1"));
195 layer_tree_host_->WillCommit(); 193 layer_tree_host_->WillCommit();
196 devtools_instrumentation::ScopedCommitTrace commit_task( 194 devtools_instrumentation::ScopedCommitTrace commit_task(
197 layer_tree_host_->id()); 195 layer_tree_host_->GetId());
198 196
199 // Commit immediately. 197 // Commit immediately.
200 { 198 {
201 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509 199 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/461509
202 // is fixed. 200 // is fixed.
203 tracked_objects::ScopedTracker tracking_profile2( 201 tracked_objects::ScopedTracker tracking_profile2(
204 FROM_HERE_WITH_EXPLICIT_FUNCTION( 202 FROM_HERE_WITH_EXPLICIT_FUNCTION(
205 "461509 SingleThreadProxy::DoCommit2")); 203 "461509 SingleThreadProxy::DoCommit2"));
206 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_); 204 DebugScopedSetMainThreadBlocked main_thread_blocked(task_runner_provider_);
207 DebugScopedSetImplThread impl(task_runner_provider_); 205 DebugScopedSetImplThread impl(task_runner_provider_);
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 // the output surface if already in BEGIN_IMPL_FRAME_STATE_IDLE. 448 // the output surface if already in BEGIN_IMPL_FRAME_STATE_IDLE.
451 layer_tree_host_->DidLoseOutputSurface(); 449 layer_tree_host_->DidLoseOutputSurface();
452 } 450 }
453 client_->DidAbortSwapBuffers(); 451 client_->DidAbortSwapBuffers();
454 if (scheduler_on_impl_thread_) 452 if (scheduler_on_impl_thread_)
455 scheduler_on_impl_thread_->DidLoseOutputSurface(); 453 scheduler_on_impl_thread_->DidLoseOutputSurface();
456 output_surface_lost_ = true; 454 output_surface_lost_ = true;
457 } 455 }
458 456
459 void SingleThreadProxy::SetBeginFrameSource(BeginFrameSource* source) { 457 void SingleThreadProxy::SetBeginFrameSource(BeginFrameSource* source) {
460 DCHECK(layer_tree_host_->settings().single_thread_proxy_scheduler); 458 DCHECK(layer_tree_host_->GetSettings().single_thread_proxy_scheduler);
461 // TODO(enne): this overrides any preexisting begin frame source. Those 459 // TODO(enne): this overrides any preexisting begin frame source. Those
462 // other sources will eventually be removed and this will be the only path. 460 // other sources will eventually be removed and this will be the only path.
463 if (!layer_tree_host_->settings().use_output_surface_begin_frame_source) 461 if (!layer_tree_host_->GetSettings().use_output_surface_begin_frame_source)
464 return; 462 return;
465 if (scheduler_on_impl_thread_) 463 if (scheduler_on_impl_thread_)
466 scheduler_on_impl_thread_->SetBeginFrameSource(source); 464 scheduler_on_impl_thread_->SetBeginFrameSource(source);
467 } 465 }
468 466
469 void SingleThreadProxy::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { 467 void SingleThreadProxy::SetEstimatedParentDrawTime(base::TimeDelta draw_time) {
470 if (scheduler_on_impl_thread_) 468 if (scheduler_on_impl_thread_)
471 scheduler_on_impl_thread_->SetEstimatedParentDrawTime(draw_time); 469 scheduler_on_impl_thread_->SetEstimatedParentDrawTime(draw_time);
472 } 470 }
473 471
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 TRACE_EVENT_SCOPE_THREAD); 722 TRACE_EVENT_SCOPE_THREAD);
725 BeginMainFrameAbortedOnImplThread( 723 BeginMainFrameAbortedOnImplThread(
726 CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT); 724 CommitEarlyOutReason::ABORTED_DEFERRED_COMMIT);
727 return; 725 return;
728 } 726 }
729 727
730 // This checker assumes NotifyReadyToCommit in this stack causes a synchronous 728 // This checker assumes NotifyReadyToCommit in this stack causes a synchronous
731 // commit. 729 // commit.
732 ScopedAbortRemainingSwapPromises swap_promise_checker(layer_tree_host_); 730 ScopedAbortRemainingSwapPromises swap_promise_checker(layer_tree_host_);
733 731
734 if (!layer_tree_host_->visible()) { 732 if (!layer_tree_host_->IsVisible()) {
735 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD); 733 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NotVisible", TRACE_EVENT_SCOPE_THREAD);
736 BeginMainFrameAbortedOnImplThread( 734 BeginMainFrameAbortedOnImplThread(
737 CommitEarlyOutReason::ABORTED_NOT_VISIBLE); 735 CommitEarlyOutReason::ABORTED_NOT_VISIBLE);
738 return; 736 return;
739 } 737 }
740 738
741 // Prevent new commits from being requested inside DoBeginMainFrame. 739 // Prevent new commits from being requested inside DoBeginMainFrame.
742 // Note: We do not want to prevent SetNeedsAnimate from requesting 740 // Note: We do not want to prevent SetNeedsAnimate from requesting
743 // a commit here. 741 // a commit here.
744 commit_requested_ = true; 742 commit_requested_ = true;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 void SingleThreadProxy::DidFinishImplFrame() { 837 void SingleThreadProxy::DidFinishImplFrame() {
840 layer_tree_host_impl_->DidFinishImplFrame(); 838 layer_tree_host_impl_->DidFinishImplFrame();
841 #if DCHECK_IS_ON() 839 #if DCHECK_IS_ON()
842 DCHECK(inside_impl_frame_) 840 DCHECK(inside_impl_frame_)
843 << "DidFinishImplFrame called while not inside an impl frame!"; 841 << "DidFinishImplFrame called while not inside an impl frame!";
844 inside_impl_frame_ = false; 842 inside_impl_frame_ = false;
845 #endif 843 #endif
846 } 844 }
847 845
848 } // namespace cc 846 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/proxy_main.cc ('k') | cc/trees/swap_promise_monitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698