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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 | 72 |
73 SchedulerSettings scheduler_settings( | 73 SchedulerSettings scheduler_settings( |
74 layer_tree_host->settings().ToSchedulerSettings()); | 74 layer_tree_host->settings().ToSchedulerSettings()); |
75 | 75 |
76 scoped_ptr<CompositorTimingHistory> compositor_timing_history( | 76 scoped_ptr<CompositorTimingHistory> compositor_timing_history( |
77 new CompositorTimingHistory( | 77 new CompositorTimingHistory( |
78 scheduler_settings.using_synchronous_renderer_compositor, | 78 scheduler_settings.using_synchronous_renderer_compositor, |
79 CompositorTimingHistory::RENDERER_UMA, | 79 CompositorTimingHistory::RENDERER_UMA, |
80 rendering_stats_instrumentation_)); | 80 rendering_stats_instrumentation_)); |
81 | 81 |
82 scheduler_ = Scheduler::Create(this, scheduler_settings, layer_tree_host_id_, | 82 BeginFrameSource* frame_source = external_begin_frame_source_.get(); |
83 task_runner_provider_->ImplThreadTaskRunner(), | 83 if (!scheduler_settings.throttle_frame_production) { |
84 external_begin_frame_source_.get(), | 84 // Unthrottled source takes precedence over external sources. |
85 std::move(compositor_timing_history)); | 85 unthrottled_begin_frame_source_ = BackToBackBeginFrameSource::Create( |
| 86 task_runner_provider_->ImplThreadTaskRunner()); |
| 87 frame_source = unthrottled_begin_frame_source_.get(); |
| 88 } |
| 89 if (!frame_source) { |
| 90 synthetic_begin_frame_source_ = SyntheticBeginFrameSource::Create( |
| 91 task_runner_provider_->ImplThreadTaskRunner(), |
| 92 BeginFrameArgs::DefaultInterval()); |
| 93 frame_source = synthetic_begin_frame_source_.get(); |
| 94 } |
| 95 scheduler_ = |
| 96 Scheduler::Create(this, scheduler_settings, layer_tree_host_id_, |
| 97 task_runner_provider_->ImplThreadTaskRunner(), |
| 98 frame_source, std::move(compositor_timing_history)); |
86 | 99 |
87 DCHECK_EQ(scheduler_->visible(), layer_tree_host_impl_->visible()); | 100 DCHECK_EQ(scheduler_->visible(), layer_tree_host_impl_->visible()); |
88 } | 101 } |
89 | 102 |
90 ProxyImpl::BlockedMainCommitOnly::BlockedMainCommitOnly() | 103 ProxyImpl::BlockedMainCommitOnly::BlockedMainCommitOnly() |
91 : layer_tree_host(nullptr) {} | 104 : layer_tree_host(nullptr) {} |
92 | 105 |
93 ProxyImpl::BlockedMainCommitOnly::~BlockedMainCommitOnly() {} | 106 ProxyImpl::BlockedMainCommitOnly::~BlockedMainCommitOnly() {} |
94 | 107 |
95 ProxyImpl::~ProxyImpl() { | 108 ProxyImpl::~ProxyImpl() { |
96 TRACE_EVENT0("cc", "ProxyImpl::~ProxyImpl"); | 109 TRACE_EVENT0("cc", "ProxyImpl::~ProxyImpl"); |
97 DCHECK(IsImplThread()); | 110 DCHECK(IsImplThread()); |
98 DCHECK(IsMainThreadBlocked()); | 111 DCHECK(IsMainThreadBlocked()); |
99 | 112 |
100 scheduler_ = nullptr; | 113 scheduler_ = nullptr; |
101 external_begin_frame_source_ = nullptr; | 114 external_begin_frame_source_ = nullptr; |
| 115 unthrottled_begin_frame_source_ = nullptr; |
| 116 synthetic_begin_frame_source_ = nullptr; |
102 layer_tree_host_impl_ = nullptr; | 117 layer_tree_host_impl_ = nullptr; |
103 // We need to explicitly shutdown the notifier to destroy any weakptrs it is | 118 // We need to explicitly shutdown the notifier to destroy any weakptrs it is |
104 // holding while still on the compositor thread. This also ensures any | 119 // holding while still on the compositor thread. This also ensures any |
105 // callbacks holding a ProxyImpl pointer are cancelled. | 120 // callbacks holding a ProxyImpl pointer are cancelled. |
106 smoothness_priority_expiration_notifier_.Shutdown(); | 121 smoothness_priority_expiration_notifier_.Shutdown(); |
107 } | 122 } |
108 | 123 |
109 void ProxyImpl::UpdateTopControlsStateOnImpl(TopControlsState constraints, | 124 void ProxyImpl::UpdateTopControlsStateOnImpl(TopControlsState constraints, |
110 TopControlsState current, | 125 TopControlsState current, |
111 bool animate) { | 126 bool animate) { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 void ProxyImpl::DidLoseOutputSurfaceOnImplThread() { | 284 void ProxyImpl::DidLoseOutputSurfaceOnImplThread() { |
270 TRACE_EVENT0("cc", "ProxyImpl::DidLoseOutputSurfaceOnImplThread"); | 285 TRACE_EVENT0("cc", "ProxyImpl::DidLoseOutputSurfaceOnImplThread"); |
271 DCHECK(IsImplThread()); | 286 DCHECK(IsImplThread()); |
272 channel_impl_->DidLoseOutputSurface(); | 287 channel_impl_->DidLoseOutputSurface(); |
273 scheduler_->DidLoseOutputSurface(); | 288 scheduler_->DidLoseOutputSurface(); |
274 } | 289 } |
275 | 290 |
276 void ProxyImpl::CommitVSyncParameters(base::TimeTicks timebase, | 291 void ProxyImpl::CommitVSyncParameters(base::TimeTicks timebase, |
277 base::TimeDelta interval) { | 292 base::TimeDelta interval) { |
278 DCHECK(IsImplThread()); | 293 DCHECK(IsImplThread()); |
279 scheduler_->CommitVSyncParameters(timebase, interval); | 294 if (!synthetic_begin_frame_source_) |
| 295 return; |
| 296 |
| 297 if (interval == base::TimeDelta()) { |
| 298 // TODO(brianderson): We should not be receiving 0 intervals. |
| 299 interval = BeginFrameArgs::DefaultInterval(); |
| 300 } |
| 301 synthetic_begin_frame_source_->OnUpdateVSyncParameters(timebase, interval); |
280 } | 302 } |
281 | 303 |
282 void ProxyImpl::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { | 304 void ProxyImpl::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { |
283 DCHECK(IsImplThread()); | 305 DCHECK(IsImplThread()); |
284 scheduler_->SetEstimatedParentDrawTime(draw_time); | 306 scheduler_->SetEstimatedParentDrawTime(draw_time); |
285 } | 307 } |
286 | 308 |
287 void ProxyImpl::DidSwapBuffersOnImplThread() { | 309 void ProxyImpl::DidSwapBuffersOnImplThread() { |
288 DCHECK(IsImplThread()); | 310 DCHECK(IsImplThread()); |
289 scheduler_->DidSwapBuffers(); | 311 scheduler_->DidSwapBuffers(); |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 bool ProxyImpl::IsMainThreadBlocked() const { | 680 bool ProxyImpl::IsMainThreadBlocked() const { |
659 return task_runner_provider_->IsMainThreadBlocked(); | 681 return task_runner_provider_->IsMainThreadBlocked(); |
660 } | 682 } |
661 | 683 |
662 ProxyImpl::BlockedMainCommitOnly& ProxyImpl::blocked_main_commit() { | 684 ProxyImpl::BlockedMainCommitOnly& ProxyImpl::blocked_main_commit() { |
663 DCHECK(IsMainThreadBlocked() && commit_completion_event_); | 685 DCHECK(IsMainThreadBlocked() && commit_completion_event_); |
664 return main_thread_blocked_commit_vars_unsafe_; | 686 return main_thread_blocked_commit_vars_unsafe_; |
665 } | 687 } |
666 | 688 |
667 } // namespace cc | 689 } // namespace cc |
OLD | NEW |