| 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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 for (int y = 0; y < height; y++) { | 189 for (int y = 0; y < height; y++) { |
| 190 memcpy(dst, src, width * bbp); | 190 memcpy(dst, src, width * bbp); |
| 191 src = (const char*)src + srcRB; | 191 src = (const char*)src + srcRB; |
| 192 dst = (char*)dst + dstRB; | 192 dst = (char*)dst + dstRB; |
| 193 } | 193 } |
| 194 } | 194 } |
| 195 return true; | 195 return true; |
| 196 } | 196 } |
| 197 | 197 |
| 198 bool GrFontScaler::getPackedGlyphDFImage(GrGlyph::PackedID packed, | 198 bool GrFontScaler::getPackedGlyphDFImage(GrGlyph::PackedID packed, |
| 199 int width, int height, | 199 int width, int height, |
| 200 void* dst) { | 200 void* dst) { |
| 201 const SkGlyph& glyph = fStrike->getGlyphIDMetrics(GrGlyph::UnpackID(packed), | 201 const SkGlyph& glyph = fStrike->getGlyphIDMetrics(GrGlyph::UnpackID(packed), |
| 202 GrGlyph::UnpackFixedX(pack
ed), | 202 GrGlyph::UnpackFixedX(pack
ed), |
| 203 GrGlyph::UnpackFixedY(pack
ed)); | 203 GrGlyph::UnpackFixedY(pack
ed)); |
| 204 SkASSERT(glyph.fWidth + 2*SK_DistanceFieldPad == width); | 204 SkASSERT(glyph.fWidth + 2*SK_DistanceFieldPad == width); |
| 205 SkASSERT(glyph.fHeight + 2*SK_DistanceFieldPad == height); | 205 SkASSERT(glyph.fHeight + 2*SK_DistanceFieldPad == height); |
| 206 const void* src = fStrike->findDistanceField(glyph); | 206 const void* image = fStrike->findImage(glyph); |
| 207 if (NULL == src) { | 207 if (NULL == image) { |
| 208 return false; |
| 209 } |
| 210 // now generate the distance field |
| 211 SkASSERT(dst); |
| 212 SkMask::Format maskFormat = static_cast<SkMask::Format>(glyph.fMaskFormat); |
| 213 if (SkMask::kA8_Format == maskFormat) { |
| 214 // make the distance field from the image |
| 215 SkGenerateDistanceFieldFromA8Image((unsigned char*)dst, |
| 216 (unsigned char*)image, |
| 217 glyph.fWidth, glyph.fHeight, |
| 218 glyph.rowBytes()); |
| 219 } else if (SkMask::kBW_Format == maskFormat) { |
| 220 // make the distance field from the image |
| 221 SkGenerateDistanceFieldFromBWImage((unsigned char*)dst, |
| 222 (unsigned char*)image, |
| 223 glyph.fWidth, glyph.fHeight, |
| 224 glyph.rowBytes()); |
| 225 } else { |
| 208 return false; | 226 return false; |
| 209 } | 227 } |
| 210 | 228 |
| 211 memcpy(dst, src, width * height); | |
| 212 | |
| 213 return true; | 229 return true; |
| 214 } | 230 } |
| 215 | 231 |
| 216 // we should just return const SkPath* (NULL means false) | 232 // we should just return const SkPath* (NULL means false) |
| 217 bool GrFontScaler::getGlyphPath(uint16_t glyphID, SkPath* path) { | 233 bool GrFontScaler::getGlyphPath(uint16_t glyphID, SkPath* path) { |
| 218 | 234 |
| 219 const SkGlyph& glyph = fStrike->getGlyphIDMetrics(glyphID); | 235 const SkGlyph& glyph = fStrike->getGlyphIDMetrics(glyphID); |
| 220 const SkPath* skPath = fStrike->findPath(glyph); | 236 const SkPath* skPath = fStrike->findPath(glyph); |
| 221 if (skPath) { | 237 if (skPath) { |
| 222 *path = *skPath; | 238 *path = *skPath; |
| 223 return true; | 239 return true; |
| 224 } | 240 } |
| 225 return false; | 241 return false; |
| 226 } | 242 } |
| OLD | NEW |