| 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) { | |
| 260 DCHECK(IsImplThread()); | |
| 261 layer_tree_host_impl_->BlockNotifyReadyToActivateForTesting(block); | |
| 262 } | |
| 263 | |
| 264 CompletionEvent* ProxyImpl::ActivationCompletionEventForTesting() { | |
| 265 DCHECK(IsImplThread()); | |
| 266 return activation_completion_event_; | |
| 267 } | |
| 268 | |
| 269 void ProxyImpl::StartCommitOnImpl(CompletionEvent* completion, | 253 void ProxyImpl::StartCommitOnImpl(CompletionEvent* completion, |
| 270 LayerTreeHost* layer_tree_host, | 254 LayerTreeHost* layer_tree_host, |
| 271 base::TimeTicks main_thread_start_time, | 255 base::TimeTicks main_thread_start_time, |
| 272 bool hold_commit_for_activation) { | 256 bool hold_commit_for_activation) { |
| 273 TRACE_EVENT0("cc", "ProxyImpl::StartCommitOnImplThread"); | 257 TRACE_EVENT0("cc", "ProxyImpl::StartCommitOnImplThread"); |
| 274 DCHECK(!commit_completion_event_); | 258 DCHECK(!commit_completion_event_); |
| 275 DCHECK(IsImplThread() && IsMainThreadBlocked()); | 259 DCHECK(IsImplThread() && IsMainThreadBlocked()); |
| 276 DCHECK(scheduler_); | 260 DCHECK(scheduler_); |
| 277 DCHECK(scheduler_->CommitPending()); | 261 DCHECK(scheduler_->CommitPending()); |
| 278 | 262 |
| 279 if (!layer_tree_host_impl_) { | 263 if (!layer_tree_host_impl_) { |
| 280 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoLayerTree", | 264 TRACE_EVENT_INSTANT0("cc", "EarlyOut_NoLayerTree", |
| 281 TRACE_EVENT_SCOPE_THREAD); | 265 TRACE_EVENT_SCOPE_THREAD); |
| 282 completion->Signal(); | 266 completion->Signal(); |
| 283 return; | 267 return; |
| 284 } | 268 } |
| 285 | 269 |
| 286 // Ideally, we should inform to impl thread when BeginMainFrame is started. | 270 // Ideally, we should inform to impl thread when BeginMainFrame is started. |
| 287 // But, we can avoid a PostTask in here. | 271 // But, we can avoid a PostTask in here. |
| 288 scheduler_->NotifyBeginMainFrameStarted(main_thread_start_time); | 272 scheduler_->NotifyBeginMainFrameStarted(main_thread_start_time); |
| 289 | 273 |
| 274 layer_tree_host_impl_->BeginMainFrameCompleted(); |
| 275 |
| 290 commit_completion_event_ = completion; | 276 commit_completion_event_ = completion; |
| 291 commit_completion_waits_for_activation_ = hold_commit_for_activation; | 277 commit_completion_waits_for_activation_ = hold_commit_for_activation; |
| 292 | 278 |
| 293 DCHECK(!blocked_main_commit().layer_tree_host); | 279 DCHECK(!blocked_main_commit().layer_tree_host); |
| 294 blocked_main_commit().layer_tree_host = layer_tree_host; | 280 blocked_main_commit().layer_tree_host = layer_tree_host; |
| 295 scheduler_->NotifyReadyToCommit(); | 281 scheduler_->NotifyReadyToCommit(); |
| 296 } | 282 } |
| 297 | 283 |
| 298 void ProxyImpl::UpdateRendererCapabilitiesOnImplThread() { | 284 void ProxyImpl::UpdateRendererCapabilitiesOnImplThread() { |
| 299 DCHECK(IsImplThread()); | 285 DCHECK(IsImplThread()); |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 bool ProxyImpl::IsMainThreadBlocked() const { | 663 bool ProxyImpl::IsMainThreadBlocked() const { |
| 678 return task_runner_provider_->IsMainThreadBlocked(); | 664 return task_runner_provider_->IsMainThreadBlocked(); |
| 679 } | 665 } |
| 680 | 666 |
| 681 ProxyImpl::BlockedMainCommitOnly& ProxyImpl::blocked_main_commit() { | 667 ProxyImpl::BlockedMainCommitOnly& ProxyImpl::blocked_main_commit() { |
| 682 DCHECK(IsMainThreadBlocked() && commit_completion_event_); | 668 DCHECK(IsMainThreadBlocked() && commit_completion_event_); |
| 683 return main_thread_blocked_commit_vars_unsafe_; | 669 return main_thread_blocked_commit_vars_unsafe_; |
| 684 } | 670 } |
| 685 | 671 |
| 686 } // namespace cc | 672 } // namespace cc |
| OLD | NEW |