Revert GrTextureStripAtlas change due to performance concerns.
git-svn-id: http://skia.googlecode.com/svn/trunk@5103 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/effects/GrTextureStripAtlas.cpp b/src/gpu/effects/GrTextureStripAtlas.cpp
index 3f3b29d..1a8a93b 100644
--- a/src/gpu/effects/GrTextureStripAtlas.cpp
+++ b/src/gpu/effects/GrTextureStripAtlas.cpp
@@ -34,8 +34,14 @@
GrTextureStripAtlas* fAtlas;
};
+// Ugly way of ensuring that we clean up the atlases on exit
+struct AtlasEntries {
+ ~AtlasEntries() { fEntries.deleteAll(); }
+ SkTDArray<AtlasEntry*> fEntries;
+};
+
GrTextureStripAtlas* GrTextureStripAtlas::GetAtlas(const GrTextureStripAtlas::Desc& desc) {
- static SkTDArray<AtlasEntry> gAtlasEntries;
+ static AtlasEntries gAtlasEntries;
static GrTHashTable<AtlasEntry, AtlasHashKey, 8> gAtlasCache;
AtlasHashKey key;
key.setKeyData(desc.asKey());
@@ -43,7 +49,8 @@
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 @@
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 @@
// 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<int>(row - fRows);