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

Unified Diff: src/core/SkScan_Hairline.cpp

Issue 1547483003: fix hair fuzz (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: handle case where all points are equal Created 5 years 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 | « gm/strokes.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkScan_Hairline.cpp
diff --git a/src/core/SkScan_Hairline.cpp b/src/core/SkScan_Hairline.cpp
index c59521abc7b3413fb072acbd7fd648e1e276b514..12553a4a54f1d1e1fbd78d54edce348bd7adb82e 100644
--- a/src/core/SkScan_Hairline.cpp
+++ b/src/core/SkScan_Hairline.cpp
@@ -428,11 +428,15 @@ void extend_pts(SkPath::Verb prevVerb, SkPath::Verb nextVerb, SkPoint* pts, int
} while (tangent.isZero() && --controls > 0);
if (tangent.isZero()) {
tangent.set(1, 0);
+ controls = ptCount - 1; // If all points are equal, move all but one
} else {
tangent.normalize();
}
- first->fX += tangent.fX * capOutset;
- first->fY += tangent.fY * capOutset;
+ do { // If the end point and control points are equal, loop to move them in tandem.
+ first->fX += tangent.fX * capOutset;
+ first->fY += tangent.fY * capOutset;
+ ++first;
+ } while (++controls < ptCount);
}
if (SkPath::kMove_Verb == nextVerb || SkPath::kDone_Verb == nextVerb) {
SkPoint* last = &pts[ptCount - 1];
@@ -444,11 +448,15 @@ void extend_pts(SkPath::Verb prevVerb, SkPath::Verb nextVerb, SkPoint* pts, int
} while (tangent.isZero() && --controls > 0);
if (tangent.isZero()) {
tangent.set(-1, 0);
+ controls = ptCount - 1;
} else {
tangent.normalize();
}
- last->fX += tangent.fX * capOutset;
- last->fY += tangent.fY * capOutset;
+ do {
+ last->fX += tangent.fX * capOutset;
+ last->fY += tangent.fY * capOutset;
+ --last;
+ } while (++controls < ptCount);
}
}
@@ -466,8 +474,8 @@ void hair_path(const SkPath& path, const SkRasterClip& rclip, SkBlitter* blitter
const SkRect* outsetClip = nullptr;
{
- const SkIRect ibounds = path.getBounds().roundOut().makeOutset(1, 1);
-
+ const int capOut = SkPaint::kButt_Cap == capStyle ? 1 : 2;
+ const SkIRect ibounds = path.getBounds().roundOut().makeOutset(capOut, capOut);
if (rclip.quickReject(ibounds)) {
return;
}
« no previous file with comments | « gm/strokes.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698