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

Unified Diff: src/ports/SkFontHost_win.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/ports/SkFontHost_mac.cpp ('k') | src/ports/SkScalerContext_win_dw.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontHost_win.cpp
diff --git a/src/ports/SkFontHost_win.cpp b/src/ports/SkFontHost_win.cpp
index 8aefd1431a525f6e4d2a34775f9b0895bee1d6de..f772d8c57e13b28faebe8ed7f4238001a2f7f271 100644
--- a/src/ports/SkFontHost_win.cpp
+++ b/src/ports/SkFontHost_win.cpp
@@ -584,6 +584,10 @@ static FIXED float2FIXED(float x) {
return SkFixedToFIXED(SkFloatToFixed(x));
}
+static inline float FIXED2float(FIXED x) {
+ return SkFixedToFloat(SkFIXEDToFixed(x));
+}
+
static BYTE compute_quality(const SkScalerContext::Rec& rec) {
switch (rec.fMaskFormat) {
case SkMask::kBW_Format:
@@ -856,7 +860,7 @@ void SkScalerContext_GDI::generateMetrics(SkGlyph* glyph) {
// Bitmap FON cannot underhang, but vector FON may.
// There appears no means of determining underhang of vector FON.
glyph->fLeft = SkToS16(0);
- glyph->fAdvanceX = SkIntToFixed(glyph->fWidth);
+ glyph->fAdvanceX = glyph->fWidth;
glyph->fAdvanceY = 0;
// Vector FON will transform nicely, but bitmap FON do not.
@@ -876,8 +880,8 @@ void SkScalerContext_GDI::generateMetrics(SkGlyph* glyph) {
}
// Apply matrix to advance.
- glyph->fAdvanceY = SkFixedMul(-SkFIXEDToFixed(fMat22.eM12), glyph->fAdvanceX);
- glyph->fAdvanceX = SkFixedMul(SkFIXEDToFixed(fMat22.eM11), glyph->fAdvanceX);
+ glyph->fAdvanceY = -FIXED2float(fMat22.eM12) * glyph->fAdvanceX;
+ glyph->fAdvanceX *= FIXED2float(fMat22.eM11);
return;
}
@@ -922,8 +926,9 @@ void SkScalerContext_GDI::generateMetrics(SkGlyph* glyph) {
glyph->fTop -= 2;
glyph->fLeft -= 2;
}
- glyph->fAdvanceX = SkIntToFixed(gm.gmCellIncX);
- glyph->fAdvanceY = SkIntToFixed(gm.gmCellIncY);
+ // TODO(benjaminwagner): What is the type of gm.gmCellInc[XY]?
+ glyph->fAdvanceX = (float)((int)gm.gmCellIncX);
+ glyph->fAdvanceY = (float)((int)gm.gmCellIncY);
glyph->fRsbDelta = 0;
glyph->fLsbDelta = 0;
@@ -933,16 +938,16 @@ void SkScalerContext_GDI::generateMetrics(SkGlyph* glyph) {
if (GDI_ERROR != status) {
SkPoint advance;
fHiResMatrix.mapXY(SkIntToScalar(gm.gmCellIncX), SkIntToScalar(gm.gmCellIncY), &advance);
- glyph->fAdvanceX = SkScalarToFixed(advance.fX);
- glyph->fAdvanceY = SkScalarToFixed(advance.fY);
+ glyph->fAdvanceX = SkScalarToFloat(advance.fX);
+ glyph->fAdvanceY = SkScalarToFloat(advance.fY);
}
} else if (!isAxisAligned(this->fRec)) {
status = GetGlyphOutlineW(fDDC, glyphId, GGO_METRICS | GGO_GLYPH_INDEX, &gm, 0, nullptr, &fGsA);
if (GDI_ERROR != status) {
SkPoint advance;
fG_inv.mapXY(SkIntToScalar(gm.gmCellIncX), SkIntToScalar(gm.gmCellIncY), &advance);
- glyph->fAdvanceX = SkScalarToFixed(advance.fX);
- glyph->fAdvanceY = SkScalarToFixed(advance.fY);
+ glyph->fAdvanceX = SkScalarToFloat(advance.fX);
+ glyph->fAdvanceY = SkScalarToFloat(advance.fY);
}
}
}
« no previous file with comments | « src/ports/SkFontHost_mac.cpp ('k') | src/ports/SkScalerContext_win_dw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698