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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 commit_completion_event_(nullptr), | 53 commit_completion_event_(nullptr), |
54 next_frame_is_newly_committed_frame_(false), | 54 next_frame_is_newly_committed_frame_(false), |
55 inside_draw_(false), | 55 inside_draw_(false), |
56 input_throttled_until_commit_(false), | 56 input_throttled_until_commit_(false), |
57 task_runner_provider_(task_runner_provider), | 57 task_runner_provider_(task_runner_provider), |
58 smoothness_priority_expiration_notifier_( | 58 smoothness_priority_expiration_notifier_( |
59 task_runner_provider->ImplThreadTaskRunner(), | 59 task_runner_provider->ImplThreadTaskRunner(), |
60 base::Bind(&ProxyImpl::RenewTreePriority, base::Unretained(this)), | 60 base::Bind(&ProxyImpl::RenewTreePriority, base::Unretained(this)), |
61 base::TimeDelta::FromSecondsD( | 61 base::TimeDelta::FromSecondsD( |
62 kSmoothnessTakesPriorityExpirationDelay)), | 62 kSmoothnessTakesPriorityExpirationDelay)), |
63 external_begin_frame_source_(std::move(external_begin_frame_source)), | 63 begin_frame_source_(std::move(external_begin_frame_source)), |
64 rendering_stats_instrumentation_( | 64 rendering_stats_instrumentation_( |
65 layer_tree_host->rendering_stats_instrumentation()), | 65 layer_tree_host->rendering_stats_instrumentation()), |
66 channel_impl_(channel_impl) { | 66 channel_impl_(channel_impl) { |
67 TRACE_EVENT0("cc", "ProxyImpl::ProxyImpl"); | 67 TRACE_EVENT0("cc", "ProxyImpl::ProxyImpl"); |
68 DCHECK(IsImplThread()); | 68 DCHECK(IsImplThread()); |
69 DCHECK(IsMainThreadBlocked()); | 69 DCHECK(IsMainThreadBlocked()); |
70 | 70 |
71 layer_tree_host_impl_ = layer_tree_host->CreateLayerTreeHostImpl(this); | 71 layer_tree_host_impl_ = layer_tree_host->CreateLayerTreeHostImpl(this); |
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 if (!scheduler_settings.throttle_frame_production) { |
83 task_runner_provider_->ImplThreadTaskRunner(), | 83 // Unthrottled source takes precedence over external sources. |
84 external_begin_frame_source_.get(), | 84 begin_frame_source_ = BackToBackBeginFrameSource::Create( |
85 std::move(compositor_timing_history)); | 85 task_runner_provider_->ImplThreadTaskRunner()); |
| 86 } |
| 87 BeginFrameSource* frame_source = begin_frame_source_.get(); |
| 88 if (!frame_source) { |
| 89 synthetic_frame_source_ = SyntheticBeginFrameSource::Create( |
| 90 task_runner_provider_->ImplThreadTaskRunner(), |
| 91 BeginFrameArgs::DefaultInterval()); |
| 92 frame_source = synthetic_frame_source_.get(); |
| 93 } |
| 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)); |
86 | 98 |
87 DCHECK_EQ(scheduler_->visible(), layer_tree_host_impl_->visible()); | 99 DCHECK_EQ(scheduler_->visible(), layer_tree_host_impl_->visible()); |
88 } | 100 } |
89 | 101 |
90 ProxyImpl::BlockedMainCommitOnly::BlockedMainCommitOnly() | 102 ProxyImpl::BlockedMainCommitOnly::BlockedMainCommitOnly() |
91 : layer_tree_host(nullptr) {} | 103 : layer_tree_host(nullptr) {} |
92 | 104 |
93 ProxyImpl::BlockedMainCommitOnly::~BlockedMainCommitOnly() {} | 105 ProxyImpl::BlockedMainCommitOnly::~BlockedMainCommitOnly() {} |
94 | 106 |
95 ProxyImpl::~ProxyImpl() { | 107 ProxyImpl::~ProxyImpl() { |
96 TRACE_EVENT0("cc", "ProxyImpl::~ProxyImpl"); | 108 TRACE_EVENT0("cc", "ProxyImpl::~ProxyImpl"); |
97 DCHECK(IsImplThread()); | 109 DCHECK(IsImplThread()); |
98 DCHECK(IsMainThreadBlocked()); | 110 DCHECK(IsMainThreadBlocked()); |
99 | 111 |
100 scheduler_ = nullptr; | 112 scheduler_ = nullptr; |
101 external_begin_frame_source_ = nullptr; | 113 begin_frame_source_ = nullptr; |
| 114 synthetic_frame_source_ = nullptr; |
102 layer_tree_host_impl_ = nullptr; | 115 layer_tree_host_impl_ = nullptr; |
103 // 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 |
104 // holding while still on the compositor thread. This also ensures any | 117 // holding while still on the compositor thread. This also ensures any |
105 // callbacks holding a ProxyImpl pointer are cancelled. | 118 // callbacks holding a ProxyImpl pointer are cancelled. |
106 smoothness_priority_expiration_notifier_.Shutdown(); | 119 smoothness_priority_expiration_notifier_.Shutdown(); |
107 } | 120 } |
108 | 121 |
109 void ProxyImpl::UpdateTopControlsStateOnImpl(TopControlsState constraints, | 122 void ProxyImpl::UpdateTopControlsStateOnImpl(TopControlsState constraints, |
110 TopControlsState current, | 123 TopControlsState current, |
111 bool animate) { | 124 bool animate) { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 void ProxyImpl::DidLoseOutputSurfaceOnImplThread() { | 282 void ProxyImpl::DidLoseOutputSurfaceOnImplThread() { |
270 TRACE_EVENT0("cc", "ProxyImpl::DidLoseOutputSurfaceOnImplThread"); | 283 TRACE_EVENT0("cc", "ProxyImpl::DidLoseOutputSurfaceOnImplThread"); |
271 DCHECK(IsImplThread()); | 284 DCHECK(IsImplThread()); |
272 channel_impl_->DidLoseOutputSurface(); | 285 channel_impl_->DidLoseOutputSurface(); |
273 scheduler_->DidLoseOutputSurface(); | 286 scheduler_->DidLoseOutputSurface(); |
274 } | 287 } |
275 | 288 |
276 void ProxyImpl::CommitVSyncParameters(base::TimeTicks timebase, | 289 void ProxyImpl::CommitVSyncParameters(base::TimeTicks timebase, |
277 base::TimeDelta interval) { | 290 base::TimeDelta interval) { |
278 DCHECK(IsImplThread()); | 291 DCHECK(IsImplThread()); |
279 scheduler_->CommitVSyncParameters(timebase, interval); | 292 if (!synthetic_frame_source_) |
| 293 return; |
| 294 |
| 295 if (interval == base::TimeDelta()) { |
| 296 // TODO(brianderson): We should not be receiving 0 intervals. |
| 297 interval = BeginFrameArgs::DefaultInterval(); |
| 298 } |
| 299 synthetic_frame_source_->OnUpdateVSyncParameters(timebase, interval); |
280 } | 300 } |
281 | 301 |
282 void ProxyImpl::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { | 302 void ProxyImpl::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { |
283 DCHECK(IsImplThread()); | 303 DCHECK(IsImplThread()); |
284 scheduler_->SetEstimatedParentDrawTime(draw_time); | 304 scheduler_->SetEstimatedParentDrawTime(draw_time); |
285 } | 305 } |
286 | 306 |
287 void ProxyImpl::DidSwapBuffersOnImplThread() { | 307 void ProxyImpl::DidSwapBuffersOnImplThread() { |
288 DCHECK(IsImplThread()); | 308 DCHECK(IsImplThread()); |
289 scheduler_->DidSwapBuffers(); | 309 scheduler_->DidSwapBuffers(); |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 bool ProxyImpl::IsMainThreadBlocked() const { | 678 bool ProxyImpl::IsMainThreadBlocked() const { |
659 return task_runner_provider_->IsMainThreadBlocked(); | 679 return task_runner_provider_->IsMainThreadBlocked(); |
660 } | 680 } |
661 | 681 |
662 ProxyImpl::BlockedMainCommitOnly& ProxyImpl::blocked_main_commit() { | 682 ProxyImpl::BlockedMainCommitOnly& ProxyImpl::blocked_main_commit() { |
663 DCHECK(IsMainThreadBlocked() && commit_completion_event_); | 683 DCHECK(IsMainThreadBlocked() && commit_completion_event_); |
664 return main_thread_blocked_commit_vars_unsafe_; | 684 return main_thread_blocked_commit_vars_unsafe_; |
665 } | 685 } |
666 | 686 |
667 } // namespace cc | 687 } // namespace cc |
OLD | NEW |