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

Unified Diff: gm/addarc.cpp

Issue 2388833002: Fix SkPath::arcTo when sweepAngle is tiny and radius is big (Closed)
Patch Set: fix compile error on win Created 4 years, 2 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/SkPath.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/addarc.cpp
diff --git a/gm/addarc.cpp b/gm/addarc.cpp
index 0a1876b2dc9367cf591867dd0ef674028ec6905e..ff67af22fcde36df7bd7c68937bb3ed79b7c4508 100644
--- a/gm/addarc.cpp
+++ b/gm/addarc.cpp
@@ -219,10 +219,13 @@ DEF_GM( return new FillCircleGM; )
//////////////////////
static void html_canvas_arc(SkPath* path, SkScalar x, SkScalar y, SkScalar r, SkScalar start,
- SkScalar end, bool ccw) {
+ SkScalar end, bool ccw, bool callArcTo) {
SkRect bounds = { x - r, y - r, x + r, y + r };
SkScalar sweep = ccw ? end - start : start - end;
- path->arcTo(bounds, start, sweep, false);
+ if (callArcTo)
+ path->arcTo(bounds, start, sweep, false);
+ else
+ path->addArc(bounds, start, sweep);
}
// Lifted from canvas-arc-circumference-fill-diffs.html
@@ -269,7 +272,7 @@ protected:
SkPath path;
path.moveTo(0, 2);
html_canvas_arc(&path, 18, 15, 10, startAngle, startAngle + (sweepAngles[j] * sign),
- anticlockwise);
+ anticlockwise, true);
path.lineTo(0, 28);
canvas->drawPath(path, paint);
canvas->translate(30, 0);
@@ -283,3 +286,37 @@ private:
typedef skiagm::GM INHERITED;
};
DEF_GM( return new ManyArcsGM; )
+
+// Lifted from https://bugs.chromium.org/p/chromium/issues/detail?id=640031
+class TinyAngleBigRadiusArcsGM : public skiagm::GM {
+public:
+ TinyAngleBigRadiusArcsGM() {}
+
+protected:
+ SkString onShortName() override { return SkString("tinyanglearcs"); }
+
+ SkISize onISize() override { return SkISize::Make(620, 330); }
+
+ void onDraw(SkCanvas* canvas) override {
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setStyle(SkPaint::kStroke_Style);
+
+ canvas->translate(50, 50);
+
+ SkPath path;
+ path.moveTo(50, 20);
+ path.lineTo(50, 0);
+ // A combination of tiny sweepAngle + large radius, we should draw a line.
+ html_canvas_arc(&path, 50, 100000, 100000, 270, 270.0f - 0.00572957795f,
+ false, true);
+ path.lineTo(60, 20);
+ html_canvas_arc(&path, 50, 100000, 99980, 270.0f - 0.00572957795f, 270,
+ false, false);
+ canvas->drawPath(path, paint);
+ }
+
+private:
+ typedef skiagm::GM INHERITED;
+};
+DEF_GM( return new TinyAngleBigRadiusArcsGM; )
« no previous file with comments | « no previous file | src/core/SkPath.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698