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 ProxyImpl::ProxyImpl( | 39 ProxyImpl::ProxyImpl(ChannelImpl* channel_impl, |
40 ChannelImpl* channel_impl, | 40 LayerTreeHostInProcess* layer_tree_host, |
41 LayerTreeHostInProcess* layer_tree_host, | 41 TaskRunnerProvider* task_runner_provider) |
42 TaskRunnerProvider* task_runner_provider, | |
43 std::unique_ptr<BeginFrameSource> external_begin_frame_source) | |
44 : layer_tree_host_id_(layer_tree_host->GetId()), | 42 : layer_tree_host_id_(layer_tree_host->GetId()), |
45 commit_completion_waits_for_activation_(false), | 43 commit_completion_waits_for_activation_(false), |
46 commit_completion_event_(nullptr), | 44 commit_completion_event_(nullptr), |
47 activation_completion_event_(nullptr), | 45 activation_completion_event_(nullptr), |
48 next_frame_is_newly_committed_frame_(false), | 46 next_frame_is_newly_committed_frame_(false), |
49 inside_draw_(false), | 47 inside_draw_(false), |
50 input_throttled_until_commit_(false), | 48 input_throttled_until_commit_(false), |
51 task_runner_provider_(task_runner_provider), | 49 task_runner_provider_(task_runner_provider), |
52 smoothness_priority_expiration_notifier_( | 50 smoothness_priority_expiration_notifier_( |
53 task_runner_provider->ImplThreadTaskRunner(), | 51 task_runner_provider->ImplThreadTaskRunner(), |
54 base::Bind(&ProxyImpl::RenewTreePriority, base::Unretained(this)), | 52 base::Bind(&ProxyImpl::RenewTreePriority, base::Unretained(this)), |
55 base::TimeDelta::FromSecondsD( | 53 base::TimeDelta::FromSecondsD( |
56 kSmoothnessTakesPriorityExpirationDelay)), | 54 kSmoothnessTakesPriorityExpirationDelay)), |
57 external_begin_frame_source_(std::move(external_begin_frame_source)), | |
58 rendering_stats_instrumentation_( | 55 rendering_stats_instrumentation_( |
59 layer_tree_host->rendering_stats_instrumentation()), | 56 layer_tree_host->rendering_stats_instrumentation()), |
60 channel_impl_(channel_impl) { | 57 channel_impl_(channel_impl) { |
61 TRACE_EVENT0("cc", "ProxyImpl::ProxyImpl"); | 58 TRACE_EVENT0("cc", "ProxyImpl::ProxyImpl"); |
62 DCHECK(IsImplThread()); | 59 DCHECK(IsImplThread()); |
63 DCHECK(IsMainThreadBlocked()); | 60 DCHECK(IsMainThreadBlocked()); |
64 | 61 |
65 // Double checking we set this correctly since double->int truncations are | 62 // Double checking we set this correctly since double->int truncations are |
66 // silent and have been done mistakenly: crbug.com/568120. | 63 // silent and have been done mistakenly: crbug.com/568120. |
67 DCHECK(!smoothness_priority_expiration_notifier_.delay().is_zero()); | 64 DCHECK(!smoothness_priority_expiration_notifier_.delay().is_zero()); |
68 | 65 |
69 layer_tree_host_impl_ = layer_tree_host->CreateLayerTreeHostImpl(this); | 66 layer_tree_host_impl_ = layer_tree_host->CreateLayerTreeHostImpl(this); |
70 const LayerTreeSettings& settings = layer_tree_host->GetSettings(); | 67 const LayerTreeSettings& settings = layer_tree_host->GetSettings(); |
71 | 68 |
72 SchedulerSettings scheduler_settings(settings.ToSchedulerSettings()); | 69 SchedulerSettings scheduler_settings(settings.ToSchedulerSettings()); |
73 | 70 |
74 std::unique_ptr<CompositorTimingHistory> compositor_timing_history( | 71 std::unique_ptr<CompositorTimingHistory> compositor_timing_history( |
75 new CompositorTimingHistory( | 72 new CompositorTimingHistory( |
76 scheduler_settings.using_synchronous_renderer_compositor, | 73 scheduler_settings.using_synchronous_renderer_compositor, |
77 CompositorTimingHistory::RENDERER_UMA, | 74 CompositorTimingHistory::RENDERER_UMA, |
78 rendering_stats_instrumentation_)); | 75 rendering_stats_instrumentation_)); |
79 | 76 scheduler_.reset(new Scheduler(this, scheduler_settings, layer_tree_host_id_, |
80 // TODO(enne): remove these settings. | |
81 DCHECK(!settings.use_external_begin_frame_source); | |
82 DCHECK(settings.use_compositor_frame_sink_begin_frame_source); | |
83 scheduler_ = Scheduler::Create(this, scheduler_settings, layer_tree_host_id_, | |
84 task_runner_provider_->ImplThreadTaskRunner(), | 77 task_runner_provider_->ImplThreadTaskRunner(), |
85 external_begin_frame_source_.get(), | 78 std::move(compositor_timing_history))); |
86 std::move(compositor_timing_history)); | |
87 | 79 |
88 DCHECK_EQ(scheduler_->visible(), layer_tree_host_impl_->visible()); | 80 DCHECK_EQ(scheduler_->visible(), layer_tree_host_impl_->visible()); |
89 } | 81 } |
90 | 82 |
91 ProxyImpl::BlockedMainCommitOnly::BlockedMainCommitOnly() | 83 ProxyImpl::BlockedMainCommitOnly::BlockedMainCommitOnly() |
92 : layer_tree_host(nullptr) {} | 84 : layer_tree_host(nullptr) {} |
93 | 85 |
94 ProxyImpl::BlockedMainCommitOnly::~BlockedMainCommitOnly() {} | 86 ProxyImpl::BlockedMainCommitOnly::~BlockedMainCommitOnly() {} |
95 | 87 |
96 ProxyImpl::~ProxyImpl() { | 88 ProxyImpl::~ProxyImpl() { |
97 TRACE_EVENT0("cc", "ProxyImpl::~ProxyImpl"); | 89 TRACE_EVENT0("cc", "ProxyImpl::~ProxyImpl"); |
98 DCHECK(IsImplThread()); | 90 DCHECK(IsImplThread()); |
99 DCHECK(IsMainThreadBlocked()); | 91 DCHECK(IsMainThreadBlocked()); |
100 | 92 |
101 // Take away the CompositorFrameSink before destroying things so it doesn't | 93 // Take away the CompositorFrameSink before destroying things so it doesn't |
102 // try to call into its client mid-shutdown. | 94 // try to call into its client mid-shutdown. |
103 scheduler_->DidLoseCompositorFrameSink(); | 95 scheduler_->DidLoseCompositorFrameSink(); |
104 layer_tree_host_impl_->ReleaseCompositorFrameSink(); | 96 layer_tree_host_impl_->ReleaseCompositorFrameSink(); |
105 | 97 |
106 scheduler_ = nullptr; | 98 scheduler_ = nullptr; |
107 external_begin_frame_source_ = nullptr; | |
108 layer_tree_host_impl_ = nullptr; | 99 layer_tree_host_impl_ = nullptr; |
109 // We need to explicitly shutdown the notifier to destroy any weakptrs it is | 100 // We need to explicitly shutdown the notifier to destroy any weakptrs it is |
110 // holding while still on the compositor thread. This also ensures any | 101 // holding while still on the compositor thread. This also ensures any |
111 // callbacks holding a ProxyImpl pointer are cancelled. | 102 // callbacks holding a ProxyImpl pointer are cancelled. |
112 smoothness_priority_expiration_notifier_.Shutdown(); | 103 smoothness_priority_expiration_notifier_.Shutdown(); |
113 } | 104 } |
114 | 105 |
115 void ProxyImpl::InitializeMutatorOnImpl( | 106 void ProxyImpl::InitializeMutatorOnImpl( |
116 std::unique_ptr<LayerTreeMutator> mutator) { | 107 std::unique_ptr<LayerTreeMutator> mutator) { |
117 TRACE_EVENT0("cc,compositor-worker", "ProxyImpl::InitializeMutatorOnImpl"); | 108 TRACE_EVENT0("cc,compositor-worker", "ProxyImpl::InitializeMutatorOnImpl"); |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 bool ProxyImpl::IsMainThreadBlocked() const { | 603 bool ProxyImpl::IsMainThreadBlocked() const { |
613 return task_runner_provider_->IsMainThreadBlocked(); | 604 return task_runner_provider_->IsMainThreadBlocked(); |
614 } | 605 } |
615 | 606 |
616 ProxyImpl::BlockedMainCommitOnly& ProxyImpl::blocked_main_commit() { | 607 ProxyImpl::BlockedMainCommitOnly& ProxyImpl::blocked_main_commit() { |
617 DCHECK(IsMainThreadBlocked() && commit_completion_event_); | 608 DCHECK(IsMainThreadBlocked() && commit_completion_event_); |
618 return main_thread_blocked_commit_vars_unsafe_; | 609 return main_thread_blocked_commit_vars_unsafe_; |
619 } | 610 } |
620 | 611 |
621 } // namespace cc | 612 } // namespace cc |
OLD | NEW |