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 "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "cc/base/thread.h" | 10 #include "cc/base/thread.h" |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
528 first_output_surface_ = first_output_surface.Pass(); | 528 first_output_surface_ = first_output_surface.Pass(); |
529 | 529 |
530 started_ = true; | 530 started_ = true; |
531 } | 531 } |
532 | 532 |
533 void ThreadProxy::Stop() { | 533 void ThreadProxy::Stop() { |
534 TRACE_EVENT0("cc", "ThreadProxy::Stop"); | 534 TRACE_EVENT0("cc", "ThreadProxy::Stop"); |
535 DCHECK(IsMainThread()); | 535 DCHECK(IsMainThread()); |
536 DCHECK(started_); | 536 DCHECK(started_); |
537 | 537 |
538 // Synchronously deletes the impl. | 538 // Synchronously finishes pending GL operations and deletes the impl. |
539 { | 539 { |
540 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 540 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
541 | 541 |
542 CompletionEvent completion; | 542 CompletionEvent completion; |
543 Proxy::ImplThread()->PostTask( | 543 Proxy::ImplThread()->PostTask( |
544 base::Bind(&ThreadProxy::FinishGLOnImplThread, | |
545 impl_thread_weak_ptr_, | |
546 &completion)); | |
547 completion.Wait(); | |
548 } { | |
piman
2013/04/27 00:42:25
nit: we usually put those on separate lines.
Also
danakj
2013/04/29 14:59:05
So, my thinking was that Finish will cause callbac
piman
2013/04/29 17:29:13
Ok, I see. I didn't think it would generally work
danakj
2013/04/30 01:30:52
Done.
| |
549 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | |
550 | |
551 CompletionEvent completion; | |
552 Proxy::ImplThread()->PostTask( | |
544 base::Bind(&ThreadProxy::LayerTreeHostClosedOnImplThread, | 553 base::Bind(&ThreadProxy::LayerTreeHostClosedOnImplThread, |
545 impl_thread_weak_ptr_, | 554 impl_thread_weak_ptr_, |
546 &completion)); | 555 &completion)); |
547 completion.Wait(); | 556 completion.Wait(); |
548 } | 557 } |
549 | 558 |
550 weak_factory_.InvalidateWeakPtrs(); | 559 weak_factory_.InvalidateWeakPtrs(); |
551 | 560 |
552 DCHECK(!layer_tree_host_impl_.get()); // verify that the impl deleted. | 561 DCHECK(!layer_tree_host_impl_.get()); // verify that the impl deleted. |
553 layer_tree_host_ = NULL; | 562 layer_tree_host_ = NULL; |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1165 set_offscreen_context_provider(offscreen_context_provider); | 1174 set_offscreen_context_provider(offscreen_context_provider); |
1166 | 1175 |
1167 scheduler_on_impl_thread_->DidCreateAndInitializeOutputSurface(); | 1176 scheduler_on_impl_thread_->DidCreateAndInitializeOutputSurface(); |
1168 } else if (offscreen_context_provider) { | 1177 } else if (offscreen_context_provider) { |
1169 offscreen_context_provider->VerifyContexts(); | 1178 offscreen_context_provider->VerifyContexts(); |
1170 } | 1179 } |
1171 | 1180 |
1172 completion->Signal(); | 1181 completion->Signal(); |
1173 } | 1182 } |
1174 | 1183 |
1184 void ThreadProxy::FinishGLOnImplThread(CompletionEvent* completion) { | |
1185 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); | |
piman
2013/04/27 00:42:25
nit: copy & paste of trace, I saw that.
danakj
2013/04/29 14:59:05
Done. *^_^*
| |
1186 DCHECK(IsImplThread()); | |
1187 if (layer_tree_host_impl_->resource_provider()) | |
1188 layer_tree_host_impl_->resource_provider()->Finish(); | |
1189 completion->Signal(); | |
1190 } | |
1191 | |
1175 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { | 1192 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { |
1176 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); | 1193 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); |
1177 DCHECK(IsImplThread()); | 1194 DCHECK(IsImplThread()); |
1178 layer_tree_host_->DeleteContentsTexturesOnImplThread( | 1195 layer_tree_host_->DeleteContentsTexturesOnImplThread( |
1179 layer_tree_host_impl_->resource_provider()); | 1196 layer_tree_host_impl_->resource_provider()); |
1180 layer_tree_host_impl_->EnableVSyncNotification(false); | 1197 layer_tree_host_impl_->EnableVSyncNotification(false); |
1181 input_handler_on_impl_thread_.reset(); | 1198 input_handler_on_impl_thread_.reset(); |
1182 layer_tree_host_impl_.reset(); | 1199 layer_tree_host_impl_.reset(); |
1183 scheduler_on_impl_thread_.reset(); | 1200 scheduler_on_impl_thread_.reset(); |
1184 weak_factory_on_impl_thread_.InvalidateWeakPtrs(); | 1201 weak_factory_on_impl_thread_.InvalidateWeakPtrs(); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1341 | 1358 |
1342 void ThreadProxy::DidReceiveLastInputEventForVSync( | 1359 void ThreadProxy::DidReceiveLastInputEventForVSync( |
1343 base::TimeTicks frame_time) { | 1360 base::TimeTicks frame_time) { |
1344 if (render_vsync_notification_enabled_) { | 1361 if (render_vsync_notification_enabled_) { |
1345 TRACE_EVENT0("cc", "ThreadProxy::DidReceiveLastInputEventForVSync"); | 1362 TRACE_EVENT0("cc", "ThreadProxy::DidReceiveLastInputEventForVSync"); |
1346 DidVSync(frame_time); | 1363 DidVSync(frame_time); |
1347 } | 1364 } |
1348 } | 1365 } |
1349 | 1366 |
1350 } // namespace cc | 1367 } // namespace cc |
OLD | NEW |