diff options
author | 2014-09-29 06:29:53 -0700 | |
---|---|---|
committer | 2014-09-29 06:29:53 -0700 | |
commit | 05c4a4322e7d4f3417b7df33825bab8603d52051 (patch) | |
tree | 79a22f660fe2b6b58bab4e9f8cc1c9f86f50d565 /src/core/SkDevice.cpp | |
parent | ee6631ef90fb5a9c80de6eacd37632f11367a088 (diff) |
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
Diffstat (limited to 'src/core/SkDevice.cpp')
-rw-r--r-- | src/core/SkDevice.cpp | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp index 63a7633648..935d489892 100644 --- a/src/core/SkDevice.cpp +++ b/src/core/SkDevice.cpp @@ -96,27 +96,6 @@ void SkBaseDevice::drawTextBlob(const SkDraw& draw, const SkTextBlob* blob, SkSc const SkPaint &paint) { SkPaint runPaint = paint; - SkMatrix localMatrix; - SkDraw localDraw(draw); - - if (x || y) { - localMatrix = *draw.fMatrix; - localMatrix.preTranslate(x, y); - localDraw.fMatrix = &localMatrix; - - if (paint.getShader()) { - // FIXME: We need to compensate for the translate above. This is suboptimal but - // temporary -- until we get proper derived class drawTextBlob implementations. - - // TODO: pass x,y down to the other methods so they can handle the additional - // translate without needing to allocate a new shader. - SkMatrix shaderMatrix; - shaderMatrix.setTranslate(-x, -y); - SkAutoTUnref<SkShader> wrapper( - SkShader::CreateLocalMatrixShader(paint.getShader(), shaderMatrix)); - runPaint.setShader(wrapper); - } - } SkTextBlob::RunIterator it(blob); while (!it.done()) { @@ -128,12 +107,15 @@ void SkBaseDevice::drawTextBlob(const SkDraw& draw, const SkTextBlob* blob, SkSc switch (it.positioning()) { case SkTextBlob::kDefault_Positioning: - this->drawText(localDraw, it.glyphs(), textLen, offset.x(), offset.y(), runPaint); + this->drawText(draw, it.glyphs(), textLen, x + offset.x(), y + offset.y(), runPaint); break; case SkTextBlob::kHorizontal_Positioning: + this->drawPosText(draw, it.glyphs(), textLen, it.pos(), 1, + SkPoint::Make(x, y + offset.y()), runPaint); + break; case SkTextBlob::kFull_Positioning: - this->drawPosText(localDraw, it.glyphs(), textLen, it.pos(), offset.y(), - SkTextBlob::ScalarsPerGlyph(it.positioning()), runPaint); + this->drawPosText(draw, it.glyphs(), textLen, it.pos(), 2, + SkPoint::Make(x, y), runPaint); break; default: SkFAIL("unhandled positioning mode"); |