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

Unified Diff: gm/addarc.cpp

Issue 931183002: add gm for path-arcs, and catch degenerate arc in conic-case (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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 | include/core/SkPath.h » ('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 67d752aeb1f32224122b9fe05774b56b5205a8b9..fea15bacb727bae6b1a15402b47b2353c428c22a 100644
--- a/gm/addarc.cpp
+++ b/gm/addarc.cpp
@@ -162,3 +162,71 @@ private:
typedef skiagm::GM INHERITED;
};
DEF_GM( return new StrokeCircleGM; )
+
+//////////////////////
+
+static void arc(SkPath* path, SkScalar x, SkScalar y, SkScalar r, SkScalar start, SkScalar end,
+ bool ccw) {
+ SkRect bounds = { x - r, y - r, x + r, y + r };
+ SkScalar sweep = ccw ? end - start : start - end;
+ path->arcTo(bounds, start, sweep, false);
+}
+
robertphillips 2015/02/17 17:33:45 Which one?
reed2 2015/02/17 18:35:36 Done.
+// Lifted from layouttest
+class ManyArcsGM : public skiagm::GM {
+public:
+ ManyArcsGM() {}
+
+protected:
+ SkString onShortName() SK_OVERRIDE { return SkString("manyarcs"); }
+
+ SkISize onISize() SK_OVERRIDE { return SkISize::Make(620, 330); }
+
+ void onDraw(SkCanvas* canvas) SK_OVERRIDE {
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setStyle(SkPaint::kStroke_Style);
+
+ canvas->translate(10, 10);
+
+ // 20 angles.
+ SkScalar sweepAngles[] = {
+ -123.7, -2.3, -2, -1, -0.3, -0.000001, 0, 0.000001, 0.3, 0.7,
+ 1, 1.3, 1.5, 1.7, 1.99999, 2, 2.00001, 2.3, 4.3, 3934723942837.3
+ };
+ for (size_t i = 0; i < SK_ARRAY_COUNT(sweepAngles); ++i) {
+ sweepAngles[i] *= 180;
+ }
+
+ SkScalar startAngles[] = { -1, -0.5, 0, 0.5 };
+ for (size_t i = 0; i < SK_ARRAY_COUNT(startAngles); ++i) {
+ startAngles[i] *= 180;
+ }
+
+ bool anticlockwise = false;
+ SkScalar sign = 1;
+ for (size_t i = 0; i < SK_ARRAY_COUNT(startAngles) * 2; ++i) {
+ if (i == SK_ARRAY_COUNT(startAngles)) {
+ anticlockwise = true;
+ sign = -1;
+ }
+ SkScalar startAngle = startAngles[i % SK_ARRAY_COUNT(startAngles)] * sign;
+ canvas->save();
+ for (size_t j = 0; j < SK_ARRAY_COUNT(sweepAngles); ++j) {
+ SkPath path;
+ path.moveTo(0, 2);
robertphillips 2015/02/17 17:33:45 overlength ?
reed2 2015/02/17 18:35:36 Not sure what you mean.
reed2 2015/02/17 18:55:20 Done.
+ arc(&path, 18, 15, 10, startAngle, startAngle + (sweepAngles[j] * sign), anticlockwise);
+ path.lineTo(0, 28);
+ canvas->drawPath(path, paint);
+ canvas->translate(30, 0);
+ }
+ canvas->restore();
+ canvas->translate(0, 40);
+ }
+ }
+
+private:
+ typedef skiagm::GM INHERITED;
+};
+DEF_GM( return new ManyArcsGM; )
+
« no previous file with comments | « no previous file | include/core/SkPath.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698