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

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

Issue 2337913003: Fork cc::OutputSurface into cc::CompositorFrameSink. (Closed)
Patch Set: cfsfork: android-vulkan 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_impl.h ('k') | cc/trees/proxy_main.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/proxy_impl.h" 5 #include "cc/trees/proxy_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/trace_event/trace_event.h" 12 #include "base/trace_event/trace_event.h"
13 #include "base/trace_event/trace_event_argument.h" 13 #include "base/trace_event/trace_event_argument.h"
14 #include "base/trace_event/trace_event_synthetic_delay.h" 14 #include "base/trace_event/trace_event_synthetic_delay.h"
15 #include "cc/animation/animation_events.h" 15 #include "cc/animation/animation_events.h"
16 #include "cc/debug/benchmark_instrumentation.h" 16 #include "cc/debug/benchmark_instrumentation.h"
17 #include "cc/debug/devtools_instrumentation.h" 17 #include "cc/debug/devtools_instrumentation.h"
18 #include "cc/input/top_controls_manager.h" 18 #include "cc/input/top_controls_manager.h"
19 #include "cc/output/compositor_frame_sink.h"
19 #include "cc/output/context_provider.h" 20 #include "cc/output/context_provider.h"
20 #include "cc/output/output_surface.h"
21 #include "cc/scheduler/compositor_timing_history.h" 21 #include "cc/scheduler/compositor_timing_history.h"
22 #include "cc/scheduler/delay_based_time_source.h" 22 #include "cc/scheduler/delay_based_time_source.h"
23 #include "cc/trees/layer_tree_host.h" 23 #include "cc/trees/layer_tree_host.h"
24 #include "cc/trees/layer_tree_impl.h" 24 #include "cc/trees/layer_tree_impl.h"
25 #include "cc/trees/task_runner_provider.h" 25 #include "cc/trees/task_runner_provider.h"
26 #include "gpu/command_buffer/client/gles2_interface.h" 26 #include "gpu/command_buffer/client/gles2_interface.h"
27 27
28 namespace cc { 28 namespace cc {
29 29
30 namespace { 30 namespace {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 SchedulerSettings scheduler_settings(settings.ToSchedulerSettings()); 72 SchedulerSettings scheduler_settings(settings.ToSchedulerSettings());
73 73
74 std::unique_ptr<CompositorTimingHistory> compositor_timing_history( 74 std::unique_ptr<CompositorTimingHistory> compositor_timing_history(
75 new CompositorTimingHistory( 75 new CompositorTimingHistory(
76 scheduler_settings.using_synchronous_renderer_compositor, 76 scheduler_settings.using_synchronous_renderer_compositor,
77 CompositorTimingHistory::RENDERER_UMA, 77 CompositorTimingHistory::RENDERER_UMA,
78 rendering_stats_instrumentation_)); 78 rendering_stats_instrumentation_));
79 79
80 // TODO(enne): remove these settings. 80 // TODO(enne): remove these settings.
81 DCHECK(!settings.use_external_begin_frame_source); 81 DCHECK(!settings.use_external_begin_frame_source);
82 DCHECK(settings.use_output_surface_begin_frame_source); 82 DCHECK(settings.use_compositor_frame_sink_begin_frame_source);
83 scheduler_ = Scheduler::Create(this, scheduler_settings, layer_tree_host_id_, 83 scheduler_ = Scheduler::Create(this, scheduler_settings, layer_tree_host_id_,
84 task_runner_provider_->ImplThreadTaskRunner(), 84 task_runner_provider_->ImplThreadTaskRunner(),
85 external_begin_frame_source_.get(), 85 external_begin_frame_source_.get(),
86 std::move(compositor_timing_history)); 86 std::move(compositor_timing_history));
87 87
88 DCHECK_EQ(scheduler_->visible(), layer_tree_host_impl_->visible()); 88 DCHECK_EQ(scheduler_->visible(), layer_tree_host_impl_->visible());
89 } 89 }
90 90
91 ProxyImpl::BlockedMainCommitOnly::BlockedMainCommitOnly() 91 ProxyImpl::BlockedMainCommitOnly::BlockedMainCommitOnly()
92 : layer_tree_host(nullptr) {} 92 : layer_tree_host(nullptr) {}
93 93
94 ProxyImpl::BlockedMainCommitOnly::~BlockedMainCommitOnly() {} 94 ProxyImpl::BlockedMainCommitOnly::~BlockedMainCommitOnly() {}
95 95
96 ProxyImpl::~ProxyImpl() { 96 ProxyImpl::~ProxyImpl() {
97 TRACE_EVENT0("cc", "ProxyImpl::~ProxyImpl"); 97 TRACE_EVENT0("cc", "ProxyImpl::~ProxyImpl");
98 DCHECK(IsImplThread()); 98 DCHECK(IsImplThread());
99 DCHECK(IsMainThreadBlocked()); 99 DCHECK(IsMainThreadBlocked());
100 100
101 // Take away the OutputSurface before destroying things so it doesn't try 101 // Take away the CompositorFrameSink before destroying things so it doesn't
102 // to call into its client mid-shutdown. 102 // try to call into its client mid-shutdown.
103 scheduler_->DidLoseOutputSurface(); 103 scheduler_->DidLoseCompositorFrameSink();
104 layer_tree_host_impl_->ReleaseOutputSurface(); 104 layer_tree_host_impl_->ReleaseCompositorFrameSink();
105 105
106 scheduler_ = nullptr; 106 scheduler_ = nullptr;
107 external_begin_frame_source_ = nullptr; 107 external_begin_frame_source_ = nullptr;
108 layer_tree_host_impl_ = nullptr; 108 layer_tree_host_impl_ = nullptr;
109 // We need to explicitly shutdown the notifier to destroy any weakptrs it is 109 // We need to explicitly shutdown the notifier to destroy any weakptrs it is
110 // holding while still on the compositor thread. This also ensures any 110 // holding while still on the compositor thread. This also ensures any
111 // callbacks holding a ProxyImpl pointer are cancelled. 111 // callbacks holding a ProxyImpl pointer are cancelled.
112 smoothness_priority_expiration_notifier_.Shutdown(); 112 smoothness_priority_expiration_notifier_.Shutdown();
113 } 113 }
114 114
115 void ProxyImpl::InitializeMutatorOnImpl( 115 void ProxyImpl::InitializeMutatorOnImpl(
116 std::unique_ptr<LayerTreeMutator> mutator) { 116 std::unique_ptr<LayerTreeMutator> mutator) {
117 TRACE_EVENT0("cc,compositor-worker", "ProxyImpl::InitializeMutatorOnImpl"); 117 TRACE_EVENT0("cc,compositor-worker", "ProxyImpl::InitializeMutatorOnImpl");
118 DCHECK(IsImplThread()); 118 DCHECK(IsImplThread());
119 layer_tree_host_impl_->SetLayerTreeMutator(std::move(mutator)); 119 layer_tree_host_impl_->SetLayerTreeMutator(std::move(mutator));
120 } 120 }
121 121
122 void ProxyImpl::UpdateTopControlsStateOnImpl(TopControlsState constraints, 122 void ProxyImpl::UpdateTopControlsStateOnImpl(TopControlsState constraints,
123 TopControlsState current, 123 TopControlsState current,
124 bool animate) { 124 bool animate) {
125 DCHECK(IsImplThread()); 125 DCHECK(IsImplThread());
126 layer_tree_host_impl_->top_controls_manager()->UpdateTopControlsState( 126 layer_tree_host_impl_->top_controls_manager()->UpdateTopControlsState(
127 constraints, current, animate); 127 constraints, current, animate);
128 } 128 }
129 129
130 void ProxyImpl::InitializeOutputSurfaceOnImpl(OutputSurface* output_surface) { 130 void ProxyImpl::InitializeCompositorFrameSinkOnImpl(
131 TRACE_EVENT0("cc", "ProxyImpl::InitializeOutputSurfaceOnImplThread"); 131 CompositorFrameSink* compositor_frame_sink) {
132 TRACE_EVENT0("cc", "ProxyImpl::InitializeCompositorFrameSinkOnImplThread");
132 DCHECK(IsImplThread()); 133 DCHECK(IsImplThread());
133 134
134 LayerTreeHostImpl* host_impl = layer_tree_host_impl_.get(); 135 LayerTreeHostImpl* host_impl = layer_tree_host_impl_.get();
135 bool success = host_impl->InitializeRenderer(output_surface); 136 bool success = host_impl->InitializeRenderer(compositor_frame_sink);
136 channel_impl_->DidInitializeOutputSurface(success); 137 channel_impl_->DidInitializeCompositorFrameSink(success);
137 if (success) 138 if (success)
138 scheduler_->DidCreateAndInitializeOutputSurface(); 139 scheduler_->DidCreateAndInitializeCompositorFrameSink();
139 } 140 }
140 141
141 void ProxyImpl::MainThreadHasStoppedFlingingOnImpl() { 142 void ProxyImpl::MainThreadHasStoppedFlingingOnImpl() {
142 DCHECK(IsImplThread()); 143 DCHECK(IsImplThread());
143 layer_tree_host_impl_->MainThreadHasStoppedFlinging(); 144 layer_tree_host_impl_->MainThreadHasStoppedFlinging();
144 } 145 }
145 146
146 void ProxyImpl::SetInputThrottledUntilCommitOnImpl(bool is_throttled) { 147 void ProxyImpl::SetInputThrottledUntilCommitOnImpl(bool is_throttled) {
147 DCHECK(IsImplThread()); 148 DCHECK(IsImplThread());
148 if (is_throttled == input_throttled_until_commit_) 149 if (is_throttled == input_throttled_until_commit_)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 scheduler_->BeginMainFrameAborted(reason); 185 scheduler_->BeginMainFrameAborted(reason);
185 } 186 }
186 187
187 void ProxyImpl::SetVisibleOnImpl(bool visible) { 188 void ProxyImpl::SetVisibleOnImpl(bool visible) {
188 TRACE_EVENT1("cc", "ProxyImpl::SetVisibleOnImplThread", "visible", visible); 189 TRACE_EVENT1("cc", "ProxyImpl::SetVisibleOnImplThread", "visible", visible);
189 DCHECK(IsImplThread()); 190 DCHECK(IsImplThread());
190 layer_tree_host_impl_->SetVisible(visible); 191 layer_tree_host_impl_->SetVisible(visible);
191 scheduler_->SetVisible(visible); 192 scheduler_->SetVisible(visible);
192 } 193 }
193 194
194 void ProxyImpl::ReleaseOutputSurfaceOnImpl(CompletionEvent* completion) { 195 void ProxyImpl::ReleaseCompositorFrameSinkOnImpl(CompletionEvent* completion) {
195 DCHECK(IsImplThread()); 196 DCHECK(IsImplThread());
196 197
197 // Unlike DidLoseOutputSurfaceOnImplThread, we don't need to call 198 // Unlike DidLoseCompositorFrameSinkOnImplThread, we don't need to call
198 // LayerTreeHost::DidLoseOutputSurface since it already knows. 199 // LayerTreeHost::DidLoseCompositorFrameSink since it already knows.
199 scheduler_->DidLoseOutputSurface(); 200 scheduler_->DidLoseCompositorFrameSink();
200 layer_tree_host_impl_->ReleaseOutputSurface(); 201 layer_tree_host_impl_->ReleaseCompositorFrameSink();
201 completion->Signal(); 202 completion->Signal();
202 } 203 }
203 204
204 void ProxyImpl::FinishGLOnImpl(CompletionEvent* completion) { 205 void ProxyImpl::FinishGLOnImpl(CompletionEvent* completion) {
205 TRACE_EVENT0("cc", "ProxyImpl::FinishGLOnImplThread"); 206 TRACE_EVENT0("cc", "ProxyImpl::FinishGLOnImplThread");
206 DCHECK(IsImplThread()); 207 DCHECK(IsImplThread());
207 if (layer_tree_host_impl_->output_surface()) { 208 if (layer_tree_host_impl_->compositor_frame_sink()) {
208 ContextProvider* context_provider = 209 ContextProvider* context_provider =
209 layer_tree_host_impl_->output_surface()->context_provider(); 210 layer_tree_host_impl_->compositor_frame_sink()->context_provider();
210 if (context_provider) 211 if (context_provider)
211 context_provider->ContextGL()->Finish(); 212 context_provider->ContextGL()->Finish();
212 } 213 }
213 completion->Signal(); 214 completion->Signal();
214 } 215 }
215 216
216 void ProxyImpl::MainFrameWillHappenOnImplForTesting( 217 void ProxyImpl::MainFrameWillHappenOnImplForTesting(
217 CompletionEvent* completion, 218 CompletionEvent* completion,
218 bool* main_frame_will_happen) { 219 bool* main_frame_will_happen) {
219 DCHECK(IsImplThread()); 220 DCHECK(IsImplThread());
220 if (layer_tree_host_impl_->output_surface()) { 221 if (layer_tree_host_impl_->compositor_frame_sink()) {
221 *main_frame_will_happen = scheduler_->MainFrameForTestingWillHappen(); 222 *main_frame_will_happen = scheduler_->MainFrameForTestingWillHappen();
222 } else { 223 } else {
223 *main_frame_will_happen = false; 224 *main_frame_will_happen = false;
224 } 225 }
225 completion->Signal(); 226 completion->Signal();
226 } 227 }
227 228
228 void ProxyImpl::NotifyReadyToCommitOnImpl( 229 void ProxyImpl::NotifyReadyToCommitOnImpl(
229 CompletionEvent* completion, 230 CompletionEvent* completion,
230 LayerTreeHost* layer_tree_host, 231 LayerTreeHost* layer_tree_host,
(...skipping 19 matching lines...) Expand all
250 layer_tree_host_impl_->ReadyToCommit(); 251 layer_tree_host_impl_->ReadyToCommit();
251 252
252 commit_completion_event_ = completion; 253 commit_completion_event_ = completion;
253 commit_completion_waits_for_activation_ = hold_commit_for_activation; 254 commit_completion_waits_for_activation_ = hold_commit_for_activation;
254 255
255 DCHECK(!blocked_main_commit().layer_tree_host); 256 DCHECK(!blocked_main_commit().layer_tree_host);
256 blocked_main_commit().layer_tree_host = layer_tree_host; 257 blocked_main_commit().layer_tree_host = layer_tree_host;
257 scheduler_->NotifyReadyToCommit(); 258 scheduler_->NotifyReadyToCommit();
258 } 259 }
259 260
260 void ProxyImpl::DidLoseOutputSurfaceOnImplThread() { 261 void ProxyImpl::DidLoseCompositorFrameSinkOnImplThread() {
261 TRACE_EVENT0("cc", "ProxyImpl::DidLoseOutputSurfaceOnImplThread"); 262 TRACE_EVENT0("cc", "ProxyImpl::DidLoseCompositorFrameSinkOnImplThread");
262 DCHECK(IsImplThread()); 263 DCHECK(IsImplThread());
263 channel_impl_->DidLoseOutputSurface(); 264 channel_impl_->DidLoseCompositorFrameSink();
264 scheduler_->DidLoseOutputSurface(); 265 scheduler_->DidLoseCompositorFrameSink();
265 } 266 }
266 267
267 void ProxyImpl::SetBeginFrameSource(BeginFrameSource* source) { 268 void ProxyImpl::SetBeginFrameSource(BeginFrameSource* source) {
268 // During shutdown, destroying the OutputSurface may unset the 269 // During shutdown, destroying the CompositorFrameSink may unset the
269 // BeginFrameSource. 270 // BeginFrameSource.
270 if (scheduler_) { 271 if (scheduler_) {
271 // TODO(enne): this overrides any preexisting begin frame source. Those 272 // TODO(enne): this overrides any preexisting begin frame source. Those
272 // other sources will eventually be removed and this will be the only path. 273 // other sources will eventually be removed and this will be the only path.
273 scheduler_->SetBeginFrameSource(source); 274 scheduler_->SetBeginFrameSource(source);
274 } 275 }
275 } 276 }
276 277
277 void ProxyImpl::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { 278 void ProxyImpl::SetEstimatedParentDrawTime(base::TimeDelta draw_time) {
278 DCHECK(IsImplThread()); 279 DCHECK(IsImplThread());
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 void ProxyImpl::DidPrepareTiles() { 425 void ProxyImpl::DidPrepareTiles() {
425 DCHECK(IsImplThread()); 426 DCHECK(IsImplThread());
426 scheduler_->DidPrepareTiles(); 427 scheduler_->DidPrepareTiles();
427 } 428 }
428 429
429 void ProxyImpl::DidCompletePageScaleAnimationOnImplThread() { 430 void ProxyImpl::DidCompletePageScaleAnimationOnImplThread() {
430 DCHECK(IsImplThread()); 431 DCHECK(IsImplThread());
431 channel_impl_->DidCompletePageScaleAnimation(); 432 channel_impl_->DidCompletePageScaleAnimation();
432 } 433 }
433 434
434 void ProxyImpl::OnDrawForOutputSurface(bool resourceless_software_draw) { 435 void ProxyImpl::OnDrawForCompositorFrameSink(bool resourceless_software_draw) {
435 DCHECK(IsImplThread()); 436 DCHECK(IsImplThread());
436 scheduler_->OnDrawForOutputSurface(resourceless_software_draw); 437 scheduler_->OnDrawForCompositorFrameSink(resourceless_software_draw);
437 } 438 }
438 439
439 void ProxyImpl::WillBeginImplFrame(const BeginFrameArgs& args) { 440 void ProxyImpl::WillBeginImplFrame(const BeginFrameArgs& args) {
440 DCHECK(IsImplThread()); 441 DCHECK(IsImplThread());
441 layer_tree_host_impl_->WillBeginImplFrame(args); 442 layer_tree_host_impl_->WillBeginImplFrame(args);
442 } 443 }
443 444
444 void ProxyImpl::DidFinishImplFrame() { 445 void ProxyImpl::DidFinishImplFrame() {
445 DCHECK(IsImplThread()); 446 DCHECK(IsImplThread());
446 layer_tree_host_impl_->DidFinishImplFrame(); 447 layer_tree_host_impl_->DidFinishImplFrame();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 524
524 next_frame_is_newly_committed_frame_ = true; 525 next_frame_is_newly_committed_frame_ = true;
525 } 526 }
526 527
527 void ProxyImpl::ScheduledActionActivateSyncTree() { 528 void ProxyImpl::ScheduledActionActivateSyncTree() {
528 TRACE_EVENT0("cc", "ProxyImpl::ScheduledActionActivateSyncTree"); 529 TRACE_EVENT0("cc", "ProxyImpl::ScheduledActionActivateSyncTree");
529 DCHECK(IsImplThread()); 530 DCHECK(IsImplThread());
530 layer_tree_host_impl_->ActivateSyncTree(); 531 layer_tree_host_impl_->ActivateSyncTree();
531 } 532 }
532 533
533 void ProxyImpl::ScheduledActionBeginOutputSurfaceCreation() { 534 void ProxyImpl::ScheduledActionBeginCompositorFrameSinkCreation() {
534 TRACE_EVENT0("cc", "ProxyImpl::ScheduledActionBeginOutputSurfaceCreation"); 535 TRACE_EVENT0("cc",
536 "ProxyImpl::ScheduledActionBeginCompositorFrameSinkCreation");
535 DCHECK(IsImplThread()); 537 DCHECK(IsImplThread());
536 channel_impl_->RequestNewOutputSurface(); 538 channel_impl_->RequestNewCompositorFrameSink();
537 } 539 }
538 540
539 void ProxyImpl::ScheduledActionPrepareTiles() { 541 void ProxyImpl::ScheduledActionPrepareTiles() {
540 TRACE_EVENT0("cc", "ProxyImpl::ScheduledActionPrepareTiles"); 542 TRACE_EVENT0("cc", "ProxyImpl::ScheduledActionPrepareTiles");
541 DCHECK(IsImplThread()); 543 DCHECK(IsImplThread());
542 layer_tree_host_impl_->PrepareTiles(); 544 layer_tree_host_impl_->PrepareTiles();
543 } 545 }
544 546
545 void ProxyImpl::ScheduledActionInvalidateOutputSurface() { 547 void ProxyImpl::ScheduledActionInvalidateCompositorFrameSink() {
546 TRACE_EVENT0("cc", "ProxyImpl::ScheduledActionInvalidateOutputSurface"); 548 TRACE_EVENT0("cc", "ProxyImpl::ScheduledActionInvalidateCompositorFrameSink");
547 DCHECK(IsImplThread()); 549 DCHECK(IsImplThread());
548 DCHECK(layer_tree_host_impl_->output_surface()); 550 DCHECK(layer_tree_host_impl_->compositor_frame_sink());
549 layer_tree_host_impl_->output_surface()->Invalidate(); 551 layer_tree_host_impl_->compositor_frame_sink()->Invalidate();
550 } 552 }
551 553
552 void ProxyImpl::SendBeginMainFrameNotExpectedSoon() { 554 void ProxyImpl::SendBeginMainFrameNotExpectedSoon() {
553 DCHECK(IsImplThread()); 555 DCHECK(IsImplThread());
554 channel_impl_->BeginMainFrameNotExpectedSoon(); 556 channel_impl_->BeginMainFrameNotExpectedSoon();
555 } 557 }
556 558
557 DrawResult ProxyImpl::DrawAndSwapInternal(bool forced_draw) { 559 DrawResult ProxyImpl::DrawAndSwapInternal(bool forced_draw) {
558 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); 560 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap");
559 561
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 bool ProxyImpl::IsMainThreadBlocked() const { 622 bool ProxyImpl::IsMainThreadBlocked() const {
621 return task_runner_provider_->IsMainThreadBlocked(); 623 return task_runner_provider_->IsMainThreadBlocked();
622 } 624 }
623 625
624 ProxyImpl::BlockedMainCommitOnly& ProxyImpl::blocked_main_commit() { 626 ProxyImpl::BlockedMainCommitOnly& ProxyImpl::blocked_main_commit() {
625 DCHECK(IsMainThreadBlocked() && commit_completion_event_); 627 DCHECK(IsMainThreadBlocked() && commit_completion_event_);
626 return main_thread_blocked_commit_vars_unsafe_; 628 return main_thread_blocked_commit_vars_unsafe_;
627 } 629 }
628 630
629 } // namespace cc 631 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/proxy_impl.h ('k') | cc/trees/proxy_main.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698