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

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: address feedback 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 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
1092 1085
1093 void ThreadProxy::HasInitializedOutputSurfaceOnImplThread( 1086 void ThreadProxy::HasInitializedOutputSurfaceOnImplThread(
1094 CompletionEvent* completion, 1087 CompletionEvent* completion,
1095 bool* has_initialized_output_surface) { 1088 bool* has_initialized_output_surface) {
1096 DCHECK(IsImplThread()); 1089 DCHECK(IsImplThread());
1097 *has_initialized_output_surface = 1090 *has_initialized_output_surface =
1098 scheduler_on_impl_thread_->HasInitializedOutputSurface(); 1091 scheduler_on_impl_thread_->HasInitializedOutputSurface();
1099 completion->Signal(); 1092 completion->Signal();
1100 } 1093 }
1101 1094
1102 void ThreadProxy::InitializeImplOnImplThread( 1095 void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion) {
1103 CompletionEvent* completion,
1104 InputHandlerClient* input_handler_client) {
1105 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); 1096 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread");
1106 DCHECK(IsImplThread()); 1097 DCHECK(IsImplThread());
1107 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); 1098 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this);
1108 const base::TimeDelta display_refresh_interval = 1099 const base::TimeDelta display_refresh_interval =
1109 base::TimeDelta::FromMicroseconds( 1100 base::TimeDelta::FromMicroseconds(
1110 base::Time::kMicrosecondsPerSecond / 1101 base::Time::kMicrosecondsPerSecond /
1111 layer_tree_host_->settings().refresh_rate); 1102 layer_tree_host_->settings().refresh_rate);
1112 scoped_ptr<FrameRateController> frame_rate_controller; 1103 scoped_ptr<FrameRateController> frame_rate_controller;
1113 if (render_vsync_enabled_) { 1104 if (render_vsync_enabled_) {
1114 if (render_vsync_notification_enabled_) { 1105 if (render_vsync_notification_enabled_) {
(...skipping 14 matching lines...) Expand all
1129 const LayerTreeSettings& settings = layer_tree_host_->settings(); 1120 const LayerTreeSettings& settings = layer_tree_host_->settings();
1130 SchedulerSettings scheduler_settings; 1121 SchedulerSettings scheduler_settings;
1131 scheduler_settings.impl_side_painting = settings.impl_side_painting; 1122 scheduler_settings.impl_side_painting = settings.impl_side_painting;
1132 scheduler_settings.timeout_and_draw_when_animation_checkerboards = 1123 scheduler_settings.timeout_and_draw_when_animation_checkerboards =
1133 settings.timeout_and_draw_when_animation_checkerboards; 1124 settings.timeout_and_draw_when_animation_checkerboards;
1134 scheduler_on_impl_thread_ = Scheduler::Create(this, 1125 scheduler_on_impl_thread_ = Scheduler::Create(this,
1135 frame_rate_controller.Pass(), 1126 frame_rate_controller.Pass(),
1136 scheduler_settings); 1127 scheduler_settings);
1137 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); 1128 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible());
1138 1129
1139 input_handler_client_on_impl_thread_.reset(input_handler_client);
1140 if (input_handler_client_on_impl_thread_) {
1141 input_handler_client_on_impl_thread_->BindToHandler(
1142 layer_tree_host_impl_.get());
1143 }
1144
1145 impl_thread_weak_ptr_ = weak_factory_on_impl_thread_.GetWeakPtr(); 1130 impl_thread_weak_ptr_ = weak_factory_on_impl_thread_.GetWeakPtr();
1146 completion->Signal(); 1131 completion->Signal();
1147 } 1132 }
1148 1133
1149 void ThreadProxy::InitializeOutputSurfaceOnImplThread( 1134 void ThreadProxy::InitializeOutputSurfaceOnImplThread(
1150 CompletionEvent* completion, 1135 CompletionEvent* completion,
1151 scoped_ptr<OutputSurface> output_surface, 1136 scoped_ptr<OutputSurface> output_surface,
1152 scoped_refptr<ContextProvider> offscreen_context_provider, 1137 scoped_refptr<ContextProvider> offscreen_context_provider,
1153 bool* success, 1138 bool* success,
1154 RendererCapabilities* capabilities) { 1139 RendererCapabilities* capabilities) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1200 layer_tree_host_impl_->resource_provider()->Finish(); 1185 layer_tree_host_impl_->resource_provider()->Finish();
1201 completion->Signal(); 1186 completion->Signal();
1202 } 1187 }
1203 1188
1204 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { 1189 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) {
1205 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); 1190 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread");
1206 DCHECK(IsImplThread()); 1191 DCHECK(IsImplThread());
1207 layer_tree_host_->DeleteContentsTexturesOnImplThread( 1192 layer_tree_host_->DeleteContentsTexturesOnImplThread(
1208 layer_tree_host_impl_->resource_provider()); 1193 layer_tree_host_impl_->resource_provider());
1209 layer_tree_host_impl_->EnableVSyncNotification(false); 1194 layer_tree_host_impl_->EnableVSyncNotification(false);
1210 input_handler_client_on_impl_thread_.reset();
1211 scheduler_on_impl_thread_.reset(); 1195 scheduler_on_impl_thread_.reset();
1212 layer_tree_host_impl_.reset(); 1196 layer_tree_host_impl_.reset();
1213 weak_factory_on_impl_thread_.InvalidateWeakPtrs(); 1197 weak_factory_on_impl_thread_.InvalidateWeakPtrs();
1214 vsync_client_ = NULL; 1198 vsync_client_ = NULL;
1215 completion->Signal(); 1199 completion->Signal();
1216 } 1200 }
1217 1201
1218 size_t ThreadProxy::MaxPartialTextureUpdates() const { 1202 size_t ThreadProxy::MaxPartialTextureUpdates() const {
1219 return ResourceUpdateController::MaxPartialTextureUpdates(); 1203 return ResourceUpdateController::MaxPartialTextureUpdates();
1220 } 1204 }
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1384 !layer_tree_host_impl_->pending_tree()) { 1368 !layer_tree_host_impl_->pending_tree()) {
1385 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation", 1369 TRACE_EVENT_INSTANT0("cc", "ReleaseCommitbyActivation",
1386 TRACE_EVENT_SCOPE_THREAD); 1370 TRACE_EVENT_SCOPE_THREAD);
1387 DCHECK(layer_tree_host_impl_->settings().impl_side_painting); 1371 DCHECK(layer_tree_host_impl_->settings().impl_side_painting);
1388 completion_event_for_commit_held_on_tree_activation_->Signal(); 1372 completion_event_for_commit_held_on_tree_activation_->Signal();
1389 completion_event_for_commit_held_on_tree_activation_ = NULL; 1373 completion_event_for_commit_held_on_tree_activation_ = NULL;
1390 } 1374 }
1391 } 1375 }
1392 1376
1393 } // namespace cc 1377 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698