aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Herb Derby <herb@google.com>2018-05-21 13:46:38 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-21 20:45:24 +0000
commit18934c653fd6f31fd464dc7db83d583c864884dc (patch)
tree8b060e44437c170789b268e3fbd1d40cc196811e /src
parentc402b778d5707ac2f66c9f38d5bbc20fb79321b5 (diff)
Simplify aligment for DFT drawText
The original code had to compensate for the alignment that was passed in throught the paint. You can simplifiy the code by just changing the paint to left alignment. Change-Id: I532ae5224ea5de078c6cd6255f03fc1db06baa83 Reviewed-on: https://skia-review.googlesource.com/129360 Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/gpu/text/GrAtlasTextContext.cpp26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/gpu/text/GrAtlasTextContext.cpp b/src/gpu/text/GrAtlasTextContext.cpp
index dfa0da83cd..1086bc4894 100644
--- a/src/gpu/text/GrAtlasTextContext.cpp
+++ b/src/gpu/text/GrAtlasTextContext.cpp
@@ -687,12 +687,6 @@ void GrAtlasTextContext::drawDFText(GrAtlasTextBlob* blob, int runIndex,
const char* textPtr = text;
SkScalar stopX = 0;
SkScalar stopY = 0;
- SkScalar origin = 0;
- switch (skPaint.getTextAlign()) {
- case SkPaint::kRight_Align: origin = SK_Scalar1; break;
- case SkPaint::kCenter_Align: origin = SK_ScalarHalf; break;
- case SkPaint::kLeft_Align: origin = 0; break;
- }
SkAutoDescriptor desc;
SkScalerContextEffects effects;
@@ -712,14 +706,11 @@ void GrAtlasTextContext::drawDFText(GrAtlasTextBlob* blob, int runIndex,
// same advance
const SkGlyph& glyph = glyphCacheProc(origPaintCache.get(), &textPtr);
- SkScalar width = SkFloatToScalar(glyph.fAdvanceX);
- positions.push_back(stopX + origin * width);
-
- SkScalar height = SkFloatToScalar(glyph.fAdvanceY);
- positions.push_back(stopY + origin * height);
+ positions.push_back(stopX);
+ positions.push_back(stopY);
- stopX += width;
- stopY += height;
+ stopX += SkFloatToScalar(glyph.fAdvanceX);
+ stopY += SkFloatToScalar(glyph.fAdvanceY);
}
SkASSERT(textPtr == stop);
}
@@ -738,8 +729,13 @@ void GrAtlasTextContext::drawDFText(GrAtlasTextBlob* blob, int runIndex,
y -= alignY;
SkPoint offset = SkPoint::Make(x, y);
- this->drawDFPosText(blob, runIndex, glyphCache, props, paint, scalerContextFlags, viewMatrix,
- text, byteLength, positions.begin(), 2, offset);
+ SkPaint leftAlignedSkPaint(skPaint);
+ leftAlignedSkPaint.setTextAlign(SkPaint::kLeft_Align);
+
+ GrTextUtils::Paint leftAlignedPaint(&leftAlignedSkPaint, paint.dstColorSpaceInfo());
+
+ this->drawDFPosText(blob, runIndex, glyphCache, props, leftAlignedPaint, scalerContextFlags,
+ viewMatrix, text, byteLength, positions.begin(), 2, offset);
}
void GrAtlasTextContext::drawDFPosText(GrAtlasTextBlob* blob, int runIndex,