OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 "GrAtlas.h" | 8 #include "GrAtlas.h" |
9 #include "GrGpu.h" | 9 #include "GrGpu.h" |
10 #include "GrRectanizer.h" | 10 #include "GrRectanizer.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 fCache.deleteAll(); | 34 fCache.deleteAll(); |
35 for (int i = 0; i < kMaskFormatCount; ++i) { | 35 for (int i = 0; i < kMaskFormatCount; ++i) { |
36 delete fAtlasMgr[i]; | 36 delete fAtlasMgr[i]; |
37 } | 37 } |
38 fGpu->unref(); | 38 fGpu->unref(); |
39 #if FONT_CACHE_STATS | 39 #if FONT_CACHE_STATS |
40 GrPrintf("Num purges: %d\n", g_PurgeCount); | 40 GrPrintf("Num purges: %d\n", g_PurgeCount); |
41 #endif | 41 #endif |
42 } | 42 } |
43 | 43 |
| 44 static GrPixelConfig mask_format_to_pixel_config(GrMaskFormat format) { |
| 45 switch (format) { |
| 46 case kA8_GrMaskFormat: |
| 47 return kAlpha_8_GrPixelConfig; |
| 48 case kA565_GrMaskFormat: |
| 49 return kRGB_565_GrPixelConfig; |
| 50 case kA888_GrMaskFormat: |
| 51 return kSkia8888_GrPixelConfig; |
| 52 default: |
| 53 SkDEBUGFAIL("unknown maskformat"); |
| 54 } |
| 55 return kUnknown_GrPixelConfig; |
| 56 } |
| 57 |
44 GrTextStrike* GrFontCache::generateStrike(GrFontScaler* scaler, | 58 GrTextStrike* GrFontCache::generateStrike(GrFontScaler* scaler, |
45 const Key& key) { | 59 const Key& key) { |
46 GrMaskFormat format = scaler->getMaskFormat(); | 60 GrMaskFormat format = scaler->getMaskFormat(); |
| 61 GrPixelConfig config = mask_format_to_pixel_config(format); |
47 if (NULL == fAtlasMgr[format]) { | 62 if (NULL == fAtlasMgr[format]) { |
48 fAtlasMgr[format] = SkNEW_ARGS(GrAtlasMgr, (fGpu, format)); | 63 fAtlasMgr[format] = SkNEW_ARGS(GrAtlasMgr, (fGpu, config)); |
49 } | 64 } |
50 GrTextStrike* strike = SkNEW_ARGS(GrTextStrike, | 65 GrTextStrike* strike = SkNEW_ARGS(GrTextStrike, |
51 (this, scaler->getKey(), | 66 (this, scaler->getKey(), format, fAtlasMgr
[format])); |
52 scaler->getMaskFormat(), fAtlasMgr[format
])); | |
53 fCache.insert(key, strike); | 67 fCache.insert(key, strike); |
54 | 68 |
55 if (fHead) { | 69 if (fHead) { |
56 fHead->fPrev = strike; | 70 fHead->fPrev = strike; |
57 } else { | 71 } else { |
58 SkASSERT(NULL == fTail); | 72 SkASSERT(NULL == fTail); |
59 fTail = strike; | 73 fTail = strike; |
60 } | 74 } |
61 strike->fPrev = NULL; | 75 strike->fPrev = NULL; |
62 strike->fNext = fHead; | 76 strike->fNext = fHead; |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 glyph->height(), storage.get(), | 272 glyph->height(), storage.get(), |
259 &glyph->fAtlasLocation); | 273 &glyph->fAtlasLocation); |
260 if (NULL == atlas) { | 274 if (NULL == atlas) { |
261 return false; | 275 return false; |
262 } | 276 } |
263 | 277 |
264 glyph->fAtlas = atlas; | 278 glyph->fAtlas = atlas; |
265 atlas->setDrawToken(currentDrawToken); | 279 atlas->setDrawToken(currentDrawToken); |
266 return true; | 280 return true; |
267 } | 281 } |
OLD | NEW |