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/layer_tree_host_impl.h" | 5 #include "cc/layer_tree_host_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1001 m_client->onCanDrawStateChanged(canDraw()); | 1001 m_client->onCanDrawStateChanged(canDraw()); |
1002 m_client->onHasPendingTreeStateChanged(pendingTree()); | 1002 m_client->onHasPendingTreeStateChanged(pendingTree()); |
1003 } | 1003 } |
1004 | 1004 |
1005 void LayerTreeHostImpl::activatePendingTreeIfNeeded() | 1005 void LayerTreeHostImpl::activatePendingTreeIfNeeded() |
1006 { | 1006 { |
1007 if (!pendingTree()) | 1007 if (!pendingTree()) |
1008 return; | 1008 return; |
1009 | 1009 |
1010 int total_pending = m_tileManager->GetTilesInBinCount(NOW_BIN, PENDING_TREE) ; | 1010 int total_pending = m_tileManager->GetTilesInBinCount(NOW_BIN, PENDING_TREE) ; |
1011 int drawable_pending = m_tileManager->GetDrawableTilesInBinCount(NOW_BIN, PE NDING_TREE); | |
1011 int total_active = m_tileManager->GetTilesInBinCount(NOW_BIN, ACTIVE_TREE); | 1012 int total_active = m_tileManager->GetTilesInBinCount(NOW_BIN, ACTIVE_TREE); |
nduca
2013/01/05 04:51:49
The more I stare at this, the more I think we shou
| |
1012 int drawable_pending = m_tileManager->GetDrawableTilesInBinCount(NOW_BIN, PE NDING_TREE); | |
1013 int drawable_active = m_tileManager->GetDrawableTilesInBinCount(NOW_BIN, ACT IVE_TREE); | |
1014 | 1013 |
1015 if (total_pending && total_active) { | 1014 // It's always fine to activate to or from an empty tree. Otherwise, only |
1016 float percent_pending = drawable_pending / static_cast<float>(total_pend ing); | 1015 // activate once all high res visible tiles are ready on the pending tree. |
1017 float percent_active = drawable_active / static_cast<float>(total_active ); | 1016 if (total_pending && total_active && total_pending != drawable_pending) |
1018 if (percent_pending < percent_active) | 1017 return; |
1019 return; | |
1020 } | |
1021 | 1018 |
1022 // If there are no pending total tiles (i.e. an empty tree), we should | |
1023 // commit immediately. Similarly, if there are no active tree tiles. | |
1024 activatePendingTree(); | 1019 activatePendingTree(); |
1025 } | 1020 } |
1026 | 1021 |
1027 void LayerTreeHostImpl::activatePendingTree() | 1022 void LayerTreeHostImpl::activatePendingTree() |
1028 { | 1023 { |
1029 CHECK(m_pendingTree); | 1024 CHECK(m_pendingTree); |
1030 m_activeTree.swap(m_pendingTree); | 1025 m_activeTree.swap(m_pendingTree); |
1031 // TODO(enne): consider recycling this tree to prevent layer churn | 1026 // TODO(enne): consider recycling this tree to prevent layer churn |
1032 m_pendingTree.reset(); | 1027 m_pendingTree.reset(); |
1033 m_client->onCanDrawStateChanged(canDraw()); | 1028 m_client->onCanDrawStateChanged(canDraw()); |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1706 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController(); | 1701 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController(); |
1707 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); | 1702 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); |
1708 if (scrollbarController && scrollbarController->animate(monotonicTime)) | 1703 if (scrollbarController && scrollbarController->animate(monotonicTime)) |
1709 m_client->setNeedsRedrawOnImplThread(); | 1704 m_client->setNeedsRedrawOnImplThread(); |
1710 | 1705 |
1711 for (size_t i = 0; i < layer->children().size(); ++i) | 1706 for (size_t i = 0; i < layer->children().size(); ++i) |
1712 animateScrollbarsRecursive(layer->children()[i], time); | 1707 animateScrollbarsRecursive(layer->children()[i], time); |
1713 } | 1708 } |
1714 | 1709 |
1715 } // namespace cc | 1710 } // namespace cc |
OLD | NEW |