aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/strokes.cpp
diff options
context:
space:
mode:
authorGravatar caryclark <caryclark@google.com>2015-12-22 06:13:33 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-12-22 06:13:33 -0800
commit40b7d3b48b522e233ee63d2c88cff82c4bd5fb15 (patch)
tree1112e387259788d114c81e8e6b1dfb2172462057 /gm/strokes.cpp
parent83ba585ecbf0270261196cf90ceaeeb22d345452 (diff)
fix hair fuzz
If the end and control points of a quad, conic, or cubic are the same, adjust all of them when stretching the curve to account for a square or round end cap. If all of the points are the same, move all but the last. Enlarge the clip check to account for the cap. The clip bug was detected by ASAN. R=reed@google.com, msarett@google.com BUG=571214 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1547483003 Review URL: https://codereview.chromium.org/1547483003
Diffstat (limited to 'gm/strokes.cpp')
-rw-r--r--gm/strokes.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/gm/strokes.cpp b/gm/strokes.cpp
index f2abb0b7dd..261db9c69d 100644
--- a/gm/strokes.cpp
+++ b/gm/strokes.cpp
@@ -236,6 +236,38 @@ DEF_SIMPLE_GM(zerolinestroke, canvas, 90, 120) {
canvas->drawPath(path, paint);
}
+DEF_SIMPLE_GM(quadcap, canvas, 200, 200) {
+ SkPaint p;
+ p.setAntiAlias(true);
+ p.setStyle(SkPaint::kStroke_Style);
+ p.setStrokeWidth(0);
+ SkPath path;
+ SkPoint pts[] = {{105.738571f,13.126318f},
+ {105.738571f,13.126318f},
+ {123.753784f,1.f}};
+ SkVector tangent = pts[1] - pts[2];
+ tangent.normalize();
+ SkPoint pts2[3];
+ memcpy(pts2, pts, sizeof(pts));
+ const SkScalar capOutset = SK_ScalarPI / 8;
+ pts2[0].fX += tangent.fX * capOutset;
+ pts2[0].fY += tangent.fY * capOutset;
+ pts2[1].fX += tangent.fX * capOutset;
+ pts2[1].fY += tangent.fY * capOutset;
+ pts2[2].fX += -tangent.fX * capOutset;
+ pts2[2].fY += -tangent.fY * capOutset;
+ path.moveTo(pts2[0]);
+ path.quadTo(pts2[1], pts2[2]);
+ canvas->drawPath(path, p);
+
+ path.reset();
+ path.moveTo(pts[0]);
+ path.quadTo(pts[1], pts[2]);
+ p.setStrokeCap(SkPaint::kRound_Cap);
+ canvas->translate(30, 0);
+ canvas->drawPath(path, p);
+}
+
class Strokes2GM : public skiagm::GM {
SkPath fPath;
protected: