OLD | NEW |
---|---|
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/thread_proxy.h" | 5 #include "cc/trees/thread_proxy.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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 main_thread_only_vars_unsafe_(this, layer_tree_host->id()), | 64 main_thread_only_vars_unsafe_(this, layer_tree_host->id()), |
65 main_thread_or_blocked_vars_unsafe_(layer_tree_host), | 65 main_thread_or_blocked_vars_unsafe_(layer_tree_host), |
66 compositor_thread_vars_unsafe_( | 66 compositor_thread_vars_unsafe_( |
67 this, | 67 this, |
68 layer_tree_host->id(), | 68 layer_tree_host->id(), |
69 layer_tree_host->rendering_stats_instrumentation(), | 69 layer_tree_host->rendering_stats_instrumentation(), |
70 external_begin_frame_source.Pass()) { | 70 external_begin_frame_source.Pass()) { |
71 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); | 71 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); |
72 DCHECK(IsMainThread()); | 72 DCHECK(IsMainThread()); |
73 DCHECK(this->layer_tree_host()); | 73 DCHECK(this->layer_tree_host()); |
74 // TODO(khushalsagar): Move this to LayerTreeHost#InitializeThreaded once | |
75 // ThreadProxy is split. LayerTreeHost creates the channel and passes it to | |
76 // ProxyMain#SetChannel | |
David Trainor- moved to gerrit
2015/09/23 17:54:12
. at end.
Khushal
2015/09/23 20:50:28
Done.
| |
77 this->SetChannel( | |
David Trainor- moved to gerrit
2015/09/23 17:54:12
remove this->?
Khushal
2015/09/23 20:50:28
Done.
| |
78 ThreadedChannel::Create(this, main_task_runner, impl_task_runner)); | |
74 } | 79 } |
75 | 80 |
76 ThreadProxy::MainThreadOnly::MainThreadOnly(ThreadProxy* proxy, | 81 ThreadProxy::MainThreadOnly::MainThreadOnly(ThreadProxy* proxy, |
77 int layer_tree_host_id) | 82 int layer_tree_host_id) |
78 : layer_tree_host_id(layer_tree_host_id), | 83 : layer_tree_host_id(layer_tree_host_id), |
79 max_requested_pipeline_stage(NO_PIPELINE_STAGE), | 84 max_requested_pipeline_stage(NO_PIPELINE_STAGE), |
80 current_pipeline_stage(NO_PIPELINE_STAGE), | 85 current_pipeline_stage(NO_PIPELINE_STAGE), |
81 final_pipeline_stage(NO_PIPELINE_STAGE), | 86 final_pipeline_stage(NO_PIPELINE_STAGE), |
82 started(false), | 87 started(false), |
83 prepare_tiles_pending(false), | 88 prepare_tiles_pending(false), |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 } | 121 } |
117 | 122 |
118 ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {} | 123 ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {} |
119 | 124 |
120 ThreadProxy::~ThreadProxy() { | 125 ThreadProxy::~ThreadProxy() { |
121 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy"); | 126 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy"); |
122 DCHECK(IsMainThread()); | 127 DCHECK(IsMainThread()); |
123 DCHECK(!main().started); | 128 DCHECK(!main().started); |
124 } | 129 } |
125 | 130 |
131 void ThreadProxy::SetChannel(scoped_ptr<ThreadedChannel> threaded_channel) { | |
132 threaded_channel_ = threaded_channel.Pass(); | |
133 main().channel_main = threaded_channel_.get(); | |
134 } | |
135 | |
126 void ThreadProxy::FinishAllRendering() { | 136 void ThreadProxy::FinishAllRendering() { |
127 DCHECK(Proxy::IsMainThread()); | 137 DCHECK(Proxy::IsMainThread()); |
128 DCHECK(!main().defer_commits); | 138 DCHECK(!main().defer_commits); |
129 | 139 |
130 // Make sure all GL drawing is finished on the impl thread. | 140 // Make sure all GL drawing is finished on the impl thread. |
131 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 141 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
132 CompletionEvent completion; | 142 CompletionEvent completion; |
133 Proxy::ImplThreadTaskRunner()->PostTask( | 143 Proxy::ImplThreadTaskRunner()->PostTask( |
134 FROM_HERE, | 144 FROM_HERE, |
135 base::Bind(&ThreadProxy::FinishAllRenderingOnImplThread, | 145 base::Bind(&ThreadProxy::FinishAllRenderingOnImplThread, |
136 impl_thread_weak_ptr_, | 146 impl_thread_weak_ptr_, |
137 &completion)); | 147 &completion)); |
138 completion.Wait(); | 148 completion.Wait(); |
139 } | 149 } |
140 | 150 |
141 bool ThreadProxy::IsStarted() const { | 151 bool ThreadProxy::IsStarted() const { |
142 DCHECK(Proxy::IsMainThread()); | 152 DCHECK(Proxy::IsMainThread()); |
143 return main().started; | 153 return main().started; |
144 } | 154 } |
145 | 155 |
146 bool ThreadProxy::CommitToActiveTree() const { | 156 bool ThreadProxy::CommitToActiveTree() const { |
147 // With ThreadProxy, we use a pending tree and activate it once it's ready to | 157 // With ThreadProxy, we use a pending tree and activate it once it's ready to |
148 // draw to allow input to modify the active tree and draw during raster. | 158 // draw to allow input to modify the active tree and draw during raster. |
149 return false; | 159 return false; |
150 } | 160 } |
151 | 161 |
152 void ThreadProxy::SetLayerTreeHostClientReady() { | 162 void ThreadProxy::SetLayerTreeHostClientReady() { |
153 TRACE_EVENT0("cc", "ThreadProxy::SetLayerTreeHostClientReady"); | 163 TRACE_EVENT0("cc", "ThreadProxy::SetLayerTreeHostClientReady"); |
154 Proxy::ImplThreadTaskRunner()->PostTask( | 164 main().channel_main->SetLayerTreeHostClientReadyOnImpl(); |
155 FROM_HERE, | |
156 base::Bind(&ThreadProxy::SetLayerTreeHostClientReadyOnImplThread, | |
157 impl_thread_weak_ptr_)); | |
158 } | 165 } |
159 | 166 |
160 void ThreadProxy::SetLayerTreeHostClientReadyOnImplThread() { | 167 void ThreadProxy::SetLayerTreeHostClientReadyOnImpl() { |
161 TRACE_EVENT0("cc", "ThreadProxy::SetLayerTreeHostClientReadyOnImplThread"); | 168 TRACE_EVENT0("cc", "ThreadProxy::SetLayerTreeHostClientReadyOnImplThread"); |
162 impl().scheduler->SetCanStart(); | 169 impl().scheduler->SetCanStart(); |
163 } | 170 } |
164 | 171 |
165 void ThreadProxy::SetVisible(bool visible) { | 172 void ThreadProxy::SetVisible(bool visible) { |
166 TRACE_EVENT1("cc", "ThreadProxy::SetVisible", "visible", visible); | 173 TRACE_EVENT1("cc", "ThreadProxy::SetVisible", "visible", visible); |
167 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 174 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
168 | 175 |
169 CompletionEvent completion; | 176 CompletionEvent completion; |
170 Proxy::ImplThreadTaskRunner()->PostTask( | 177 Proxy::ImplThreadTaskRunner()->PostTask( |
171 FROM_HERE, | 178 FROM_HERE, |
172 base::Bind(&ThreadProxy::SetVisibleOnImplThread, | 179 base::Bind(&ThreadProxy::SetVisibleOnImplThread, |
173 impl_thread_weak_ptr_, | 180 impl_thread_weak_ptr_, |
174 &completion, | 181 &completion, |
175 visible)); | 182 visible)); |
176 completion.Wait(); | 183 completion.Wait(); |
177 } | 184 } |
178 | 185 |
179 void ThreadProxy::SetVisibleOnImplThread(CompletionEvent* completion, | 186 void ThreadProxy::SetVisibleOnImplThread(CompletionEvent* completion, |
180 bool visible) { | 187 bool visible) { |
181 TRACE_EVENT1("cc", "ThreadProxy::SetVisibleOnImplThread", "visible", visible); | 188 TRACE_EVENT1("cc", "ThreadProxy::SetVisibleOnImplThread", "visible", visible); |
182 impl().layer_tree_host_impl->SetVisible(visible); | 189 impl().layer_tree_host_impl->SetVisible(visible); |
183 impl().scheduler->SetVisible(visible); | 190 impl().scheduler->SetVisible(visible); |
184 completion->Signal(); | 191 completion->Signal(); |
185 } | 192 } |
186 | 193 |
187 void ThreadProxy::SetThrottleFrameProduction(bool throttle) { | 194 void ThreadProxy::SetThrottleFrameProduction(bool throttle) { |
188 TRACE_EVENT1("cc", "ThreadProxy::SetThrottleFrameProduction", "throttle", | 195 TRACE_EVENT1("cc", "ThreadProxy::SetThrottleFrameProduction", "throttle", |
189 throttle); | 196 throttle); |
190 Proxy::ImplThreadTaskRunner()->PostTask( | 197 main().channel_main->SetThrottleFrameProductionOnImpl(throttle); |
191 FROM_HERE, | |
192 base::Bind(&ThreadProxy::SetThrottleFrameProductionOnImplThread, | |
193 impl_thread_weak_ptr_, throttle)); | |
194 } | 198 } |
195 | 199 |
196 void ThreadProxy::SetThrottleFrameProductionOnImplThread(bool throttle) { | 200 void ThreadProxy::SetThrottleFrameProductionOnImpl(bool throttle) { |
197 TRACE_EVENT1("cc", "ThreadProxy::SetThrottleFrameProductionOnImplThread", | 201 TRACE_EVENT1("cc", "ThreadProxy::SetThrottleFrameProductionOnImplThread", |
198 "throttle", throttle); | 202 "throttle", throttle); |
199 impl().scheduler->SetThrottleFrameProduction(throttle); | 203 impl().scheduler->SetThrottleFrameProduction(throttle); |
200 } | 204 } |
201 | 205 |
202 void ThreadProxy::DidLoseOutputSurface() { | 206 void ThreadProxy::DidLoseOutputSurface() { |
203 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurface"); | 207 TRACE_EVENT0("cc", "ThreadProxy::DidLoseOutputSurface"); |
204 DCHECK(IsMainThread()); | 208 DCHECK(IsMainThread()); |
205 layer_tree_host()->DidLoseOutputSurface(); | 209 layer_tree_host()->DidLoseOutputSurface(); |
206 } | 210 } |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
352 | 356 |
353 void ThreadProxy::DidSwapBuffersOnImplThread() { | 357 void ThreadProxy::DidSwapBuffersOnImplThread() { |
354 impl().scheduler->DidSwapBuffers(); | 358 impl().scheduler->DidSwapBuffers(); |
355 } | 359 } |
356 | 360 |
357 void ThreadProxy::DidSwapBuffersCompleteOnImplThread() { | 361 void ThreadProxy::DidSwapBuffersCompleteOnImplThread() { |
358 TRACE_EVENT0("cc,benchmark", | 362 TRACE_EVENT0("cc,benchmark", |
359 "ThreadProxy::DidSwapBuffersCompleteOnImplThread"); | 363 "ThreadProxy::DidSwapBuffersCompleteOnImplThread"); |
360 DCHECK(IsImplThread()); | 364 DCHECK(IsImplThread()); |
361 impl().scheduler->DidSwapBuffersComplete(); | 365 impl().scheduler->DidSwapBuffersComplete(); |
362 Proxy::MainThreadTaskRunner()->PostTask( | 366 impl().channel_impl->DidCompleteSwapBuffers(); |
363 FROM_HERE, | |
364 base::Bind(&ThreadProxy::DidCompleteSwapBuffers, main_thread_weak_ptr_)); | |
365 } | 367 } |
366 | 368 |
367 void ThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { | 369 void ThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { |
368 impl().layer_tree_host_impl->WillBeginImplFrame(args); | 370 impl().layer_tree_host_impl->WillBeginImplFrame(args); |
369 if (impl().last_processed_begin_main_frame_args.IsValid()) { | 371 if (impl().last_processed_begin_main_frame_args.IsValid()) { |
370 // Last processed begin main frame args records the frame args that we sent | 372 // Last processed begin main frame args records the frame args that we sent |
371 // to the main thread for the last frame that we've processed. If that is | 373 // to the main thread for the last frame that we've processed. If that is |
372 // set, that means the current frame is one past the frame in which we've | 374 // set, that means the current frame is one past the frame in which we've |
373 // finished the processing. | 375 // finished the processing. |
374 impl().layer_tree_host_impl->RecordMainFrameTiming( | 376 impl().layer_tree_host_impl->RecordMainFrameTiming( |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1031 | 1033 |
1032 void ThreadProxy::SetAnimationEvents(scoped_ptr<AnimationEventsVector> events) { | 1034 void ThreadProxy::SetAnimationEvents(scoped_ptr<AnimationEventsVector> events) { |
1033 TRACE_EVENT0("cc", "ThreadProxy::SetAnimationEvents"); | 1035 TRACE_EVENT0("cc", "ThreadProxy::SetAnimationEvents"); |
1034 DCHECK(IsMainThread()); | 1036 DCHECK(IsMainThread()); |
1035 layer_tree_host()->SetAnimationEvents(events.Pass()); | 1037 layer_tree_host()->SetAnimationEvents(events.Pass()); |
1036 } | 1038 } |
1037 | 1039 |
1038 void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion) { | 1040 void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion) { |
1039 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); | 1041 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); |
1040 DCHECK(IsImplThread()); | 1042 DCHECK(IsImplThread()); |
1043 | |
1044 // TODO(khushalsagar): ThreadedChannel will create ProxyImpl here and pass a | |
1045 // reference to itself. | |
1046 impl().channel_impl = threaded_channel_.get(); | |
1047 | |
1041 impl().layer_tree_host_impl = | 1048 impl().layer_tree_host_impl = |
1042 layer_tree_host()->CreateLayerTreeHostImpl(this); | 1049 layer_tree_host()->CreateLayerTreeHostImpl(this); |
1043 | 1050 |
1044 SchedulerSettings scheduler_settings( | 1051 SchedulerSettings scheduler_settings( |
1045 layer_tree_host()->settings().ToSchedulerSettings()); | 1052 layer_tree_host()->settings().ToSchedulerSettings()); |
1046 | 1053 |
1047 scoped_ptr<CompositorTimingHistory> compositor_timing_history( | 1054 scoped_ptr<CompositorTimingHistory> compositor_timing_history( |
1048 new CompositorTimingHistory(CompositorTimingHistory::RENDERER_UMA, | 1055 new CompositorTimingHistory(CompositorTimingHistory::RENDERER_UMA, |
1049 impl().rendering_stats_instrumentation)); | 1056 impl().rendering_stats_instrumentation)); |
1050 | 1057 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1265 } | 1272 } |
1266 | 1273 |
1267 void ThreadProxy::PostFrameTimingEvents( | 1274 void ThreadProxy::PostFrameTimingEvents( |
1268 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, | 1275 scoped_ptr<FrameTimingTracker::CompositeTimingSet> composite_events, |
1269 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { | 1276 scoped_ptr<FrameTimingTracker::MainFrameTimingSet> main_frame_events) { |
1270 DCHECK(IsMainThread()); | 1277 DCHECK(IsMainThread()); |
1271 layer_tree_host()->RecordFrameTimingEvents(composite_events.Pass(), | 1278 layer_tree_host()->RecordFrameTimingEvents(composite_events.Pass(), |
1272 main_frame_events.Pass()); | 1279 main_frame_events.Pass()); |
1273 } | 1280 } |
1274 | 1281 |
1282 base::WeakPtr<ProxyMain> ThreadProxy::GetMainWeakPtr() { | |
1283 return main_thread_weak_ptr_; | |
1284 } | |
1285 | |
1286 base::WeakPtr<ProxyImpl> ThreadProxy::GetImplWeakPtr() { | |
1287 return impl_thread_weak_ptr_; | |
1288 } | |
1289 | |
1275 } // namespace cc | 1290 } // namespace cc |
OLD | NEW |