Chromium Code Reviews| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTre eHostImplClient* client, Proxy* proxy) | 208 LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTre eHostImplClient* client, Proxy* proxy) |
| 209 : m_client(client) | 209 : m_client(client) |
| 210 , m_proxy(proxy) | 210 , m_proxy(proxy) |
| 211 , m_scrollDeltaIsInViewportSpace(false) | 211 , m_scrollDeltaIsInViewportSpace(false) |
| 212 , m_settings(settings) | 212 , m_settings(settings) |
| 213 , m_debugState(settings.initialDebugState) | 213 , m_debugState(settings.initialDebugState) |
| 214 , m_deviceScaleFactor(1) | 214 , m_deviceScaleFactor(1) |
| 215 , m_visible(true) | 215 , m_visible(true) |
| 216 , m_contentsTexturesPurged(false) | 216 , m_contentsTexturesPurged(false) |
| 217 , m_managedMemoryPolicy(PrioritizedResourceManager::defaultMemoryAllocationL imit(), | 217 , m_managedMemoryPolicy(PrioritizedResourceManager::defaultMemoryAllocationL imit(), |
| 218 PriorityCalculator::allowEverythingCutoff(), | 218 ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING, |
| 219 0, | 219 0, |
| 220 PriorityCalculator::allowNothingCutoff()) | 220 ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING) |
| 221 , m_backgroundColor(0) | 221 , m_backgroundColor(0) |
| 222 , m_hasTransparentBackground(false) | 222 , m_hasTransparentBackground(false) |
| 223 , m_needsAnimateLayers(false) | 223 , m_needsAnimateLayers(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) |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 783 return false; | 783 return false; |
| 784 | 784 |
| 785 // If we return true, then we expect drawLayers() to be called before this f unction is called again. | 785 // If we return true, then we expect drawLayers() to be called before this f unction is called again. |
| 786 return true; | 786 return true; |
| 787 } | 787 } |
| 788 | 788 |
| 789 void LayerTreeHostImpl::enforceManagedMemoryPolicy(const ManagedMemoryPolicy& po licy) | 789 void LayerTreeHostImpl::enforceManagedMemoryPolicy(const ManagedMemoryPolicy& po licy) |
| 790 { | 790 { |
| 791 bool evictedResources = m_client->reduceContentsTextureMemoryOnImplThread( | 791 bool evictedResources = m_client->reduceContentsTextureMemoryOnImplThread( |
| 792 m_visible ? policy.bytesLimitWhenVisible : policy.bytesLimitWhenNotVisib le, | 792 m_visible ? policy.bytesLimitWhenVisible : policy.bytesLimitWhenNotVisib le, |
| 793 m_visible ? policy.priorityCutoffWhenVisible : policy.priorityCutoffWhen NotVisible); | 793 ManagedMemoryPolicy::priorityCutoffValue( |
| 794 m_visible ? policy.priorityCutoffWhenVisible : policy.priorityCutoff WhenNotVisible)); | |
| 794 if (evictedResources) { | 795 if (evictedResources) { |
| 795 setContentsTexturesPurged(); | 796 setContentsTexturesPurged(); |
| 796 m_client->setNeedsCommitOnImplThread(); | 797 m_client->setNeedsCommitOnImplThread(); |
| 797 m_client->onCanDrawStateChanged(canDraw()); | 798 m_client->onCanDrawStateChanged(canDraw()); |
| 798 } | 799 } |
| 799 m_client->sendManagedMemoryStats(); | 800 m_client->sendManagedMemoryStats(); |
| 800 | 801 |
| 801 if (m_tileManager) { | 802 if (m_tileManager) { |
| 802 // TODO(nduca): Pass something useful into the memory manager. | 803 // TODO(nduca): Pass something useful into the memory manager. |
| 803 LOG(INFO) << "Setting up initial tile manager policy"; | 804 LOG(INFO) << "Setting up initial tile manager policy"; |
| 804 GlobalStateThatImpactsTilePriority new_state(m_tileManager->GlobalState()) ; | 805 GlobalStateThatImpactsTilePriority new_state(m_tileManager->GlobalState()) ; |
| 805 new_state.memory_limit_in_bytes = PrioritizedResourceManager::defaultMemor yAllocationLimit(); | 806 new_state.memory_limit_in_bytes = m_visible ? policy.bytesLimitWhenVisible : policy.bytesLimitWhenNotVisible; |
| 806 new_state.memory_limit_policy = ALLOW_ANYTHING; | 807 new_state.memory_limit_policy = ManagedMemoryPolicy::priorityCutoffToMemor yLimitPolicy( |
| 808 m_visible ? policy.priorityCutoffWhenVisible : policy.priorityCutoffW henNotVisible); | |
| 807 m_tileManager->SetGlobalState(new_state); | 809 m_tileManager->SetGlobalState(new_state); |
|
nduca
2012/12/19 21:46:32
I think we might want a to just pass the enforce c
| |
| 808 } | 810 } |
| 809 } | 811 } |
| 810 | 812 |
| 811 bool LayerTreeHostImpl::hasImplThread() const | 813 bool LayerTreeHostImpl::hasImplThread() const |
| 812 { | 814 { |
| 813 return m_proxy->hasImplThread(); | 815 return m_proxy->hasImplThread(); |
| 814 } | 816 } |
| 815 | 817 |
| 816 void LayerTreeHostImpl::ScheduleManageTiles() | 818 void LayerTreeHostImpl::ScheduleManageTiles() |
| 817 { | 819 { |
| (...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1690 } | 1692 } |
| 1691 | 1693 |
| 1692 void LayerTreeHostImpl::sendManagedMemoryStats( | 1694 void LayerTreeHostImpl::sendManagedMemoryStats( |
| 1693 size_t memoryVisibleBytes, | 1695 size_t memoryVisibleBytes, |
| 1694 size_t memoryVisibleAndNearbyBytes, | 1696 size_t memoryVisibleAndNearbyBytes, |
| 1695 size_t memoryUseBytes) | 1697 size_t memoryUseBytes) |
| 1696 { | 1698 { |
| 1697 if (!renderer()) | 1699 if (!renderer()) |
| 1698 return; | 1700 return; |
| 1699 | 1701 |
| 1702 // XXX - these numbers are coming from the priorized texture manager. | |
| 1703 // If we have a tile manager, the numbers should come from there! | |
| 1704 | |
| 1700 // Round the numbers being sent up to the next 8MB, to throttle the rate | 1705 // Round the numbers being sent up to the next 8MB, to throttle the rate |
| 1701 // at which we spam the GPU process. | 1706 // at which we spam the GPU process. |
| 1702 static const size_t roundingStep = 8 * 1024 * 1024; | 1707 static const size_t roundingStep = 8 * 1024 * 1024; |
| 1703 memoryVisibleBytes = RoundUp(memoryVisibleBytes, roundingStep); | 1708 memoryVisibleBytes = RoundUp(memoryVisibleBytes, roundingStep); |
| 1704 memoryVisibleAndNearbyBytes = RoundUp(memoryVisibleAndNearbyBytes, roundingS tep); | 1709 memoryVisibleAndNearbyBytes = RoundUp(memoryVisibleAndNearbyBytes, roundingS tep); |
| 1705 memoryUseBytes = RoundUp(memoryUseBytes, roundingStep); | 1710 memoryUseBytes = RoundUp(memoryUseBytes, roundingStep); |
| 1706 if (m_lastSentMemoryVisibleBytes == memoryVisibleBytes && | 1711 if (m_lastSentMemoryVisibleBytes == memoryVisibleBytes && |
| 1707 m_lastSentMemoryVisibleAndNearbyBytes == memoryVisibleAndNearbyBytes && | 1712 m_lastSentMemoryVisibleAndNearbyBytes == memoryVisibleAndNearbyBytes && |
| 1708 m_lastSentMemoryUseBytes == memoryUseBytes) { | 1713 m_lastSentMemoryUseBytes == memoryUseBytes) { |
| 1709 return; | 1714 return; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 1730 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController(); | 1735 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController(); |
| 1731 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); | 1736 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); |
| 1732 if (scrollbarController && scrollbarController->animate(monotonicTime)) | 1737 if (scrollbarController && scrollbarController->animate(monotonicTime)) |
| 1733 m_client->setNeedsRedrawOnImplThread(); | 1738 m_client->setNeedsRedrawOnImplThread(); |
| 1734 | 1739 |
| 1735 for (size_t i = 0; i < layer->children().size(); ++i) | 1740 for (size_t i = 0; i < layer->children().size(); ++i) |
| 1736 animateScrollbarsRecursive(layer->children()[i], time); | 1741 animateScrollbarsRecursive(layer->children()[i], time); |
| 1737 } | 1742 } |
| 1738 | 1743 |
| 1739 } // namespace cc | 1744 } // namespace cc |
| OLD | NEW |