| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 int layer_tree_host_id) | 109 int layer_tree_host_id) |
| 110 : layer_tree_host_id(layer_tree_host_id), | 110 : layer_tree_host_id(layer_tree_host_id), |
| 111 contents_texture_manager(NULL), | 111 contents_texture_manager(NULL), |
| 112 commit_completion_event(NULL), | 112 commit_completion_event(NULL), |
| 113 completion_event_for_commit_held_on_tree_activation(NULL), | 113 completion_event_for_commit_held_on_tree_activation(NULL), |
| 114 next_frame_is_newly_committed_frame(false), | 114 next_frame_is_newly_committed_frame(false), |
| 115 inside_draw(false), | 115 inside_draw(false), |
| 116 input_throttled_until_commit(false), | 116 input_throttled_until_commit(false), |
| 117 animations_frozen_until_next_draw(false), | 117 animations_frozen_until_next_draw(false), |
| 118 did_commit_after_animating(false), | 118 did_commit_after_animating(false), |
| 119 renew_tree_priority_pending(false), | 119 smoothness_priority_expiration_notifier( |
| 120 proxy->ImplThreadTaskRunner(), |
| 121 base::Bind(&ThreadProxy::RenewTreePriority, base::Unretained(proxy)), |
| 122 base::TimeDelta::FromMilliseconds( |
| 123 kSmoothnessTakesPriorityExpirationDelay * 1000)), |
| 120 weak_factory(proxy) { | 124 weak_factory(proxy) { |
| 121 } | 125 } |
| 122 | 126 |
| 123 ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {} | 127 ThreadProxy::CompositorThreadOnly::~CompositorThreadOnly() {} |
| 124 | 128 |
| 125 ThreadProxy::~ThreadProxy() { | 129 ThreadProxy::~ThreadProxy() { |
| 126 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy"); | 130 TRACE_EVENT0("cc", "ThreadProxy::~ThreadProxy"); |
| 127 DCHECK(IsMainThread()); | 131 DCHECK(IsMainThread()); |
| 128 DCHECK(!main().started); | 132 DCHECK(!main().started); |
| 129 } | 133 } |
| (...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1394 } | 1398 } |
| 1395 | 1399 |
| 1396 void ThreadProxy::RenewTreePriority() { | 1400 void ThreadProxy::RenewTreePriority() { |
| 1397 DCHECK(IsImplThread()); | 1401 DCHECK(IsImplThread()); |
| 1398 bool smoothness_takes_priority = | 1402 bool smoothness_takes_priority = |
| 1399 impl().layer_tree_host_impl->pinch_gesture_active() || | 1403 impl().layer_tree_host_impl->pinch_gesture_active() || |
| 1400 impl().layer_tree_host_impl->page_scale_animation_active() || | 1404 impl().layer_tree_host_impl->page_scale_animation_active() || |
| 1401 (impl().layer_tree_host_impl->IsCurrentlyScrolling() && | 1405 (impl().layer_tree_host_impl->IsCurrentlyScrolling() && |
| 1402 !impl().layer_tree_host_impl->scroll_affects_scroll_handler()); | 1406 !impl().layer_tree_host_impl->scroll_affects_scroll_handler()); |
| 1403 | 1407 |
| 1404 base::TimeTicks now = impl().layer_tree_host_impl->CurrentFrameTimeTicks(); | 1408 // Schedule expiration if smoothness currently takes priority. |
| 1405 | 1409 if (smoothness_takes_priority) |
| 1406 // Update expiration time if smoothness currently takes priority. | 1410 impl().smoothness_priority_expiration_notifier.Schedule(); |
| 1407 if (smoothness_takes_priority) { | |
| 1408 impl().smoothness_takes_priority_expiration_time = | |
| 1409 now + base::TimeDelta::FromMilliseconds( | |
| 1410 kSmoothnessTakesPriorityExpirationDelay * 1000); | |
| 1411 } | |
| 1412 | 1411 |
| 1413 // We use the same priority for both trees by default. | 1412 // We use the same priority for both trees by default. |
| 1414 TreePriority priority = SAME_PRIORITY_FOR_BOTH_TREES; | 1413 TreePriority priority = SAME_PRIORITY_FOR_BOTH_TREES; |
| 1415 | 1414 |
| 1416 // Smoothness takes priority if expiration time is in the future. | 1415 // Smoothness takes priority if we have an expiration for it scheduled. |
| 1417 if (impl().smoothness_takes_priority_expiration_time > now) | 1416 if (impl().smoothness_priority_expiration_notifier.HasPendingNotification()) |
| 1418 priority = SMOOTHNESS_TAKES_PRIORITY; | 1417 priority = SMOOTHNESS_TAKES_PRIORITY; |
| 1419 | 1418 |
| 1420 // New content always takes priority when the active tree has | 1419 // New content always takes priority when the active tree has |
| 1421 // evicted resources or there is an invalid viewport size. | 1420 // evicted resources or there is an invalid viewport size. |
| 1422 if (impl().layer_tree_host_impl->active_tree()->ContentsTexturesPurged() || | 1421 if (impl().layer_tree_host_impl->active_tree()->ContentsTexturesPurged() || |
| 1423 impl().layer_tree_host_impl->active_tree()->ViewportSizeInvalid() || | 1422 impl().layer_tree_host_impl->active_tree()->ViewportSizeInvalid() || |
| 1424 impl().layer_tree_host_impl->EvictedUIResourcesExist() || | 1423 impl().layer_tree_host_impl->EvictedUIResourcesExist() || |
| 1425 impl().input_throttled_until_commit) { | 1424 impl().input_throttled_until_commit) { |
| 1426 // Once we enter NEW_CONTENTS_TAKES_PRIORITY mode, visible tiles on active | 1425 // Once we enter NEW_CONTENTS_TAKES_PRIORITY mode, visible tiles on active |
| 1427 // tree might be freed. We need to set RequiresHighResToDraw to ensure that | 1426 // tree might be freed. We need to set RequiresHighResToDraw to ensure that |
| 1428 // high res tiles will be required to activate pending tree. | 1427 // high res tiles will be required to activate pending tree. |
| 1429 impl().layer_tree_host_impl->active_tree()->SetRequiresHighResToDraw(); | 1428 impl().layer_tree_host_impl->active_tree()->SetRequiresHighResToDraw(); |
| 1430 priority = NEW_CONTENT_TAKES_PRIORITY; | 1429 priority = NEW_CONTENT_TAKES_PRIORITY; |
| 1431 } | 1430 } |
| 1432 | 1431 |
| 1433 impl().layer_tree_host_impl->SetTreePriority(priority); | 1432 impl().layer_tree_host_impl->SetTreePriority(priority); |
| 1434 impl().scheduler->SetSmoothnessTakesPriority(priority == | 1433 impl().scheduler->SetSmoothnessTakesPriority(priority == |
| 1435 SMOOTHNESS_TAKES_PRIORITY); | 1434 SMOOTHNESS_TAKES_PRIORITY); |
| 1436 | 1435 |
| 1437 // Notify the the client of this compositor via the output surface. | 1436 // Notify the the client of this compositor via the output surface. |
| 1438 // TODO(epenner): Route this to compositor-thread instead of output-surface | 1437 // TODO(epenner): Route this to compositor-thread instead of output-surface |
| 1439 // after GTFO refactor of compositor-thread (http://crbug/170828). | 1438 // after GTFO refactor of compositor-thread (http://crbug/170828). |
| 1440 if (impl().layer_tree_host_impl->output_surface()) { | 1439 if (impl().layer_tree_host_impl->output_surface()) { |
| 1441 impl() | 1440 impl() |
| 1442 .layer_tree_host_impl->output_surface() | 1441 .layer_tree_host_impl->output_surface() |
| 1443 ->UpdateSmoothnessTakesPriority(priority == SMOOTHNESS_TAKES_PRIORITY); | 1442 ->UpdateSmoothnessTakesPriority(priority == SMOOTHNESS_TAKES_PRIORITY); |
| 1444 } | 1443 } |
| 1445 | |
| 1446 base::TimeDelta delay = | |
| 1447 impl().smoothness_takes_priority_expiration_time - now; | |
| 1448 | |
| 1449 // Need to make sure a delayed task is posted when we have smoothness | |
| 1450 // takes priority expiration time in the future. | |
| 1451 if (delay <= base::TimeDelta()) | |
| 1452 return; | |
| 1453 if (impl().renew_tree_priority_pending) | |
| 1454 return; | |
| 1455 | |
| 1456 Proxy::ImplThreadTaskRunner()->PostDelayedTask( | |
| 1457 FROM_HERE, | |
| 1458 base::Bind(&ThreadProxy::RenewTreePriorityOnImplThread, | |
| 1459 impl_thread_weak_ptr_), | |
| 1460 delay); | |
| 1461 | |
| 1462 impl().renew_tree_priority_pending = true; | |
| 1463 } | |
| 1464 | |
| 1465 void ThreadProxy::RenewTreePriorityOnImplThread() { | |
| 1466 DCHECK(impl().renew_tree_priority_pending); | |
| 1467 impl().renew_tree_priority_pending = false; | |
| 1468 | |
| 1469 RenewTreePriority(); | |
| 1470 } | 1444 } |
| 1471 | 1445 |
| 1472 void ThreadProxy::PostDelayedScrollbarFadeOnImplThread( | 1446 void ThreadProxy::PostDelayedScrollbarFadeOnImplThread( |
| 1473 const base::Closure& start_fade, | 1447 const base::Closure& start_fade, |
| 1474 base::TimeDelta delay) { | 1448 base::TimeDelta delay) { |
| 1475 Proxy::ImplThreadTaskRunner()->PostDelayedTask(FROM_HERE, start_fade, delay); | 1449 Proxy::ImplThreadTaskRunner()->PostDelayedTask(FROM_HERE, start_fade, delay); |
| 1476 } | 1450 } |
| 1477 | 1451 |
| 1478 void ThreadProxy::DidActivatePendingTree() { | 1452 void ThreadProxy::DidActivatePendingTree() { |
| 1479 TRACE_EVENT0("cc", "ThreadProxy::DidActivatePendingTreeOnImplThread"); | 1453 TRACE_EVENT0("cc", "ThreadProxy::DidActivatePendingTreeOnImplThread"); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1492 | 1466 |
| 1493 impl().timing_history.DidActivatePendingTree(); | 1467 impl().timing_history.DidActivatePendingTree(); |
| 1494 } | 1468 } |
| 1495 | 1469 |
| 1496 void ThreadProxy::DidManageTiles() { | 1470 void ThreadProxy::DidManageTiles() { |
| 1497 DCHECK(IsImplThread()); | 1471 DCHECK(IsImplThread()); |
| 1498 impl().scheduler->DidManageTiles(); | 1472 impl().scheduler->DidManageTiles(); |
| 1499 } | 1473 } |
| 1500 | 1474 |
| 1501 } // namespace cc | 1475 } // namespace cc |
| OLD | NEW |