From 40b7d3b48b522e233ee63d2c88cff82c4bd5fb15 Mon Sep 17 00:00:00 2001 From: caryclark Date: Tue, 22 Dec 2015 06:13:33 -0800 Subject: 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 --- gm/strokes.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'gm/strokes.cpp') 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: -- cgit v1.2.3