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

Unified Diff: gm/addarc.cpp

Issue 2221103002: Analytic AntiAlias for Convex Shapes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Simplify gm 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
« gm/aaa.cpp ('K') | « gm/aaa.cpp ('k') | gyp/core.gypi » ('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 9280140794af70413a949847c64fde74d9171efd..bb973089c98bcf541ebaeaad44cdf5c153fe840a 100644
--- a/gm/addarc.cpp
+++ b/gm/addarc.cpp
@@ -163,6 +163,54 @@ private:
};
DEF_GM( return new StrokeCircleGM; )
+// Fill circles and rotate them to test our Analytic Anti-Aliasing
+class FillCircleGM : public skiagm::GM {
+public:
+ FillCircleGM() : fRotate(0) {}
+
+protected:
+ SkString onShortName() override { return SkString("fillcircle"); }
+
+ SkISize onISize() override { return SkISize::Make(520, 520); }
+
+ void onDraw(SkCanvas* canvas) override {
+ canvas->scale(20, 20);
+ canvas->translate(13, 13);
+
+ SkPaint paint;
+ paint.setAntiAlias(true);
+ paint.setStyle(SkPaint::kStroke_Style);
+ paint.setStrokeWidth(SK_Scalar1 / 2);
+
+ const SkScalar delta = paint.getStrokeWidth() * 3 / 2;
+ SkRect r = SkRect::MakeXYWH(-12, -12, 24, 24);
+ SkRandom rand;
+
+ SkScalar sign = 1;
+ while (r.width() > paint.getStrokeWidth() * 2) {
+ SkAutoCanvasRestore acr(canvas, true);
+ canvas->rotate(fRotate * sign);
+
+ paint.setColor(sk_tool_utils::color_to_565(rand.nextU() | (0xFF << 24)));
+ paint.setStyle(SkPaint::kFill_Style);
+ canvas->drawOval(r, paint);
+ r.inset(delta, delta);
+ sign = -sign;
+ }
+ }
+
+ bool onAnimate(const SkAnimTimer& timer) override {
+ fRotate = timer.scaled(60, 360);
+ return true;
+ }
+
+private:
+ SkScalar fRotate;
+
+ typedef skiagm::GM INHERITED;
+};
+DEF_GM( return new FillCircleGM; )
+
//////////////////////
static void html_canvas_arc(SkPath* path, SkScalar x, SkScalar y, SkScalar r, SkScalar start,
« gm/aaa.cpp ('K') | « gm/aaa.cpp ('k') | gyp/core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698