aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu')
-rw-r--r--src/gpu/text/GrStencilAndCoverTextContext.cpp25
-rw-r--r--src/gpu/text/GrTextUtils.cpp26
2 files changed, 23 insertions, 28 deletions
diff --git a/src/gpu/text/GrStencilAndCoverTextContext.cpp b/src/gpu/text/GrStencilAndCoverTextContext.cpp
index 661f22512d..4c2a615a66 100644
--- a/src/gpu/text/GrStencilAndCoverTextContext.cpp
+++ b/src/gpu/text/GrStencilAndCoverTextContext.cpp
@@ -457,8 +457,8 @@ void GrStencilAndCoverTextContext::TextRun::setText(const char text[], size_t by
// Measure first if needed.
if (fFont.getTextAlign() != SkPaint::kLeft_Align) {
- SkFixed stopX = 0;
- SkFixed stopY = 0;
+ SkScalar stopX = 0;
+ SkScalar stopY = 0;
const char* textPtr = text;
while (textPtr < stop) {
@@ -466,13 +466,13 @@ void GrStencilAndCoverTextContext::TextRun::setText(const char text[], size_t by
// same advance.
const SkGlyph& glyph = glyphCacheProc(glyphCache, &textPtr);
- stopX += glyph.fAdvanceX;
- stopY += glyph.fAdvanceY;
+ stopX += SkFloatToScalar(glyph.fAdvanceX);
+ stopY += SkFloatToScalar(glyph.fAdvanceY);
}
SkASSERT(textPtr == stop);
- SkScalar alignX = SkFixedToScalar(stopX) * fTextRatio;
- SkScalar alignY = SkFixedToScalar(stopY) * fTextRatio;
+ SkScalar alignX = stopX * fTextRatio;
+ SkScalar alignY = stopY * fTextRatio;
if (fFont.getTextAlign() == SkPaint::kCenter_Align) {
alignX = SkScalarHalf(alignX);
@@ -485,21 +485,16 @@ void GrStencilAndCoverTextContext::TextRun::setText(const char text[], size_t by
SkAutoKern autokern;
- SkFixed fixedSizeRatio = SkScalarToFixed(fTextRatio);
-
- SkFixed fx = SkScalarToFixed(x);
- SkFixed fy = SkScalarToFixed(y);
FallbackBlobBuilder fallback;
while (text < stop) {
const SkGlyph& glyph = glyphCacheProc(glyphCache, &text);
- fx += SkFixedMul(autokern.adjust(glyph), fixedSizeRatio);
+ x += autokern.adjust(glyph) * fTextRatio;
if (glyph.fWidth) {
- this->appendGlyph(glyph, SkPoint::Make(SkFixedToScalar(fx), SkFixedToScalar(fy)),
- &fallback);
+ this->appendGlyph(glyph, SkPoint::Make(x, y), &fallback);
}
- fx += SkFixedMul(glyph.fAdvanceX, fixedSizeRatio);
- fy += SkFixedMul(glyph.fAdvanceY, fixedSizeRatio);
+ x += SkFloatToScalar(glyph.fAdvanceX) * fTextRatio;
+ y += SkFloatToScalar(glyph.fAdvanceY) * fTextRatio;
}
fFallbackTextBlob.reset(fallback.buildIfNeeded(&fFallbackGlyphCount));
diff --git a/src/gpu/text/GrTextUtils.cpp b/src/gpu/text/GrTextUtils.cpp
index edf813dcc0..0b26c84168 100644
--- a/src/gpu/text/GrTextUtils.cpp
+++ b/src/gpu/text/GrTextUtils.cpp
@@ -267,12 +267,12 @@ void GrTextUtils::DrawDFText(GrAtlasTextBlob* blob, int runIndex,
SkTArray<SkScalar> positions;
const char* textPtr = text;
- SkFixed stopX = 0;
- SkFixed stopY = 0;
- SkFixed origin = 0;
+ SkScalar stopX = 0;
+ SkScalar stopY = 0;
+ SkScalar origin = 0;
switch (skPaint.getTextAlign()) {
- case SkPaint::kRight_Align: origin = SK_Fixed1; break;
- case SkPaint::kCenter_Align: origin = SK_FixedHalf; break;
+ case SkPaint::kRight_Align: origin = SK_Scalar1; break;
+ case SkPaint::kCenter_Align: origin = SK_ScalarHalf; break;
case SkPaint::kLeft_Align: origin = 0; break;
}
@@ -283,11 +283,11 @@ void GrTextUtils::DrawDFText(GrAtlasTextBlob* blob, int runIndex,
// same advance
const SkGlyph& glyph = glyphCacheProc(origPaintCache, &textPtr);
- SkFixed width = glyph.fAdvanceX + autokern.adjust(glyph);
- positions.push_back(SkFixedToScalar(stopX + SkFixedMul(origin, width)));
+ SkScalar width = SkFloatToScalar(glyph.fAdvanceX) + autokern.adjust(glyph);
+ positions.push_back(stopX + origin * width);
- SkFixed height = glyph.fAdvanceY;
- positions.push_back(SkFixedToScalar(stopY + SkFixedMul(origin, height)));
+ SkScalar height = SkFloatToScalar(glyph.fAdvanceY);
+ positions.push_back(stopY + origin * height);
stopX += width;
stopY += height;
@@ -297,8 +297,8 @@ void GrTextUtils::DrawDFText(GrAtlasTextBlob* blob, int runIndex,
SkGlyphCache::AttachCache(origPaintCache);
// now adjust starting point depending on alignment
- SkScalar alignX = SkFixedToScalar(stopX);
- SkScalar alignY = SkFixedToScalar(stopY);
+ SkScalar alignX = stopX;
+ SkScalar alignY = stopY;
if (skPaint.getTextAlign() == SkPaint::kCenter_Align) {
alignX = SkScalarHalf(alignX);
alignY = SkScalarHalf(alignY);
@@ -387,8 +387,8 @@ void GrTextUtils::DrawDFPosText(GrAtlasTextBlob* blob, int runIndex,
SkScalar x = offset.x() + pos[0];
SkScalar y = offset.y() + (2 == scalarsPerPosition ? pos[1] : 0);
- SkScalar advanceX = SkFixedToScalar(glyph.fAdvanceX) * alignMul * textRatio;
- SkScalar advanceY = SkFixedToScalar(glyph.fAdvanceY) * alignMul * textRatio;
+ SkScalar advanceX = SkFloatToScalar(glyph.fAdvanceX) * alignMul * textRatio;
+ SkScalar advanceY = SkFloatToScalar(glyph.fAdvanceY) * alignMul * textRatio;
if (!DfAppendGlyph(blob,
runIndex,