| 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTre
eHostImplClient* client, Proxy* proxy) | 209 LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTre
eHostImplClient* client, Proxy* proxy) |
| 210 : m_client(client) | 210 : m_client(client) |
| 211 , m_proxy(proxy) | 211 , m_proxy(proxy) |
| 212 , m_scrollDeltaIsInViewportSpace(false) | 212 , m_scrollDeltaIsInViewportSpace(false) |
| 213 , m_settings(settings) | 213 , m_settings(settings) |
| 214 , m_debugState(settings.initialDebugState) | 214 , m_debugState(settings.initialDebugState) |
| 215 , m_deviceScaleFactor(1) | 215 , m_deviceScaleFactor(1) |
| 216 , m_visible(true) | 216 , m_visible(true) |
| 217 , m_contentsTexturesPurged(false) | 217 , m_contentsTexturesPurged(false) |
| 218 , m_managedMemoryPolicy(PrioritizedResourceManager::defaultMemoryAllocationL
imit(), | 218 , m_managedMemoryPolicy(PrioritizedResourceManager::defaultMemoryAllocationL
imit(), |
| 219 PriorityCalculator::allowEverythingCutoff(), | 219 ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING, |
| 220 0, | 220 0, |
| 221 PriorityCalculator::allowNothingCutoff()) | 221 ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING) |
| 222 , m_backgroundColor(0) | 222 , m_backgroundColor(0) |
| 223 , m_hasTransparentBackground(false) | 223 , m_hasTransparentBackground(false) |
| 224 , m_needsUpdateDrawProperties(false) | 224 , m_needsUpdateDrawProperties(false) |
| 225 , m_pinchGestureActive(false) | 225 , m_pinchGestureActive(false) |
| 226 , m_fpsCounter(FrameRateCounter::create(m_proxy->hasImplThread())) | 226 , m_fpsCounter(FrameRateCounter::create(m_proxy->hasImplThread())) |
| 227 , m_debugRectHistory(DebugRectHistory::create()) | 227 , m_debugRectHistory(DebugRectHistory::create()) |
| 228 , m_numImplThreadScrolls(0) | 228 , m_numImplThreadScrolls(0) |
| 229 , m_numMainThreadScrolls(0) | 229 , m_numMainThreadScrolls(0) |
| 230 , m_cumulativeNumLayersDrawn(0) | 230 , m_cumulativeNumLayersDrawn(0) |
| 231 , m_cumulativeNumMissingTiles(0) | 231 , m_cumulativeNumMissingTiles(0) |
| (...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 return false; | 757 return false; |
| 758 | 758 |
| 759 // If we return true, then we expect drawLayers() to be called before this f
unction is called again. | 759 // If we return true, then we expect drawLayers() to be called before this f
unction is called again. |
| 760 return true; | 760 return true; |
| 761 } | 761 } |
| 762 | 762 |
| 763 void LayerTreeHostImpl::enforceManagedMemoryPolicy(const ManagedMemoryPolicy& po
licy) | 763 void LayerTreeHostImpl::enforceManagedMemoryPolicy(const ManagedMemoryPolicy& po
licy) |
| 764 { | 764 { |
| 765 bool evictedResources = m_client->reduceContentsTextureMemoryOnImplThread( | 765 bool evictedResources = m_client->reduceContentsTextureMemoryOnImplThread( |
| 766 m_visible ? policy.bytesLimitWhenVisible : policy.bytesLimitWhenNotVisib
le, | 766 m_visible ? policy.bytesLimitWhenVisible : policy.bytesLimitWhenNotVisib
le, |
| 767 m_visible ? policy.priorityCutoffWhenVisible : policy.priorityCutoffWhen
NotVisible); | 767 ManagedMemoryPolicy::priorityCutoffToValue( |
| 768 m_visible ? policy.priorityCutoffWhenVisible : policy.priorityCutoff
WhenNotVisible)); |
| 768 if (evictedResources) { | 769 if (evictedResources) { |
| 769 setContentsTexturesPurged(); | 770 setContentsTexturesPurged(); |
| 770 m_client->setNeedsCommitOnImplThread(); | 771 m_client->setNeedsCommitOnImplThread(); |
| 771 m_client->onCanDrawStateChanged(canDraw()); | 772 m_client->onCanDrawStateChanged(canDraw()); |
| 772 } | 773 } |
| 773 m_client->sendManagedMemoryStats(); | |
| 774 | 774 |
| 775 if (m_tileManager) { | 775 if (m_tileManager) { |
| 776 // TODO(nduca): Pass something useful into the memory manager. | |
| 777 LOG(INFO) << "Setting up initial tile manager policy"; | 776 LOG(INFO) << "Setting up initial tile manager policy"; |
| 778 GlobalStateThatImpactsTilePriority new_state(m_tileManager->GlobalState())
; | 777 GlobalStateThatImpactsTilePriority new_state(m_tileManager->GlobalState())
; |
| 779 new_state.memory_limit_in_bytes = PrioritizedResourceManager::defaultMemor
yAllocationLimit(); | 778 new_state.memory_limit_in_bytes = m_visible ? policy.bytesLimitWhenVisible
: policy.bytesLimitWhenNotVisible; |
| 780 new_state.memory_limit_policy = ALLOW_ANYTHING; | 779 new_state.memory_limit_policy = ManagedMemoryPolicy::priorityCutoffToTileM
emoryLimitPolicy( |
| 780 m_visible ? policy.priorityCutoffWhenVisible : policy.priorityCutoffWh
enNotVisible); |
| 781 m_tileManager->SetGlobalState(new_state); | 781 m_tileManager->SetGlobalState(new_state); |
| 782 } | 782 } |
| 783 |
| 784 m_client->sendManagedMemoryStats(); |
| 783 } | 785 } |
| 784 | 786 |
| 785 bool LayerTreeHostImpl::hasImplThread() const | 787 bool LayerTreeHostImpl::hasImplThread() const |
| 786 { | 788 { |
| 787 return m_proxy->hasImplThread(); | 789 return m_proxy->hasImplThread(); |
| 788 } | 790 } |
| 789 | 791 |
| 790 void LayerTreeHostImpl::ScheduleManageTiles() | 792 void LayerTreeHostImpl::ScheduleManageTiles() |
| 791 { | 793 { |
| 792 if (m_client) | 794 if (m_client) |
| (...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1667 } | 1669 } |
| 1668 | 1670 |
| 1669 void LayerTreeHostImpl::sendManagedMemoryStats( | 1671 void LayerTreeHostImpl::sendManagedMemoryStats( |
| 1670 size_t memoryVisibleBytes, | 1672 size_t memoryVisibleBytes, |
| 1671 size_t memoryVisibleAndNearbyBytes, | 1673 size_t memoryVisibleAndNearbyBytes, |
| 1672 size_t memoryUseBytes) | 1674 size_t memoryUseBytes) |
| 1673 { | 1675 { |
| 1674 if (!renderer()) | 1676 if (!renderer()) |
| 1675 return; | 1677 return; |
| 1676 | 1678 |
| 1679 // If we are doing impl-side painting, then override the values we were |
| 1680 // handed by the prioritized resource manager with values from the tile |
| 1681 // manager. |
| 1682 if (m_tileManager) { |
| 1683 m_tileManager->GetManagedMemoryStats( |
| 1684 &memoryVisibleBytes, |
| 1685 &memoryVisibleAndNearbyBytes, |
| 1686 &memoryUseBytes); |
| 1687 } |
| 1688 |
| 1677 // Round the numbers being sent up to the next 8MB, to throttle the rate | 1689 // Round the numbers being sent up to the next 8MB, to throttle the rate |
| 1678 // at which we spam the GPU process. | 1690 // at which we spam the GPU process. |
| 1679 static const size_t roundingStep = 8 * 1024 * 1024; | 1691 static const size_t roundingStep = 8 * 1024 * 1024; |
| 1680 memoryVisibleBytes = RoundUp(memoryVisibleBytes, roundingStep); | 1692 memoryVisibleBytes = RoundUp(memoryVisibleBytes, roundingStep); |
| 1681 memoryVisibleAndNearbyBytes = RoundUp(memoryVisibleAndNearbyBytes, roundingS
tep); | 1693 memoryVisibleAndNearbyBytes = RoundUp(memoryVisibleAndNearbyBytes, roundingS
tep); |
| 1682 memoryUseBytes = RoundUp(memoryUseBytes, roundingStep); | 1694 memoryUseBytes = RoundUp(memoryUseBytes, roundingStep); |
| 1683 if (m_lastSentMemoryVisibleBytes == memoryVisibleBytes && | 1695 if (m_lastSentMemoryVisibleBytes == memoryVisibleBytes && |
| 1684 m_lastSentMemoryVisibleAndNearbyBytes == memoryVisibleAndNearbyBytes && | 1696 m_lastSentMemoryVisibleAndNearbyBytes == memoryVisibleAndNearbyBytes && |
| 1685 m_lastSentMemoryUseBytes == memoryUseBytes) { | 1697 m_lastSentMemoryUseBytes == memoryUseBytes) { |
| 1686 return; | 1698 return; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1707 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio
nController(); | 1719 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio
nController(); |
| 1708 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); | 1720 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); |
| 1709 if (scrollbarController && scrollbarController->animate(monotonicTime)) | 1721 if (scrollbarController && scrollbarController->animate(monotonicTime)) |
| 1710 m_client->setNeedsRedrawOnImplThread(); | 1722 m_client->setNeedsRedrawOnImplThread(); |
| 1711 | 1723 |
| 1712 for (size_t i = 0; i < layer->children().size(); ++i) | 1724 for (size_t i = 0; i < layer->children().size(); ++i) |
| 1713 animateScrollbarsRecursive(layer->children()[i], time); | 1725 animateScrollbarsRecursive(layer->children()[i], time); |
| 1714 } | 1726 } |
| 1715 | 1727 |
| 1716 } // namespace cc | 1728 } // namespace cc |
| OLD | NEW |