diff options
author | 2012-08-14 21:06:15 +0000 | |
---|---|---|
committer | 2012-08-14 21:06:15 +0000 | |
commit | 50b2bcf321d0a6657679c26cfcf703b746cf0660 (patch) | |
tree | e807c3e2c0f8feb6021a75aaa1f7cf8405de0547 /src/gpu | |
parent | 5224d7532da041ef1eee14274fd9f893d247b292 (diff) |
Made gradient effects use GrTextureStripAtlas.
Review URL: https://codereview.appspot.com/6450131
git-svn-id: http://skia.googlecode.com/svn/trunk@5101 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/effects/GrTextureStripAtlas.cpp | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/gpu/effects/GrTextureStripAtlas.cpp b/src/gpu/effects/GrTextureStripAtlas.cpp index 1a8a93b90a..3f3b29d7d0 100644 --- a/src/gpu/effects/GrTextureStripAtlas.cpp +++ b/src/gpu/effects/GrTextureStripAtlas.cpp @@ -34,14 +34,8 @@ 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 AtlasEntries gAtlasEntries; + static SkTDArray<AtlasEntry> gAtlasEntries; static GrTHashTable<AtlasEntry, AtlasHashKey, 8> gAtlasCache; AtlasHashKey key; key.setKeyData(desc.asKey()); @@ -49,8 +43,7 @@ GrTextureStripAtlas* GrTextureStripAtlas::GetAtlas(const GrTextureStripAtlas::De if (NULL != entry) { return entry->fAtlas; } else { - entry = SkNEW(AtlasEntry); - gAtlasEntries.fEntries.push(entry); + entry = gAtlasEntries.push(); entry->fAtlas = SkNEW_ARGS(GrTextureStripAtlas, (desc)); entry->fKey = key; gAtlasCache.insert(key, entry); @@ -115,8 +108,6 @@ 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. @@ -125,13 +116,15 @@ 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); |