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 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 | 509 |
510 void ThreadProxy::MainThreadHasStoppedFlinging() { | 510 void ThreadProxy::MainThreadHasStoppedFlinging() { |
511 DCHECK(IsMainThread()); | 511 DCHECK(IsMainThread()); |
512 Proxy::ImplThread()->PostTask( | 512 Proxy::ImplThread()->PostTask( |
513 base::Bind(&ThreadProxy::MainThreadHasStoppedFlingingOnImplThread, | 513 base::Bind(&ThreadProxy::MainThreadHasStoppedFlingingOnImplThread, |
514 impl_thread_weak_ptr_)); | 514 impl_thread_weak_ptr_)); |
515 } | 515 } |
516 | 516 |
517 void ThreadProxy::MainThreadHasStoppedFlingingOnImplThread() { | 517 void ThreadProxy::MainThreadHasStoppedFlingingOnImplThread() { |
518 DCHECK(IsImplThread()); | 518 DCHECK(IsImplThread()); |
519 if (input_handler_client_on_impl_thread_) | 519 layer_tree_host_impl_->MainThreadHasStoppedFlinging(); |
520 input_handler_client_on_impl_thread_->MainThreadHasStoppedFlinging(); | |
521 } | 520 } |
522 | 521 |
523 void ThreadProxy::Start(scoped_ptr<OutputSurface> first_output_surface) { | 522 void ThreadProxy::Start(scoped_ptr<OutputSurface> first_output_surface) { |
524 DCHECK(IsMainThread()); | 523 DCHECK(IsMainThread()); |
525 DCHECK(Proxy::ImplThread()); | 524 DCHECK(Proxy::ImplThread()); |
526 DCHECK(first_output_surface); | 525 DCHECK(first_output_surface); |
527 // Create LayerTreeHostImpl. | 526 // Create LayerTreeHostImpl. |
528 DebugScopedSetMainThreadBlocked main_thread_blocked(this); | 527 DebugScopedSetMainThreadBlocked main_thread_blocked(this); |
529 CompletionEvent completion; | 528 CompletionEvent completion; |
530 scoped_ptr<InputHandlerClient> input_handler_client = | |
531 layer_tree_host_->CreateInputHandlerClient(); | |
532 Proxy::ImplThread()->PostTask( | 529 Proxy::ImplThread()->PostTask( |
533 base::Bind(&ThreadProxy::InitializeImplOnImplThread, | 530 base::Bind(&ThreadProxy::InitializeImplOnImplThread, |
534 base::Unretained(this), | 531 base::Unretained(this), |
535 &completion, | 532 &completion)); |
536 input_handler_client.release())); | |
537 completion.Wait(); | 533 completion.Wait(); |
538 | 534 |
539 main_thread_weak_ptr_ = weak_factory_.GetWeakPtr(); | 535 main_thread_weak_ptr_ = weak_factory_.GetWeakPtr(); |
540 first_output_surface_ = first_output_surface.Pass(); | 536 first_output_surface_ = first_output_surface.Pass(); |
541 | 537 |
542 started_ = true; | 538 started_ = true; |
543 } | 539 } |
544 | 540 |
545 void ThreadProxy::Stop() { | 541 void ThreadProxy::Stop() { |
546 TRACE_EVENT0("cc", "ThreadProxy::Stop"); | 542 TRACE_EVENT0("cc", "ThreadProxy::Stop"); |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 return result; | 886 return result; |
891 | 887 |
892 DCHECK(layer_tree_host_impl_->renderer()); | 888 DCHECK(layer_tree_host_impl_->renderer()); |
893 if (!layer_tree_host_impl_->renderer()) | 889 if (!layer_tree_host_impl_->renderer()) |
894 return result; | 890 return result; |
895 | 891 |
896 base::TimeTicks monotonic_time = | 892 base::TimeTicks monotonic_time = |
897 layer_tree_host_impl_->CurrentFrameTimeTicks(); | 893 layer_tree_host_impl_->CurrentFrameTimeTicks(); |
898 base::Time wall_clock_time = layer_tree_host_impl_->CurrentFrameTime(); | 894 base::Time wall_clock_time = layer_tree_host_impl_->CurrentFrameTime(); |
899 | 895 |
900 if (input_handler_client_on_impl_thread_) | |
901 input_handler_client_on_impl_thread_->Animate(monotonic_time); | |
902 | |
903 layer_tree_host_impl_->ActivatePendingTreeIfNeeded(); | 896 layer_tree_host_impl_->ActivatePendingTreeIfNeeded(); |
904 layer_tree_host_impl_->Animate(monotonic_time, wall_clock_time); | 897 layer_tree_host_impl_->Animate(monotonic_time, wall_clock_time); |
905 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(false); | 898 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(false); |
906 | 899 |
907 // This method is called on a forced draw, regardless of whether we are able | 900 // This method is called on a forced draw, regardless of whether we are able |
908 // to produce a frame, as the calling site on main thread is blocked until its | 901 // to produce a frame, as the calling site on main thread is blocked until its |
909 // request completes, and we signal completion here. If CanDraw() is false, we | 902 // request completes, and we signal completion here. If CanDraw() is false, we |
910 // will indicate success=false to the caller, but we must still signal | 903 // will indicate success=false to the caller, but we must still signal |
911 // completion to avoid deadlock. | 904 // completion to avoid deadlock. |
912 | 905 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1098 | 1091 |
1099 void ThreadProxy::HasInitializedOutputSurfaceOnImplThread( | 1092 void ThreadProxy::HasInitializedOutputSurfaceOnImplThread( |
1100 CompletionEvent* completion, | 1093 CompletionEvent* completion, |
1101 bool* has_initialized_output_surface) { | 1094 bool* has_initialized_output_surface) { |
1102 DCHECK(IsImplThread()); | 1095 DCHECK(IsImplThread()); |
1103 *has_initialized_output_surface = | 1096 *has_initialized_output_surface = |
1104 scheduler_on_impl_thread_->HasInitializedOutputSurface(); | 1097 scheduler_on_impl_thread_->HasInitializedOutputSurface(); |
1105 completion->Signal(); | 1098 completion->Signal(); |
1106 } | 1099 } |
1107 | 1100 |
1108 void ThreadProxy::InitializeImplOnImplThread( | 1101 void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion) { |
1109 CompletionEvent* completion, | |
1110 InputHandlerClient* input_handler_client) { | |
1111 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); | 1102 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); |
1112 DCHECK(IsImplThread()); | 1103 DCHECK(IsImplThread()); |
1113 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); | 1104 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); |
1114 const base::TimeDelta display_refresh_interval = | 1105 const base::TimeDelta display_refresh_interval = |
1115 base::TimeDelta::FromMicroseconds( | 1106 base::TimeDelta::FromMicroseconds( |
1116 base::Time::kMicrosecondsPerSecond / | 1107 base::Time::kMicrosecondsPerSecond / |
1117 layer_tree_host_->settings().refresh_rate); | 1108 layer_tree_host_->settings().refresh_rate); |
1118 scoped_ptr<FrameRateController> frame_rate_controller; | 1109 scoped_ptr<FrameRateController> frame_rate_controller; |
1119 if (render_vsync_enabled_) { | 1110 if (render_vsync_enabled_) { |
1120 if (render_vsync_notification_enabled_) { | 1111 if (render_vsync_notification_enabled_) { |
(...skipping 14 matching lines...) Expand all Loading... |
1135 const LayerTreeSettings& settings = layer_tree_host_->settings(); | 1126 const LayerTreeSettings& settings = layer_tree_host_->settings(); |
1136 SchedulerSettings scheduler_settings; | 1127 SchedulerSettings scheduler_settings; |
1137 scheduler_settings.impl_side_painting = settings.impl_side_painting; | 1128 scheduler_settings.impl_side_painting = settings.impl_side_painting; |
1138 scheduler_settings.timeout_and_draw_when_animation_checkerboards = | 1129 scheduler_settings.timeout_and_draw_when_animation_checkerboards = |
1139 settings.timeout_and_draw_when_animation_checkerboards; | 1130 settings.timeout_and_draw_when_animation_checkerboards; |
1140 scheduler_on_impl_thread_ = Scheduler::Create(this, | 1131 scheduler_on_impl_thread_ = Scheduler::Create(this, |
1141 frame_rate_controller.Pass(), | 1132 frame_rate_controller.Pass(), |
1142 scheduler_settings); | 1133 scheduler_settings); |
1143 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); | 1134 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); |
1144 | 1135 |
1145 input_handler_client_on_impl_thread_.reset(input_handler_client); | |
1146 if (input_handler_client_on_impl_thread_) { | |
1147 input_handler_client_on_impl_thread_->BindToHandler( | |
1148 layer_tree_host_impl_.get()); | |
1149 } | |
1150 | |
1151 impl_thread_weak_ptr_ = weak_factory_on_impl_thread_.GetWeakPtr(); | 1136 impl_thread_weak_ptr_ = weak_factory_on_impl_thread_.GetWeakPtr(); |
1152 completion->Signal(); | 1137 completion->Signal(); |
1153 } | 1138 } |
1154 | 1139 |
1155 void ThreadProxy::InitializeOutputSurfaceOnImplThread( | 1140 void ThreadProxy::InitializeOutputSurfaceOnImplThread( |
1156 CompletionEvent* completion, | 1141 CompletionEvent* completion, |
1157 scoped_ptr<OutputSurface> output_surface, | 1142 scoped_ptr<OutputSurface> output_surface, |
1158 scoped_refptr<ContextProvider> offscreen_context_provider, | 1143 scoped_refptr<ContextProvider> offscreen_context_provider, |
1159 bool* success, | 1144 bool* success, |
1160 RendererCapabilities* capabilities) { | 1145 RendererCapabilities* capabilities) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 layer_tree_host_impl_->resource_provider()->Finish(); | 1191 layer_tree_host_impl_->resource_provider()->Finish(); |
1207 completion->Signal(); | 1192 completion->Signal(); |
1208 } | 1193 } |
1209 | 1194 |
1210 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { | 1195 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { |
1211 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); | 1196 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); |
1212 DCHECK(IsImplThread()); | 1197 DCHECK(IsImplThread()); |
1213 layer_tree_host_->DeleteContentsTexturesOnImplThread( | 1198 layer_tree_host_->DeleteContentsTexturesOnImplThread( |
1214 layer_tree_host_impl_->resource_provider()); | 1199 layer_tree_host_impl_->resource_provider()); |
1215 layer_tree_host_impl_->EnableVSyncNotification(false); | 1200 layer_tree_host_impl_->EnableVSyncNotification(false); |
1216 input_handler_client_on_impl_thread_.reset(); | |
1217 layer_tree_host_impl_.reset(); | 1201 layer_tree_host_impl_.reset(); |
1218 scheduler_on_impl_thread_.reset(); | 1202 scheduler_on_impl_thread_.reset(); |
1219 weak_factory_on_impl_thread_.InvalidateWeakPtrs(); | 1203 weak_factory_on_impl_thread_.InvalidateWeakPtrs(); |
1220 vsync_client_ = NULL; | 1204 vsync_client_ = NULL; |
1221 completion->Signal(); | 1205 completion->Signal(); |
1222 } | 1206 } |
1223 | 1207 |
1224 size_t ThreadProxy::MaxPartialTextureUpdates() const { | 1208 size_t ThreadProxy::MaxPartialTextureUpdates() const { |
1225 return ResourceUpdateController::MaxPartialTextureUpdates(); | 1209 return ResourceUpdateController::MaxPartialTextureUpdates(); |
1226 } | 1210 } |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1376 | 1360 |
1377 void ThreadProxy::DidReceiveLastInputEventForVSync( | 1361 void ThreadProxy::DidReceiveLastInputEventForVSync( |
1378 base::TimeTicks frame_time) { | 1362 base::TimeTicks frame_time) { |
1379 if (render_vsync_notification_enabled_) { | 1363 if (render_vsync_notification_enabled_) { |
1380 TRACE_EVENT0("cc", "ThreadProxy::DidReceiveLastInputEventForVSync"); | 1364 TRACE_EVENT0("cc", "ThreadProxy::DidReceiveLastInputEventForVSync"); |
1381 DidVSync(frame_time); | 1365 DidVSync(frame_time); |
1382 } | 1366 } |
1383 } | 1367 } |
1384 | 1368 |
1385 } // namespace cc | 1369 } // namespace cc |
OLD | NEW |