diff options
author | 2012-08-14 21:33:15 +0000 | |
---|---|---|
committer | 2012-08-14 21:33:15 +0000 | |
commit | 9a92714d1344fd66c174d09cd080c89ed35d56ea (patch) | |
tree | b361280593a1910be6175672439d6116e6b3f8d7 /src/gpu | |
parent | 9766ecd04f5829ff3d711bb32a687c65b4d68acc (diff) |
Revert GrTextureStripAtlas change due to performance concerns.
git-svn-id: http://skia.googlecode.com/svn/trunk@5103 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/effects/GrTextureStripAtlas.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
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<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 @@ 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<int>(row - fRows); |