Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Unified Diff: src/core/SkDraw.cpp

Issue 20693003: Fix several issues with drawing text as paths. Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkPaint.cpp » ('j') | src/core/SkPaint.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkDraw.cpp
===================================================================
--- src/core/SkDraw.cpp (revision 10398)
+++ src/core/SkDraw.cpp (working copy)
@@ -2108,7 +2108,7 @@
void SkDraw::drawTextOnPath(const char text[], size_t byteLength,
const SkPath& follow, const SkMatrix* matrix,
- const SkPaint& paint) const {
+ const SkPaint& origPaint) const {
SkASSERT(byteLength == 0 || text != NULL);
// nothing to draw
@@ -2116,7 +2116,11 @@
return;
}
+ // setup our std paint, in hopes of getting hits in the cache
+ SkPaint paint(origPaint);
+ SkScalar textScale = paint.setupForAsPaths();
SkTextToPathIter iter(text, byteLength, paint, true);
+
SkPathMeasure meas(follow, false);
SkScalar hOffset = 0;
@@ -2129,19 +2133,19 @@
hOffset += pathLen;
}
- const SkPath* iterPath;
- SkScalar xpos;
- SkMatrix scaledMatrix;
- SkScalar scale = iter.getPathScale();
+ SkScalar scale = iter.getPathScale();
+ SkMatrix scaledMatrix;
+ scaledMatrix.setScale(scale * textScale, scale * textScale);
- scaledMatrix.setScale(scale, scale);
-
+ const SkPath* iterPath;
+ SkScalar xpos;
while (iter.next(&iterPath, &xpos)) {
if (iterPath) {
SkPath tmp;
SkMatrix m(scaledMatrix);
- m.postTranslate(xpos + hOffset, 0);
+ SkScalar xposScaled = xpos * textScale;
+ m.postTranslate(xposScaled + hOffset, 0);
if (matrix) {
m.postConcat(*matrix);
}
« no previous file with comments | « no previous file | src/core/SkPaint.cpp » ('j') | src/core/SkPaint.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698