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

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: Fix clang build Created 7 years, 11 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
« no previous file with comments | « cc/gl_renderer.cc ('k') | cc/managed_memory_policy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 { 319 {
320 animatePageScale(monotonicTime); 320 animatePageScale(monotonicTime);
321 animateLayers(monotonicTime, wallClockTime); 321 animateLayers(monotonicTime, wallClockTime);
322 animateScrollbars(monotonicTime); 322 animateScrollbars(monotonicTime);
323 } 323 }
324 324
325 void LayerTreeHostImpl::manageTiles() 325 void LayerTreeHostImpl::manageTiles()
326 { 326 {
327 DCHECK(m_tileManager); 327 DCHECK(m_tileManager);
328 m_tileManager->ManageTiles(); 328 m_tileManager->ManageTiles();
329
330 size_t memoryRequiredBytes;
331 size_t memoryNiceToHaveBytes;
332 size_t memoryUsedBytes;
333 m_tileManager->GetMemoryStats(&memoryRequiredBytes,
334 &memoryNiceToHaveBytes,
335 &memoryUsedBytes);
336 sendManagedMemoryStats(memoryRequiredBytes,
337 memoryNiceToHaveBytes,
338 memoryUsedBytes);
329 } 339 }
330 340
331 void LayerTreeHostImpl::startPageScaleAnimation(gfx::Vector2d targetOffset, bool anchorPoint, float pageScale, base::TimeTicks startTime, base::TimeDelta durati on) 341 void LayerTreeHostImpl::startPageScaleAnimation(gfx::Vector2d targetOffset, bool anchorPoint, float pageScale, base::TimeTicks startTime, base::TimeDelta durati on)
332 { 342 {
333 if (!rootScrollLayer()) 343 if (!rootScrollLayer())
334 return; 344 return;
335 345
336 gfx::Vector2dF scrollTotal = rootScrollLayer()->scrollOffset() + rootScrollL ayer()->scrollDelta(); 346 gfx::Vector2dF scrollTotal = rootScrollLayer()->scrollOffset() + rootScrollL ayer()->scrollDelta();
337 gfx::SizeF scaledContentSize = contentSize(); 347 gfx::SizeF scaledContentSize = contentSize();
338 if (!m_settings.pageScalePinchZoomEnabled) { 348 if (!m_settings.pageScalePinchZoomEnabled) {
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 return false; 767 return false;
758 768
759 // If we return true, then we expect drawLayers() to be called before this f unction is called again. 769 // If we return true, then we expect drawLayers() to be called before this f unction is called again.
760 return true; 770 return true;
761 } 771 }
762 772
763 void LayerTreeHostImpl::enforceManagedMemoryPolicy(const ManagedMemoryPolicy& po licy) 773 void LayerTreeHostImpl::enforceManagedMemoryPolicy(const ManagedMemoryPolicy& po licy)
764 { 774 {
765 bool evictedResources = m_client->reduceContentsTextureMemoryOnImplThread( 775 bool evictedResources = m_client->reduceContentsTextureMemoryOnImplThread(
766 m_visible ? policy.bytesLimitWhenVisible : policy.bytesLimitWhenNotVisib le, 776 m_visible ? policy.bytesLimitWhenVisible : policy.bytesLimitWhenNotVisib le,
767 m_visible ? policy.priorityCutoffWhenVisible : policy.priorityCutoffWhen NotVisible); 777 ManagedMemoryPolicy::priorityCutoffToValue(
778 m_visible ? policy.priorityCutoffWhenVisible : policy.priorityCutoff WhenNotVisible));
768 if (evictedResources) { 779 if (evictedResources) {
769 setContentsTexturesPurged(); 780 setContentsTexturesPurged();
770 m_client->setNeedsCommitOnImplThread(); 781 m_client->setNeedsCommitOnImplThread();
771 m_client->onCanDrawStateChanged(canDraw()); 782 m_client->onCanDrawStateChanged(canDraw());
772 } 783 }
773 m_client->sendManagedMemoryStats(); 784 m_client->sendManagedMemoryStats();
774 785
775 if (m_tileManager) { 786 if (m_tileManager) {
776 // TODO(nduca): Pass something useful into the memory manager. 787 LOG(INFO) << "Setting up initial tile manager policy";
777 GlobalStateThatImpactsTilePriority new_state(m_tileManager->GlobalState()) ; 788 GlobalStateThatImpactsTilePriority new_state(m_tileManager->GlobalState()) ;
778 new_state.memory_limit_in_bytes = PrioritizedResourceManager::defaultMemor yAllocationLimit(); 789 new_state.memory_limit_in_bytes = m_visible ? policy.bytesLimitWhenVisible : policy.bytesLimitWhenNotVisible;
779 new_state.memory_limit_policy = ALLOW_ANYTHING; 790 new_state.memory_limit_policy = ManagedMemoryPolicy::priorityCutoffToTileM emoryLimitPolicy(
791 m_visible ? policy.priorityCutoffWhenVisible : policy.priorityCutoffWh enNotVisible);
780 m_tileManager->SetGlobalState(new_state); 792 m_tileManager->SetGlobalState(new_state);
781 } 793 }
782 } 794 }
783 795
784 bool LayerTreeHostImpl::hasImplThread() const 796 bool LayerTreeHostImpl::hasImplThread() const
785 { 797 {
786 return m_proxy->hasImplThread(); 798 return m_proxy->hasImplThread();
787 } 799 }
788 800
789 void LayerTreeHostImpl::ScheduleManageTiles() 801 void LayerTreeHostImpl::ScheduleManageTiles()
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after
1706 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController(); 1718 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController();
1707 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); 1719 double monotonicTime = (time - base::TimeTicks()).InSecondsF();
1708 if (scrollbarController && scrollbarController->animate(monotonicTime)) 1720 if (scrollbarController && scrollbarController->animate(monotonicTime))
1709 m_client->setNeedsRedrawOnImplThread(); 1721 m_client->setNeedsRedrawOnImplThread();
1710 1722
1711 for (size_t i = 0; i < layer->children().size(); ++i) 1723 for (size_t i = 0; i < layer->children().size(); ++i)
1712 animateScrollbarsRecursive(layer->children()[i], time); 1724 animateScrollbarsRecursive(layer->children()[i], time);
1713 } 1725 }
1714 1726
1715 } // namespace cc 1727 } // namespace cc
OLDNEW
« no previous file with comments | « cc/gl_renderer.cc ('k') | cc/managed_memory_policy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698