OLD | NEW |
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" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 70 |
71 SchedulerSettings scheduler_settings( | 71 SchedulerSettings scheduler_settings( |
72 layer_tree_host->settings().ToSchedulerSettings()); | 72 layer_tree_host->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 BeginFrameSource* frame_source = external_begin_frame_source_.get(); | 80 // BFS must either be external or come from the output surface. If |
81 if (!scheduler_settings.throttle_frame_production) { | 81 // external, it must be provided. If from the output surface, it must |
82 // Unthrottled source takes precedence over external sources. | 82 // not be provided. |
83 unthrottled_begin_frame_source_.reset( | 83 // TODO(enne): Make all BFS come from the output surface. |
84 new BackToBackBeginFrameSource(base::MakeUnique<DelayBasedTimeSource>( | 84 DCHECK(layer_tree_host->settings().use_external_begin_frame_source ^ |
85 task_runner_provider_->ImplThreadTaskRunner()))); | 85 layer_tree_host->settings().use_output_surface_begin_frame_source); |
86 frame_source = unthrottled_begin_frame_source_.get(); | 86 DCHECK(!layer_tree_host->settings().use_external_begin_frame_source || |
87 } | 87 external_begin_frame_source_); |
88 if (!frame_source) { | 88 DCHECK(!layer_tree_host->settings().use_output_surface_begin_frame_source || |
89 synthetic_begin_frame_source_.reset( | 89 !external_begin_frame_source_); |
90 new DelayBasedBeginFrameSource(base::MakeUnique<DelayBasedTimeSource>( | 90 scheduler_ = Scheduler::Create(this, scheduler_settings, layer_tree_host_id_, |
91 task_runner_provider_->ImplThreadTaskRunner()))); | 91 task_runner_provider_->ImplThreadTaskRunner(), |
92 frame_source = synthetic_begin_frame_source_.get(); | 92 external_begin_frame_source_.get(), |
93 } | 93 std::move(compositor_timing_history)); |
94 scheduler_ = | |
95 Scheduler::Create(this, scheduler_settings, layer_tree_host_id_, | |
96 task_runner_provider_->ImplThreadTaskRunner(), | |
97 frame_source, std::move(compositor_timing_history)); | |
98 | 94 |
99 DCHECK_EQ(scheduler_->visible(), layer_tree_host_impl_->visible()); | 95 DCHECK_EQ(scheduler_->visible(), layer_tree_host_impl_->visible()); |
100 } | 96 } |
101 | 97 |
102 ProxyImpl::BlockedMainCommitOnly::BlockedMainCommitOnly() | 98 ProxyImpl::BlockedMainCommitOnly::BlockedMainCommitOnly() |
103 : layer_tree_host(nullptr) {} | 99 : layer_tree_host(nullptr) {} |
104 | 100 |
105 ProxyImpl::BlockedMainCommitOnly::~BlockedMainCommitOnly() {} | 101 ProxyImpl::BlockedMainCommitOnly::~BlockedMainCommitOnly() {} |
106 | 102 |
107 ProxyImpl::~ProxyImpl() { | 103 ProxyImpl::~ProxyImpl() { |
108 TRACE_EVENT0("cc", "ProxyImpl::~ProxyImpl"); | 104 TRACE_EVENT0("cc", "ProxyImpl::~ProxyImpl"); |
109 DCHECK(IsImplThread()); | 105 DCHECK(IsImplThread()); |
110 DCHECK(IsMainThreadBlocked()); | 106 DCHECK(IsMainThreadBlocked()); |
111 | 107 |
112 // Take away the OutputSurface before destroying things so it doesn't try | 108 // Take away the OutputSurface before destroying things so it doesn't try |
113 // to call into its client mid-shutdown. | 109 // to call into its client mid-shutdown. |
114 scheduler_->DidLoseOutputSurface(); | 110 scheduler_->DidLoseOutputSurface(); |
115 layer_tree_host_impl_->ReleaseOutputSurface(); | 111 layer_tree_host_impl_->ReleaseOutputSurface(); |
116 | 112 |
117 scheduler_ = nullptr; | 113 scheduler_ = nullptr; |
118 external_begin_frame_source_ = nullptr; | 114 external_begin_frame_source_ = nullptr; |
119 unthrottled_begin_frame_source_ = nullptr; | |
120 synthetic_begin_frame_source_ = nullptr; | |
121 layer_tree_host_impl_ = nullptr; | 115 layer_tree_host_impl_ = nullptr; |
122 // We need to explicitly shutdown the notifier to destroy any weakptrs it is | 116 // We need to explicitly shutdown the notifier to destroy any weakptrs it is |
123 // holding while still on the compositor thread. This also ensures any | 117 // holding while still on the compositor thread. This also ensures any |
124 // callbacks holding a ProxyImpl pointer are cancelled. | 118 // callbacks holding a ProxyImpl pointer are cancelled. |
125 smoothness_priority_expiration_notifier_.Shutdown(); | 119 smoothness_priority_expiration_notifier_.Shutdown(); |
126 } | 120 } |
127 | 121 |
128 void ProxyImpl::InitializeMutatorOnImpl( | 122 void ProxyImpl::InitializeMutatorOnImpl( |
129 std::unique_ptr<LayerTreeMutator> mutator) { | 123 std::unique_ptr<LayerTreeMutator> mutator) { |
130 TRACE_EVENT0("cc,compositor-worker", "ProxyImpl::InitializeMutatorOnImpl"); | 124 TRACE_EVENT0("cc,compositor-worker", "ProxyImpl::InitializeMutatorOnImpl"); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 scheduler_->NotifyReadyToCommit(); | 264 scheduler_->NotifyReadyToCommit(); |
271 } | 265 } |
272 | 266 |
273 void ProxyImpl::DidLoseOutputSurfaceOnImplThread() { | 267 void ProxyImpl::DidLoseOutputSurfaceOnImplThread() { |
274 TRACE_EVENT0("cc", "ProxyImpl::DidLoseOutputSurfaceOnImplThread"); | 268 TRACE_EVENT0("cc", "ProxyImpl::DidLoseOutputSurfaceOnImplThread"); |
275 DCHECK(IsImplThread()); | 269 DCHECK(IsImplThread()); |
276 channel_impl_->DidLoseOutputSurface(); | 270 channel_impl_->DidLoseOutputSurface(); |
277 scheduler_->DidLoseOutputSurface(); | 271 scheduler_->DidLoseOutputSurface(); |
278 } | 272 } |
279 | 273 |
280 void ProxyImpl::CommitVSyncParameters(base::TimeTicks timebase, | |
281 base::TimeDelta interval) { | |
282 DCHECK(IsImplThread()); | |
283 if (synthetic_begin_frame_source_) | |
284 synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval); | |
285 } | |
286 | |
287 void ProxyImpl::SetBeginFrameSource(BeginFrameSource* source) { | 274 void ProxyImpl::SetBeginFrameSource(BeginFrameSource* source) { |
288 // During shutdown, destroying the OutputSurface may unset the | 275 // During shutdown, destroying the OutputSurface may unset the |
289 // BeginFrameSource. | 276 // BeginFrameSource. |
290 if (scheduler_) { | 277 if (scheduler_) { |
291 // TODO(enne): this overrides any preexisting begin frame source. Those | 278 // TODO(enne): this overrides any preexisting begin frame source. Those |
292 // other sources will eventually be removed and this will be the only path. | 279 // other sources will eventually be removed and this will be the only path. |
293 scheduler_->SetBeginFrameSource(source); | 280 scheduler_->SetBeginFrameSource(source); |
294 } | 281 } |
295 } | 282 } |
296 | 283 |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 bool ProxyImpl::IsMainThreadBlocked() const { | 632 bool ProxyImpl::IsMainThreadBlocked() const { |
646 return task_runner_provider_->IsMainThreadBlocked(); | 633 return task_runner_provider_->IsMainThreadBlocked(); |
647 } | 634 } |
648 | 635 |
649 ProxyImpl::BlockedMainCommitOnly& ProxyImpl::blocked_main_commit() { | 636 ProxyImpl::BlockedMainCommitOnly& ProxyImpl::blocked_main_commit() { |
650 DCHECK(IsMainThreadBlocked() && commit_completion_event_); | 637 DCHECK(IsMainThreadBlocked() && commit_completion_event_); |
651 return main_thread_blocked_commit_vars_unsafe_; | 638 return main_thread_blocked_commit_vars_unsafe_; |
652 } | 639 } |
653 | 640 |
654 } // namespace cc | 641 } // namespace cc |
OLD | NEW |