| 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 30 matching lines...) Expand all Loading... |
| 41 GrBatchFontCache::GrBatchFontCache(GrContext* context) | 41 GrBatchFontCache::GrBatchFontCache(GrContext* context) |
| 42 : fContext(context) | 42 : fContext(context) |
| 43 , fPreserveStrike(nullptr) { | 43 , fPreserveStrike(nullptr) { |
| 44 for (int i = 0; i < kMaskFormatCount; ++i) { | 44 for (int i = 0; i < kMaskFormatCount; ++i) { |
| 45 fAtlases[i] = nullptr; | 45 fAtlases[i] = nullptr; |
| 46 } | 46 } |
| 47 | 47 |
| 48 // setup default atlas configs | 48 // setup default atlas configs |
| 49 fAtlasConfigs[kA8_GrMaskFormat].fWidth = 2048; | 49 fAtlasConfigs[kA8_GrMaskFormat].fWidth = 2048; |
| 50 fAtlasConfigs[kA8_GrMaskFormat].fHeight = 2048; | 50 fAtlasConfigs[kA8_GrMaskFormat].fHeight = 2048; |
| 51 fAtlasConfigs[kA8_GrMaskFormat].fLog2Width = 11; |
| 52 fAtlasConfigs[kA8_GrMaskFormat].fLog2Height = 11; |
| 51 fAtlasConfigs[kA8_GrMaskFormat].fPlotWidth = 512; | 53 fAtlasConfigs[kA8_GrMaskFormat].fPlotWidth = 512; |
| 52 fAtlasConfigs[kA8_GrMaskFormat].fPlotHeight = 256; | 54 fAtlasConfigs[kA8_GrMaskFormat].fPlotHeight = 256; |
| 53 | 55 |
| 54 fAtlasConfigs[kA565_GrMaskFormat].fWidth = 1024; | 56 fAtlasConfigs[kA565_GrMaskFormat].fWidth = 1024; |
| 55 fAtlasConfigs[kA565_GrMaskFormat].fHeight = 2048; | 57 fAtlasConfigs[kA565_GrMaskFormat].fHeight = 2048; |
| 58 fAtlasConfigs[kA565_GrMaskFormat].fLog2Width = 10; |
| 59 fAtlasConfigs[kA565_GrMaskFormat].fLog2Height = 11; |
| 56 fAtlasConfigs[kA565_GrMaskFormat].fPlotWidth = 256; | 60 fAtlasConfigs[kA565_GrMaskFormat].fPlotWidth = 256; |
| 57 fAtlasConfigs[kA565_GrMaskFormat].fPlotHeight = 256; | 61 fAtlasConfigs[kA565_GrMaskFormat].fPlotHeight = 256; |
| 58 | 62 |
| 59 fAtlasConfigs[kARGB_GrMaskFormat].fWidth = 1024; | 63 fAtlasConfigs[kARGB_GrMaskFormat].fWidth = 1024; |
| 60 fAtlasConfigs[kARGB_GrMaskFormat].fHeight = 2048; | 64 fAtlasConfigs[kARGB_GrMaskFormat].fHeight = 2048; |
| 65 fAtlasConfigs[kARGB_GrMaskFormat].fLog2Width = 10; |
| 66 fAtlasConfigs[kARGB_GrMaskFormat].fLog2Height = 11; |
| 61 fAtlasConfigs[kARGB_GrMaskFormat].fPlotWidth = 256; | 67 fAtlasConfigs[kARGB_GrMaskFormat].fPlotWidth = 256; |
| 62 fAtlasConfigs[kARGB_GrMaskFormat].fPlotHeight = 256; | 68 fAtlasConfigs[kARGB_GrMaskFormat].fPlotHeight = 256; |
| 63 } | 69 } |
| 64 | 70 |
| 65 GrBatchFontCache::~GrBatchFontCache() { | 71 GrBatchFontCache::~GrBatchFontCache() { |
| 66 SkTDynamicHash<GrBatchTextStrike, GrFontDescKey>::Iter iter(&fCache); | 72 SkTDynamicHash<GrBatchTextStrike, GrFontDescKey>::Iter iter(&fCache); |
| 67 while (!iter.done()) { | 73 while (!iter.done()) { |
| 68 (*iter).fIsAbandoned = true; | 74 (*iter).fIsAbandoned = true; |
| 69 (*iter).unref(); | 75 (*iter).unref(); |
| 70 ++iter; | 76 ++iter; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 233 |
| 228 bool success = fBatchFontCache->addToAtlas(this, &glyph->fID, target, expect
edMaskFormat, | 234 bool success = fBatchFontCache->addToAtlas(this, &glyph->fID, target, expect
edMaskFormat, |
| 229 glyph->width(), glyph->height(), | 235 glyph->width(), glyph->height(), |
| 230 storage.get(), &glyph->fAtlasLoca
tion); | 236 storage.get(), &glyph->fAtlasLoca
tion); |
| 231 if (success) { | 237 if (success) { |
| 232 SkASSERT(GrBatchAtlas::kInvalidAtlasID != glyph->fID); | 238 SkASSERT(GrBatchAtlas::kInvalidAtlasID != glyph->fID); |
| 233 fAtlasedGlyphs++; | 239 fAtlasedGlyphs++; |
| 234 } | 240 } |
| 235 return success; | 241 return success; |
| 236 } | 242 } |
| OLD | NEW |