| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "GrBatchFontCache.h" | 8 #include "GrBatchFontCache.h" |
| 9 #include "GrContext.h" | 9 #include "GrContext.h" |
| 10 #include "GrGpu.h" | 10 #include "GrGpu.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 } | 63 } |
| 64 | 64 |
| 65 GrBatchFontCache::~GrBatchFontCache() { | 65 GrBatchFontCache::~GrBatchFontCache() { |
| 66 SkTDynamicHash<GrBatchTextStrike, GrFontDescKey>::Iter iter(&fCache); | 66 SkTDynamicHash<GrBatchTextStrike, GrFontDescKey>::Iter iter(&fCache); |
| 67 while (!iter.done()) { | 67 while (!iter.done()) { |
| 68 (*iter).fIsAbandoned = true; | 68 (*iter).fIsAbandoned = true; |
| 69 (*iter).unref(); | 69 (*iter).unref(); |
| 70 ++iter; | 70 ++iter; |
| 71 } | 71 } |
| 72 for (int i = 0; i < kMaskFormatCount; ++i) { | 72 for (int i = 0; i < kMaskFormatCount; ++i) { |
| 73 SkDELETE(fAtlases[i]); | 73 delete fAtlases[i]; |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 void GrBatchFontCache::freeAll() { | 77 void GrBatchFontCache::freeAll() { |
| 78 SkTDynamicHash<GrBatchTextStrike, GrFontDescKey>::Iter iter(&fCache); | 78 SkTDynamicHash<GrBatchTextStrike, GrFontDescKey>::Iter iter(&fCache); |
| 79 while (!iter.done()) { | 79 while (!iter.done()) { |
| 80 (*iter).fIsAbandoned = true; | 80 (*iter).fIsAbandoned = true; |
| 81 (*iter).unref(); | 81 (*iter).unref(); |
| 82 ++iter; | 82 ++iter; |
| 83 } | 83 } |
| 84 fCache.rewind(); | 84 fCache.rewind(); |
| 85 for (int i = 0; i < kMaskFormatCount; ++i) { | 85 for (int i = 0; i < kMaskFormatCount; ++i) { |
| 86 SkDELETE(fAtlases[i]); | 86 delete fAtlases[i]; |
| 87 fAtlases[i] = NULL; | 87 fAtlases[i] = NULL; |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 | 90 |
| 91 void GrBatchFontCache::HandleEviction(GrBatchAtlas::AtlasID id, void* ptr) { | 91 void GrBatchFontCache::HandleEviction(GrBatchAtlas::AtlasID id, void* ptr) { |
| 92 GrBatchFontCache* fontCache = reinterpret_cast<GrBatchFontCache*>(ptr); | 92 GrBatchFontCache* fontCache = reinterpret_cast<GrBatchFontCache*>(ptr); |
| 93 | 93 |
| 94 SkTDynamicHash<GrBatchTextStrike, GrFontDescKey>::Iter iter(&fontCache->fCac
he); | 94 SkTDynamicHash<GrBatchTextStrike, GrFontDescKey>::Iter iter(&fontCache->fCac
he); |
| 95 for (; !iter.done(); ++iter) { | 95 for (; !iter.done(); ++iter) { |
| 96 GrBatchTextStrike* strike = &*iter; | 96 GrBatchTextStrike* strike = &*iter; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 ++gDumpCount; | 125 ++gDumpCount; |
| 126 } | 126 } |
| 127 | 127 |
| 128 void GrBatchFontCache::setAtlasSizes_ForTesting(const GrBatchAtlasConfig configs
[3]) { | 128 void GrBatchFontCache::setAtlasSizes_ForTesting(const GrBatchAtlasConfig configs
[3]) { |
| 129 // delete any old atlases, this should be safe to do as long as we are not i
n the middle of a | 129 // delete any old atlases, this should be safe to do as long as we are not i
n the middle of a |
| 130 // flush | 130 // flush |
| 131 for (int i = 0; i < kMaskFormatCount; i++) { | 131 for (int i = 0; i < kMaskFormatCount; i++) { |
| 132 if (fAtlases[i]) { | 132 if (fAtlases[i]) { |
| 133 SkDELETE(fAtlases[i]); | 133 delete fAtlases[i]; |
| 134 fAtlases[i] = NULL; | 134 fAtlases[i] = NULL; |
| 135 } | 135 } |
| 136 } | 136 } |
| 137 memcpy(fAtlasConfigs, configs, sizeof(fAtlasConfigs)); | 137 memcpy(fAtlasConfigs, configs, sizeof(fAtlasConfigs)); |
| 138 } | 138 } |
| 139 | 139 |
| 140 /////////////////////////////////////////////////////////////////////////////// | 140 /////////////////////////////////////////////////////////////////////////////// |
| 141 | 141 |
| 142 /* | 142 /* |
| 143 The text strike is specific to a given font/style/matrix setup, which is | 143 The text strike is specific to a given font/style/matrix setup, which is |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 | 225 |
| 226 bool success = fBatchFontCache->addToAtlas(this, &glyph->fID, target, expect
edMaskFormat, | 226 bool success = fBatchFontCache->addToAtlas(this, &glyph->fID, target, expect
edMaskFormat, |
| 227 glyph->width(), glyph->height(), | 227 glyph->width(), glyph->height(), |
| 228 storage.get(), &glyph->fAtlasLoca
tion); | 228 storage.get(), &glyph->fAtlasLoca
tion); |
| 229 if (success) { | 229 if (success) { |
| 230 SkASSERT(GrBatchAtlas::kInvalidAtlasID != glyph->fID); | 230 SkASSERT(GrBatchAtlas::kInvalidAtlasID != glyph->fID); |
| 231 fAtlasedGlyphs++; | 231 fAtlasedGlyphs++; |
| 232 } | 232 } |
| 233 return success; | 233 return success; |
| 234 } | 234 } |
| OLD | NEW |