From 9a92714d1344fd66c174d09cd080c89ed35d56ea Mon Sep 17 00:00:00 2001 From: "rileya@google.com" Date: Tue, 14 Aug 2012 21:33:15 +0000 Subject: Revert GrTextureStripAtlas change due to performance concerns. git-svn-id: http://skia.googlecode.com/svn/trunk@5103 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/gpu/effects/GrTextureStripAtlas.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/gpu') diff --git a/src/gpu/effects/GrTextureStripAtlas.cpp b/src/gpu/effects/GrTextureStripAtlas.cpp index 3f3b29d7d0..1a8a93b90a 100644 --- a/src/gpu/effects/GrTextureStripAtlas.cpp +++ b/src/gpu/effects/GrTextureStripAtlas.cpp @@ -34,8 +34,14 @@ public: GrTextureStripAtlas* fAtlas; }; +// Ugly way of ensuring that we clean up the atlases on exit +struct AtlasEntries { + ~AtlasEntries() { fEntries.deleteAll(); } + SkTDArray fEntries; +}; + GrTextureStripAtlas* GrTextureStripAtlas::GetAtlas(const GrTextureStripAtlas::Desc& desc) { - static SkTDArray gAtlasEntries; + static AtlasEntries gAtlasEntries; static GrTHashTable gAtlasCache; AtlasHashKey key; key.setKeyData(desc.asKey()); @@ -43,7 +49,8 @@ GrTextureStripAtlas* GrTextureStripAtlas::GetAtlas(const GrTextureStripAtlas::De if (NULL != entry) { return entry->fAtlas; } else { - entry = gAtlasEntries.push(); + entry = SkNEW(AtlasEntry); + gAtlasEntries.fEntries.push(entry); entry->fAtlas = SkNEW_ARGS(GrTextureStripAtlas, (desc)); entry->fKey = key; gAtlasCache.insert(key, entry); @@ -108,6 +115,8 @@ int GrTextureStripAtlas::lockRow(const SkBitmap& data) { this->removeFromLRU(row); uint32_t oldKey = row->fKey; + row->fKey = key; + row->fLocks = 1; // If we are writing into a row that already held bitmap data, we need to remove the // reference to that genID which is stored in our sorted table of key values. @@ -116,15 +125,13 @@ int GrTextureStripAtlas::lockRow(const SkBitmap& data) { // Find the entry in the list; if it's before the index where we plan on adding the new // entry, we decrement since it will shift elements ahead of it back by one. int oldIndex = this->searchByKey(oldKey); - if (oldIndex < index) { + if (oldIndex <= index) { --index; } fKeyTable.remove(oldIndex); } - row->fKey = key; - row->fLocks = 1; fKeyTable.insert(index, 1, &row); rowNumber = static_cast(row - fRows); -- cgit v1.2.3