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 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 main_thread_weak_ptr_ = weak_factory_.GetWeakPtr(); | 539 main_thread_weak_ptr_ = weak_factory_.GetWeakPtr(); |
540 | 540 |
541 started_ = true; | 541 started_ = true; |
542 } | 542 } |
543 | 543 |
544 void ThreadProxy::Stop() { | 544 void ThreadProxy::Stop() { |
545 TRACE_EVENT0("cc", "ThreadProxy::Stop"); | 545 TRACE_EVENT0("cc", "ThreadProxy::Stop"); |
546 DCHECK(IsMainThread()); | 546 DCHECK(IsMainThread()); |
547 DCHECK(started_); | 547 DCHECK(started_); |
548 | 548 |
549 // Synchronously deletes the impl. | 549 // Synchronously finishes pending GL operations and deletes the impl. |
550 { | 550 { |
551 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 551 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
552 | 552 |
553 CompletionEvent completion; | 553 CompletionEvent completion; |
554 Proxy::ImplThread()->PostTask( | 554 Proxy::ImplThread()->PostTask( |
| 555 base::Bind(&ThreadProxy::FinishGLOnImplThread, |
| 556 impl_thread_weak_ptr_, |
| 557 &completion)); |
| 558 completion.Wait(); |
| 559 } { |
| 560 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
| 561 |
| 562 CompletionEvent completion; |
| 563 Proxy::ImplThread()->PostTask( |
555 base::Bind(&ThreadProxy::LayerTreeHostClosedOnImplThread, | 564 base::Bind(&ThreadProxy::LayerTreeHostClosedOnImplThread, |
556 impl_thread_weak_ptr_, | 565 impl_thread_weak_ptr_, |
557 &completion)); | 566 &completion)); |
558 completion.Wait(); | 567 completion.Wait(); |
559 } | 568 } |
560 | 569 |
561 weak_factory_.InvalidateWeakPtrs(); | 570 weak_factory_.InvalidateWeakPtrs(); |
562 | 571 |
563 DCHECK(!layer_tree_host_impl_.get()); // verify that the impl deleted. | 572 DCHECK(!layer_tree_host_impl_.get()); // verify that the impl deleted. |
564 layer_tree_host_ = NULL; | 573 layer_tree_host_ = NULL; |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1146 max_frames_pending = FrameRateController::DEFAULT_MAX_FRAMES_PENDING; | 1155 max_frames_pending = FrameRateController::DEFAULT_MAX_FRAMES_PENDING; |
1147 if (layer_tree_host_impl_->output_surface()->capabilities(). | 1156 if (layer_tree_host_impl_->output_surface()->capabilities(). |
1148 has_parent_compositor) | 1157 has_parent_compositor) |
1149 max_frames_pending = 1; | 1158 max_frames_pending = 1; |
1150 scheduler_on_impl_thread_->SetMaxFramesPending(max_frames_pending); | 1159 scheduler_on_impl_thread_->SetMaxFramesPending(max_frames_pending); |
1151 } | 1160 } |
1152 | 1161 |
1153 completion->Signal(); | 1162 completion->Signal(); |
1154 } | 1163 } |
1155 | 1164 |
| 1165 void ThreadProxy::FinishGLOnImplThread(CompletionEvent* completion) { |
| 1166 TRACE_EVENT0("cc", "ThreadProxy::FinishGLOnImplThread"); |
| 1167 DCHECK(IsImplThread()); |
| 1168 if (layer_tree_host_impl_->resource_provider()) |
| 1169 layer_tree_host_impl_->resource_provider()->Finish(); |
| 1170 completion->Signal(); |
| 1171 } |
| 1172 |
1156 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { | 1173 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { |
1157 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); | 1174 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); |
1158 DCHECK(IsImplThread()); | 1175 DCHECK(IsImplThread()); |
1159 layer_tree_host_->DeleteContentsTexturesOnImplThread( | 1176 layer_tree_host_->DeleteContentsTexturesOnImplThread( |
1160 layer_tree_host_impl_->resource_provider()); | 1177 layer_tree_host_impl_->resource_provider()); |
1161 layer_tree_host_impl_->EnableVSyncNotification(false); | 1178 layer_tree_host_impl_->EnableVSyncNotification(false); |
1162 input_handler_on_impl_thread_.reset(); | 1179 input_handler_on_impl_thread_.reset(); |
1163 layer_tree_host_impl_.reset(); | 1180 layer_tree_host_impl_.reset(); |
1164 scheduler_on_impl_thread_.reset(); | 1181 scheduler_on_impl_thread_.reset(); |
1165 weak_factory_on_impl_thread_.InvalidateWeakPtrs(); | 1182 weak_factory_on_impl_thread_.InvalidateWeakPtrs(); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1349 | 1366 |
1350 void ThreadProxy::DidReceiveLastInputEventForVSync( | 1367 void ThreadProxy::DidReceiveLastInputEventForVSync( |
1351 base::TimeTicks frame_time) { | 1368 base::TimeTicks frame_time) { |
1352 if (render_vsync_notification_enabled_) { | 1369 if (render_vsync_notification_enabled_) { |
1353 TRACE_EVENT0("cc", "ThreadProxy::DidReceiveLastInputEventForVSync"); | 1370 TRACE_EVENT0("cc", "ThreadProxy::DidReceiveLastInputEventForVSync"); |
1354 DidVSync(frame_time); | 1371 DidVSync(frame_time); |
1355 } | 1372 } |
1356 } | 1373 } |
1357 | 1374 |
1358 } // namespace cc | 1375 } // namespace cc |
OLD | NEW |