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 <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 &completion, | 173 &completion, |
174 visible)); | 174 visible)); |
175 completion.Wait(); | 175 completion.Wait(); |
176 } | 176 } |
177 | 177 |
178 void ThreadProxy::SetVisibleOnImplThread(CompletionEvent* completion, | 178 void ThreadProxy::SetVisibleOnImplThread(CompletionEvent* completion, |
179 bool visible) { | 179 bool visible) { |
180 TRACE_EVENT0("cc", "ThreadProxy::SetVisibleOnImplThread"); | 180 TRACE_EVENT0("cc", "ThreadProxy::SetVisibleOnImplThread"); |
181 impl().layer_tree_host_impl->SetVisible(visible); | 181 impl().layer_tree_host_impl->SetVisible(visible); |
182 impl().scheduler->SetVisible(visible); | 182 impl().scheduler->SetVisible(visible); |
183 UpdateBackgroundAnimateTicking(); | |
184 completion->Signal(); | 183 completion->Signal(); |
185 } | 184 } |
186 | 185 |
187 void ThreadProxy::UpdateBackgroundAnimateTicking() { | |
188 bool should_background_tick = | |
189 !impl().scheduler->WillDrawIfNeeded() && | |
190 impl().layer_tree_host_impl->active_tree()->root_layer(); | |
191 impl().layer_tree_host_impl->UpdateBackgroundAnimateTicking( | |
192 should_background_tick); | |
193 if (should_background_tick) | |
194 impl().animations_frozen_until_next_draw = false; | |
195 } | |
196 | |
197 void ThreadProxy::DoCreateAndInitializeOutputSurface() { | 186 void ThreadProxy::DoCreateAndInitializeOutputSurface() { |
198 TRACE_EVENT0("cc", "ThreadProxy::DoCreateAndInitializeOutputSurface"); | 187 TRACE_EVENT0("cc", "ThreadProxy::DoCreateAndInitializeOutputSurface"); |
199 DCHECK(IsMainThread()); | 188 DCHECK(IsMainThread()); |
200 | 189 |
201 scoped_ptr<OutputSurface> output_surface = | 190 scoped_ptr<OutputSurface> output_surface = |
202 layer_tree_host()->CreateOutputSurface(); | 191 layer_tree_host()->CreateOutputSurface(); |
203 | 192 |
204 RendererCapabilities capabilities; | 193 RendererCapabilities capabilities; |
205 bool success = !!output_surface; | 194 bool success = !!output_surface; |
206 if (success) { | 195 if (success) { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 } | 293 } |
305 | 294 |
306 void ThreadProxy::CheckOutputSurfaceStatusOnImplThread() { | 295 void ThreadProxy::CheckOutputSurfaceStatusOnImplThread() { |
307 TRACE_EVENT0("cc", "ThreadProxy::CheckOutputSurfaceStatusOnImplThread"); | 296 TRACE_EVENT0("cc", "ThreadProxy::CheckOutputSurfaceStatusOnImplThread"); |
308 DCHECK(IsImplThread()); | 297 DCHECK(IsImplThread()); |
309 if (!impl().layer_tree_host_impl->IsContextLost()) | 298 if (!impl().layer_tree_host_impl->IsContextLost()) |
310 return; | 299 return; |
311 impl().scheduler->DidLoseOutputSurface(); | 300 impl().scheduler->DidLoseOutputSurface(); |
312 } | 301 } |
313 | 302 |
314 void ThreadProxy::CommitVSyncParameters(base::TimeTicks timebase, | |
315 base::TimeDelta interval) { | |
316 impl().scheduler->CommitVSyncParameters(timebase, interval); | |
317 } | |
318 | |
319 void ThreadProxy::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { | 303 void ThreadProxy::SetEstimatedParentDrawTime(base::TimeDelta draw_time) { |
320 impl().scheduler->SetEstimatedParentDrawTime(draw_time); | 304 impl().scheduler->SetEstimatedParentDrawTime(draw_time); |
321 } | 305 } |
322 | 306 |
323 void ThreadProxy::SetMaxSwapsPendingOnImplThread(int max) { | 307 void ThreadProxy::SetMaxSwapsPendingOnImplThread(int max) { |
324 impl().scheduler->SetMaxSwapsPending(max); | 308 impl().scheduler->SetMaxSwapsPending(max); |
325 } | 309 } |
326 | 310 |
327 void ThreadProxy::DidSwapBuffersOnImplThread() { | 311 void ThreadProxy::DidSwapBuffersOnImplThread() { |
328 impl().scheduler->DidSwapBuffers(); | 312 impl().scheduler->DidSwapBuffers(); |
329 } | 313 } |
330 | 314 |
331 void ThreadProxy::DidSwapBuffersCompleteOnImplThread() { | 315 void ThreadProxy::DidSwapBuffersCompleteOnImplThread() { |
332 TRACE_EVENT0("cc", "ThreadProxy::DidSwapBuffersCompleteOnImplThread"); | 316 TRACE_EVENT0("cc", "ThreadProxy::DidSwapBuffersCompleteOnImplThread"); |
333 DCHECK(IsImplThread()); | |
334 impl().scheduler->DidSwapBuffersComplete(); | 317 impl().scheduler->DidSwapBuffersComplete(); |
335 Proxy::MainThreadTaskRunner()->PostTask( | 318 Proxy::MainThreadTaskRunner()->PostTask( |
336 FROM_HERE, | 319 FROM_HERE, |
337 base::Bind(&ThreadProxy::DidCompleteSwapBuffers, main_thread_weak_ptr_)); | 320 base::Bind(&ThreadProxy::DidCompleteSwapBuffers, main_thread_weak_ptr_)); |
338 } | 321 } |
339 | 322 |
340 void ThreadProxy::SetNeedsBeginFrame(bool enable) { | |
341 TRACE_EVENT1("cc", "ThreadProxy::SetNeedsBeginFrame", "enable", enable); | |
342 impl().layer_tree_host_impl->SetNeedsBeginFrame(enable); | |
343 UpdateBackgroundAnimateTicking(); | |
344 } | |
345 | |
346 void ThreadProxy::BeginFrame(const BeginFrameArgs& args) { | |
347 impl().scheduler->BeginFrame(args); | |
348 } | |
349 | |
350 void ThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { | 323 void ThreadProxy::WillBeginImplFrame(const BeginFrameArgs& args) { |
351 impl().layer_tree_host_impl->WillBeginImplFrame(args); | 324 impl().layer_tree_host_impl->WillBeginImplFrame(args); |
352 } | 325 } |
353 | 326 |
354 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { | 327 void ThreadProxy::OnCanDrawStateChanged(bool can_draw) { |
355 TRACE_EVENT1( | 328 TRACE_EVENT1( |
356 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); | 329 "cc", "ThreadProxy::OnCanDrawStateChanged", "can_draw", can_draw); |
357 DCHECK(IsImplThread()); | 330 DCHECK(IsImplThread()); |
358 impl().scheduler->SetCanDraw(can_draw); | 331 impl().scheduler->SetCanDraw(can_draw); |
359 UpdateBackgroundAnimateTicking(); | |
360 } | 332 } |
361 | 333 |
362 void ThreadProxy::NotifyReadyToActivate() { | 334 void ThreadProxy::NotifyReadyToActivate() { |
363 TRACE_EVENT0("cc", "ThreadProxy::NotifyReadyToActivate"); | 335 TRACE_EVENT0("cc", "ThreadProxy::NotifyReadyToActivate"); |
364 impl().scheduler->NotifyReadyToActivate(); | 336 impl().scheduler->NotifyReadyToActivate(); |
365 } | 337 } |
366 | 338 |
367 void ThreadProxy::SetNeedsCommitOnImplThread() { | 339 void ThreadProxy::SetNeedsCommitOnImplThread() { |
368 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsCommitOnImplThread"); | 340 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsCommitOnImplThread"); |
369 DCHECK(IsImplThread()); | 341 DCHECK(IsImplThread()); |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 impl().commit_completion_event->Signal(); | 948 impl().commit_completion_event->Signal(); |
977 impl().commit_completion_event = NULL; | 949 impl().commit_completion_event = NULL; |
978 } | 950 } |
979 | 951 |
980 // Delay this step until afer the main thread has been released as it's | 952 // Delay this step until afer the main thread has been released as it's |
981 // often a good bit of work to update the tree and prepare the new frame. | 953 // often a good bit of work to update the tree and prepare the new frame. |
982 impl().layer_tree_host_impl->CommitComplete(); | 954 impl().layer_tree_host_impl->CommitComplete(); |
983 | 955 |
984 SetInputThrottledUntilCommitOnImplThread(false); | 956 SetInputThrottledUntilCommitOnImplThread(false); |
985 | 957 |
986 UpdateBackgroundAnimateTicking(); | |
987 | |
988 impl().next_frame_is_newly_committed_frame = true; | 958 impl().next_frame_is_newly_committed_frame = true; |
989 | 959 |
990 impl().timing_history.DidCommit(); | 960 impl().timing_history.DidCommit(); |
991 } | 961 } |
992 | 962 |
993 void ThreadProxy::ScheduledActionUpdateVisibleTiles() { | 963 void ThreadProxy::ScheduledActionUpdateVisibleTiles() { |
994 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionUpdateVisibleTiles"); | 964 TRACE_EVENT0("cc", "ThreadProxy::ScheduledActionUpdateVisibleTiles"); |
995 DCHECK(IsImplThread()); | 965 DCHECK(IsImplThread()); |
996 impl().layer_tree_host_impl->UpdateVisibleTiles(); | 966 impl().layer_tree_host_impl->UpdateVisibleTiles(); |
997 } | 967 } |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1245 settings.timeout_and_draw_when_animation_checkerboards; | 1215 settings.timeout_and_draw_when_animation_checkerboards; |
1246 scheduler_settings.maximum_number_of_failed_draws_before_draw_is_forced_ = | 1216 scheduler_settings.maximum_number_of_failed_draws_before_draw_is_forced_ = |
1247 settings.maximum_number_of_failed_draws_before_draw_is_forced_; | 1217 settings.maximum_number_of_failed_draws_before_draw_is_forced_; |
1248 scheduler_settings.using_synchronous_renderer_compositor = | 1218 scheduler_settings.using_synchronous_renderer_compositor = |
1249 settings.using_synchronous_renderer_compositor; | 1219 settings.using_synchronous_renderer_compositor; |
1250 scheduler_settings.throttle_frame_production = | 1220 scheduler_settings.throttle_frame_production = |
1251 settings.throttle_frame_production; | 1221 settings.throttle_frame_production; |
1252 impl().scheduler = Scheduler::Create(this, | 1222 impl().scheduler = Scheduler::Create(this, |
1253 scheduler_settings, | 1223 scheduler_settings, |
1254 impl().layer_tree_host_id, | 1224 impl().layer_tree_host_id, |
| 1225 impl().layer_tree_host_impl.get(), |
1255 ImplThreadTaskRunner()); | 1226 ImplThreadTaskRunner()); |
1256 impl().scheduler->SetVisible(impl().layer_tree_host_impl->visible()); | 1227 impl().scheduler->SetVisible(impl().layer_tree_host_impl->visible()); |
1257 | 1228 |
1258 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr(); | 1229 impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr(); |
1259 completion->Signal(); | 1230 completion->Signal(); |
1260 } | 1231 } |
1261 | 1232 |
1262 void ThreadProxy::InitializeOutputSurfaceOnImplThread( | 1233 void ThreadProxy::InitializeOutputSurfaceOnImplThread( |
1263 CompletionEvent* completion, | 1234 CompletionEvent* completion, |
1264 scoped_ptr<OutputSurface> output_surface, | 1235 scoped_ptr<OutputSurface> output_surface, |
(...skipping 28 matching lines...) Expand all Loading... |
1293 impl().layer_tree_host_impl->resource_provider()->Finish(); | 1264 impl().layer_tree_host_impl->resource_provider()->Finish(); |
1294 completion->Signal(); | 1265 completion->Signal(); |
1295 } | 1266 } |
1296 | 1267 |
1297 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { | 1268 void ThreadProxy::LayerTreeHostClosedOnImplThread(CompletionEvent* completion) { |
1298 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); | 1269 TRACE_EVENT0("cc", "ThreadProxy::LayerTreeHostClosedOnImplThread"); |
1299 DCHECK(IsImplThread()); | 1270 DCHECK(IsImplThread()); |
1300 layer_tree_host()->DeleteContentsTexturesOnImplThread( | 1271 layer_tree_host()->DeleteContentsTexturesOnImplThread( |
1301 impl().layer_tree_host_impl->resource_provider()); | 1272 impl().layer_tree_host_impl->resource_provider()); |
1302 impl().current_resource_update_controller.reset(); | 1273 impl().current_resource_update_controller.reset(); |
1303 impl().layer_tree_host_impl->SetNeedsBeginFrame(false); | |
1304 impl().scheduler.reset(); | 1274 impl().scheduler.reset(); |
1305 impl().layer_tree_host_impl.reset(); | 1275 impl().layer_tree_host_impl.reset(); |
1306 impl().weak_factory.InvalidateWeakPtrs(); | 1276 impl().weak_factory.InvalidateWeakPtrs(); |
1307 impl().contents_texture_manager = NULL; | 1277 impl().contents_texture_manager = NULL; |
1308 completion->Signal(); | 1278 completion->Signal(); |
1309 } | 1279 } |
1310 | 1280 |
1311 size_t ThreadProxy::MaxPartialTextureUpdates() const { | 1281 size_t ThreadProxy::MaxPartialTextureUpdates() const { |
1312 return ResourceUpdateController::MaxPartialTextureUpdates(); | 1282 return ResourceUpdateController::MaxPartialTextureUpdates(); |
1313 } | 1283 } |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1481 DCHECK(!impl().layer_tree_host_impl->pending_tree()); | 1451 DCHECK(!impl().layer_tree_host_impl->pending_tree()); |
1482 | 1452 |
1483 if (impl().completion_event_for_commit_held_on_tree_activation) { | 1453 if (impl().completion_event_for_commit_held_on_tree_activation) { |
1484 TRACE_EVENT_INSTANT0( | 1454 TRACE_EVENT_INSTANT0( |
1485 "cc", "ReleaseCommitbyActivation", TRACE_EVENT_SCOPE_THREAD); | 1455 "cc", "ReleaseCommitbyActivation", TRACE_EVENT_SCOPE_THREAD); |
1486 DCHECK(impl().layer_tree_host_impl->settings().impl_side_painting); | 1456 DCHECK(impl().layer_tree_host_impl->settings().impl_side_painting); |
1487 impl().completion_event_for_commit_held_on_tree_activation->Signal(); | 1457 impl().completion_event_for_commit_held_on_tree_activation->Signal(); |
1488 impl().completion_event_for_commit_held_on_tree_activation = NULL; | 1458 impl().completion_event_for_commit_held_on_tree_activation = NULL; |
1489 } | 1459 } |
1490 | 1460 |
1491 UpdateBackgroundAnimateTicking(); | |
1492 | |
1493 impl().timing_history.DidActivatePendingTree(); | 1461 impl().timing_history.DidActivatePendingTree(); |
1494 } | 1462 } |
1495 | 1463 |
1496 void ThreadProxy::DidManageTiles() { | 1464 void ThreadProxy::DidManageTiles() { |
1497 DCHECK(IsImplThread()); | 1465 DCHECK(IsImplThread()); |
1498 impl().scheduler->DidManageTiles(); | 1466 impl().scheduler->DidManageTiles(); |
1499 } | 1467 } |
1500 | 1468 |
1501 } // namespace cc | 1469 } // namespace cc |
OLD | NEW |