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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 void ThreadProxy::NotifyReadyToActivate() { | 388 void ThreadProxy::NotifyReadyToActivate() { |
389 TRACE_EVENT0("cc", "ThreadProxy::NotifyReadyToActivate"); | 389 TRACE_EVENT0("cc", "ThreadProxy::NotifyReadyToActivate"); |
390 impl().scheduler->NotifyReadyToActivate(); | 390 impl().scheduler->NotifyReadyToActivate(); |
391 } | 391 } |
392 | 392 |
393 void ThreadProxy::NotifyReadyToDraw() { | 393 void ThreadProxy::NotifyReadyToDraw() { |
394 TRACE_EVENT0("cc", "ThreadProxy::NotifyReadyToDraw"); | 394 TRACE_EVENT0("cc", "ThreadProxy::NotifyReadyToDraw"); |
395 impl().scheduler->NotifyReadyToDraw(); | 395 impl().scheduler->NotifyReadyToDraw(); |
396 } | 396 } |
397 | 397 |
| 398 void ThreadProxy::SetRequiresHighResToDraw(bool required) { |
| 399 impl().scheduler->SetRequiresHighResToDraw(required); |
| 400 } |
| 401 |
398 void ThreadProxy::SetNeedsCommitOnImplThread() { | 402 void ThreadProxy::SetNeedsCommitOnImplThread() { |
399 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsCommitOnImplThread"); | 403 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsCommitOnImplThread"); |
400 DCHECK(IsImplThread()); | 404 DCHECK(IsImplThread()); |
401 impl().scheduler->SetNeedsCommit(); | 405 impl().scheduler->SetNeedsCommit(); |
402 } | 406 } |
403 | 407 |
404 void ThreadProxy::SetVideoNeedsBeginFrames(bool needs_begin_frames) { | 408 void ThreadProxy::SetVideoNeedsBeginFrames(bool needs_begin_frames) { |
405 TRACE_EVENT1("cc", "ThreadProxy::SetVideoNeedsBeginFrames", | 409 TRACE_EVENT1("cc", "ThreadProxy::SetVideoNeedsBeginFrames", |
406 "needs_begin_frames", needs_begin_frames); | 410 "needs_begin_frames", needs_begin_frames); |
407 DCHECK(IsImplThread()); | 411 DCHECK(IsImplThread()); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 DCHECK(IsImplThread()); | 508 DCHECK(IsImplThread()); |
505 impl().scheduler->SetNeedsRedraw(); | 509 impl().scheduler->SetNeedsRedraw(); |
506 } | 510 } |
507 | 511 |
508 void ThreadProxy::SetNeedsAnimateOnImplThread() { | 512 void ThreadProxy::SetNeedsAnimateOnImplThread() { |
509 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsAnimateOnImplThread"); | 513 TRACE_EVENT0("cc", "ThreadProxy::SetNeedsAnimateOnImplThread"); |
510 DCHECK(IsImplThread()); | 514 DCHECK(IsImplThread()); |
511 impl().scheduler->SetNeedsAnimate(); | 515 impl().scheduler->SetNeedsAnimate(); |
512 } | 516 } |
513 | 517 |
514 void ThreadProxy::SetNeedsPrepareTilesOnImplThread() { | 518 void ThreadProxy::SetNeedsPrepareTilesOnImplThread(bool for_commit) { |
515 DCHECK(IsImplThread()); | 519 DCHECK(IsImplThread()); |
516 impl().scheduler->SetNeedsPrepareTiles(); | 520 impl().scheduler->SetNeedsPrepareTiles(for_commit); |
517 } | 521 } |
518 | 522 |
519 void ThreadProxy::SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) { | 523 void ThreadProxy::SetNeedsRedrawRectOnImplThread(const gfx::Rect& damage_rect) { |
520 DCHECK(IsImplThread()); | 524 DCHECK(IsImplThread()); |
521 impl().layer_tree_host_impl->SetViewportDamage(damage_rect); | 525 impl().layer_tree_host_impl->SetViewportDamage(damage_rect); |
522 SetNeedsRedrawOnImplThread(); | 526 SetNeedsRedrawOnImplThread(); |
523 } | 527 } |
524 | 528 |
525 void ThreadProxy::MainThreadHasStoppedFlinging() { | 529 void ThreadProxy::MainThreadHasStoppedFlinging() { |
526 DCHECK(IsMainThread()); | 530 DCHECK(IsMainThread()); |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 DrawResult ThreadProxy::DrawSwapInternal(bool forced_draw) { | 1056 DrawResult ThreadProxy::DrawSwapInternal(bool forced_draw) { |
1053 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); | 1057 TRACE_EVENT_SYNTHETIC_DELAY("cc.DrawAndSwap"); |
1054 DrawResult result; | 1058 DrawResult result; |
1055 | 1059 |
1056 DCHECK(IsImplThread()); | 1060 DCHECK(IsImplThread()); |
1057 DCHECK(impl().layer_tree_host_impl.get()); | 1061 DCHECK(impl().layer_tree_host_impl.get()); |
1058 | 1062 |
1059 impl().timing_history.DidStartDrawing(); | 1063 impl().timing_history.DidStartDrawing(); |
1060 base::AutoReset<bool> mark_inside(&impl().inside_draw, true); | 1064 base::AutoReset<bool> mark_inside(&impl().inside_draw, true); |
1061 | 1065 |
1062 if (impl().layer_tree_host_impl->pending_tree()) { | |
1063 bool update_lcd_text = false; | |
1064 impl().layer_tree_host_impl->pending_tree()->UpdateDrawProperties( | |
1065 update_lcd_text); | |
1066 } | |
1067 | |
1068 // This method is called on a forced draw, regardless of whether we are able | 1066 // This method is called on a forced draw, regardless of whether we are able |
1069 // to produce a frame, as the calling site on main thread is blocked until its | 1067 // to produce a frame, as the calling site on main thread is blocked until its |
1070 // request completes, and we signal completion here. If CanDraw() is false, we | 1068 // request completes, and we signal completion here. If CanDraw() is false, we |
1071 // will indicate success=false to the caller, but we must still signal | 1069 // will indicate success=false to the caller, but we must still signal |
1072 // completion to avoid deadlock. | 1070 // completion to avoid deadlock. |
1073 | 1071 |
1074 // We guard PrepareToDraw() with CanDraw() because it always returns a valid | 1072 // We guard PrepareToDraw() with CanDraw() because it always returns a valid |
1075 // frame, so can only be used when such a frame is possible. Since | 1073 // frame, so can only be used when such a frame is possible. Since |
1076 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on | 1074 // DrawLayers() depends on the result of PrepareToDraw(), it is guarded on |
1077 // CanDraw() as well. | 1075 // CanDraw() as well. |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1342 | 1340 |
1343 // New content always takes priority when the active tree has | 1341 // New content always takes priority when the active tree has |
1344 // evicted resources or there is an invalid viewport size. | 1342 // evicted resources or there is an invalid viewport size. |
1345 if (impl().layer_tree_host_impl->active_tree()->ContentsTexturesPurged() || | 1343 if (impl().layer_tree_host_impl->active_tree()->ContentsTexturesPurged() || |
1346 impl().layer_tree_host_impl->active_tree()->ViewportSizeInvalid() || | 1344 impl().layer_tree_host_impl->active_tree()->ViewportSizeInvalid() || |
1347 impl().layer_tree_host_impl->EvictedUIResourcesExist() || | 1345 impl().layer_tree_host_impl->EvictedUIResourcesExist() || |
1348 impl().input_throttled_until_commit) { | 1346 impl().input_throttled_until_commit) { |
1349 // Once we enter NEW_CONTENTS_TAKES_PRIORITY mode, visible tiles on active | 1347 // Once we enter NEW_CONTENTS_TAKES_PRIORITY mode, visible tiles on active |
1350 // tree might be freed. We need to set RequiresHighResToDraw to ensure that | 1348 // tree might be freed. We need to set RequiresHighResToDraw to ensure that |
1351 // high res tiles will be required to activate pending tree. | 1349 // high res tiles will be required to activate pending tree. |
1352 impl().layer_tree_host_impl->SetRequiresHighResToDraw(); | 1350 impl().layer_tree_host_impl->SetRequiresHighResToDraw(true); |
1353 priority = NEW_CONTENT_TAKES_PRIORITY; | 1351 priority = NEW_CONTENT_TAKES_PRIORITY; |
1354 } | 1352 } |
1355 | 1353 |
1356 impl().layer_tree_host_impl->SetTreePriority(priority); | 1354 impl().layer_tree_host_impl->SetTreePriority(priority); |
1357 | 1355 |
1358 // Only put the scheduler in impl latency prioritization mode if we don't | 1356 // Only put the scheduler in impl latency prioritization mode if we don't |
1359 // have a scroll listener. This gives the scroll listener a better chance of | 1357 // have a scroll listener. This gives the scroll listener a better chance of |
1360 // handling scroll updates within the same frame. The tree itself is still | 1358 // handling scroll updates within the same frame. The tree itself is still |
1361 // kept in prefer smoothness mode to allow checkerboarding. | 1359 // kept in prefer smoothness mode to allow checkerboarding. |
1362 impl().scheduler->SetImplLatencyTakesPriority( | 1360 impl().scheduler->SetImplLatencyTakesPriority( |
(...skipping 26 matching lines...) Expand all Loading... |
1389 DCHECK(impl().layer_tree_host_impl->settings().impl_side_painting); | 1387 DCHECK(impl().layer_tree_host_impl->settings().impl_side_painting); |
1390 impl().completion_event_for_commit_held_on_tree_activation->Signal(); | 1388 impl().completion_event_for_commit_held_on_tree_activation->Signal(); |
1391 impl().completion_event_for_commit_held_on_tree_activation = NULL; | 1389 impl().completion_event_for_commit_held_on_tree_activation = NULL; |
1392 } | 1390 } |
1393 | 1391 |
1394 impl().timing_history.DidActivateSyncTree(); | 1392 impl().timing_history.DidActivateSyncTree(); |
1395 impl().last_processed_begin_main_frame_args = | 1393 impl().last_processed_begin_main_frame_args = |
1396 impl().last_begin_main_frame_args; | 1394 impl().last_begin_main_frame_args; |
1397 } | 1395 } |
1398 | 1396 |
1399 void ThreadProxy::DidPrepareTiles() { | |
1400 DCHECK(IsImplThread()); | |
1401 impl().scheduler->DidPrepareTiles(); | |
1402 } | |
1403 | |
1404 void ThreadProxy::DidCompletePageScaleAnimationOnImplThread() { | 1397 void ThreadProxy::DidCompletePageScaleAnimationOnImplThread() { |
1405 DCHECK(IsImplThread()); | 1398 DCHECK(IsImplThread()); |
1406 Proxy::MainThreadTaskRunner()->PostTask( | 1399 Proxy::MainThreadTaskRunner()->PostTask( |
1407 FROM_HERE, base::Bind(&ThreadProxy::DidCompletePageScaleAnimation, | 1400 FROM_HERE, base::Bind(&ThreadProxy::DidCompletePageScaleAnimation, |
1408 main_thread_weak_ptr_)); | 1401 main_thread_weak_ptr_)); |
1409 } | 1402 } |
1410 | 1403 |
1411 void ThreadProxy::OnDrawForOutputSurface() { | 1404 void ThreadProxy::OnDrawForOutputSurface() { |
1412 DCHECK(IsImplThread()); | 1405 DCHECK(IsImplThread()); |
1413 impl().scheduler->OnDrawForOutputSurface(); | 1406 impl().scheduler->OnDrawForOutputSurface(); |
1414 } | 1407 } |
1415 | 1408 |
1416 } // namespace cc | 1409 } // namespace cc |
OLD | NEW |