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
This commit is contained in:
fmalita 2014-09-29 06:29:53 -07:00 committed by Commit bot
parent ee6631ef90
commit 05c4a4322e
27 changed files with 111 additions and 134 deletions

View File

@ -120,10 +120,10 @@ protected:
}
virtual void drawPosText(const SkDraw& dummy1, const void* text, size_t len,
const SkScalar pos[], SkScalar constY,
int scalarsPerPos, const SkPaint& paint) {
const SkScalar pos[], int scalarsPerPos,
const SkPoint& offset, const SkPaint& paint) {
before();
INHERITED::drawPosText(dummy1, text, len, pos, constY, scalarsPerPos, paint);
INHERITED::drawPosText(dummy1, text, len, pos, scalarsPerPos, offset, paint);
after();
}

View File

@ -96,8 +96,8 @@ protected:
virtual void drawText(const SkDraw&, const void* text, size_t len,
SkScalar x, SkScalar y, const SkPaint& paint) SK_OVERRIDE;
virtual void drawPosText(const SkDraw&, const void* text, size_t len,
const SkScalar pos[], SkScalar constY,
int scalarsPerPos, const SkPaint& paint) SK_OVERRIDE;
const SkScalar pos[], int scalarsPerPos,
const SkPoint& offset, const SkPaint& paint) SK_OVERRIDE;
virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len,
const SkPath& path, const SkMatrix* matrix,
const SkPaint& paint) SK_OVERRIDE;

View File

@ -218,8 +218,8 @@ protected:
virtual void drawText(const SkDraw&, const void* text, size_t len,
SkScalar x, SkScalar y, const SkPaint& paint) = 0;
virtual void drawPosText(const SkDraw&, const void* text, size_t len,
const SkScalar pos[], SkScalar constY,
int scalarsPerPos, const SkPaint& paint) = 0;
const SkScalar pos[], int scalarsPerPos,
const SkPoint& offset, const SkPaint& paint) = 0;
virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len,
const SkPath& path, const SkMatrix* matrix,
const SkPaint& paint) = 0;

View File

@ -60,8 +60,8 @@ public:
void drawText(const char text[], size_t byteLength, SkScalar x,
SkScalar y, const SkPaint& paint) const;
void drawPosText(const char text[], size_t byteLength,
const SkScalar pos[], SkScalar constY,
int scalarsPerPosition, const SkPaint& paint) const;
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset, const SkPaint& paint) const;
void drawTextOnPath(const char text[], size_t byteLength,
const SkPath&, const SkMatrix*, const SkPaint&) const;
void drawVertices(SkCanvas::VertexMode mode, int count,
@ -113,8 +113,8 @@ public:
void drawText_asPaths(const char text[], size_t byteLength,
SkScalar x, SkScalar y, const SkPaint&) const;
void drawPosText_asPaths(const char text[], size_t byteLength,
const SkScalar pos[], SkScalar constY,
int scalarsPerPosition, const SkPaint&) const;
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset, const SkPaint&) const;
private:
void drawDevMask(const SkMask& mask, const SkPaint&) const;

View File

@ -118,8 +118,8 @@ protected:
virtual void drawPosText(
const SkDraw&,
const void* text, size_t len,
const SkScalar pos[], SkScalar constY, int scalarsPerPos,
const SkPaint& paint) SK_OVERRIDE;
const SkScalar pos[], int scalarsPerPos,
const SkPoint& offset, const SkPaint& paint) SK_OVERRIDE;
virtual void drawTextOnPath(
const SkDraw&,

View File

@ -98,8 +98,8 @@ public:
virtual void drawText(const SkDraw&, const void* text, size_t len,
SkScalar x, SkScalar y, const SkPaint&) SK_OVERRIDE;
virtual void drawPosText(const SkDraw&, const void* text, size_t len,
const SkScalar pos[], SkScalar constY,
int scalarsPerPos, const SkPaint&) SK_OVERRIDE;
const SkScalar pos[], int scalarsPerPos,
const SkPoint& offset, const SkPaint&) SK_OVERRIDE;
virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len,
const SkPath& path, const SkMatrix* matrix,
const SkPaint& paint) SK_OVERRIDE;

View File

