diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2010-05-10 11:17:23 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2010-05-10 11:17:23 -0700 |
commit | ff1f66966879e612660387285b7ead9c040ff88f (patch) | |
tree | f4263db3bc1eedcdde086934dc17652795f9e0de /src/core/SkDraw.cpp | |
parent | 7ef57352294644757b279dd22931b6f82a78c6ba (diff) | |
parent | 97615b8c5e62abbb520ab3d538f78b420994f6b4 (diff) | |
download | external_skia-ff1f66966879e612660387285b7ead9c040ff88f.zip external_skia-ff1f66966879e612660387285b7ead9c040ff88f.tar.gz external_skia-ff1f66966879e612660387285b7ead9c040ff88f.tar.bz2 |
merge from open-source master
Change-Id: I064902aa9745342ccfe868331ccc000767e92fc0
Diffstat (limited to 'src/core/SkDraw.cpp')
-rw-r--r-- | src/core/SkDraw.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/core/SkDraw.cpp b/src/core/SkDraw.cpp index 45b4c35..301c0e4 100644 --- a/src/core/SkDraw.cpp +++ b/src/core/SkDraw.cpp @@ -1870,6 +1870,68 @@ void SkDraw::drawTextOnPath(const char text[], size_t byteLength, } } +void SkDraw::drawPosTextOnPath(const char text[], size_t byteLength, + const SkPoint pos[], const SkPaint& paint, + const SkPath& path, const SkMatrix* matrix) const { + // nothing to draw + if (text == NULL || byteLength == 0 || fClip->isEmpty() || + (paint.getAlpha() == 0 && paint.getXfermode() == NULL)) { + return; + } + + SkMatrix scaledMatrix; + SkPathMeasure meas(path, false); + + SkMeasureCacheProc glyphCacheProc = paint.getMeasureCacheProc( + SkPaint::kForward_TextBufferDirection, true); + + // Copied (modified) from SkTextToPathIter constructor to setup paint + SkPaint tempPaint(paint); + + tempPaint.setLinearText(true); + tempPaint.setMaskFilter(NULL); // don't want this affecting our path-cache lookup + + if (tempPaint.getPathEffect() == NULL && !(tempPaint.getStrokeWidth() > 0 + && tempPaint.getStyle() != SkPaint::kFill_Style)) { + tempPaint.setStyle(SkPaint::kFill_Style); + tempPaint.setPathEffect(NULL); + } + // End copied from SkTextToPathIter constructor + + // detach cache + SkGlyphCache* cache = tempPaint.detachCache(NULL); + + // Must set scale, even if 1 + SkScalar scale = SK_Scalar1; + scaledMatrix.setScale(scale, scale); + + // Loop over all glyph ids + for (const char* stop = text + byteLength; text < stop; pos++) { + + const SkGlyph& glyph = glyphCacheProc(cache, &text); + SkPath tmp; + + const SkPath* glyphPath = cache->findPath(glyph); + if (glyphPath == NULL) { + continue; + } + + SkMatrix m(scaledMatrix); + m.postTranslate(pos->fX, 0); + + if (matrix) { + m.postConcat(*matrix); + } + + morphpath(&tmp, *glyphPath, meas, m); + this->drawPath(tmp, tempPaint); + + } + + // re-attach cache + SkGlyphCache::AttachCache(cache); +} + /////////////////////////////////////////////////////////////////////////////// struct VertState { |