aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar caryclark <caryclark@google.com>2016-03-16 07:34:02 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-03-16 07:34:02 -0700
commitd7ea92f2ff8ba41783296ff8e6203a59a5549c1a (patch)
treec712e4c9885d0e430f5b8e367b91de3bbffb5b72
parent523fa2a332d9c621bb871337893270a2bde31ea1 (diff)
pass cap to dash text
Pass the paint cap parameter through to text rendering so that dashed text draws correctly. R=bungeman@google.com BUG=226341 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1776983002 Review URL: https://codereview.chromium.org/1776983002
-rw-r--r--gm/dashing.cpp14
-rw-r--r--src/core/SkPaint.cpp2
-rw-r--r--src/core/SkScalerContext.cpp6
-rw-r--r--src/core/SkScalerContext.h3
4 files changed, 21 insertions, 4 deletions
diff --git a/gm/dashing.cpp b/gm/dashing.cpp
index e44e356b87..0e249c7d61 100644
--- a/gm/dashing.cpp
+++ b/gm/dashing.cpp
@@ -528,6 +528,20 @@ DEF_SIMPLE_GM(longwavyline, canvas, 512, 512) {
canvas->drawPath(wavy, p);
}
+DEF_SIMPLE_GM(dashtextcaps, canvas, 512, 512) {
+ SkPaint p;
+ p.setAntiAlias(true);
+ p.setStyle(SkPaint::kStroke_Style);
+ p.setStrokeWidth(10);
+ p.setStrokeCap(SkPaint::kRound_Cap);
+ p.setTextSize(100);
+ p.setARGB(0xff, 0xbb, 0x00, 0x00);
+ const SkScalar intervals[] = { 12, 12 };
+ p.setPathEffect(SkDashPathEffect::Create(intervals, SK_ARRAY_COUNT(intervals), 0))->unref();
+ canvas->drawText("Sausages", 8, 10, 90, p);
+ canvas->drawLine(8, 120, 456, 120, p);
+}
+
//////////////////////////////////////////////////////////////////////////////
DEF_GM(return new DashingGM;)
diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp
index f7959429a7..5e813f78c4 100644
--- a/src/core/SkPaint.cpp
+++ b/src/core/SkPaint.cpp
@@ -1356,6 +1356,7 @@ void SkScalerContext::MakeRec(const SkPaint& paint,
rec->fFrameWidth = strokeWidth;
rec->fMiterLimit = paint.getStrokeMiter();
rec->fStrokeJoin = SkToU8(paint.getStrokeJoin());
+ rec->fStrokeCap = SkToU8(paint.getStrokeCap());
if (style == SkPaint::kStrokeAndFill_Style) {
flags |= SkScalerContext::kFrameAndFill_Flag;
@@ -1364,6 +1365,7 @@ void SkScalerContext::MakeRec(const SkPaint& paint,
rec->fFrameWidth = 0;
rec->fMiterLimit = 0;
rec->fStrokeJoin = 0;
+ rec->fStrokeCap = 0;
}
rec->fMaskFormat = SkToU8(compute_mask_format(paint));
diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp
index c67ca3e9fa..a479c3782f 100644
--- a/src/core/SkScalerContext.cpp
+++ b/src/core/SkScalerContext.cpp
@@ -100,9 +100,9 @@ SkScalerContext::SkScalerContext(SkTypeface* typeface, const SkDescriptor* desc)
SkDebugf(" textsize %g prescale %g preskew %g post [%g %g %g %g]\n",
rec->fTextSize, rec->fPreScaleX, rec->fPreSkewX, rec->fPost2x2[0][0],
rec->fPost2x2[0][1], rec->fPost2x2[1][0], rec->fPost2x2[1][1]);
- SkDebugf(" frame %g miter %g hints %d framefill %d format %d join %d\n",
+ SkDebugf(" frame %g miter %g hints %d framefill %d format %d join %d cap %d\n",
rec->fFrameWidth, rec->fMiterLimit, rec->fHints, rec->fFrameAndFill,
- rec->fMaskFormat, rec->fStrokeJoin);
+ rec->fMaskFormat, rec->fStrokeJoin, rec->fStrokeCap);
SkDebugf(" pathEffect %x maskFilter %x\n",
desc->findEntry(kPathEffect_SkDescriptorTag, nullptr),
desc->findEntry(kMaskFilter_SkDescriptorTag, nullptr));
@@ -635,7 +635,7 @@ void SkScalerContext::internalGetPath(const SkGlyph& glyph, SkPath* fillPath,
SkToBool(fRec.fFlags & kFrameAndFill_Flag));
// glyphs are always closed contours, so cap type is ignored,
// so we just pass something.
- rec.setStrokeParams(SkPaint::kButt_Cap,
+ rec.setStrokeParams((SkPaint::Cap)fRec.fStrokeCap,
(SkPaint::Join)fRec.fStrokeJoin,
fRec.fMiterLimit);
}
diff --git a/src/core/SkScalerContext.h b/src/core/SkScalerContext.h
index 9249bfb2a9..f2df93cef3 100644
--- a/src/core/SkScalerContext.h
+++ b/src/core/SkScalerContext.h
@@ -79,7 +79,8 @@ struct SkScalerContextRec {
}
uint8_t fMaskFormat;
- uint8_t fStrokeJoin;
+ uint8_t fStrokeJoin : 4;
+ uint8_t fStrokeCap : 4;
uint16_t fFlags;
// Warning: when adding members note that the size of this structure
// must be a multiple of 4. SkDescriptor requires that its arguments be