aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrFontScaler.cpp
diff options
context:
space:
mode:
authorGravatar jvanverth <jvanverth@google.com>2015-01-07 10:12:16 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-01-07 10:12:16 -0800
commita27b82ddf0fad959371a4ab1fba931826edb2f54 (patch)
tree126562d38bd42ba438aa9c6f835d8c77ff5e2a1f /src/gpu/GrFontScaler.cpp
parent690fc594f11a987ba0e885a7eb01aff363395f12 (diff)
Remove distance field generation and storage from SkGlyphCache.
Diffstat (limited to 'src/gpu/GrFontScaler.cpp')
-rw-r--r--src/gpu/GrFontScaler.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/gpu/GrFontScaler.cpp b/src/gpu/GrFontScaler.cpp
index 0f85b83e16..ed1970e262 100644
--- a/src/gpu/GrFontScaler.cpp
+++ b/src/gpu/GrFontScaler.cpp
@@ -196,19 +196,35 @@ bool GrFontScaler::getPackedGlyphImage(GrGlyph::PackedID packed,
}
bool GrFontScaler::getPackedGlyphDFImage(GrGlyph::PackedID packed,
- int width, int height,
- void* dst) {
+ int width, int height,
+ void* dst) {
const SkGlyph& glyph = fStrike->getGlyphIDMetrics(GrGlyph::UnpackID(packed),
GrGlyph::UnpackFixedX(packed),
GrGlyph::UnpackFixedY(packed));
SkASSERT(glyph.fWidth + 2*SK_DistanceFieldPad == width);
SkASSERT(glyph.fHeight + 2*SK_DistanceFieldPad == height);
- const void* src = fStrike->findDistanceField(glyph);
- if (NULL == src) {
+ const void* image = fStrike->findImage(glyph);
+ if (NULL == image) {
+ return false;
+ }
+ // now generate the distance field
+ SkASSERT(dst);
+ SkMask::Format maskFormat = static_cast<SkMask::Format>(glyph.fMaskFormat);
+ if (SkMask::kA8_Format == maskFormat) {
+ // make the distance field from the image
+ SkGenerateDistanceFieldFromA8Image((unsigned char*)dst,
+ (unsigned char*)image,
+ glyph.fWidth, glyph.fHeight,
+ glyph.rowBytes());
+ } else if (SkMask::kBW_Format == maskFormat) {
+ // make the distance field from the image
+ SkGenerateDistanceFieldFromBWImage((unsigned char*)dst,
+ (unsigned char*)image,
+ glyph.fWidth, glyph.fHeight,
+ glyph.rowBytes());
+ } else {
return false;
}
-
- memcpy(dst, src, width * height);
return true;
}