Move all debug flags in a single place.
This change also adds a new memory usage flag. When turned on, the following is printed after every frame: D/OpenGLRenderer( 3723): Current memory usage / total memory usage (bytes): D/OpenGLRenderer( 3723): TextureCache 3766680 / 20971520 D/OpenGLRenderer( 3723): LayerCache 3538944 / 8388608 D/OpenGLRenderer( 3723): GradientCache 135168 / 524288 D/OpenGLRenderer( 3723): PathCache 41180 / 4194304 D/OpenGLRenderer( 3723): TextDropShadowCache 0 / 2097152 D/OpenGLRenderer( 3723): FontRenderer 0 262144 / 262144 D/OpenGLRenderer( 3723): FontRenderer 1 262144 / 262144 D/OpenGLRenderer( 3723): FontRenderer 2 262144 / 262144 D/OpenGLRenderer( 3723): Other: D/OpenGLRenderer( 3723): FboCache 2 / 12 D/OpenGLRenderer( 3723): PatchCache 31 / 512 D/OpenGLRenderer( 3723): Total memory usage: D/OpenGLRenderer( 3723): 8268404 bytes, 7.89 MB This should help tracking possibe memory issues. Change-Id: I83f483ca1d2dbef904829bce368e33fe5503e8d6
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
#define LOG_TAG "OpenGLRenderer"
|
||||
|
||||
#include <utils/Log.h>
|
||||
|
||||
#include "Caches.h"
|
||||
|
||||
namespace android {
|
||||
@@ -53,6 +55,41 @@ Caches::~Caches() {
|
||||
delete[] mRegionMesh;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Debug
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Caches::dumpMemoryUsage() {
|
||||
LOGD("Current memory usage / total memory usage (bytes):");
|
||||
LOGD(" TextureCache %8d / %8d", textureCache.getSize(), textureCache.getMaxSize());
|
||||
LOGD(" LayerCache %8d / %8d", layerCache.getSize(), layerCache.getMaxSize());
|
||||
LOGD(" GradientCache %8d / %8d", gradientCache.getSize(), gradientCache.getMaxSize());
|
||||
LOGD(" PathCache %8d / %8d", pathCache.getSize(), pathCache.getMaxSize());
|
||||
LOGD(" TextDropShadowCache %8d / %8d", dropShadowCache.getSize(),
|
||||
dropShadowCache.getMaxSize());
|
||||
for (uint32_t i = 0; i < fontRenderer.getFontRendererCount(); i++) {
|
||||
const uint32_t size = fontRenderer.getFontRendererSize(i);
|
||||
LOGD(" FontRenderer %d %8d / %8d", i, size, size);
|
||||
}
|
||||
LOGD("Other:");
|
||||
LOGD(" FboCache %8d / %8d", fboCache.getSize(), fboCache.getMaxSize());
|
||||
LOGD(" PatchCache %8d / %8d", patchCache.getSize(), patchCache.getMaxSize());
|
||||
|
||||
uint32_t total = 0;
|
||||
total += textureCache.getSize();
|
||||
total += layerCache.getSize();
|
||||
total += gradientCache.getSize();
|
||||
total += pathCache.getSize();
|
||||
total += dropShadowCache.getSize();
|
||||
for (uint32_t i = 0; i < fontRenderer.getFontRendererCount(); i++) {
|
||||
total += fontRenderer.getFontRendererSize(i);
|
||||
}
|
||||
|
||||
LOGD("Total memory usage:");
|
||||
LOGD(" %d bytes, %.2f MB", total, total / 1024.0f / 1024.0f);
|
||||
LOGD("\n");
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// VBO
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -114,6 +114,11 @@ public:
|
||||
*/
|
||||
TextureVertex* getRegionMesh();
|
||||
|
||||
/**
|
||||
* Displays the memory usage of each cache and the total sum.
|
||||
*/
|
||||
void dumpMemoryUsage();
|
||||
|
||||
bool blend;
|
||||
GLenum lastSrcMode;
|
||||
GLenum lastDstMode;
|
||||
|
||||
44
libs/hwui/Debug.h
Normal file
44
libs/hwui/Debug.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_HWUI_DEBUG_H
|
||||
#define ANDROID_HWUI_DEBUG_H
|
||||
|
||||
// Turn on to check for OpenGL errors on each frame
|
||||
#define DEBUG_OPENGL 1
|
||||
|
||||
// Turn on to enable memory usage summary on each frame
|
||||
#define DEBUG_MEMORY_USAGE 0
|
||||
|
||||
// Turn on to enable layers debugging when renderered as regions
|
||||
#define DEBUG_LAYERS_AS_REGIONS 0
|
||||
|
||||
// Turn on to display debug info about vertex/fragment shaders
|
||||
#define DEBUG_PROGRAMS 0
|
||||
|
||||
// Turn on to display info about layers
|
||||
#define DEBUG_LAYERS 0
|
||||
|
||||
// Turn on to display debug infor about 9patch objects
|
||||
#define DEBUG_PATCHES 0
|
||||
|
||||
// Turn on to display debug info about paths
|
||||
#define DEBUG_PATHS 0
|
||||
|
||||
// Turn on to display debug info about textures
|
||||
#define DEBUG_TEXTURES 0
|
||||
|
||||
#endif // ANDROID_HWUI_DEBUG_H
|
||||
@@ -169,6 +169,14 @@ public:
|
||||
return mTextureId;
|
||||
}
|
||||
|
||||
uint32_t getCacheWidth() const {
|
||||
return mCacheWidth;
|
||||
}
|
||||
|
||||
uint32_t getCacheHeight() const {
|
||||
return mCacheHeight;
|
||||
}
|
||||
|
||||
protected:
|
||||
friend class Font;
|
||||
|
||||
@@ -207,14 +215,6 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
uint32_t getCacheWidth() const {
|
||||
return mCacheWidth;
|
||||
}
|
||||
|
||||
uint32_t getCacheHeight() const {
|
||||
return mCacheHeight;
|
||||
}
|
||||
|
||||
void initTextTexture();
|
||||
bool cacheBitmap(const SkGlyph& glyph, uint32_t *retOriginX, uint32_t *retOriginY);
|
||||
|
||||
|
||||
@@ -29,6 +29,22 @@ struct GammaFontRenderer {
|
||||
|
||||
FontRenderer& getFontRenderer(const SkPaint* paint);
|
||||
|
||||
uint32_t getFontRendererCount() const {
|
||||
return 3;
|
||||
}
|
||||
|
||||
uint32_t getFontRendererSize(uint32_t fontRenderer) const {
|
||||
switch (fontRenderer) {
|
||||
case 0:
|
||||
return mDefaultRenderer.getCacheHeight() * mDefaultRenderer.getCacheWidth();
|
||||
case 1:
|
||||
return mBlackGammaRenderer.getCacheHeight() * mBlackGammaRenderer.getCacheWidth();
|
||||
case 2:
|
||||
return mWhiteGammaRenderer.getCacheHeight() * mWhiteGammaRenderer.getCacheWidth();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private:
|
||||
FontRenderer mDefaultRenderer;
|
||||
FontRenderer mBlackGammaRenderer;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#ifndef ANDROID_HWUI_LAYER_CACHE_H
|
||||
#define ANDROID_HWUI_LAYER_CACHE_H
|
||||
|
||||
#include "Debug.h"
|
||||
#include "Layer.h"
|
||||
#include "utils/SortedList.h"
|
||||
|
||||
@@ -27,9 +28,6 @@ namespace uirenderer {
|
||||
// Defines
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Debug
|
||||
#define DEBUG_LAYERS 0
|
||||
|
||||
// Indicates whether to remove the biggest layers first, or the smaller ones
|
||||
#define LAYER_REMOVE_BIGGEST 0
|
||||
// Textures used by layers must have dimensions multiples of this number
|
||||
|
||||
@@ -161,6 +161,9 @@ void OpenGLRenderer::finish() {
|
||||
LOGD("GL error from OpenGLRenderer: 0x%x", status);
|
||||
}
|
||||
#endif
|
||||
#if DEBUG_MEMORY_USAGE
|
||||
mCaches.dumpMemoryUsage();
|
||||
#endif
|
||||
}
|
||||
|
||||
void OpenGLRenderer::acquireContext() {
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <utils/RefBase.h>
|
||||
#include <utils/Vector.h>
|
||||
|
||||
#include "Debug.h"
|
||||
#include "Extensions.h"
|
||||
#include "Matrix.h"
|
||||
#include "Program.h"
|
||||
@@ -47,12 +48,8 @@ namespace uirenderer {
|
||||
// Defines
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Debug
|
||||
#define DEBUG_OPENGL 1
|
||||
|
||||
// If turned on, layers drawn inside FBOs are optimized with regions
|
||||
#define RENDER_LAYERS_AS_REGIONS 0
|
||||
#define DEBUG_LAYERS_AS_REGIONS 0
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Renderer
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <utils/KeyedVector.h>
|
||||
|
||||
#include "Debug.h"
|
||||
#include "Patch.h"
|
||||
|
||||
namespace android {
|
||||
@@ -28,9 +29,6 @@ namespace uirenderer {
|
||||
// Defines
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Debug
|
||||
#define DEBUG_PATCHES 0
|
||||
|
||||
// Debug
|
||||
#if DEBUG_PATCHES
|
||||
#define PATCH_LOGD(...) LOGD(__VA_ARGS__)
|
||||
@@ -54,6 +52,14 @@ public:
|
||||
const uint32_t width, const uint32_t height, const int8_t numColors);
|
||||
void clear();
|
||||
|
||||
uint32_t getSize() const {
|
||||
return mCache.size();
|
||||
}
|
||||
|
||||
uint32_t getMaxSize() const {
|
||||
return mMaxEntries;
|
||||
}
|
||||
|
||||
private:
|
||||
uint32_t mMaxEntries;
|
||||
KeyedVector<PatchDescription, Patch*> mCache;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <SkPaint.h>
|
||||
#include <SkPath.h>
|
||||
|
||||
#include "Debug.h"
|
||||
#include "Texture.h"
|
||||
#include "utils/Compare.h"
|
||||
#include "utils/GenerationCache.h"
|
||||
@@ -32,9 +33,6 @@ namespace uirenderer {
|
||||
// Defines
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Debug
|
||||
#define DEBUG_PATHS 0
|
||||
|
||||
// Debug
|
||||
#if DEBUG_PATHS
|
||||
#define PATH_LOGD(...) LOGD(__VA_ARGS__)
|
||||
|
||||
@@ -456,11 +456,11 @@ String8 ProgramCache::generateFragmentShader(const ProgramDescription& descripti
|
||||
}
|
||||
|
||||
if (fast) {
|
||||
if (DEBUG_PROGRAM_CACHE) {
|
||||
#if DEBUG_PROGRAMS
|
||||
PROGRAM_LOGD("*** Fast case:\n");
|
||||
PROGRAM_LOGD("*** Generated fragment shader:\n\n");
|
||||
printLongString(shader);
|
||||
}
|
||||
#endif
|
||||
|
||||
return shader;
|
||||
}
|
||||
@@ -542,10 +542,10 @@ String8 ProgramCache::generateFragmentShader(const ProgramDescription& descripti
|
||||
// End the shader
|
||||
shader.append(gFS_Footer);
|
||||
|
||||
if (DEBUG_PROGRAM_CACHE) {
|
||||
#if DEBUG_PROGRAMS
|
||||
PROGRAM_LOGD("*** Generated fragment shader:\n\n");
|
||||
printLongString(shader);
|
||||
}
|
||||
#endif
|
||||
|
||||
return shader;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include <SkXfermode.h>
|
||||
|
||||
#include "Debug.h"
|
||||
#include "Program.h"
|
||||
|
||||
namespace android {
|
||||
@@ -35,10 +36,7 @@ namespace uirenderer {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Debug
|
||||
#define DEBUG_PROGRAM_CACHE 0
|
||||
|
||||
// Debug
|
||||
#if DEBUG_PROGRAM_CACHE
|
||||
#if DEBUG_PROGRAMS
|
||||
#define PROGRAM_LOGD(...) LOGD(__VA_ARGS__)
|
||||
#else
|
||||
#define PROGRAM_LOGD(...)
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <SkBitmap.h>
|
||||
|
||||
#include "Debug.h"
|
||||
#include "Texture.h"
|
||||
#include "utils/GenerationCache.h"
|
||||
|
||||
@@ -29,9 +30,6 @@ namespace uirenderer {
|
||||
// Defines
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Debug
|
||||
#define DEBUG_TEXTURES 0
|
||||
|
||||
// Debug
|
||||
#if DEBUG_TEXTURES
|
||||
#define TEXTURE_LOGD(...) LOGD(__VA_ARGS__)
|
||||
|
||||
Reference in New Issue
Block a user