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" |
11 #include "cc/input/input_handler.h" | 11 #include "cc/input/input_handler.h" |
12 #include "cc/output/context_provider.h" | 12 #include "cc/output/context_provider.h" |
13 #include "cc/output/output_surface.h" | 13 #include "cc/output/output_surface.h" |
14 #include "cc/quads/draw_quad.h" | 14 #include "cc/quads/draw_quad.h" |
15 #include "cc/resources/prioritized_resource_manager.h" | 15 #include "cc/resources/prioritized_resource_manager.h" |
16 #include "cc/scheduler/delay_based_time_source.h" | 16 #include "cc/scheduler/delay_based_time_source.h" |
17 #include "cc/scheduler/frame_rate_controller.h" | 17 #include "cc/scheduler/frame_rate_controller.h" |
18 #include "cc/scheduler/scheduler.h" | 18 #include "cc/scheduler/scheduler.h" |
| 19 #include "cc/scheduler/vsync_time_source.h" |
19 #include "cc/trees/layer_tree_host.h" | 20 #include "cc/trees/layer_tree_host.h" |
20 #include "cc/trees/layer_tree_impl.h" | 21 #include "cc/trees/layer_tree_impl.h" |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
24 // Measured in seconds. | 25 // Measured in seconds. |
25 const double kContextRecreationTickRate = 0.03; | 26 const double kContextRecreationTickRate = 0.03; |
26 | 27 |
27 // Measured in seconds. | 28 // Measured in seconds. |
28 const double kSmoothnessTakesPriorityExpirationDelay = 0.25; | 29 const double kSmoothnessTakesPriorityExpirationDelay = 0.25; |
(...skipping 23 matching lines...) Expand all Loading... |
52 manage_tiles_pending_(false), | 53 manage_tiles_pending_(false), |
53 weak_factory_on_impl_thread_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 54 weak_factory_on_impl_thread_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
54 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 55 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
55 begin_frame_completion_event_on_impl_thread_(NULL), | 56 begin_frame_completion_event_on_impl_thread_(NULL), |
56 readback_request_on_impl_thread_(NULL), | 57 readback_request_on_impl_thread_(NULL), |
57 commit_completion_event_on_impl_thread_(NULL), | 58 commit_completion_event_on_impl_thread_(NULL), |
58 completion_event_for_commit_held_on_tree_activation_(NULL), | 59 completion_event_for_commit_held_on_tree_activation_(NULL), |
59 texture_acquisition_completion_event_on_impl_thread_(NULL), | 60 texture_acquisition_completion_event_on_impl_thread_(NULL), |
60 next_frame_is_newly_committed_frame_on_impl_thread_(false), | 61 next_frame_is_newly_committed_frame_on_impl_thread_(false), |
61 render_vsync_enabled_(layer_tree_host->settings().render_vsync_enabled), | 62 render_vsync_enabled_(layer_tree_host->settings().render_vsync_enabled), |
| 63 render_vsync_notification_enabled_( |
| 64 layer_tree_host->settings().render_vsync_notification_enabled), |
| 65 vsync_client_(NULL), |
62 inside_draw_(false), | 66 inside_draw_(false), |
63 defer_commits_(false), | 67 defer_commits_(false), |
64 renew_tree_priority_on_impl_thread_pending_(false) { | 68 renew_tree_priority_on_impl_thread_pending_(false) { |
65 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); | 69 TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); |
66 DCHECK(IsMainThread()); | 70 DCHECK(IsMainThread()); |
67 } | 71 } |
68 | 72 |
69 ThreadProxy::~ThreadProxy() { | 73 ThreadProxy::~ThreadProxy() { |
70 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy"); | 74 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy"); |
71 DCHECK(IsMainThread()); | 75 DCHECK(IsMainThread()); |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 DCHECK(IsImplThread()); | 347 DCHECK(IsImplThread()); |
344 TRACE_EVENT2("cc", | 348 TRACE_EVENT2("cc", |
345 "ThreadProxy::OnVSyncParametersChanged", | 349 "ThreadProxy::OnVSyncParametersChanged", |
346 "timebase", | 350 "timebase", |
347 (timebase - base::TimeTicks()).InMilliseconds(), | 351 (timebase - base::TimeTicks()).InMilliseconds(), |
348 "interval", | 352 "interval", |
349 interval.InMilliseconds()); | 353 interval.InMilliseconds()); |
350 scheduler_on_impl_thread_->SetTimebaseAndInterval(timebase, interval); | 354 scheduler_on_impl_thread_->SetTimebaseAndInterval(timebase, interval); |
351 } | 355 } |
352 | 356 |
| 357 void ThreadProxy::DidVSync(base::TimeTicks frame_time) { |
| 358 DCHECK(IsImplThread()); |
| 359 TRACE_EVENT0("cc", "ThreadProxy::DidVSync"); |
| 360 if (vsync_client_) |
| 361 vsync_client_->DidVSync(frame_time); |
| 362 } |
| 363 |
| 364 void ThreadProxy::RequestVSyncNotification(VSyncClient* client) { |
| 365 DCHECK(IsImplThread()); |
| 366 TRACE_EVENT1( |
| 367 "cc", "ThreadProxy::RequestVSyncNotification", "enable", !!client); |
| 368 vsync_client_ = client; |
| 369 layer_tree_host_impl_->EnableVSyncNotification(client); |
| 370 } |
| 371 |
353 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { | 372 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { |
354 DCHECK(IsImplThread()); | 373 DCHECK(IsImplThread()); |
355 TRACE_EVENT1( | 374 TRACE_EVENT1( |
356 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); | 375 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); |
357 scheduler_on_impl_thread_->SetCanDraw(can_draw); | 376 scheduler_on_impl_thread_->SetCanDraw(can_draw); |
358 } | 377 } |
359 | 378 |
360 void ThreadProxy::OnHasPendingTreeStateChanged(bool has_pending_tree) { | 379 void ThreadProxy::OnHasPendingTreeStateChanged(bool has_pending_tree) { |
361 DCHECK(IsImplThread()); | 380 DCHECK(IsImplThread()); |
362 TRACE_EVENT1("cc", | 381 TRACE_EVENT1("cc", |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion, | 1077 void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion, |
1059 InputHandler* handler) { | 1078 InputHandler* handler) { |
1060 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); | 1079 TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); |
1061 DCHECK(IsImplThread()); | 1080 DCHECK(IsImplThread()); |
1062 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); | 1081 layer_tree_host_impl_ = layer_tree_host_->CreateLayerTreeHostImpl(this); |
1063 const base::TimeDelta display_refresh_interval = | 1082 const base::TimeDelta display_refresh_interval = |
1064 base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond / | 1083 base::TimeDelta::FromMicroseconds(base::Time::kMicrosecondsPerSecond / |
1065 60); | 1084 60); |
1066 scoped_ptr<FrameRateController> frame_rate_controller; | 1085 scoped_ptr<FrameRateController> frame_rate_controller; |
1067 if (render_vsync_enabled_) { | 1086 if (render_vsync_enabled_) { |
1068 frame_rate_controller.reset( | 1087 if (render_vsync_notification_enabled_) { |
1069 new FrameRateController(DelayBasedTimeSource::Create( | 1088 frame_rate_controller.reset( |
1070 display_refresh_interval, Proxy::ImplThread()))); | 1089 new FrameRateController(VSyncTimeSource::Create(this))); |
| 1090 } else { |
| 1091 frame_rate_controller.reset( |
| 1092 new FrameRateController(DelayBasedTimeSource::Create( |
| 1093 display_refresh_interval, Proxy::ImplThread()))); |
| 1094 } |
1071 } else { | 1095 } else { |
1072 frame_rate_controller.reset(new FrameRateController(Proxy::ImplThread())); | 1096 frame_rate_controller.reset(new FrameRateController(Proxy::ImplThread())); |
1073 } | 1097 } |
1074 SchedulerSettings scheduler_settings; | 1098 SchedulerSettings scheduler_settings; |
1075 scheduler_settings.impl_side_painting = | 1099 scheduler_settings.impl_side_painting = |
1076 layer_tree_host_->settings().impl_side_painting; | 1100 layer_tree_host_->settings().impl_side_painting; |
1077 scheduler_on_impl_thread_ = Scheduler::Create(this, | 1101 scheduler_on_impl_thread_ = Scheduler::Create(this, |
1078 frame_rate_controller.Pass(), | 1102 frame_rate_controller.Pass(), |
1079 scheduler_settings); | 1103 scheduler_settings); |
1080 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); | 1104 scheduler_on_impl_thread_->SetVisible(layer_tree_host_impl_->visible()); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1119 } | 1143 } |
1120 | 1144 |
1121 completion->Signal(); | 1145 completion->Signal(); |
1122 } | 1146 } |
1123 | 1147 |
1124 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { | 1148 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { |
1125 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); | 1149 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); |
1126 DCHECK(IsImplThread()); | 1150 DCHECK(IsImplThread()); |
1127 layer_tree_host_->DeleteContentsTexturesOnImplThread( | 1151 layer_tree_host_->DeleteContentsTexturesOnImplThread( |
1128 layer_tree_host_impl_->resource_provider()); | 1152 layer_tree_host_impl_->resource_provider()); |
| 1153 layer_tree_host_impl_->EnableVSyncNotification(false); |
1129 input_handler_on_impl_thread_.reset(); | 1154 input_handler_on_impl_thread_.reset(); |
1130 layer_tree_host_impl_.reset(); | 1155 layer_tree_host_impl_.reset(); |
1131 scheduler_on_impl_thread_.reset(); | 1156 scheduler_on_impl_thread_.reset(); |
1132 weak_factory_on_impl_thread_.InvalidateWeakPtrs(); | 1157 weak_factory_on_impl_thread_.InvalidateWeakPtrs(); |
| 1158 vsync_client_ = NULL; |
1133 completion->Signal(); | 1159 completion->Signal(); |
1134 } | 1160 } |
1135 | 1161 |
1136 void ThreadProxy::SetFullRootLayerDamageOnImplThread() { | 1162 void ThreadProxy::SetFullRootLayerDamageOnImplThread() { |
1137 DCHECK(IsImplThread()); | 1163 DCHECK(IsImplThread()); |
1138 layer_tree_host_impl_->SetFullRootLayerDamage(); | 1164 layer_tree_host_impl_->SetFullRootLayerDamage(); |
1139 } | 1165 } |
1140 | 1166 |
1141 size_t ThreadProxy::MaxPartialTextureUpdates() const { | 1167 size_t ThreadProxy::MaxPartialTextureUpdates() const { |
1142 return ResourceUpdateController::MaxPartialTextureUpdates(); | 1168 return ResourceUpdateController::MaxPartialTextureUpdates(); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1311 base::Bind(&ThreadProxy::StartScrollbarAnimationOnImplThread, | 1337 base::Bind(&ThreadProxy::StartScrollbarAnimationOnImplThread, |
1312 impl_thread_weak_ptr_), | 1338 impl_thread_weak_ptr_), |
1313 delay); | 1339 delay); |
1314 } | 1340 } |
1315 | 1341 |
1316 void ThreadProxy::StartScrollbarAnimationOnImplThread() { | 1342 void ThreadProxy::StartScrollbarAnimationOnImplThread() { |
1317 layer_tree_host_impl_->StartScrollbarAnimation(base::TimeTicks::Now()); | 1343 layer_tree_host_impl_->StartScrollbarAnimation(base::TimeTicks::Now()); |
1318 } | 1344 } |
1319 | 1345 |
1320 } // namespace cc | 1346 } // namespace cc |
OLD | NEW |