Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: cc/layer_tree_host_impl.cc

Issue 11637022: Send memory management policies to the tile manager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporate review feedback Created 7 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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)
793 m_client->setNeedsManageTilesOnImplThread(); 795 m_client->setNeedsManageTilesOnImplThread();
794 } 796 }
795 797
796 void LayerTreeHostImpl::ScheduleCheckForCompletedSetPixels() 798 void LayerTreeHostImpl::ScheduleCheckForCompletedSetPixels()
797 { 799 {
798 // CheckForCompletedSetPixels() should be called before we draw and 800 // CheckForCompletedSetPixels() should be called before we draw and
799 // preferably only once per vsync interval. For now just make sure 801 // preferably only once per vsync interval. For now just make sure
800 // a redraw is scheduled and call CheckForCompletedSetPixels() in 802 // a redraw is scheduled and call CheckForCompletedSetPixels() in
801 // prepareToDraw(). 803 // prepareToDraw().
802 if (m_client) 804 if (m_client)
803 m_client->setNeedsRedrawOnImplThread(); 805 m_client->setNeedsRedrawOnImplThread();
804 } 806 }
805 807
808 void LayerTreeHostImpl::SendTileManagerMemoryStats(
809 size_t memoryRequiredBytes,
810 size_t memoryNiceToHaveBytes,
811 size_t memoryUsedBytes)
812 {
813 sendManagedMemoryStats(memoryRequiredBytes, memoryNiceToHaveBytes, memoryUse dBytes);
814 }
815
806 bool LayerTreeHostImpl::shouldClearRootRenderPass() const 816 bool LayerTreeHostImpl::shouldClearRootRenderPass() const
807 { 817 {
808 return m_settings.shouldClearRootRenderPass; 818 return m_settings.shouldClearRootRenderPass;
809 } 819 }
810 820
811 void LayerTreeHostImpl::setManagedMemoryPolicy(const ManagedMemoryPolicy& policy ) 821 void LayerTreeHostImpl::setManagedMemoryPolicy(const ManagedMemoryPolicy& policy )
812 { 822 {
813 if (m_managedMemoryPolicy == policy) 823 if (m_managedMemoryPolicy == policy)
814 return; 824 return;
815 825
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after
1707 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController(); 1717 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController();
1708 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); 1718 double monotonicTime = (time - base::TimeTicks()).InSecondsF();
1709 if (scrollbarController && scrollbarController->animate(monotonicTime)) 1719 if (scrollbarController && scrollbarController->animate(monotonicTime))
1710 m_client->setNeedsRedrawOnImplThread(); 1720 m_client->setNeedsRedrawOnImplThread();
1711 1721
1712 for (size_t i = 0; i < layer->children().size(); ++i) 1722 for (size_t i = 0; i < layer->children().size(); ++i)
1713 animateScrollbarsRecursive(layer->children()[i], time); 1723 animateScrollbarsRecursive(layer->children()[i], time);
1714 } 1724 }
1715 1725
1716 } // namespace cc 1726 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_tree_host_impl.h ('k') | cc/managed_memory_policy.h » ('j') | cc/thread_proxy.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698