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

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

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

Powered by Google App Engine
This is Rietveld 408576698