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

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

Powered by Google App Engine
This is Rietveld 408576698