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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 GrMaskFormat SkGrFontScaler::getMaskFormat() { | 79 GrMaskFormat SkGrFontScaler::getMaskFormat() { |
80 SkMask::Format format = fStrike->getMaskFormat(); | 80 SkMask::Format format = fStrike->getMaskFormat(); |
81 switch (format) { | 81 switch (format) { |
82 case SkMask::kBW_Format: | 82 case SkMask::kBW_Format: |
83 // fall through to kA8 -- we store BW glyphs in our 8-bit cache | 83 // fall through to kA8 -- we store BW glyphs in our 8-bit cache |
84 case SkMask::kA8_Format: | 84 case SkMask::kA8_Format: |
85 return kA8_GrMaskFormat; | 85 return kA8_GrMaskFormat; |
86 case SkMask::kLCD16_Format: | 86 case SkMask::kLCD16_Format: |
87 return kA565_GrMaskFormat; | 87 return kA565_GrMaskFormat; |
88 // TODO: properly support kARGB32_Format. | |
89 case SkMask::kARGB32_Format: | |
90 case SkMask::kLCD32_Format: | 88 case SkMask::kLCD32_Format: |
91 return kA888_GrMaskFormat; | 89 return kA888_GrMaskFormat; |
| 90 case SkMask::kARGB32_Format: |
| 91 return kARGB_GrMaskFormat; |
92 default: | 92 default: |
93 SkDEBUGFAIL("unsupported SkMask::Format"); | 93 SkDEBUGFAIL("unsupported SkMask::Format"); |
94 return kA8_GrMaskFormat; | 94 return kA8_GrMaskFormat; |
95 } | 95 } |
96 } | 96 } |
97 | 97 |
98 const GrKey* SkGrFontScaler::getKey() { | 98 const GrKey* SkGrFontScaler::getKey() { |
99 if (NULL == fKey) { | 99 if (NULL == fKey) { |
100 fKey = SkNEW_ARGS(SkGrDescKey, (fStrike->getDescriptor())); | 100 fKey = SkNEW_ARGS(SkGrDescKey, (fStrike->getDescriptor())); |
101 } | 101 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 case kA565_GrMaskFormat: { | 167 case kA565_GrMaskFormat: { |
168 uint16_t* rgb565 = reinterpret_cast<uint16_t*>(dst); | 168 uint16_t* rgb565 = reinterpret_cast<uint16_t*>(dst); |
169 expand_bits(rgb565, bits, width, height, dstRB, srcRB); | 169 expand_bits(rgb565, bits, width, height, dstRB, srcRB); |
170 break; | 170 break; |
171 } | 171 } |
172 case kA888_GrMaskFormat: { | 172 case kA888_GrMaskFormat: { |
173 uint32_t* rgba8888 = reinterpret_cast<uint32_t*>(dst); | 173 uint32_t* rgba8888 = reinterpret_cast<uint32_t*>(dst); |
174 expand_bits(rgba8888, bits, width, height, dstRB, srcRB); | 174 expand_bits(rgba8888, bits, width, height, dstRB, srcRB); |
175 break; | 175 break; |
176 } | 176 } |
177 default: | 177 default: |
178 GrCrash("Unknown GrMaskFormat"); | 178 GrCrash("Invalid GrMaskFormat"); |
179 } | 179 } |
180 } else if (srcRB == dstRB) { | 180 } else if (srcRB == dstRB) { |
181 memcpy(dst, src, dstRB * height); | 181 memcpy(dst, src, dstRB * height); |
182 } else { | 182 } else { |
183 const int bbp = GrMaskFormatBytesPerPixel(this->getMaskFormat()); | 183 const int bbp = GrMaskFormatBytesPerPixel(this->getMaskFormat()); |
184 for (int y = 0; y < height; y++) { | 184 for (int y = 0; y < height; y++) { |
185 memcpy(dst, src, width * bbp); | 185 memcpy(dst, src, width * bbp); |
186 src = (const char*)src + srcRB; | 186 src = (const char*)src + srcRB; |
187 dst = (char*)dst + dstRB; | 187 dst = (char*)dst + dstRB; |
188 } | 188 } |
189 } | 189 } |
190 return true; | 190 return true; |
191 } | 191 } |
192 | 192 |
193 // we should just return const SkPath* (NULL means false) | 193 // we should just return const SkPath* (NULL means false) |
194 bool SkGrFontScaler::getGlyphPath(uint16_t glyphID, SkPath* path) { | 194 bool SkGrFontScaler::getGlyphPath(uint16_t glyphID, SkPath* path) { |
195 | 195 |
196 const SkGlyph& glyph = fStrike->getGlyphIDMetrics(glyphID); | 196 const SkGlyph& glyph = fStrike->getGlyphIDMetrics(glyphID); |
197 const SkPath* skPath = fStrike->findPath(glyph); | 197 const SkPath* skPath = fStrike->findPath(glyph); |
198 if (skPath) { | 198 if (skPath) { |
199 *path = *skPath; | 199 *path = *skPath; |
200 return true; | 200 return true; |
201 } | 201 } |
202 return false; | 202 return false; |
203 } | 203 } |
OLD | NEW |