Revert of Revert of Fix SkTextBlob offset semantics. (patchset #1 id:1 of https://codereview.chromium.org/609223003/)
Reason for revert:
Re-landing: Chromium-side fix to be landed with the roll (https://codereview.chromium.org/607853003/)
Original issue's description:
> Revert of Fix SkTextBlob offset semantics. (patchset #2 id:20001 of https://codereview.chromium.org/605533002/)
>
> Reason for revert:
> Breaking the Chrome builds with the error:
>
> [14:54:14.317833] ../../skia/ext/pixel_ref_utils.cc:221:16: error: 'drawPosText' marked 'override' but does not override any member functions
> [14:54:14.318022] virtual void drawPosText(const SkDraw& draw,
> [14:54:14.318082] ^
>
> Original issue's description:
> > Fix SkTextBlob offset semantics.
> >
> > Implement proper x/y drawTextBlob() handling by plumbing a
> > drawPosText() offset parameter (to act as an additional glyph pos
> > translation) throughout the device layer.
> >
> > The new offset superceeds the existing constY, with a minor semantic
> > tweak: whereas previous implementations were ignoring constY in 2D
> > positioning mode (scalarsPerGlyph == 2), now the offset is always
> > observed, in all positioning modes. We can do this because existing
> > drawPosText() clients always pass constY == 0 for full positioning mode.
> >
> > R=reed@google.com, jvanverth@google.com, robertphillips@google.com
> >
> > Committed: https://skia.googlesource.com/skia/+/c13bc571d3e61a43b87eb97f0719abd304cafaf2
>
> TBR=jvanverth@google.com,reed@google.com,bsalomon@google.com,fmalita@chromium.org
> NOTREECHECKS=true
> NOTRY=true
>
> Committed: https://skia.googlesource.com/skia/+/d46b8d2bab7cfba8458432248e1568ac377429e9
R=jvanverth@google.com, reed@google.com, bsalomon@google.com, robertphillips@google.com
TBR=bsalomon@google.com, jvanverth@google.com, reed@google.com, robertphillips@google.com
NOTREECHECKS=true
NOTRY=true
Author: fmalita@chromium.org
Review URL: https://codereview.chromium.org/607413003
diff --git a/src/gpu/GrStencilAndCoverTextContext.cpp b/src/gpu/GrStencilAndCoverTextContext.cpp
index c1d9e9d..cfcabe9 100644
--- a/src/gpu/GrStencilAndCoverTextContext.cpp
+++ b/src/gpu/GrStencilAndCoverTextContext.cpp
@@ -54,7 +54,7 @@
// will turn off the use of device-space glyphs when perspective transforms
// are in use.
- this->init(paint, skPaint, byteLength, kMaxAccuracy_RenderMode);
+ this->init(paint, skPaint, byteLength, kMaxAccuracy_RenderMode, SkPoint::Make(0, 0));
// Transform our starting point.
if (fNeedsDeviceSpaceGlyphs) {
@@ -123,8 +123,8 @@
const char text[],
size_t byteLength,
const SkScalar pos[],
- SkScalar constY,
- int scalarsPerPosition) {
+ int scalarsPerPosition,
+ const SkPoint& offset) {
SkASSERT(byteLength == 0 || text != NULL);
SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition);
@@ -141,8 +141,7 @@
// transform is not part of SkPaint::measureText API, and thus we use the
// same glyphs as what were measured.
- const float textTranslateY = (1 == scalarsPerPosition ? constY : 0);
- this->init(paint, skPaint, byteLength, kMaxPerformance_RenderMode, textTranslateY);
+ this->init(paint, skPaint, byteLength, kMaxPerformance_RenderMode, offset);
SkDrawCacheProc glyphCacheProc = fSkPaint.getDrawCacheProc();
@@ -171,7 +170,7 @@
}
} else {
fTransformType = GrPathRendering::kTranslate_PathTransformType;
- SkTextMapStateProc tmsProc(SkMatrix::I(), 0, scalarsPerPosition);
+ SkTextMapStateProc tmsProc(SkMatrix::I(), SkPoint::Make(0, 0), scalarsPerPosition);
SkTextAlignProcScalar alignProc(fSkPaint.getTextAlign());
while (text < stop) {
const SkGlyph& glyph = glyphCacheProc(fGlyphCache, &text, 0, 0);
@@ -242,7 +241,7 @@
const SkPaint& skPaint,
size_t textByteLength,
RenderMode renderMode,
- SkScalar textTranslateY) {
+ const SkPoint& textTranslate) {
GrTextContext::init(paint, skPaint);
fContextInitialMatrix = fContext->getMatrix();
@@ -258,7 +257,7 @@
if (fNeedsDeviceSpaceGlyphs) {
// SkDraw::ShouldDrawTextAsPaths takes care of perspective transforms.
SkASSERT(!fContextInitialMatrix.hasPerspective());
- SkASSERT(0 == textTranslateY); // TODO: Handle textTranslateY in device-space usecase.
+ SkASSERT(textTranslate.isZero()); // TODO: Handle textTranslate in device-space usecase.
fTextRatio = fTextInverseRatio = 1.0f;
@@ -340,7 +339,7 @@
}
SkMatrix textMatrix;
- textMatrix.setTranslate(0, textTranslateY);
+ textMatrix.setTranslate(textTranslate.x(), textTranslate.y());
// Glyphs loaded by GPU path rendering have an inverted y-direction.
textMatrix.preScale(fTextRatio, -fTextRatio);
fPaint.localCoordChange(textMatrix);