@ -329,9 +329,9 @@ void SkBitmapDevice::drawText(const SkDraw& draw, const void* text, size_t len,
}
void SkBitmapDevice::drawPosText(const SkDraw& draw, const void* text, size_t len,
const SkScalar xpos[], SkScalar y,
int scalarsPerPos, const SkPaint& paint) {
draw.drawPosText((const char*)text, len, xpos, y, scalarsPerPos, paint);
const SkScalar xpos[], int scalarsPerPos,
const SkPoint& offset, const SkPaint& paint) {
draw.drawPosText((const char*)text, len, xpos, scalarsPerPos, offset, paint);
}
void SkBitmapDevice::drawTextOnPath(const SkDraw& draw, const void* text,

View File

@ -2152,11 +2152,13 @@ void SkCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, SkSca
void SkCanvas::onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[],
const SkPaint& paint) {
SkPoint textOffset = SkPoint::Make(0, 0);
LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL)
while (iter.next()) {
SkDeviceFilteredPaint dfp(iter.fDevice, looper.paint());
iter.fDevice->drawPosText(iter, text, byteLength, &pos->fX, 0, 2,
iter.fDevice->drawPosText(iter, text, byteLength, &pos->fX, 2, textOffset,
dfp.paint());
}
@ -2165,11 +2167,14 @@ void SkCanvas::onDrawPosText(const void* text, size_t byteLength, const SkPoint
void SkCanvas::onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
SkScalar constY, const SkPaint& paint) {
SkPoint textOffset = SkPoint::Make(0, constY);
LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL)
while (iter.next()) {
SkDeviceFilteredPaint dfp(iter.fDevice, looper.paint());
iter.fDevice->drawPosText(iter, text, byteLength, xpos, constY, 1,
iter.fDevice->drawPosText(iter, text, byteLength, xpos, 1, textOffset,
dfp.paint());
}

View File

@ -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");

View File

@ -1655,9 +1655,8 @@ void SkDraw::drawText(const char text[], size_t byteLength,
//////////////////////////////////////////////////////////////////////////////
void SkDraw::drawPosText_asPaths(const char text[], size_t byteLength,
const SkScalar pos[], SkScalar constY,
int scalarsPerPosition,
const SkPaint& origPaint) const {
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset, const SkPaint& origPaint) const {
// setup our std paint, in hopes of getting hits in the cache
SkPaint paint(origPaint);
SkScalar matrixScale = paint.setupForAsPaths();
@ -1675,7 +1674,7 @@ void SkDraw::drawPosText_asPaths(const char text[], size_t byteLength,
const char* stop = text + byteLength;
SkTextAlignProcScalar alignProc(paint.getTextAlign());
SkTextMapStateProc tmsProc(SkMatrix::I(), constY, scalarsPerPosition);
SkTextMapStateProc tmsProc(SkMatrix::I(), offset, scalarsPerPosition);
// Now restore the original settings, so we "draw" with whatever style/stroking.
paint.setStyle(origPaint.getStyle());
@ -1705,8 +1704,8 @@ void SkDraw::drawPosText_asPaths(const char text[], size_t byteLength,
}
void SkDraw::drawPosText(const char text[], size_t byteLength,
const SkScalar pos[], SkScalar constY,
int scalarsPerPosition, const SkPaint& paint) const {
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset, const SkPaint& paint) const {
SkASSERT(byteLength == 0 || text != NULL);
SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition);
@ -1718,8 +1717,7 @@ void SkDraw::drawPosText(const char text[], size_t byteLength,
}
if (ShouldDrawTextAsPaths(paint, *fMatrix)) {
this->drawPosText_asPaths(text, byteLength, pos, constY,
scalarsPerPosition, paint);
this->drawPosText_asPaths(text, byteLength, pos, scalarsPerPosition, offset, paint);
return;
}
@ -1743,7 +1741,7 @@ void SkDraw::drawPosText(const char text[], size_t byteLength,
SkTextAlignProc alignProc(paint.getTextAlign());
SkDraw1Glyph d1g;
SkDraw1Glyph::Proc proc = d1g.init(this, blitter, cache, paint);
SkTextMapStateProc tmsProc(*fMatrix, constY, scalarsPerPosition);
SkTextMapStateProc tmsProc(*fMatrix, offset, scalarsPerPosition);
if (cache->isSubpixel()) {
// maybe we should skip the rounding if linearText is set

View File

@ -13,20 +13,22 @@
class SkTextMapStateProc {
public:
SkTextMapStateProc(const SkMatrix& matrix, SkScalar y, int scalarsPerPosition)
SkTextMapStateProc(const SkMatrix& matrix, const SkPoint& offset, int scalarsPerPosition)
: fMatrix(matrix)
, fProc(matrix.getMapXYProc())
, fY(y)
, fScaleX(fMatrix.getScaleX())
, fTransX(fMatrix.getTranslateX()) {
, fOffset(offset)
, fScaleX(fMatrix.getScaleX()) {
SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition);
if (1 == scalarsPerPosition) {
unsigned mtype = fMatrix.getType();
if (mtype & (SkMatrix::kAffine_Mask | SkMatrix::kPerspective_Mask)) {
fMapCase = kX;
} else {
fY = SkScalarMul(y, fMatrix.getScaleY()) +
fMatrix.getTranslateY();
// Bake the matrix scale/translation components into fOffset,
// to expedite proc computations.
fOffset.set(SkScalarMul(offset.x(), fMatrix.getScaleX()) + fMatrix.getTranslateX(),
SkScalarMul(offset.y(), fMatrix.getScaleY()) + fMatrix.getTranslateY());
if (mtype & SkMatrix::kScale_Mask) {
fMapCase = kOnlyScaleX;
} else {
@ -49,25 +51,25 @@ private:
kX
} fMapCase;
const SkMatrix::MapXYProc fProc;
SkScalar fY; // Ignored by kXY case.
SkScalar fScaleX, fTransX; // These are only used by Only... cases.
SkPoint fOffset; // In kOnly* mode, this includes the matrix translation component.
SkScalar fScaleX; // This is only used by kOnly... cases.
};
inline void SkTextMapStateProc::operator()(const SkScalar pos[], SkPoint* loc) const {
switch(fMapCase) {
case kXY:
fProc(fMatrix, pos[0], pos[1], loc);
fProc(fMatrix, pos[0] + fOffset.x(), pos[1] + fOffset.y(), loc);
break;
case kOnlyScaleX:
loc->set(SkScalarMul(fScaleX, *pos) + fTransX, fY);
loc->set(SkScalarMul(fScaleX, *pos) + fOffset.x(), fOffset.y());
break;
case kOnlyTransX:
loc->set(*pos + fTransX, fY);
loc->set(*pos + fOffset.x(), fOffset.y());
break;
default:
SkASSERT(false);
case kX:
fProc(fMatrix, *pos, fY, loc);
fProc(fMatrix, *pos + fOffset.x(), fOffset.y(), loc);
break;
}
}

View File

@ -2165,9 +2165,8 @@ void SkXPSDevice::drawText(const SkDraw& d,
void SkXPSDevice::drawPosText(const SkDraw& d,
const void* text, size_t byteLen,
const SkScalar pos[],
SkScalar constY, int scalarsPerPos,
const SkPaint& paint) {
const SkScalar pos[], int scalarsPerPos,
const SkPoint& offset, const SkPaint& paint) {
if (byteLen < 1) return;
if (text_must_be_pathed(paint, *d.fMatrix)) {
@ -2187,9 +2186,7 @@ void SkXPSDevice::drawPosText(const SkDraw& d,
SkXPSDrawProcs procs;
text_draw_init(paint, text, byteLen, *typeface->glyphsUsed, myDraw, procs);
myDraw.drawPosText(static_cast<const char*>(text), byteLen,
pos, constY, scalarsPerPos,
paint);
myDraw.drawPosText(static_cast<const char*>(text), byteLen, pos, scalarsPerPos, offset, paint);
// SkDraw may have clipped out the glyphs, so we need to check
if (procs.xpsGlyphs.count() == 0) {

View File

@ -270,8 +270,8 @@ void GrBitmapTextContext::drawText(const GrPaint& paint, const SkPaint& skPaint,
void GrBitmapTextContext::drawPosText(const GrPaint& paint, const SkPaint& skPaint,
const char text[], size_t byteLength,
const SkScalar pos[], SkScalar constY,
int scalarsPerPosition) {
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset) {
SkASSERT(byteLength == 0 || text != NULL);
SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition);
@ -295,7 +295,7 @@ void GrBitmapTextContext::drawPosText(const GrPaint& paint, const SkPaint& skPai
const char* stop = text + byteLength;
SkTextAlignProc alignProc(fSkPaint.getTextAlign());
SkTextMapStateProc tmsProc(ctm, constY, scalarsPerPosition);
SkTextMapStateProc tmsProc(ctm, offset, scalarsPerPosition);
SkFixed halfSampleX = 0, halfSampleY = 0;
if (cache->isSubpixel()) {

View File

@ -25,8 +25,8 @@ public:
SkScalar x, SkScalar y) SK_OVERRIDE;
virtual void drawPosText(const GrPaint&, const SkPaint&,
const char text[], size_t byteLength,
const SkScalar pos[], SkScalar constY,
int scalarsPerPosition) SK_OVERRIDE;
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset) SK_OVERRIDE;
virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE;

View File

@ -609,8 +609,8 @@ void GrDistanceFieldTextContext::drawText(const GrPaint& paint, const SkPaint& s
void GrDistanceFieldTextContext::drawPosText(const GrPaint& paint, const SkPaint& skPaint,
const char text[], size_t byteLength,
const SkScalar pos[], SkScalar constY,
int scalarsPerPosition) {
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset) {
SkASSERT(byteLength == 0 || text != NULL);
SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition);
@ -638,8 +638,8 @@ void GrDistanceFieldTextContext::drawPosText(const GrPaint& paint, const SkPaint
const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0);
if (glyph.fWidth) {
SkScalar x = pos[0];
SkScalar y = scalarsPerPosition == 1 ? constY : pos[1];
SkScalar x = offset.x() + pos[0];
SkScalar y = offset.y() + (2 == scalarsPerPosition ? pos[1] : 0);
this->drawPackedGlyph(GrGlyph::Pack(glyph.getGlyphID(),
glyph.getSubXFixed(),
@ -657,8 +657,8 @@ void GrDistanceFieldTextContext::drawPosText(const GrPaint& paint, const SkPaint
const SkGlyph& glyph = glyphCacheProc(cache, &text, 0, 0);
if (glyph.fWidth) {
SkScalar x = pos[0];
SkScalar y = scalarsPerPosition == 1 ? constY : pos[1];
SkScalar x = offset.x() + pos[0];
SkScalar y = offset.y() + (2 == scalarsPerPosition ? pos[1] : 0);
this->drawPackedGlyph(GrGlyph::Pack(glyph.getGlyphID(),
glyph.getSubXFixed(),

View File

@ -25,8 +25,8 @@ public:
SkScalar x, SkScalar y) SK_OVERRIDE;
virtual void drawPosText(const GrPaint&, const SkPaint&,
const char text[], size_t byteLength,
const SkScalar pos[], SkScalar constY,
int scalarsPerPosition) SK_OVERRIDE;
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset) SK_OVERRIDE;
virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE;

View File

@ -54,7 +54,7 @@ void GrStencilAndCoverTextContext::drawText(const GrPaint& paint,
// 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 @@ void GrStencilAndCoverTextContext::drawPosText(const GrPaint& paint,
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 @@ void GrStencilAndCoverTextContext::drawPosText(const GrPaint& paint,
// 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 @@ void GrStencilAndCoverTextContext::drawPosText(const GrPaint& paint,
}
} 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 @@ void GrStencilAndCoverTextContext::init(const GrPaint& paint,
const SkPaint& skPaint,
size_t textByteLength,
RenderMode renderMode,
SkScalar textTranslateY) {
const SkPoint& textTranslate) {
GrTextContext::init(paint, skPaint);
fContextInitialMatrix = fContext->getMatrix();
@ -258,7 +257,7 @@ void GrStencilAndCoverTextContext::init(const GrPaint& paint,
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 @@ void GrStencilAndCoverTextContext::init(const GrPaint& paint,
}
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);

View File

@ -32,8 +32,8 @@ public:
SkScalar x, SkScalar y) SK_OVERRIDE;
virtual void drawPosText(const GrPaint&, const SkPaint&,
const char text[], size_t byteLength,
const SkScalar pos[], SkScalar constY,
int scalarsPerPosition) SK_OVERRIDE;
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset) SK_OVERRIDE;
virtual bool canDraw(const SkPaint& paint) SK_OVERRIDE;
@ -62,7 +62,7 @@ private:
};
void init(const GrPaint&, const SkPaint&, size_t textByteLength,
RenderMode, SkScalar textTranslateY = 0);
RenderMode, const SkPoint& textTranslate);
void initGlyphs(SkGlyphCache* cache);
void appendGlyph(uint16_t glyphID, float x);
void appendGlyph(uint16_t glyphID, float x, float y);

View File

@ -28,8 +28,8 @@ public:
SkScalar x, SkScalar y) = 0;
virtual void drawPosText(const GrPaint&, const SkPaint&,
const char text[], size_t byteLength,
const SkScalar pos[], SkScalar constY,
int scalarsPerPosition) = 0;
const SkScalar pos[], int scalarsPerPosition,
const SkPoint& offset) = 0;
virtual bool canDraw(const SkPaint& paint) = 0;

View File

@ -1713,10 +1713,9 @@ void SkGpuDevice::drawText(const SkDraw& draw, const void* text,
}
}
void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text,
size_t byteLength, const SkScalar pos[],
SkScalar constY, int scalarsPerPos,
const SkPaint& paint) {
void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text, size_t byteLength,
const SkScalar pos[], int scalarsPerPos,
const SkPoint& offset, const SkPaint& paint) {
GR_CREATE_TRACE_MARKER_CONTEXT("SkGpuDevice::drawPosText", fContext);
CHECK_SHOULD_DRAW(draw, false);
@ -1727,7 +1726,7 @@ void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text,
SkDEBUGCODE(this->validate();)
fMainTextContext->drawPosText(grPaint, paint, (const char *)text, byteLength, pos,
constY, scalarsPerPos);
scalarsPerPos, offset);
} else if (fFallbackTextContext && fFallbackTextContext->canDraw(paint)) {
GrPaint grPaint;
SkPaint2GrPaintShader(this->context(), paint, true, &grPaint);
@ -1735,10 +1734,9 @@ void SkGpuDevice::drawPosText(const SkDraw& draw, const void* text,
SkDEBUGCODE(this->validate();)
fFallbackTextContext->drawPosText(grPaint, paint, (const char *)text, byteLength, pos,
constY, scalarsPerPos);
scalarsPerPos, offset);
} else {
draw.drawPosText_asPaths((const char*)text, byteLength, pos, constY,
scalarsPerPos, paint);
draw.drawPosText_asPaths((const char*)text, byteLength, pos, scalarsPerPos, offset, paint);
}
}

View File

@ -90,8 +90,8 @@ public:
virtual void drawText(const SkDraw&, const void* text, size_t len,
SkScalar x, SkScalar y, const SkPaint&) SK_OVERRIDE;
virtual void drawPosText(const SkDraw&, const void* text, size_t len,
const SkScalar pos[], SkScalar constY,
int scalarsPerPos, const SkPaint&) SK_OVERRIDE;
const SkScalar pos[], int scalarsPerPos,
const SkPoint& offset, const SkPaint&) SK_OVERRIDE;
virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len,
const SkPath& path, const SkMatrix* matrix,
const SkPaint&) SK_OVERRIDE;

View File

@ -1144,8 +1144,8 @@ void SkPDFDevice::drawText(const SkDraw& d, const void* text, size_t len,
}
void SkPDFDevice::drawPosText(const SkDraw& d, const void* text, size_t len,
const SkScalar pos[], SkScalar constY,
int scalarsPerPos, const SkPaint& paint) {
const SkScalar pos[], int scalarsPerPos,
const SkPoint& offset, const SkPaint& paint) {
NOT_IMPLEMENTED(paint.getMaskFilter() != NULL, false);
if (paint.getMaskFilter() != NULL) {
// Don't pretend we support drawing MaskFilters, it makes for artifacts
@ -1177,8 +1177,9 @@ void SkPDFDevice::drawPosText(const SkDraw& d, const void* text, size_t len,
continue;
}
fFontGlyphUsage->noteGlyphUsage(font, &encodedValue, 1);
SkScalar x = pos[i * scalarsPerPos];
SkScalar y = scalarsPerPos == 1 ? constY : pos[i * scalarsPerPos + 1];
SkScalar x = offset.x() + pos[i * scalarsPerPos];
SkScalar y = offset.y() + (2 == scalarsPerPos ? pos[i * scalarsPerPos + 1] : 0);
align_text(glyphCacheProc, textPaint, glyphIDs + i, 1, &x, &y);
set_text_transform(x, y, textPaint.getTextSkewX(),
&content.entry()->fContent);

View File

@ -123,13 +123,13 @@ void SkPDFDeviceFlattener::drawText(const SkDraw& d, const void* text, size_t le
}
void SkPDFDeviceFlattener::drawPosText(const SkDraw& d, const void* text, size_t len,
const SkScalar pos[], SkScalar constY,
int scalarsPerPos, const SkPaint& paint) {
const SkScalar pos[], int scalarsPerPos,
const SkPoint& offset, const SkPaint& paint) {
if (mustPathText(d, paint)) {
d.drawPosText_asPaths((const char*)text, len, pos, constY, scalarsPerPos, paint);
d.drawPosText_asPaths((const char*)text, len, pos, scalarsPerPos, offset, paint);
return;
}
INHERITED::drawPosText(d, text, len, pos, constY,scalarsPerPos, paint);
INHERITED::drawPosText(d, text, len, pos, scalarsPerPos, offset, paint);
}
void SkPDFDeviceFlattener::drawTextOnPath(const SkDraw& d, const void* text, size_t len,

View File

@ -37,8 +37,8 @@ public:
virtual void drawText(const SkDraw&, const void* text, size_t len,
SkScalar x, SkScalar y, const SkPaint&) SK_OVERRIDE;
virtual void drawPosText(const SkDraw&, const void* text, size_t len,
const SkScalar pos[], SkScalar constY,
int scalarsPerPos, const SkPaint&) SK_OVERRIDE;
const SkScalar pos[], int scalarsPerPos,
const SkPoint& offset, const SkPaint&) SK_OVERRIDE;
virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len,
const SkPath& path, const SkMatrix* matrix,
const SkPaint& paint) SK_OVERRIDE;

View File

@ -210,8 +210,8 @@ protected:
SkScalar x, SkScalar y, const SkPaint& paint) SK_OVERRIDE
{SkASSERT(0);}
virtual void drawPosText(const SkDraw&, const void* text, size_t len,
const SkScalar pos[], SkScalar constY,
int scalarsPerPos, const SkPaint& paint) SK_OVERRIDE
const SkScalar pos[], int scalarsPerPos,
const SkPoint& offset, const SkPaint& paint) SK_OVERRIDE
{SkASSERT(0);}
virtual void drawTextOnPath(const SkDraw&, const void* text,
size_t len, const SkPath& path,

View File

@ -195,8 +195,8 @@ protected:
this->drawRect(draw, bounds, paint);
}
virtual void drawPosText(const SkDraw& draw, const void* text, size_t len,
const SkScalar pos[], SkScalar constY,
int scalarsPerPos, const SkPaint& paint) SK_OVERRIDE {
const SkScalar pos[], int scalarsPerPos,
const SkPoint& offset, const SkPaint& paint) SK_OVERRIDE {
SkBitmap bitmap;
if (!GetBitmapFromPaint(paint, &bitmap)) {
return;
@ -209,18 +209,13 @@ protected:
// Similar to SkDraw asserts.
SkASSERT(scalarsPerPos == 1 || scalarsPerPos == 2);
SkScalar y = scalarsPerPos == 1 ? constY : constY + pos[1];
SkPoint min, max;
min.set(pos[0], y);
max.set(pos[0], y);
SkPoint min = SkPoint::Make(offset.x() + pos[0],
offset.y() + (2 == scalarsPerPos ? pos[1] : 0));
SkPoint max = min;
for (size_t i = 1; i < len; ++i) {
SkScalar x = pos[i * scalarsPerPos];
SkScalar y = constY;
if (2 == scalarsPerPos) {
y += pos[i * scalarsPerPos + 1];
}
SkScalar x = offset.x() + pos[i * scalarsPerPos];
SkScalar y = offset.y() + (2 == scalarsPerPos ? pos[i * 2 + 1] : 0);
min.set(SkMinScalar(x, min.x()), SkMinScalar(y, min.y()));
max.set(SkMaxScalar(x, max.x()), SkMaxScalar(y, max.y()));

View File

@ -132,8 +132,8 @@ public:
this->addBitmapFromPaint(paint);
}
virtual void drawPosText(const SkDraw&, const void* text, size_t len,
const SkScalar pos[], SkScalar constY,
int, const SkPaint& paint) SK_OVERRIDE {
const SkScalar pos[], int,
const SkPoint&, const SkPaint& paint) SK_OVERRIDE {
this->addBitmapFromPaint(paint);
}
virtual void drawTextOnPath(const SkDraw&, const void* text, size_t len,