diff options
author | ccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-08 06:24:28 +0000 |
---|---|---|
committer | ccameron@chromium.org <ccameron@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-08 06:24:28 +0000 |
commit | d3afa1118465dff80232d36b7452700c43997d57 (patch) | |
tree | 6533e98e8935fc64c3c45b9174b65b88996f965b | |
parent | 3639b07133f3c9a2b0e3dc8ae92bb7f2f0bd9a8d (diff) | |
download | chromium_src-d3afa1118465dff80232d36b7452700c43997d57.zip chromium_src-d3afa1118465dff80232d36b7452700c43997d57.tar.gz chromium_src-d3afa1118465dff80232d36b7452700c43997d57.tar.bz2 |
Round managed memory stats to the nearest 8MB, and don't perform
redundant updates, to avoid frequently descheduling the renderer.
BUG=164947
Review URL: https://chromiumcodereview.appspot.com/11470024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171949 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | cc/cc.gyp | 1 | ||||
-rw-r--r-- | cc/layer_tree_host_impl.cc | 32 | ||||
-rw-r--r-- | cc/layer_tree_host_impl.h | 9 | ||||
-rw-r--r-- | cc/single_thread_proxy.cc | 4 | ||||
-rw-r--r-- | cc/texture_uploader.cc | 10 | ||||
-rw-r--r-- | cc/thread_proxy.cc | 4 | ||||
-rw-r--r-- | cc/util.h | 18 |
7 files changed, 65 insertions, 13 deletions
@@ -265,6 +265,7 @@ 'transferable_resource.h', 'tree_synchronizer.cc', 'tree_synchronizer.h', + 'util.h', 'video_layer.cc', 'video_layer.h', 'video_layer_impl.cc', diff --git a/cc/layer_tree_host_impl.cc b/cc/layer_tree_host_impl.cc index da778a9..e0b1f30 100644 --- a/cc/layer_tree_host_impl.cc +++ b/cc/layer_tree_host_impl.cc @@ -34,6 +34,7 @@ #include "cc/software_renderer.h" #include "cc/solid_color_draw_quad.h" #include "cc/texture_uploader.h" +#include "cc/util.h" #include "ui/gfx/size_conversions.h" #include "ui/gfx/vector2d_conversions.h" @@ -224,6 +225,9 @@ LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTre , m_numMainThreadScrolls(0) , m_cumulativeNumLayersDrawn(0) , m_cumulativeNumMissingTiles(0) + , m_lastSentMemoryVisibleBytes(0) + , m_lastSentMemoryVisibleAndNearbyBytes(0) + , m_lastSentMemoryUseBytes(0) { DCHECK(m_proxy->isImplThread()); didVisibilityChange(this, m_visible); @@ -1591,6 +1595,34 @@ void LayerTreeHostImpl::renderingStats(RenderingStats* stats) const m_tileManager->renderingStats(stats); } +void LayerTreeHostImpl::sendManagedMemoryStats( + size_t memoryVisibleBytes, + size_t memoryVisibleAndNearbyBytes, + size_t memoryUseBytes) +{ + if (!renderer()) + return; + + // Round the numbers being sent up to the next 8MB, to throttle the rate + // at which we spam the GPU process. + static const size_t roundingStep = 8 * 1024 * 1024; + memoryVisibleBytes = RoundUp(memoryVisibleBytes, roundingStep); + memoryVisibleAndNearbyBytes = RoundUp(memoryVisibleAndNearbyBytes, roundingStep); + memoryUseBytes = RoundUp(memoryUseBytes, roundingStep); + if (m_lastSentMemoryVisibleBytes == memoryVisibleBytes && + m_lastSentMemoryVisibleAndNearbyBytes == memoryVisibleAndNearbyBytes && + m_lastSentMemoryUseBytes == memoryUseBytes) { + return; + } + m_lastSentMemoryVisibleBytes = memoryVisibleBytes; + m_lastSentMemoryVisibleAndNearbyBytes = memoryVisibleAndNearbyBytes; + m_lastSentMemoryUseBytes = memoryUseBytes; + + renderer()->sendManagedMemoryStats(m_lastSentMemoryVisibleBytes, + m_lastSentMemoryVisibleAndNearbyBytes, + m_lastSentMemoryUseBytes); +} + void LayerTreeHostImpl::animateScrollbars(base::TimeTicks time) { animateScrollbarsRecursive(rootLayer(), time); diff --git a/cc/layer_tree_host_impl.h b/cc/layer_tree_host_impl.h index 891d3e11..ff61b75 100644 --- a/cc/layer_tree_host_impl.h +++ b/cc/layer_tree_host_impl.h @@ -255,6 +255,11 @@ public: void updateRootScrollLayerImplTransform(); + void sendManagedMemoryStats( + size_t memoryVisibleBytes, + size_t memoryVisibleAndNearbyBytes, + size_t memoryUseBytes); + FrameRateCounter* fpsCounter() const { return m_fpsCounter.get(); } DebugRectHistory* debugRectHistory() const { return m_debugRectHistory.get(); } ResourceProvider* resourceProvider() const { return m_resourceProvider.get(); } @@ -395,6 +400,10 @@ private: AnimationControllerSet m_allAnimationControllers; #endif + size_t m_lastSentMemoryVisibleBytes; + size_t m_lastSentMemoryVisibleAndNearbyBytes; + size_t m_lastSentMemoryUseBytes; + DISALLOW_COPY_AND_ASSIGN(LayerTreeHostImpl); }; diff --git a/cc/single_thread_proxy.cc b/cc/single_thread_proxy.cc index d3787bc..911f90d 100644 --- a/cc/single_thread_proxy.cc +++ b/cc/single_thread_proxy.cc @@ -297,12 +297,10 @@ void SingleThreadProxy::sendManagedMemoryStats() DCHECK(Proxy::isImplThread()); if (!m_layerTreeHostImpl.get()) return; - if (!m_layerTreeHostImpl->renderer()) - return; if (!m_layerTreeHost->contentsTextureManager()) return; - m_layerTreeHostImpl->renderer()->sendManagedMemoryStats( + m_layerTreeHostImpl->sendManagedMemoryStats( m_layerTreeHost->contentsTextureManager()->memoryVisibleBytes(), m_layerTreeHost->contentsTextureManager()->memoryVisibleAndNearbyBytes(), m_layerTreeHost->contentsTextureManager()->memoryUseBytes()); diff --git a/cc/texture_uploader.cc b/cc/texture_uploader.cc index 6ff13c7..bac2871 100644 --- a/cc/texture_uploader.cc +++ b/cc/texture_uploader.cc @@ -12,6 +12,7 @@ #include "base/metrics/histogram.h" #include "cc/prioritized_resource.h" #include "cc/resource.h" +#include "cc/util.h" #include "third_party/khronos/GLES2/gl2.h" #include "third_party/khronos/GLES2/gl2ext.h" #include "ui/gfx/rect.h" @@ -32,11 +33,6 @@ static const double defaultEstimatedTexturesPerSecond = 48.0 * 60.0; // Flush interval when performing texture uploads. const int textureUploadFlushPeriod = 4; -unsigned int RoundUp(unsigned int n, unsigned int mul) -{ - return (((n - 1) / mul) * mul) + mul; -} - } // anonymous namespace namespace cc { @@ -237,7 +233,7 @@ void TextureUploader::uploadWithTexSubImage(const uint8* image, // Use 4-byte row alignment (OpenGL default) for upload performance. // Assuming that GL_UNPACK_ALIGNMENT has not changed from default. unsigned int upload_image_stride = - RoundUp(bytes_per_pixel * source_rect.width(), 4); + RoundUp(bytes_per_pixel * source_rect.width(), 4u); if (upload_image_stride == image_rect.width() * bytes_per_pixel && !offset.x()) { pixel_source = &image[image_rect.width() * bytes_per_pixel * offset.y()]; @@ -307,7 +303,7 @@ void TextureUploader::uploadWithMapTexSubImage(const uint8* image, // Use 4-byte row alignment (OpenGL default) for upload performance. // Assuming that GL_UNPACK_ALIGNMENT has not changed from default. unsigned int upload_image_stride = - RoundUp(bytes_per_pixel * source_rect.width(), 4); + RoundUp(bytes_per_pixel * source_rect.width(), 4u); // Upload tile data via a mapped transfer buffer uint8* pixel_dest = static_cast<uint8*>( diff --git a/cc/thread_proxy.cc b/cc/thread_proxy.cc index f2a6214..cd0baa3 100644 --- a/cc/thread_proxy.cc +++ b/cc/thread_proxy.cc @@ -386,12 +386,10 @@ void ThreadProxy::sendManagedMemoryStats() DCHECK(isImplThread()); if (!m_layerTreeHostImpl.get()) return; - if (!m_layerTreeHostImpl->renderer()) - return; if (!m_layerTreeHost->contentsTextureManager()) return; - m_layerTreeHostImpl->renderer()->sendManagedMemoryStats( + m_layerTreeHostImpl->sendManagedMemoryStats( m_layerTreeHost->contentsTextureManager()->memoryVisibleBytes(), m_layerTreeHost->contentsTextureManager()->memoryVisibleAndNearbyBytes(), m_layerTreeHost->contentsTextureManager()->memoryUseBytes()); diff --git a/cc/util.h b/cc/util.h new file mode 100644 index 0000000..6da3a69 --- /dev/null +++ b/cc/util.h @@ -0,0 +1,18 @@ +// Copyright 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CC_UTIL_H_ +#define CC_UTIL_H_ + +namespace cc { + +template<typename T> +T RoundUp(T n, T mul) +{ + return ((n + mul - 1) / mul) * mul; +} + +} // namespace cc + +#endif // CC_UTIL_H_ |