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

Side by Side Diff: cc/layer_tree_host_impl.cc

Issue 11470024: Don't spam the GPU process with memory usage stats (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 PriorityCalculator::allowNothingCutoff()) 220 PriorityCalculator::allowNothingCutoff())
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_pinchGestureActive(false) 224 , m_pinchGestureActive(false)
225 , m_fpsCounter(FrameRateCounter::create(m_proxy->hasImplThread())) 225 , m_fpsCounter(FrameRateCounter::create(m_proxy->hasImplThread()))
226 , m_debugRectHistory(DebugRectHistory::create()) 226 , m_debugRectHistory(DebugRectHistory::create())
227 , m_numImplThreadScrolls(0) 227 , m_numImplThreadScrolls(0)
228 , m_numMainThreadScrolls(0) 228 , m_numMainThreadScrolls(0)
229 , m_cumulativeNumLayersDrawn(0) 229 , m_cumulativeNumLayersDrawn(0)
230 , m_lastSentMemoryVisibleBytes(0)
231 , m_lastSentMemoryVisibleAndNearbyBytes(0)
232 , m_lastSentMemoryUseBytes(0)
230 { 233 {
231 DCHECK(m_proxy->isImplThread()); 234 DCHECK(m_proxy->isImplThread());
232 didVisibilityChange(this, m_visible); 235 didVisibilityChange(this, m_visible);
233 } 236 }
234 237
235 LayerTreeHostImpl::~LayerTreeHostImpl() 238 LayerTreeHostImpl::~LayerTreeHostImpl()
236 { 239 {
237 DCHECK(m_proxy->isImplThread()); 240 DCHECK(m_proxy->isImplThread());
238 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()"); 241 TRACE_EVENT0("cc", "LayerTreeHostImpl::~LayerTreeHostImpl()");
239 242
(...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after
1612 stats->numFramesSentToScreen = fpsCounter()->currentFrameNumber(); 1615 stats->numFramesSentToScreen = fpsCounter()->currentFrameNumber();
1613 stats->droppedFrameCount = fpsCounter()->droppedFrameCount(); 1616 stats->droppedFrameCount = fpsCounter()->droppedFrameCount();
1614 stats->numImplThreadScrolls = m_numImplThreadScrolls; 1617 stats->numImplThreadScrolls = m_numImplThreadScrolls;
1615 stats->numMainThreadScrolls = m_numMainThreadScrolls; 1618 stats->numMainThreadScrolls = m_numMainThreadScrolls;
1616 stats->numLayersDrawn = m_cumulativeNumLayersDrawn; 1619 stats->numLayersDrawn = m_cumulativeNumLayersDrawn;
1617 1620
1618 if (m_tileManager) 1621 if (m_tileManager)
1619 m_tileManager->renderingStats(stats); 1622 m_tileManager->renderingStats(stats);
1620 } 1623 }
1621 1624
1625 void LayerTreeHostImpl::sendManagedMemoryStats(
1626 size_t memoryVisibleBytes,
1627 size_t memoryVisibleAndNearbyBytes,
1628 size_t memoryUseBytes)
1629 {
1630 if (!renderer())
1631 return;
1632
1633 // Round the numbers being sent up to the next 8MB, to throttle the rate
ccameron 2012/12/07 21:58:41 Do we have a ROUND_UP macro, or something like tha
1634 // at which we spam the GPU process.
1635 const size_t roundingStep = 8 * 1024 * 1024;
1636 memoryVisibleBytes = ((memoryVisibleBytes + roundingStep - 1) / roundingStep ) * roundingStep;
1637 memoryVisibleAndNearbyBytes = ((memoryVisibleAndNearbyBytes + roundingStep - 1) / roundingStep) * roundingStep;
1638 memoryUseBytes = ((memoryUseBytes + roundingStep - 1) / roundingStep) * roun dingStep;
1639 if (m_lastSentMemoryVisibleBytes == memoryVisibleBytes &&
jamesr 2012/12/07 22:14:34 alternately, why not just calculate a diff from th
ccameron 2012/12/07 22:33:49 The is less artifact-prone (it doesn't depend on t
1640 m_lastSentMemoryVisibleAndNearbyBytes == memoryVisibleAndNearbyBytes &&
1641 m_lastSentMemoryUseBytes == memoryUseBytes) {
1642 return;
1643 }
1644 m_lastSentMemoryVisibleBytes = memoryVisibleBytes;
1645 m_lastSentMemoryVisibleAndNearbyBytes = memoryVisibleAndNearbyBytes;
1646 m_lastSentMemoryUseBytes = memoryUseBytes;
1647
1648 renderer()->sendManagedMemoryStats(m_lastSentMemoryVisibleBytes,
1649 m_lastSentMemoryVisibleAndNearbyBytes,
1650 m_lastSentMemoryUseBytes);
1651 }
1652
1622 void LayerTreeHostImpl::animateScrollbars(base::TimeTicks time) 1653 void LayerTreeHostImpl::animateScrollbars(base::TimeTicks time)
1623 { 1654 {
1624 animateScrollbarsRecursive(m_rootLayerImpl.get(), time); 1655 animateScrollbarsRecursive(m_rootLayerImpl.get(), time);
1625 } 1656 }
1626 1657
1627 void LayerTreeHostImpl::animateScrollbarsRecursive(LayerImpl* layer, base::TimeT icks time) 1658 void LayerTreeHostImpl::animateScrollbarsRecursive(LayerImpl* layer, base::TimeT icks time)
1628 { 1659 {
1629 if (!layer) 1660 if (!layer)
1630 return; 1661 return;
1631 1662
1632 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController(); 1663 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController();
1633 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); 1664 double monotonicTime = (time - base::TimeTicks()).InSecondsF();
1634 if (scrollbarController && scrollbarController->animate(monotonicTime)) 1665 if (scrollbarController && scrollbarController->animate(monotonicTime))
1635 m_client->setNeedsRedrawOnImplThread(); 1666 m_client->setNeedsRedrawOnImplThread();
1636 1667
1637 for (size_t i = 0; i < layer->children().size(); ++i) 1668 for (size_t i = 0; i < layer->children().size(); ++i)
1638 animateScrollbarsRecursive(layer->children()[i], time); 1669 animateScrollbarsRecursive(layer->children()[i], time);
1639 } 1670 }
1640 1671
1641 } // namespace cc 1672 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698