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 18 matching lines...) Expand all Loading... |
29 | 29 |
30 namespace { | 30 namespace { |
31 | 31 |
32 // Measured in seconds. | 32 // Measured in seconds. |
33 const double kSmoothnessTakesPriorityExpirationDelay = 0.25; | 33 const double kSmoothnessTakesPriorityExpirationDelay = 0.25; |
34 | 34 |
35 unsigned int nextBeginFrameId = 0; | 35 unsigned int nextBeginFrameId = 0; |
36 | 36 |
37 } // namespace | 37 } // namespace |
38 | 38 |
39 std::unique_ptr<ProxyImpl> ProxyImpl::Create( | |
40 ChannelImpl* channel_impl, | |
41 LayerTreeHost* layer_tree_host, | |
42 TaskRunnerProvider* task_runner_provider, | |
43 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { | |
44 return base::WrapUnique( | |
45 new ProxyImpl(channel_impl, layer_tree_host, task_runner_provider, | |
46 std::move(external_begin_frame_source))); | |
47 } | |
48 | |
49 ProxyImpl::ProxyImpl( | 39 ProxyImpl::ProxyImpl( |
50 ChannelImpl* channel_impl, | 40 ChannelImpl* channel_impl, |
51 LayerTreeHost* layer_tree_host, | 41 LayerTreeHost* layer_tree_host, |
52 TaskRunnerProvider* task_runner_provider, | 42 TaskRunnerProvider* task_runner_provider, |
53 std::unique_ptr<BeginFrameSource> external_begin_frame_source) | 43 std::unique_ptr<BeginFrameSource> external_begin_frame_source) |
54 : layer_tree_host_id_(layer_tree_host->id()), | 44 : layer_tree_host_id_(layer_tree_host->id()), |
55 commit_completion_waits_for_activation_(false), | 45 commit_completion_waits_for_activation_(false), |
56 commit_completion_event_(nullptr), | 46 commit_completion_event_(nullptr), |
57 activation_completion_event_(nullptr), | 47 activation_completion_event_(nullptr), |
58 next_frame_is_newly_committed_frame_(false), | 48 next_frame_is_newly_committed_frame_(false), |
59 inside_draw_(false), | 49 inside_draw_(false), |
60 input_throttled_until_commit_(false), | 50 input_throttled_until_commit_(false), |
61 task_runner_provider_(task_runner_provider), | 51 task_runner_provider_(task_runner_provider), |
62 smoothness_priority_expiration_notifier_( | 52 smoothness_priority_expiration_notifier_( |
63 task_runner_provider->ImplThreadTaskRunner(), | 53 task_runner_provider->ImplThreadTaskRunner(), |
64 base::Bind(&ProxyImpl::RenewTreePriority, base::Unretained(this)), | 54 base::Bind(&ProxyImpl::RenewTreePriority, base::Unretained(this)), |
65 base::TimeDelta::FromSecondsD( | 55 base::TimeDelta::FromSecondsD( |
66 kSmoothnessTakesPriorityExpirationDelay)), | 56 kSmoothnessTakesPriorityExpirationDelay)), |
67 external_begin_frame_source_(std::move(external_begin_frame_source)), | 57 external_begin_frame_source_(std::move(external_begin_frame_source)), |
68 rendering_stats_instrumentation_( | 58 rendering_stats_instrumentation_( |
69 layer_tree_host->rendering_stats_instrumentation()), | 59 layer_tree_host->rendering_stats_instrumentation()), |
70 channel_impl_(channel_impl) { | 60 channel_impl_(channel_impl) { |
71 TRACE_EVENT0("cc", "ProxyImpl::ProxyImpl"); | 61 TRACE_EVENT0("cc", "ProxyImpl::ProxyImpl"); |
72 DCHECK(IsImplThread()); | 62 DCHECK(IsImplThread()); |
73 DCHECK(IsMainThreadBlocked()); | 63 DCHECK(IsMainThreadBlocked()); |
74 | 64 |
| 65 // Double checking we set this correctly since double->int truncations are |
| 66 // silent and have been done mistakenly: crbug.com/568120. |
| 67 DCHECK(!smoothness_priority_expiration_notifier_.delay().is_zero()); |
| 68 |
75 layer_tree_host_impl_ = layer_tree_host->CreateLayerTreeHostImpl(this); | 69 layer_tree_host_impl_ = layer_tree_host->CreateLayerTreeHostImpl(this); |
76 | 70 |
77 SchedulerSettings scheduler_settings( | 71 SchedulerSettings scheduler_settings( |
78 layer_tree_host->settings().ToSchedulerSettings()); | 72 layer_tree_host->settings().ToSchedulerSettings()); |
79 | 73 |
80 std::unique_ptr<CompositorTimingHistory> compositor_timing_history( | 74 std::unique_ptr<CompositorTimingHistory> compositor_timing_history( |
81 new CompositorTimingHistory( | 75 new CompositorTimingHistory( |
82 scheduler_settings.using_synchronous_renderer_compositor, | 76 scheduler_settings.using_synchronous_renderer_compositor, |
83 CompositorTimingHistory::RENDERER_UMA, | 77 CompositorTimingHistory::RENDERER_UMA, |
84 rendering_stats_instrumentation_)); | 78 rendering_stats_instrumentation_)); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 bool* main_frame_will_happen) { | 243 bool* main_frame_will_happen) { |
250 DCHECK(IsImplThread()); | 244 DCHECK(IsImplThread()); |
251 if (layer_tree_host_impl_->output_surface()) { | 245 if (layer_tree_host_impl_->output_surface()) { |
252 *main_frame_will_happen = scheduler_->MainFrameForTestingWillHappen(); | 246 *main_frame_will_happen = scheduler_->MainFrameForTestingWillHappen(); |
253 } else { | 247 } else { |
254 *main_frame_will_happen = false; | 248 *main_frame_will_happen = false; |
255 } | 249 } |
256 completion->Signal(); | 250 completion->Signal(); |
257 } | 251 } |
258 | 252 |
259 void ProxyImpl::BlockNotifyReadyToActivateForTesting(bool block) { | 253 void ProxyImpl::NotifyReadyToCommitOnImpl( |
260 DCHECK(IsImplThread()); | 254 CompletionEvent* completion, |
261 layer_tree_host_impl_->BlockNotifyReadyToActivateForTesting(block); | 255 LayerTreeHost* layer_tree_host, |
262 } | 256 base::TimeTicks main_thread_start_time, |
263 | 257 bool hold_commit_for_activation) { |
264 CompletionEvent* ProxyImpl::ActivationCompletionEventForTesting() { | 258 TRACE_EVENT0("cc", "ProxyImpl::NotifyReadyToCommitOnImpl"); |
265 DCHECK(IsImplThread()); | |
266 return activation_completion_event_; | |
267 } | |
268 | |
269 void ProxyImpl::StartCommitOnImpl(CompletionEvent* completion, | |
270 LayerTreeHost* layer_tree_host, | |
271 base::TimeTicks main_thread_start_time, | |
272 bool hold_commit_for_activation) { | |
273 TRACE_EVENT0("cc", "ProxyImpl::StartCommitOnImplThread"); | |
274 DCHECK(!commit_completion_event_); | 259 DCHECK(!commit_completion_event_); |
275 DCHECK(IsImplThread() && IsMainThreadBlocked()); | 260 DCHECK(IsImplThread() && IsMainThreadBlocked()); |
276 DCHECK(scheduler_); | 261 DCHECK(scheduler_); |
277 DCHECK(scheduler_->CommitPending()); | 262 DCHECK(scheduler_->CommitPending()); |
278 | 263 |
279 if (!layer_tree_host_impl_) { | 264 if (!layer_tree_host_impl_) { |
280 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoLayerTree", | 265 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoLayerTree", |
281 TRACE_EVENT_SCOPE_THREAD); | 266 TRACE_EVENT_SCOPE_THREAD); |
282 completion->Signal(); | 267 completion->Signal(); |
283 return; | 268 return; |
284 } | 269 } |
285 | 270 |
286 // Ideally, we should inform to impl thread when BeginMainFrame is started. | 271 // Ideally, we should inform to impl thread when BeginMainFrame is started. |
287 // But, we can avoid a PostTask in here. | 272 // But, we can avoid a PostTask in here. |
288 scheduler_->NotifyBeginMainFrameStarted(main_thread_start_time); | 273 scheduler_->NotifyBeginMainFrameStarted(main_thread_start_time); |
289 | 274 |
| 275 layer_tree_host_impl_->ReadyToCommit(); |
| 276 |
290 commit_completion_event_ = completion; | 277 commit_completion_event_ = completion; |
291 commit_completion_waits_for_activation_ = hold_commit_for_activation; | 278 commit_completion_waits_for_activation_ = hold_commit_for_activation; |
292 | 279 |
293 DCHECK(!blocked_main_commit().layer_tree_host); | 280 DCHECK(!blocked_main_commit().layer_tree_host); |
294 blocked_main_commit().layer_tree_host = layer_tree_host; | 281 blocked_main_commit().layer_tree_host = layer_tree_host; |
295 scheduler_->NotifyReadyToCommit(); | 282 scheduler_->NotifyReadyToCommit(); |
296 } | 283 } |
297 | 284 |
298 void ProxyImpl::UpdateRendererCapabilitiesOnImplThread() { | 285 void ProxyImpl::UpdateRendererCapabilitiesOnImplThread() { |
299 DCHECK(IsImplThread()); | 286 DCHECK(IsImplThread()); |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 bool ProxyImpl::IsMainThreadBlocked() const { | 664 bool ProxyImpl::IsMainThreadBlocked() const { |
678 return task_runner_provider_->IsMainThreadBlocked(); | 665 return task_runner_provider_->IsMainThreadBlocked(); |
679 } | 666 } |
680 | 667 |
681 ProxyImpl::BlockedMainCommitOnly& ProxyImpl::blocked_main_commit() { | 668 ProxyImpl::BlockedMainCommitOnly& ProxyImpl::blocked_main_commit() { |
682 DCHECK(IsMainThreadBlocked() && commit_completion_event_); | 669 DCHECK(IsMainThreadBlocked() && commit_completion_event_); |
683 return main_thread_blocked_commit_vars_unsafe_; | 670 return main_thread_blocked_commit_vars_unsafe_; |
684 } | 671 } |
685 | 672 |
686 } // namespace cc | 673 } // namespace cc |
OLD | NEW |