OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "GrTemplates.h" | 10 #include "GrTemplates.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 52 |
53 GrFontScaler::GrFontScaler(SkGlyphCache* strike) { | 53 GrFontScaler::GrFontScaler(SkGlyphCache* strike) { |
54 fStrike = strike; | 54 fStrike = strike; |
55 fKey = NULL; | 55 fKey = NULL; |
56 } | 56 } |
57 | 57 |
58 GrFontScaler::~GrFontScaler() { | 58 GrFontScaler::~GrFontScaler() { |
59 SkSafeUnref(fKey); | 59 SkSafeUnref(fKey); |
60 } | 60 } |
61 | 61 |
62 GrMaskFormat GrFontScaler::getMaskFormat() const { | 62 GrMaskFormat GrFontScaler::getMaskFormat() { |
63 SkMask::Format format = fStrike->getMaskFormat(); | 63 SkMask::Format format = fStrike->getMaskFormat(); |
64 switch (format) { | 64 switch (format) { |
65 case SkMask::kBW_Format: | 65 case SkMask::kBW_Format: |
66 // fall through to kA8 -- we store BW glyphs in our 8-bit cache | 66 // fall through to kA8 -- we store BW glyphs in our 8-bit cache |
67 case SkMask::kA8_Format: | 67 case SkMask::kA8_Format: |
68 return kA8_GrMaskFormat; | 68 return kA8_GrMaskFormat; |
69 case SkMask::kLCD16_Format: | 69 case SkMask::kLCD16_Format: |
70 return kA565_GrMaskFormat; | 70 return kA565_GrMaskFormat; |
71 case SkMask::kLCD32_Format: | 71 case SkMask::kLCD32_Format: |
72 return kA888_GrMaskFormat; | 72 return kA888_GrMaskFormat; |
73 case SkMask::kARGB32_Format: | 73 case SkMask::kARGB32_Format: |
74 return kARGB_GrMaskFormat; | 74 return kARGB_GrMaskFormat; |
75 default: | 75 default: |
76 SkDEBUGFAIL("unsupported SkMask::Format"); | 76 SkDEBUGFAIL("unsupported SkMask::Format"); |
77 return kA8_GrMaskFormat; | 77 return kA8_GrMaskFormat; |
78 } | 78 } |
79 } | 79 } |
80 | 80 |
81 const GrFontDescKey* GrFontScaler::getKey() { | 81 const GrFontDescKey* GrFontScaler::getKey() { |
82 if (NULL == fKey) { | 82 if (NULL == fKey) { |
83 fKey = SkNEW_ARGS(GrFontDescKey, (fStrike->getDescriptor())); | 83 fKey = SkNEW_ARGS(GrFontDescKey, (fStrike->getDescriptor())); |
84 } | 84 } |
85 return fKey; | 85 return fKey; |
86 } | 86 } |
87 | 87 |
88 GrMaskFormat GrFontScaler::getPackedGlyphMaskFormat(GrGlyph::PackedID packed) co
nst { | |
89 const SkGlyph& glyph = fStrike->getGlyphIDMetrics(GrGlyph::UnpackID(packed), | |
90 GrGlyph::UnpackFixedX(pack
ed), | |
91 GrGlyph::UnpackFixedY(pack
ed)); | |
92 SkMask::Format format = static_cast<SkMask::Format>(glyph.fMaskFormat); | |
93 switch (format) { | |
94 case SkMask::kBW_Format: | |
95 // fall through to kA8 -- we store BW glyphs in our 8-bit cache | |
96 case SkMask::kA8_Format: | |
97 return kA8_GrMaskFormat; | |
98 case SkMask::kLCD16_Format: | |
99 return kA565_GrMaskFormat; | |
100 case SkMask::kLCD32_Format: | |
101 return kA888_GrMaskFormat; | |
102 case SkMask::kARGB32_Format: | |
103 return kARGB_GrMaskFormat; | |
104 default: | |
105 SkDEBUGFAIL("unsupported SkMask::Format"); | |
106 return kA8_GrMaskFormat; | |
107 } | |
108 } | |
109 | |
110 bool GrFontScaler::getPackedGlyphBounds(GrGlyph::PackedID packed, SkIRect* bound
s) { | 88 bool GrFontScaler::getPackedGlyphBounds(GrGlyph::PackedID packed, SkIRect* bound
s) { |
111 const SkGlyph& glyph = fStrike->getGlyphIDMetrics(GrGlyph::UnpackID(packed), | 89 const SkGlyph& glyph = fStrike->getGlyphIDMetrics(GrGlyph::UnpackID(packed), |
112 GrGlyph::UnpackFixedX(pack
ed), | 90 GrGlyph::UnpackFixedX(pack
ed), |
113 GrGlyph::UnpackFixedY(pack
ed)); | 91 GrGlyph::UnpackFixedY(pack
ed)); |
114 bounds->setXYWH(glyph.fLeft, glyph.fTop, glyph.fWidth, glyph.fHeight); | 92 bounds->setXYWH(glyph.fLeft, glyph.fTop, glyph.fWidth, glyph.fHeight); |
115 | 93 |
116 return true; | 94 return true; |
117 } | 95 } |
118 | 96 |
119 bool GrFontScaler::getPackedGlyphDFBounds(GrGlyph::PackedID packed, SkIRect* bou
nds) { | 97 bool GrFontScaler::getPackedGlyphDFBounds(GrGlyph::PackedID packed, SkIRect* bou
nds) { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 bool GrFontScaler::getGlyphPath(uint16_t glyphID, SkPath* path) { | 204 bool GrFontScaler::getGlyphPath(uint16_t glyphID, SkPath* path) { |
227 | 205 |
228 const SkGlyph& glyph = fStrike->getGlyphIDMetrics(glyphID); | 206 const SkGlyph& glyph = fStrike->getGlyphIDMetrics(glyphID); |
229 const SkPath* skPath = fStrike->findPath(glyph); | 207 const SkPath* skPath = fStrike->findPath(glyph); |
230 if (skPath) { | 208 if (skPath) { |
231 *path = *skPath; | 209 *path = *skPath; |
232 return true; | 210 return true; |
233 } | 211 } |
234 return false; | 212 return false; |
235 } | 213 } |
OLD | NEW |