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