diff options
author | 2010-08-23 21:05:08 -0700 | |
---|---|---|
committer | 2010-08-24 17:18:14 -0700 | |
commit | fb8b763f762ae21923c58d64caa729b012f40e05 (patch) | |
tree | 013792d41f32bff4dd35e6d53eebac711c513729 /libs/hwui/TextureCache.cpp | |
parent | a1f1174b396cda7bdff469a2e974a737600c5eb0 (diff) |
Use only one GL context per process, share chaches.
Change-Id: Ieabaa25338d2f4b8d4fd90e7401ad6e7452eae11
Diffstat (limited to 'libs/hwui/TextureCache.cpp')
-rw-r--r-- | libs/hwui/TextureCache.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/libs/hwui/TextureCache.cpp b/libs/hwui/TextureCache.cpp index 2e8a8be3cf86..753c5446b5bc 100644 --- a/libs/hwui/TextureCache.cpp +++ b/libs/hwui/TextureCache.cpp @@ -19,6 +19,7 @@ #include <GLES2/gl2.h> #include "TextureCache.h" +#include "Properties.h" namespace android { namespace uirenderer { @@ -27,19 +28,37 @@ namespace uirenderer { // Constructors/destructor /////////////////////////////////////////////////////////////////////////////// +TextureCache::TextureCache(): + mCache(GenerationCache<SkBitmap*, Texture*>::kUnlimitedCapacity), + mSize(0), mMaxSize(MB(DEFAULT_TEXTURE_CACHE_SIZE)) { + char property[PROPERTY_VALUE_MAX]; + if (property_get(PROPERTY_TEXTURE_CACHE_SIZE, property, NULL) > 0) { + LOGD(" Setting texture cache size to %sMB", property); + setMaxSize(MB(atof(property))); + } else { + LOGD(" Using default texture cache size of %.2fMB", DEFAULT_TEXTURE_CACHE_SIZE); + } + + init(); +} + TextureCache::TextureCache(uint32_t maxByteSize): mCache(GenerationCache<SkBitmap*, Texture*>::kUnlimitedCapacity), mSize(0), mMaxSize(maxByteSize) { - mCache.setOnEntryRemovedListener(this); - - glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize); - LOGD("Maximum texture dimension is %d pixels", mMaxTextureSize); + init(); } TextureCache::~TextureCache() { mCache.clear(); } +void TextureCache::init() { + mCache.setOnEntryRemovedListener(this); + + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize); + LOGD(" Maximum texture dimension is %d pixels", mMaxTextureSize); +} + /////////////////////////////////////////////////////////////////////////////// // Size management /////////////////////////////////////////////////////////////////////////////// |