Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(851)

Unified Diff: src/ports/SkFontHost_FreeType.cpp

Issue 1737693006: Change type of SkGlyph::fAdvance[XY] to float. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Should be float, not SkScalar. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pdf/SkPDFFont.cpp ('k') | src/ports/SkFontHost_mac.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontHost_FreeType.cpp
diff --git a/src/ports/SkFontHost_FreeType.cpp b/src/ports/SkFontHost_FreeType.cpp
index e7cb6d2963684370a7569f1c3c18a7c98d0e1d27..5c00d1b697194c33edb02cf9d2d6688ecc6bf9a2 100644
--- a/src/ports/SkFontHost_FreeType.cpp
+++ b/src/ports/SkFontHost_FreeType.cpp
@@ -1006,6 +1006,10 @@ SkUnichar SkScalerContext_FreeType::generateGlyphToChar(uint16_t glyph) {
return 0;
}
+static SkScalar SkFT_FixedToScalar(FT_Fixed x) {
+ return SkFixedToScalar(x);
+}
+
void SkScalerContext_FreeType::generateAdvance(SkGlyph* glyph) {
/* unhinted and light hinted text have linearly scaled advances
* which are very cheap to compute with some font formats...
@@ -1027,8 +1031,9 @@ void SkScalerContext_FreeType::generateAdvance(SkGlyph* glyph) {
if (0 == error) {
glyph->fRsbDelta = 0;
glyph->fLsbDelta = 0;
- glyph->fAdvanceX = SkFixedMul(fMatrix22.xx, advance);
- glyph->fAdvanceY = - SkFixedMul(fMatrix22.yx, advance);
+ const SkScalar advanceScalar = SkFT_FixedToScalar(advance);
+ glyph->fAdvanceX = SkScalarToFloat(fMatrix22Scalar.getScaleX() * advanceScalar);
+ glyph->fAdvanceY = -SkScalarToFloat(fMatrix22Scalar.getSkewY() * advanceScalar);
return;
}
}
@@ -1108,9 +1113,9 @@ inline void scaleGlyphMetrics(SkGlyph& glyph, SkScalar scale) {
glyph.fTop *= scale;
glyph.fLeft *= scale;
- SkFixed fixedScale = SkScalarToFixed(scale);
- glyph.fAdvanceX = SkFixedMul(glyph.fAdvanceX, fixedScale);
- glyph.fAdvanceY = SkFixedMul(glyph.fAdvanceY, fixedScale);
+ float floatScale = SkScalarToFloat(scale);
+ glyph.fAdvanceX *= floatScale;
+ glyph.fAdvanceY *= floatScale;
}
void SkScalerContext_FreeType::generateMetrics(SkGlyph* glyph) {
@@ -1181,19 +1186,21 @@ void SkScalerContext_FreeType::generateMetrics(SkGlyph* glyph) {
if (fRec.fFlags & SkScalerContext::kVertical_Flag) {
if (fDoLinearMetrics) {
- glyph->fAdvanceX = -SkFixedMul(fMatrix22.xy, fFace->glyph->linearVertAdvance);
- glyph->fAdvanceY = SkFixedMul(fMatrix22.yy, fFace->glyph->linearVertAdvance);
+ const SkScalar advanceScalar = SkFT_FixedToScalar(fFace->glyph->linearVertAdvance);
+ glyph->fAdvanceX = -SkScalarToFloat(fMatrix22Scalar.getSkewX() * advanceScalar);
+ glyph->fAdvanceY = SkScalarToFloat(fMatrix22Scalar.getScaleY() * advanceScalar);
} else {
- glyph->fAdvanceX = -SkFDot6ToFixed(fFace->glyph->advance.x);
- glyph->fAdvanceY = SkFDot6ToFixed(fFace->glyph->advance.y);
+ glyph->fAdvanceX = -SkFDot6ToFloat(fFace->glyph->advance.x);
+ glyph->fAdvanceY = SkFDot6ToFloat(fFace->glyph->advance.y);
}
} else {
if (fDoLinearMetrics) {
- glyph->fAdvanceX = SkFixedMul(fMatrix22.xx, fFace->glyph->linearHoriAdvance);
- glyph->fAdvanceY = -SkFixedMul(fMatrix22.yx, fFace->glyph->linearHoriAdvance);
+ const SkScalar advanceScalar = SkFT_FixedToScalar(fFace->glyph->linearHoriAdvance);
+ glyph->fAdvanceX = SkScalarToFloat(fMatrix22Scalar.getScaleX() * advanceScalar);
+ glyph->fAdvanceY = -SkScalarToFloat(fMatrix22Scalar.getSkewY() * advanceScalar);
} else {
- glyph->fAdvanceX = SkFDot6ToFixed(fFace->glyph->advance.x);
- glyph->fAdvanceY = -SkFDot6ToFixed(fFace->glyph->advance.y);
+ glyph->fAdvanceX = SkFDot6ToFloat(fFace->glyph->advance.x);
+ glyph->fAdvanceY = -SkFDot6ToFloat(fFace->glyph->advance.y);
if (fRec.fFlags & kDevKernText_Flag) {
glyph->fRsbDelta = SkToS8(fFace->glyph->rsb_delta);
« no previous file with comments | « src/pdf/SkPDFFont.cpp ('k') | src/ports/SkFontHost_mac.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698