Merge "Add new runtime debug flags."
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include <utils/Log.h>
|
||||
|
||||
#include "Caches.h"
|
||||
#include "Properties.h"
|
||||
|
||||
namespace android {
|
||||
|
||||
@@ -49,6 +50,9 @@ Caches::Caches(): Singleton<Caches>(), blend(false), lastSrcMode(GL_ZERO),
|
||||
|
||||
mCurrentBuffer = meshBuffer;
|
||||
mRegionMesh = NULL;
|
||||
|
||||
mDebugLevel = readDebugLevel();
|
||||
LOGD("Enabling debug mode %d", mDebugLevel);
|
||||
}
|
||||
|
||||
Caches::~Caches() {
|
||||
|
||||
@@ -83,7 +83,7 @@ class Caches: public Singleton<Caches> {
|
||||
|
||||
friend class Singleton<Caches>;
|
||||
|
||||
CacheLogger mlogger;
|
||||
CacheLogger mLogger;
|
||||
|
||||
GLuint mCurrentBuffer;
|
||||
|
||||
@@ -92,6 +92,14 @@ class Caches: public Singleton<Caches> {
|
||||
GLuint mRegionMeshIndices;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Indicates whether the renderer is in debug mode.
|
||||
* This debug mode provides limited information to app developers.
|
||||
*/
|
||||
DebugLevel getDebugLevel() const {
|
||||
return mDebugLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Binds the VBO used to render simple textured quads.
|
||||
*/
|
||||
@@ -145,6 +153,9 @@ public:
|
||||
ResourceCache resourceCache;
|
||||
|
||||
Line line;
|
||||
|
||||
private:
|
||||
DebugLevel mDebugLevel;
|
||||
}; // class Caches
|
||||
|
||||
}; // namespace uirenderer
|
||||
|
||||
@@ -163,6 +163,10 @@ void OpenGLRenderer::finish() {
|
||||
#endif
|
||||
#if DEBUG_MEMORY_USAGE
|
||||
mCaches.dumpMemoryUsage();
|
||||
#else
|
||||
if (mCaches.getDebugLevel() & kDebugMemory) {
|
||||
mCaches.dumpMemoryUsage();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,8 @@ void PathCache::init() {
|
||||
GLint maxTextureSize;
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
||||
mMaxTextureSize = maxTextureSize;
|
||||
|
||||
mDebugEnabled = readDebugLevel() & kDebugCaches;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -98,6 +100,9 @@ void PathCache::operator()(PathCacheEntry& path, PathTexture*& texture) {
|
||||
|
||||
PATH_LOGD("PathCache::callback: delete path: name, size, mSize = %d, %d, %d",
|
||||
texture->id, size, mSize);
|
||||
if (mDebugEnabled) {
|
||||
LOGD("Path deleted, size = %d", size);
|
||||
}
|
||||
|
||||
glDeleteTextures(1, &texture->id);
|
||||
delete texture;
|
||||
@@ -199,6 +204,9 @@ PathTexture* PathCache::addTexture(const PathCacheEntry& entry,
|
||||
mSize += size;
|
||||
PATH_LOGD("PathCache::get: create path: name, size, mSize = %d, %d, %d",
|
||||
texture->id, size, mSize);
|
||||
if (mDebugEnabled) {
|
||||
LOGD("Path created, size = %d", size);
|
||||
}
|
||||
mCache.put(entry, texture);
|
||||
mLock.unlock();
|
||||
} else {
|
||||
|
||||
@@ -176,6 +176,8 @@ private:
|
||||
uint32_t mMaxSize;
|
||||
GLuint mMaxTextureSize;
|
||||
|
||||
bool mDebugEnabled;
|
||||
|
||||
/**
|
||||
* Used to access mCache and mSize. All methods are accessed from a single
|
||||
* thread except for remove().
|
||||
|
||||
@@ -18,12 +18,27 @@
|
||||
#define ANDROID_HWUI_PROPERTIES_H
|
||||
|
||||
#include <cutils/properties.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/**
|
||||
* This file contains the list of system properties used to configure
|
||||
* the OpenGLRenderer.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Debug level for app developers.
|
||||
*/
|
||||
#define PROPERTY_DEBUG "hwui.debug_level"
|
||||
|
||||
/**
|
||||
* Debug levels. Debug levels are used as flags.
|
||||
*/
|
||||
enum DebugLevel {
|
||||
kDebugDisabled = 0,
|
||||
kDebugMemory = 1,
|
||||
kDebugCaches = 2
|
||||
};
|
||||
|
||||
// These properties are defined in mega-bytes
|
||||
#define PROPERTY_TEXTURE_CACHE_SIZE "ro.hwui.texture_cache_size"
|
||||
#define PROPERTY_LAYER_CACHE_SIZE "ro.hwui.layer_cache_size"
|
||||
@@ -56,4 +71,12 @@
|
||||
#define DEFAULT_TEXT_BLACK_GAMMA_THRESHOLD 64
|
||||
#define DEFAULT_TEXT_WHITE_GAMMA_THRESHOLD 192
|
||||
|
||||
static DebugLevel readDebugLevel() {
|
||||
char property[PROPERTY_VALUE_MAX];
|
||||
if (property_get(PROPERTY_DEBUG, property, NULL) > 0) {
|
||||
return (DebugLevel) atoi(property);
|
||||
}
|
||||
return kDebugDisabled;
|
||||
}
|
||||
|
||||
#endif // ANDROID_HWUI_PROPERTIES_H
|
||||
|
||||
@@ -62,6 +62,8 @@ void TextureCache::init() {
|
||||
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize);
|
||||
LOGD(" Maximum texture dimension is %d pixels", mMaxTextureSize);
|
||||
|
||||
mDebugEnabled = readDebugLevel() & kDebugCaches;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -96,6 +98,9 @@ void TextureCache::operator()(SkBitmap*& bitmap, Texture*& texture) {
|
||||
mSize -= texture->bitmapSize;
|
||||
TEXTURE_LOGD("TextureCache::callback: name, removed size, mSize = %d, %d, %d",
|
||||
texture->id, texture->bitmapSize, mSize);
|
||||
if (mDebugEnabled) {
|
||||
LOGD("Texture deleted, size = %d", texture->bitmapSize);
|
||||
}
|
||||
glDeleteTextures(1, &texture->id);
|
||||
delete texture;
|
||||
}
|
||||
@@ -135,6 +140,9 @@ Texture* TextureCache::get(SkBitmap* bitmap) {
|
||||
mSize += size;
|
||||
TEXTURE_LOGD("TextureCache::get: create texture(%p): name, size, mSize = %d, %d, %d",
|
||||
bitmap, texture->id, size, mSize);
|
||||
if (mDebugEnabled) {
|
||||
LOGD("Texture created, size = %d", size);
|
||||
}
|
||||
mCache.put(bitmap, texture);
|
||||
mLock.unlock();
|
||||
} else {
|
||||
|
||||
@@ -107,6 +107,8 @@ private:
|
||||
uint32_t mMaxSize;
|
||||
GLint mMaxTextureSize;
|
||||
|
||||
bool mDebugEnabled;
|
||||
|
||||
/**
|
||||
* Used to access mCache and mSize. All methods are accessed from a single
|
||||
* thread except for remove().
|
||||
|
||||
Reference in New Issue
Block a user