don't support virtual onDrawTextOnPath
Bug: skia:7554 Change-Id: Ia8c663918fea7bc91f3474d1c94e7a1c5536a1d4 Reviewed-on: https://skia-review.googlesource.com/149805 Reviewed-by: Florin Malita <fmalita@chromium.org> Commit-Queue: Mike Reed <reed@google.com>
This commit is contained in:
parent
de47928988
commit
7c8d2e940e
@ -2431,9 +2431,11 @@ protected:
|
||||
virtual void onDrawPosTextH(const void* text, size_t byteLength,
|
||||
const SkScalar xpos[], SkScalar constY,
|
||||
const SkPaint& paint);
|
||||
virtual void onDrawTextOnPath(const void* text, size_t byteLength,
|
||||
const SkPath& path, const SkMatrix* matrix,
|
||||
const SkPaint& paint);
|
||||
#ifdef SK_SUPPORT_LEGACY_ONDRAWTEXTONPATH
|
||||
// DEPRECATED -- do not override
|
||||
virtual void onDrawTextOnPath(const void*, size_t, const SkPath&, const SkMatrix*,
|
||||
const SkPaint&) {}
|
||||
#endif
|
||||
virtual void onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[],
|
||||
const SkRect* cullRect, const SkPaint& paint);
|
||||
virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
|
||||
|
@ -36,8 +36,6 @@ protected:
|
||||
const SkPaint& paint) override = 0;
|
||||
void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
|
||||
SkScalar constY, const SkPaint& paint) override = 0;
|
||||
void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
|
||||
const SkMatrix* matrix, const SkPaint& paint) override = 0;
|
||||
void onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[],
|
||||
const SkRect* cullRect, const SkPaint& paint) override = 0;
|
||||
void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
|
||||
|
@ -24,8 +24,6 @@ public:
|
||||
void onDrawText(const void*, size_t, SkScalar, SkScalar, const SkPaint&) override;
|
||||
void onDrawPosText(const void*, size_t, const SkPoint[], const SkPaint&) override;
|
||||
void onDrawPosTextH(const void*, size_t, const SkScalar[], SkScalar, const SkPaint&) override;
|
||||
void onDrawTextOnPath(const void*, size_t, const SkPath&, const SkMatrix*,
|
||||
const SkPaint&) override;
|
||||
void onDrawTextRSXform(const void*, size_t, const SkRSXform[], const SkRect*,
|
||||
const SkPaint&) override;
|
||||
void onDrawTextBlob(const SkTextBlob*, SkScalar, SkScalar, const SkPaint&) override;
|
||||
|
@ -36,8 +36,6 @@ protected:
|
||||
const SkPaint&) override;
|
||||
virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
|
||||
SkScalar constY, const SkPaint&) override;
|
||||
virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
|
||||
const SkMatrix* matrix, const SkPaint&) override;
|
||||
void onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[],
|
||||
const SkRect* cull, const SkPaint& paint) override;
|
||||
virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
|
||||
|
@ -39,8 +39,6 @@ protected:
|
||||
const SkPaint&) override;
|
||||
virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
|
||||
SkScalar constY, const SkPaint&) override;
|
||||
virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
|
||||
const SkMatrix* matrix, const SkPaint&) override;
|
||||
virtual void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
|
||||
const SkPaint& paint) override;
|
||||
void onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[],
|
||||
|
@ -46,8 +46,6 @@ protected:
|
||||
void onDrawText(const void*, size_t, SkScalar, SkScalar, const SkPaint&) override {}
|
||||
void onDrawPosText(const void*, size_t, const SkPoint[], const SkPaint&) override {}
|
||||
void onDrawPosTextH(const void*, size_t, const SkScalar[], SkScalar, const SkPaint&) override {}
|
||||
void onDrawTextOnPath(const void*, size_t, const SkPath&, const SkMatrix*,
|
||||
const SkPaint&) override {}
|
||||
void onDrawTextRSXform(const void*, size_t, const SkRSXform[], const SkRect*,
|
||||
const SkPaint&) override {}
|
||||
void onDrawTextBlob(const SkTextBlob*, SkScalar, SkScalar, const SkPaint&) override {}
|
||||
|
@ -102,8 +102,6 @@ protected:
|
||||
const SkPaint&) override;
|
||||
void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
|
||||
SkScalar constY, const SkPaint&) override;
|
||||
void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
|
||||
const SkMatrix* matrix, const SkPaint&) override;
|
||||
void onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[],
|
||||
const SkRect* cull, const SkPaint& paint) override;
|
||||
void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
|
||||
|
@ -2473,13 +2473,6 @@ void SkCanvas::onDrawPosTextH(const void* text, size_t byteLength, const SkScala
|
||||
LOOPER_END
|
||||
}
|
||||
|
||||
#include "SkTextOnPath.h"
|
||||
|
||||
void SkCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
|
||||
const SkMatrix* matrix, const SkPaint& paint) {
|
||||
SkDrawTextOnPath(text, byteLength, paint, path, matrix, this);
|
||||
}
|
||||
|
||||
void SkCanvas::onDrawTextRSXform(const void* text, size_t len, const SkRSXform xform[],
|
||||
const SkRect* cullRect, const SkPaint& paint) {
|
||||
if (cullRect && this->quickReject(*cullRect)) {
|
||||
@ -2554,12 +2547,16 @@ void SkCanvas::drawPosTextH(const void* text, size_t byteLength, const SkScalar
|
||||
this->onDrawPosTextH(text, byteLength, xpos, constY, paint);
|
||||
}
|
||||
}
|
||||
|
||||
#include "SkTextOnPath.h"
|
||||
|
||||
void SkCanvas::drawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
|
||||
const SkMatrix* matrix, const SkPaint& paint) {
|
||||
TRACE_EVENT0("skia", TRACE_FUNC);
|
||||
if (byteLength) {
|
||||
sk_msan_assert_initialized(text, SkTAddOffset<const void>(text, byteLength));
|
||||
this->onDrawTextOnPath(text, byteLength, path, matrix, paint);
|
||||
|
||||
SkDrawTextOnPath(text, byteLength, paint, path, matrix, this);
|
||||
}
|
||||
}
|
||||
void SkCanvas::drawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[],
|
||||
|
@ -123,11 +123,6 @@ public:
|
||||
const SkPaint& paint) override {
|
||||
fTarget->drawPosTextH(ptr, len, xs, y, fXformer->apply(paint));
|
||||
}
|
||||
void onDrawTextOnPath(const void* ptr, size_t len,
|
||||
const SkPath& path, const SkMatrix* matrix,
|
||||
const SkPaint& paint) override {
|
||||
fTarget->drawTextOnPath(ptr, len, path, matrix, fXformer->apply(paint));
|
||||
}
|
||||
void onDrawTextRSXform(const void* ptr, size_t len,
|
||||
const SkRSXform* xforms, const SkRect* cull,
|
||||
const SkPaint& paint) override {
|
||||
|
@ -305,130 +305,6 @@ bool SkBaseDevice::peekPixels(SkPixmap* pmap) {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void morphpoints(SkPoint dst[], const SkPoint src[], int count,
|
||||
SkPathMeasure& meas, const SkMatrix& matrix) {
|
||||
SkMatrixPriv::MapXYProc proc = SkMatrixPriv::GetMapXYProc(matrix);
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
SkPoint pos;
|
||||
SkVector tangent;
|
||||
|
||||
proc(matrix, src[i].fX, src[i].fY, &pos);
|
||||
SkScalar sx = pos.fX;
|
||||
SkScalar sy = pos.fY;
|
||||
|
||||
if (!meas.getPosTan(sx, &pos, &tangent)) {
|
||||
// set to 0 if the measure failed, so that we just set dst == pos
|
||||
tangent.set(0, 0);
|
||||
}
|
||||
|
||||
/* This is the old way (that explains our approach but is way too slow
|
||||
SkMatrix matrix;
|
||||
SkPoint pt;
|
||||
|
||||
pt.set(sx, sy);
|
||||
matrix.setSinCos(tangent.fY, tangent.fX);
|
||||
matrix.preTranslate(-sx, 0);
|
||||
matrix.postTranslate(pos.fX, pos.fY);
|
||||
matrix.mapPoints(&dst[i], &pt, 1);
|
||||
*/
|
||||
dst[i].set(pos.fX - tangent.fY * sy, pos.fY + tangent.fX * sy);
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO
|
||||
|
||||
Need differentially more subdivisions when the follow-path is curvy. Not sure how to
|
||||
determine that, but we need it. I guess a cheap answer is let the caller tell us,
|
||||
but that seems like a cop-out. Another answer is to get Rob Johnson to figure it out.
|
||||
*/
|
||||
static void morphpath(SkPath* dst, const SkPath& src, SkPathMeasure& meas,
|
||||
const SkMatrix& matrix) {
|
||||
SkPath::Iter iter(src, false);
|
||||
SkPoint srcP[4], dstP[3];
|
||||
SkPath::Verb verb;
|
||||
|
||||
while ((verb = iter.next(srcP)) != SkPath::kDone_Verb) {
|
||||
switch (verb) {
|
||||
case SkPath::kMove_Verb:
|
||||
morphpoints(dstP, srcP, 1, meas, matrix);
|
||||
dst->moveTo(dstP[0]);
|
||||
break;
|
||||
case SkPath::kLine_Verb:
|
||||
// turn lines into quads to look bendy
|
||||
srcP[0].fX = SkScalarAve(srcP[0].fX, srcP[1].fX);
|
||||
srcP[0].fY = SkScalarAve(srcP[0].fY, srcP[1].fY);
|
||||
morphpoints(dstP, srcP, 2, meas, matrix);
|
||||
dst->quadTo(dstP[0], dstP[1]);
|
||||
break;
|
||||
case SkPath::kQuad_Verb:
|
||||
morphpoints(dstP, &srcP[1], 2, meas, matrix);
|
||||
dst->quadTo(dstP[0], dstP[1]);
|
||||
break;
|
||||
case SkPath::kConic_Verb:
|
||||
morphpoints(dstP, &srcP[1], 2, meas, matrix);
|
||||
dst->conicTo(dstP[0], dstP[1], iter.conicWeight());
|
||||
break;
|
||||
case SkPath::kCubic_Verb:
|
||||
morphpoints(dstP, &srcP[1], 3, meas, matrix);
|
||||
dst->cubicTo(dstP[0], dstP[1], dstP[2]);
|
||||
break;
|
||||
case SkPath::kClose_Verb:
|
||||
dst->close();
|
||||
break;
|
||||
default:
|
||||
SkDEBUGFAIL("unknown verb");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SkBaseDevice::drawTextOnPath(const void* text, size_t byteLength,
|
||||
const SkPath& follow, const SkMatrix* matrix,
|
||||
const SkPaint& paint) {
|
||||
SkASSERT(byteLength == 0 || text != nullptr);
|
||||
|
||||
// nothing to draw
|
||||
if (text == nullptr || byteLength == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
SkTextToPathIter iter((const char*)text, byteLength, paint, true);
|
||||
SkPathMeasure meas(follow, false);
|
||||
SkScalar hOffset = 0;
|
||||
|
||||
// need to measure first
|
||||
if (paint.getTextAlign() != SkPaint::kLeft_Align) {
|
||||
SkScalar pathLen = meas.getLength();
|
||||
if (paint.getTextAlign() == SkPaint::kCenter_Align) {
|
||||
pathLen = SkScalarHalf(pathLen);
|
||||
}
|
||||
hOffset += pathLen;
|
||||
}
|
||||
|
||||
const SkPath* iterPath;
|
||||
SkScalar xpos;
|
||||
SkMatrix scaledMatrix;
|
||||
SkScalar scale = iter.getPathScale();
|
||||
|
||||
scaledMatrix.setScale(scale, scale);
|
||||
|
||||
while (iter.next(&iterPath, &xpos)) {
|
||||
if (iterPath) {
|
||||
SkPath tmp;
|
||||
SkMatrix m(scaledMatrix);
|
||||
|
||||
tmp.setIsVolatile(true);
|
||||
m.postTranslate(xpos + hOffset, 0);
|
||||
if (matrix) {
|
||||
m.postConcat(*matrix);
|
||||
}
|
||||
morphpath(&tmp, *iterPath, meas, m);
|
||||
this->drawPath(tmp, iter.getPaint(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#include "SkUtils.h"
|
||||
|
||||
void SkBaseDevice::drawGlyphRunRSXform(SkGlyphRun* run, const SkRSXform* xform) {
|
||||
|
@ -231,11 +231,8 @@ protected:
|
||||
/** The SkDevice passed will be an SkDevice which was returned by a call to
|
||||
onCreateDevice on this device with kNeverTile_TileExpectation.
|
||||
*/
|
||||
virtual void drawDevice(SkBaseDevice*, int x, int y,
|
||||
const SkPaint&) = 0;
|
||||
virtual void drawDevice(SkBaseDevice*, int x, int y, const SkPaint&) = 0;
|
||||
|
||||
virtual void drawTextOnPath(const void* text, size_t len, const SkPath&,
|
||||
const SkMatrix*, const SkPaint&);
|
||||
void drawGlyphRunRSXform(SkGlyphRun* run, const SkRSXform* xform);
|
||||
|
||||
virtual void drawSpecial(SkSpecialImage*, int x, int y, const SkPaint&,
|
||||
|
@ -106,11 +106,6 @@ void SkLiteRecorder::onDrawPosTextH(const void* text, size_t bytes,
|
||||
const SkPaint& paint) {
|
||||
fDL->drawPosTextH(text, bytes, xs, y, paint);
|
||||
}
|
||||
void SkLiteRecorder::onDrawTextOnPath(const void* text, size_t bytes,
|
||||
const SkPath& path, const SkMatrix* matrix,
|
||||
const SkPaint& paint) {
|
||||
fDL->drawTextOnPath(text, bytes, path, matrix, paint);
|
||||
}
|
||||
void SkLiteRecorder::onDrawTextRSXform(const void* text, size_t bytes,
|
||||
const SkRSXform xform[], const SkRect* cull,
|
||||
const SkPaint& paint) {
|
||||
|
@ -51,8 +51,6 @@ public:
|
||||
void onDrawText (const void*, size_t, SkScalar x, SkScalar y, const SkPaint&) override;
|
||||
void onDrawPosText (const void*, size_t, const SkPoint[], const SkPaint&) override;
|
||||
void onDrawPosTextH (const void*, size_t, const SkScalar[], SkScalar, const SkPaint&) override;
|
||||
void onDrawTextOnPath(const void*, size_t,
|
||||
const SkPath&, const SkMatrix*, const SkPaint&) override;
|
||||
void onDrawTextRSXform(const void*, size_t,
|
||||
const SkRSXform[], const SkRect*, const SkPaint&) override;
|
||||
void onDrawTextBlob(const SkTextBlob*, SkScalar, SkScalar, const SkPaint&) override;
|
||||
|
@ -89,12 +89,6 @@ void SkOverdrawCanvas::onDrawPosTextH(const void* text, size_t byteLength, const
|
||||
this->drawPosTextCommon(text, byteLength, (SkScalar*) xs, 1, SkPoint::Make(0, y), paint);
|
||||
}
|
||||
|
||||
void SkOverdrawCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
|
||||
const SkMatrix* matrix, const SkPaint& paint) {
|
||||
SkASSERT(false);
|
||||
return;
|
||||
}
|
||||
|
||||
typedef int (*CountTextProc)(const char* text, const char* stop);
|
||||
static int count_utf16(const char* text, const char* stop) {
|
||||
const uint16_t* prev = (const uint16_t*)text;
|
||||
|
@ -49,7 +49,7 @@ enum DrawType {
|
||||
DRAW_RRECT,
|
||||
DRAW_SPRITE_RETIRED_2015_REMOVED_2018,
|
||||
DRAW_TEXT,
|
||||
DRAW_TEXT_ON_PATH,
|
||||
DRAW_TEXT_ON_PATH_RETIRED_08_2018,
|
||||
DRAW_TEXT_TOP_BOTTOM, // fast variant of DRAW_TEXT
|
||||
DRAW_VERTICES_RETIRED_03_2017_REMOVED_01_2018,
|
||||
RESTORE,
|
||||
|
@ -583,7 +583,7 @@ void SkPicturePlayback::handleOp(SkReadBuffer* reader,
|
||||
canvas->drawText(text.text(), text.length(), ptr[0], ptr[1], *paint);
|
||||
}
|
||||
} break;
|
||||
case DRAW_TEXT_ON_PATH: {
|
||||
case DRAW_TEXT_ON_PATH_RETIRED_08_2018: {
|
||||
const SkPaint* paint = fPictureData->getPaint(reader);
|
||||
TextContainer text(reader, paint);
|
||||
const SkPath& path = fPictureData->getPath(reader);
|
||||
|
@ -592,20 +592,6 @@ void SkPictureRecord::onDrawPosTextH(const void* text, size_t byteLength, const
|
||||
this->validate(initialOffset, size);
|
||||
}
|
||||
|
||||
void SkPictureRecord::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
|
||||
const SkMatrix* matrix, const SkPaint& paint) {
|
||||
// op + paint index + length + 'length' worth of data + path index + matrix
|
||||
const SkMatrix& m = matrix ? *matrix : SkMatrix::I();
|
||||
size_t size = 3 * kUInt32Size + SkAlign4(byteLength) + kUInt32Size +
|
||||
SkMatrixPriv::WriteToMemory(m, nullptr);
|
||||
size_t initialOffset = this->addDraw(DRAW_TEXT_ON_PATH, &size);
|
||||
this->addPaint(paint);
|
||||
this->addText(text, byteLength);
|
||||
this->addPath(path);
|
||||
this->addMatrix(m);
|
||||
this->validate(initialOffset, size);
|
||||
}
|
||||
|
||||
void SkPictureRecord::onDrawTextRSXform(const void* text, size_t byteLength,
|
||||
const SkRSXform xform[], const SkRect* cull,
|
||||
const SkPaint& paint) {
|
||||
|
@ -168,8 +168,6 @@ protected:
|
||||
void onDrawPosText(const void* text, size_t, const SkPoint pos[], const SkPaint&) override;
|
||||
void onDrawPosTextH(const void* text, size_t, const SkScalar xpos[], SkScalar constY,
|
||||
const SkPaint&) override;
|
||||
void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
|
||||
const SkMatrix* matrix, const SkPaint&) override;
|
||||
void onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[],
|
||||
const SkRect* cull, const SkPaint&) override;
|
||||
void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
|
||||
|
@ -280,16 +280,6 @@ void SkRecorder::onDrawPosTextH(const void* text, size_t byteLength,
|
||||
this->copy(xpos, points));
|
||||
}
|
||||
|
||||
void SkRecorder::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
|
||||
const SkMatrix* matrix, const SkPaint& paint) {
|
||||
this->append<SkRecords::DrawTextOnPath>(
|
||||
paint,
|
||||
this->copy((const char*)text, byteLength),
|
||||
byteLength,
|
||||
path,
|
||||
matrix ? *matrix : SkMatrix::I());
|
||||
}
|
||||
|
||||
void SkRecorder::onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[],
|
||||
const SkRect* cull, const SkPaint& paint) {
|
||||
this->append<SkRecords::DrawTextRSXform>(
|
||||
|
@ -81,11 +81,6 @@ public:
|
||||
const SkScalar xpos[],
|
||||
SkScalar constY,
|
||||
const SkPaint& paint) override;
|
||||
void onDrawTextOnPath(const void* text,
|
||||
size_t byteLength,
|
||||
const SkPath& path,
|
||||
const SkMatrix* matrix,
|
||||
const SkPaint& paint) override;
|
||||
void onDrawTextRSXform(const void* text,
|
||||
size_t byteLength,
|
||||
const SkRSXform[],
|
||||
|
@ -626,30 +626,6 @@ void SkPipeCanvas::onDrawPosTextH(const void* text, size_t byteLength, const SkS
|
||||
write_paint(writer, paint, kText_PaintUsage);
|
||||
}
|
||||
|
||||
void SkPipeCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
|
||||
const SkMatrix* matrix, const SkPaint& paint) {
|
||||
SkASSERT(byteLength > 0);
|
||||
|
||||
unsigned extra = 0;
|
||||
if (byteLength <= kTextLength_DrawTextOnPathMask) {
|
||||
extra |= byteLength;
|
||||
} // else we will write the length after the packedverb
|
||||
SkMatrix::TypeMask tm = matrix ? matrix->getType() : SkMatrix::kIdentity_Mask;
|
||||
extra |= (unsigned)tm << kMatrixType_DrawTextOnPathShift;
|
||||
|
||||
SkPipeWriter writer(this);
|
||||
writer.write32(pack_verb(SkPipeVerb::kDrawTextOnPath, extra));
|
||||
if (byteLength > kTextLength_DrawTextOnPathMask) {
|
||||
writer.write32(byteLength);
|
||||
}
|
||||
write_pad(&writer, text, byteLength);
|
||||
writer.writePath(path);
|
||||
if (matrix) {
|
||||
write_sparse_matrix(&writer, *matrix);
|
||||
}
|
||||
write_paint(writer, paint, kText_PaintUsage);
|
||||
}
|
||||
|
||||
void SkPipeCanvas::onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[],
|
||||
const SkRect* cull, const SkPaint& paint) {
|
||||
SkASSERT(byteLength);
|
||||
|
@ -111,8 +111,6 @@ protected:
|
||||
const SkPaint&) override;
|
||||
void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
|
||||
SkScalar constY, const SkPaint&) override;
|
||||
void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath&, const SkMatrix*,
|
||||
const SkPaint&) override;
|
||||
void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, const SkPaint&) override;
|
||||
void onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[],
|
||||
const SkRect* cull, const SkPaint& paint) override;
|
||||
|
@ -1003,43 +1003,6 @@ void SkSVGDevice::drawPosText(const void* text, size_t len,
|
||||
elem.addText(builder.text());
|
||||
}
|
||||
|
||||
void SkSVGDevice::drawTextOnPath(const void* text, size_t len, const SkPath& path,
|
||||
const SkMatrix* matrix, const SkPaint& paint) {
|
||||
SkString pathID = fResourceBucket->addPath();
|
||||
|
||||
{
|
||||
AutoElement defs("defs", fWriter);
|
||||
AutoElement pathElement("path", fWriter);
|
||||
pathElement.addAttribute("id", pathID);
|
||||
pathElement.addPathAttributes(path);
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
AutoElement textElement("text", fWriter);
|
||||
textElement.addTextAttributes(paint);
|
||||
|
||||
if (matrix && !matrix->isIdentity()) {
|
||||
textElement.addAttribute("transform", svg_transform(*matrix));
|
||||
}
|
||||
|
||||
{
|
||||
AutoElement textPathElement("textPath", fWriter);
|
||||
textPathElement.addAttribute("xlink:href", SkStringPrintf("#%s", pathID.c_str()));
|
||||
|
||||
if (paint.getTextAlign() != SkPaint::kLeft_Align) {
|
||||
SkASSERT(paint.getTextAlign() == SkPaint::kCenter_Align ||
|
||||
paint.getTextAlign() == SkPaint::kRight_Align);
|
||||
textPathElement.addAttribute("startOffset",
|
||||
paint.getTextAlign() == SkPaint::kCenter_Align ? "50%" : "100%");
|
||||
}
|
||||
|
||||
SVGTextBuilder builder(text, len, paint, SkPoint::Make(0, 0), 0);
|
||||
textPathElement.addText(builder.text());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SkSVGDevice::drawVertices(const SkVertices*, const SkVertices::Bone[], int, SkBlendMode,
|
||||
const SkPaint&) {
|
||||
// todo
|
||||
|
@ -39,9 +39,6 @@ protected:
|
||||
void drawPosText(const void* text, size_t len,
|
||||
const SkScalar pos[], int scalarsPerPos,
|
||||
const SkPoint& offset, const SkPaint& paint) override;
|
||||
void drawTextOnPath(const void* text, size_t len,
|
||||
const SkPath& path, const SkMatrix* matrix,
|
||||
const SkPaint& paint) override;
|
||||
void drawVertices(const SkVertices*, const SkVertices::Bone bones[], int boneCount, SkBlendMode,
|
||||
const SkPaint& paint) override;
|
||||
|
||||
|
@ -276,14 +276,6 @@ void SkLuaCanvas::onDrawPosTextH(const void* text, size_t byteLength, const SkSc
|
||||
lua.pushPaint(paint, "paint");
|
||||
}
|
||||
|
||||
void SkLuaCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
|
||||
const SkMatrix* matrix, const SkPaint& paint) {
|
||||
AUTO_LUA("drawTextOnPath");
|
||||
lua.pushPath(path, "path");
|
||||
lua.pushEncodedText(paint.getTextEncoding(), text, byteLength);
|
||||
lua.pushPaint(paint, "paint");
|
||||
}
|
||||
|
||||
void SkLuaCanvas::onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[],
|
||||
const SkRect* cull, const SkPaint& paint) {
|
||||
AUTO_LUA("drawTextRSXform");
|
||||
|
@ -281,14 +281,6 @@ void SkNWayCanvas::onDrawPosTextH(const void* text, size_t byteLength, const SkS
|
||||
}
|
||||
}
|
||||
|
||||
void SkNWayCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
|
||||
const SkMatrix* matrix, const SkPaint& paint) {
|
||||
Iter iter(fList);
|
||||
while (iter.next()) {
|
||||
iter->drawTextOnPath(text, byteLength, path, matrix, paint);
|
||||
}
|
||||
}
|
||||
|
||||
void SkNWayCanvas::onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[],
|
||||
const SkRect* cull, const SkPaint& paint) {
|
||||
Iter iter(fList);
|
||||
|
@ -233,14 +233,6 @@ void SkPaintFilterCanvas::onDrawPosTextH(const void* text, size_t byteLength, co
|
||||
}
|
||||
}
|
||||
|
||||
void SkPaintFilterCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
|
||||
const SkMatrix* matrix, const SkPaint& paint) {
|
||||
AutoPaintFilter apf(this, kText_Type, paint);
|
||||
if (apf.shouldDraw()) {
|
||||
this->SkNWayCanvas::onDrawTextOnPath(text, byteLength, path, matrix, *apf.paint());
|
||||
}
|
||||
}
|
||||
|
||||
void SkPaintFilterCanvas::onDrawTextRSXform(const void* text, size_t byteLength,
|
||||
const SkRSXform xform[], const SkRect* cull,
|
||||
const SkPaint& paint) {
|
||||
|
@ -422,12 +422,6 @@ void SkDebugCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x,
|
||||
this->addDrawCommand(new SkDrawTextCommand(text, byteLength, x, y, paint));
|
||||
}
|
||||
|
||||
void SkDebugCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
|
||||
const SkMatrix* matrix, const SkPaint& paint) {
|
||||
this->addDrawCommand(
|
||||
new SkDrawTextOnPathCommand(text, byteLength, path, matrix, paint));
|
||||
}
|
||||
|
||||
void SkDebugCanvas::onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform xform[],
|
||||
const SkRect* cull, const SkPaint& paint) {
|
||||
this->addDrawCommand(new SkDrawTextRSXformCommand(text, byteLength, xform, cull, paint));
|
||||
|
@ -130,8 +130,6 @@ protected:
|
||||
const SkPaint&) override;
|
||||
void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[],
|
||||
SkScalar constY, const SkPaint&) override;
|
||||
void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path,
|
||||
const SkMatrix* matrix, const SkPaint&) override;
|
||||
void onDrawTextRSXform(const void* text, size_t byteLength, const SkRSXform[], const SkRect*,
|
||||
const SkPaint&) override;
|
||||
void onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
|
||||
|
Loading…
Reference in New Issue
Block a user