Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: cc/trees/thread_proxy.cc

Issue 13844021: Move compositor thread input handling logic into content (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win component build Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 506
507 void ThreadProxy::MainThreadHasStoppedFlinging() { 507 void ThreadProxy::MainThreadHasStoppedFlinging() {
508 DCHECK(IsMainThread()); 508 DCHECK(IsMainThread());
509 Proxy::ImplThread()->PostTask( 509 Proxy::ImplThread()->PostTask(
510 base::Bind(&ThreadProxy::MainThreadHasStoppedFlingingOnImplThread, 510 base::Bind(&ThreadProxy::MainThreadHasStoppedFlingingOnImplThread,
511 impl_thread_weak_ptr_)); 511 impl_thread_weak_ptr_));
512 } 512 }
513 513
514 void ThreadProxy::MainThreadHasStoppedFlingingOnImplThread() { 514 void ThreadProxy::MainThreadHasStoppedFlingingOnImplThread() {
515 DCHECK(IsImplThread()); 515 DCHECK(IsImplThread());
516 if (input_handler_client_on_impl_thread_) 516 layer_tree_host_impl_->MainThreadHasStoppedFlinging();
517 input_handler_client_on_impl_thread_->MainThreadHasStoppedFlinging();
518 } 517 }
519 518
520 void ThreadProxy::Start(scoped_ptr<OutputSurface> first_output_surface) { 519 void ThreadProxy::Start(scoped_ptr<OutputSurface> first_output_surface) {
521 DCHECK(IsMainThread()); 520 DCHECK(IsMainThread());
522 DCHECK(Proxy::ImplThread()); 521 DCHECK(Proxy::ImplThread());
523 DCHECK(first_output_surface); 522 DCHECK(first_output_surface);
524 // Create LayerTreeHostImpl. 523 // Create LayerTreeHostImpl.
525 DebugScopedSetMainThreadBlocked main_thread_blocked(this); 524 DebugScopedSetMainThreadBlocked main_thread_blocked(this);
526 CompletionEvent completion; 525 CompletionEvent completion;
527 scoped_ptr<InputHandlerClient> input_handler_client =
528 layer_tree_host_->CreateInputHandlerClient();
529 Proxy::ImplThread()->PostTask( 526 Proxy::ImplThread()->PostTask(
530 base::Bind(&ThreadProxy::InitializeImplOnImplThread, 527 base::Bind(&ThreadProxy::InitializeImplOnImplThread,
531 base::Unretained(this), 528 base::Unretained(this),
532 &completion, 529 &completion));
533 input_handler_client.release()));
534 completion.Wait(); 530 completion.Wait();
535 531
536 main_thread_weak_ptr_ = weak_factory_.GetWeakPtr(); 532 main_thread_weak_ptr_ = weak_factory_.GetWeakPtr();
537 first_output_surface_ = first_output_surface.Pass(); 533 first_output_surface_ = first_output_surface.Pass();
538 534
539 started_ = true; 535 started_ = true;
540 } 536 }
541 537
542 void ThreadProxy::Stop() { 538 void ThreadProxy::Stop() {
543 TRACE_EVENT0("cc", "ThreadProxy::Stop"); 539 TRACE_EVENT0("cc", "ThreadProxy::Stop");
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 return result; 881 return result;
886 882
887 DCHECK(layer_tree_host_impl_->renderer()); 883 DCHECK(layer_tree_host_impl_->renderer());
888 if (!layer_tree_host_impl_->renderer()) 884 if (!layer_tree_host_impl_->renderer())
889 return result; 885 return result;
890 886
891 base::TimeTicks monotonic_time = 887 base::TimeTicks monotonic_time =
892 layer_tree_host_impl_->CurrentFrameTimeTicks(); 888 layer_tree_host_impl_->CurrentFrameTimeTicks();
893 base::Time wall_clock_time = layer_tree_host_impl_->CurrentFrameTime(); 889 base::Time wall_clock_time = layer_tree_host_impl_->CurrentFrameTime();
894 890
895 if (input_handler_client_on_impl_thread_)
896 input_handler_client_on_impl_thread_->Animate(monotonic_time);
897
898 layer_tree_host_impl_->ActivatePendingTreeIfNeeded(); 891 layer_tree_host_impl_->ActivatePendingTreeIfNeeded();
899 layer_tree_host_impl_->Animate(monotonic_time, wall_clock_time); 892 layer_tree_host_impl_->Animate(monotonic_time, wall_clock_time);
900 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(false); 893 layer_tree_host_impl_->UpdateBackgroundAnimateTicking(false);
901 894
902 // This method is called on a forced draw, regardless of whether we are able 895 // This method is called on a forced draw, regardless of whether we are able
903 // to produce a frame, as the calling site on main thread is blocked until its 896 // to produce a frame, as the calling site on main thread is blocked until its
904 // request completes, and we signal completion here. If CanDraw() is false, we 897 // request completes, and we signal completion here. If CanDraw() is false, we
905 // will indicate success=false to the caller, but we must still signal 898 // will indicate success=false to the caller, but we must still signal
906 // completion to avoid deadlock. 899 // completion to avoid deadlock.
907 900
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1093 1086
1094 void ThreadProxy::HasInitializedOutputSurfaceOnImplThread( 1087 void ThreadProxy::HasInitializedOutputSurfaceOnImplThread(
1095 CompletionEvent* completion, 1088 CompletionEvent* completion,
1096 bool* has_initialized_output_surface) { 1089 bool* has_initialized_output_surface) {
1097 DCHECK(IsImplThread()); 1090 DCHECK(IsImplThread());
1098 *has_initialized_output_surface = 1091 *has_initialized_output_surface =
1099 scheduler_on_impl_thread_->HasInitializedOutputSurface(); 1092 scheduler_on_impl_thread_->HasInitializedOutputSurface();
1100 completion->Signal(); 1093 completion->Signal();
1101 } 1094 }
1102 1095
1103 void ThreadProxy::InitializeImplOnImplThread( 1096 void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion) {
1104 CompletionEvent* completion,
1105 InputHandlerClient* input_handler_client) {
1106 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); 1097 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread");
1107 DCHECK(IsImplThread()); 1098 DCHECK(IsImplThread());
1108 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); 1099 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this);
1109 const base::TimeDelta display_refresh_interval = 1100 const base::TimeDelta display_refresh_interval =
1110 base::TimeDelta::FromMicroseconds( 1101 base::TimeDelta::FromMicroseconds(
1111 base::Time::kMicrosecondsPerSecond / 1102 base::Time::kMicrosecondsPerSecond /
1112 layer_tree_host_->settings().refresh_rate); 1103 layer_tree_host_->settings().refresh_rate);
1113 scoped_ptr<FrameRateController> frame_rate_controller; 1104 scoped_ptr<FrameRateController> frame_rate_controller;
1114 if (render_vsync_enabled_) { 1105 if (render_vsync_enabled_) {
1115 if (render_vsync_notification_enabled_) { 1106 if (render_vsync_notification_enabled_) {
(...skipping 10 matching lines...) Expand all
1126 const LayerTreeSettings& settings = layer_tree_host_->settings(); 1117 const LayerTreeSettings& settings = layer_tree_host_->settings();
1127 SchedulerSettings scheduler_settings; 1118 SchedulerSettings scheduler_settings;
1128 scheduler_settings.impl_side_painting = settings.impl_side_painting; 1119 scheduler_settings.impl_side_painting = settings.impl_side_painting;
1129 scheduler_settings.timeout_and_draw_when_animation_checkerboards = 1120 scheduler_settings.timeout_and_draw_when_animation_checkerboards =
1130 settings.timeout_and_draw_when_animation_checkerboards; 1121 settings.timeout_and_draw_when_animation_checkerboards;
1131 scheduler_on_impl_thread_ = Scheduler::Create(this, 1122 scheduler_on_impl_thread_ = Scheduler::Create(this,
1132 frame_rate_controller.Pass(), 1123 frame_rate_controller.Pass(),
1133 scheduler_settings); 1124 scheduler_settings);
1134 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); 1125 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible());
1135 1126
1136 input_handler_client_on_impl_thread_.reset(input_handler_client);
1137 if (input_handler_client_on_impl_thread_) {
1138 input_handler_client_on_impl_thread_->BindToHandler(
1139 layer_tree_host_impl_.get());
1140 }
1141
1142 impl_thread_weak_ptr_ = weak_factory_on_impl_thread_.GetWeakPtr(); 1127 impl_thread_weak_ptr_ = weak_factory_on_impl_thread_.GetWeakPtr();
1143 completion->Signal(); 1128 completion->Signal();
1144 } 1129 }
1145 1130
1146 void ThreadProxy::InitializeOutputSurfaceOnImplThread( 1131 void ThreadProxy::InitializeOutputSurfaceOnImplThread(
1147 CompletionEvent* completion, 1132 CompletionEvent* completion,
1148 scoped_ptr<OutputSurface> output_surface, 1133 scoped_ptr<OutputSurface> output_surface,
1149 scoped_refptr<ContextProvider> offscreen_context_provider, 1134 scoped_refptr<ContextProvider> offscreen_context_provider,
1150 bool* success, 1135 bool* success,
1151 RendererCapabilities* capabilities) { 1136 RendererCapabilities* capabilities) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 layer_tree_host_impl_->resource_provider()->Finish(); 1182 layer_tree_host_impl_->resource_provider()->Finish();
1198 completion->Signal(); 1183 completion->Signal();
1199 } 1184 }
1200 1185
1201 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { 1186 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) {
1202 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); 1187 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread");
1203 DCHECK(IsImplThread()); 1188 DCHECK(IsImplThread());
1204 layer_tree_host_->DeleteContentsTexturesOnImplThread( 1189 layer_tree_host_->DeleteContentsTexturesOnImplThread(
1205 layer_tree_host_impl_->resource_provider()); 1190 layer_tree_host_impl_->resource_provider());
1206 layer_tree_host_impl_->EnableVSyncNotification(false); 1191 layer_tree_host_impl_->EnableVSyncNotification(false);
1207 input_handler_client_on_impl_thread_.reset();
1208 layer_tree_host_impl_.reset(); 1192 layer_tree_host_impl_.reset();
1209 scheduler_on_impl_thread_.reset(); 1193 scheduler_on_impl_thread_.reset();
1210 weak_factory_on_impl_thread_.InvalidateWeakPtrs(); 1194 weak_factory_on_impl_thread_.InvalidateWeakPtrs();
1211 vsync_client_ = NULL; 1195 vsync_client_ = NULL;
1212 completion->Signal(); 1196 completion->Signal();
1213 } 1197 }
1214 1198
1215 size_t ThreadProxy::MaxPartialTextureUpdates() const { 1199 size_t ThreadProxy::MaxPartialTextureUpdates() const {
1216 return ResourceUpdateController::MaxPartialTextureUpdates(); 1200 return ResourceUpdateController::MaxPartialTextureUpdates();
1217 } 1201 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 1351
1368 void ThreadProxy::DidReceiveLastInputEventForVSync( 1352 void ThreadProxy::DidReceiveLastInputEventForVSync(
1369 base::TimeTicks frame_time) { 1353 base::TimeTicks frame_time) {
1370 if (render_vsync_notification_enabled_) { 1354 if (render_vsync_notification_enabled_) {
1371 TRACE_EVENT0("cc", "ThreadProxy::DidReceiveLastInputEventForVSync"); 1355 TRACE_EVENT0("cc", "ThreadProxy::DidReceiveLastInputEventForVSync");
1372 DidVSync(frame_time); 1356 DidVSync(frame_time);
1373 } 1357 }
1374 } 1358 }
1375 1359
1376 } // namespace cc 1360 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698