diff options
| author | 2013-06-12 00:23:27 +0000 | |
|---|---|---|
| committer | 2013-06-12 00:23:27 +0000 | |
| commit | 1e4795ab64755bdae48fe7b8cd78f204c9022791 (patch) | |
| tree | d5a5dc28396667854f0bfc5719844a9c18b716af /libs/hwui/PatchCache.cpp | |
| parent | fc74f85f2e54ee561888dfef57cd70cb6ab6f2d1 (diff) | |
| parent | 4c2547fa9244e78115cde0a259291053108c3dc7 (diff) | |
Merge "Avoid 9patch cache lookups when possible"
Diffstat (limited to 'libs/hwui/PatchCache.cpp')
| -rw-r--r-- | libs/hwui/PatchCache.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/libs/hwui/PatchCache.cpp b/libs/hwui/PatchCache.cpp index c6ed275e3cae..c23e99155a11 100644 --- a/libs/hwui/PatchCache.cpp +++ b/libs/hwui/PatchCache.cpp @@ -30,7 +30,9 @@ namespace uirenderer { // Constructors/destructor /////////////////////////////////////////////////////////////////////////////// -PatchCache::PatchCache(): mCache(LruCache<PatchDescription, Patch*>::kUnlimitedCapacity) { +PatchCache::PatchCache(): + mSize(0), mCache(LruCache<PatchDescription, Patch*>::kUnlimitedCapacity), + mMeshBuffer(0), mGenerationId(0) { char property[PROPERTY_VALUE_MAX]; if (property_get(PROPERTY_PATCH_CACHE_SIZE, property, NULL) > 0) { INIT_LOGD(" Setting patch cache size to %skB", property); @@ -39,8 +41,6 @@ PatchCache::PatchCache(): mCache(LruCache<PatchDescription, Patch*>::kUnlimitedC INIT_LOGD(" Using default patch cache size of %.2fkB", DEFAULT_PATCH_CACHE_SIZE); mMaxSize = KB(DEFAULT_PATCH_CACHE_SIZE); } - mSize = 0; - mMeshBuffer = 0; } PatchCache::~PatchCache() { @@ -58,7 +58,7 @@ void PatchCache::init(Caches& caches) { caches.resetVertexPointers(); if (created) { - glBufferData(GL_ARRAY_BUFFER, mMaxSize, NULL, GL_DYNAMIC_DRAW); + createVertexBuffer(); } } @@ -99,6 +99,12 @@ void PatchCache::clearCache() { mCache.clear(); } +void PatchCache::createVertexBuffer() { + glBufferData(GL_ARRAY_BUFFER, mMaxSize, NULL, GL_DYNAMIC_DRAW); + mSize = 0; + mGenerationId++; +} + const Patch* PatchCache::get(const AssetAtlas::Entry* entry, const uint32_t bitmapWidth, const uint32_t bitmapHeight, const float pixelWidth, const float pixelHeight, const Res_png_9patch* patch) { @@ -127,8 +133,7 @@ const Patch* PatchCache::get(const AssetAtlas::Entry* entry, uint32_t size = newMesh->getSize(); if (mSize + size > mMaxSize) { clearCache(); - glBufferData(GL_ARRAY_BUFFER, mMaxSize, NULL, GL_DYNAMIC_DRAW); - mSize = 0; + createVertexBuffer(); } newMesh->offset = (GLintptr) mSize; |