Add GMs for Analytic Anti-Aliasing

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2386293002

Review-Url: https://codereview.chromium.org/2386293002
diff --git a/gm/aaa.cpp b/gm/aaa.cpp
new file mode 100644
index 0000000..d49d3f0
--- /dev/null
+++ b/gm/aaa.cpp
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2014 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "gm.h"
+#include "SkPath.h"
+#include "SkScan.h"
+
+#define W   800
+#define H   800
+
+class AnalyticAntiAliasConvexGM : public skiagm::GM {
+public:
+    AnalyticAntiAliasConvexGM() {}
+
+protected:
+
+    SkString onShortName() override {
+        return SkString("analytic_antialias_convex");
+    }
+
+    SkISize onISize() override {
+        return SkISize::Make(W, H);
+    }
+
+    void onDraw(SkCanvas* canvas) override {
+        SkPaint p;
+        p.setColor(SK_ColorRED);
+        p.setAntiAlias(true);
+
+        canvas->clear(0xFFFFFFFF);
+
+        canvas->save();
+
+        SkScalar y = 0;
+
+        canvas->translate(0, y);
+        canvas->rotate(1);
+        canvas->drawRectCoords(20, 20, 200, 200, p);
+        canvas->restore();
+
+        y += 200;
+
+        canvas->translate(0, y);
+        canvas->rotate(1);
+        canvas->drawRectCoords(20, 20, 20.2f, 200, p);
+        canvas->drawRectCoords(20, 200, 200, 200.1f, p);
+        canvas->drawCircle(100, 100, 30, p);
+        canvas->restore();
+    }
+
+private:
+    typedef skiagm::GM INHERITED;
+};
+
+DEF_GM( return new AnalyticAntiAliasConvexGM; )
diff --git a/gm/addarc.cpp b/gm/addarc.cpp
index 9280140..0a1876b 100644
--- a/gm/addarc.cpp
+++ b/gm/addarc.cpp
@@ -165,6 +165,59 @@
 
 //////////////////////
 
+// Fill circles and rotate them to test our Analytic Anti-Aliasing.
+// This test is based on StrokeCircleGM.
+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 strokeWidth = paint.getStrokeWidth();
+        const SkScalar delta = strokeWidth * 3 / 2;
+        SkRect r = SkRect::MakeXYWH(-12, -12, 24, 24);
+        SkRandom rand;
+
+        // Reset style to fill. We only need stroke stype for producing delta and strokeWidth
+        paint.setStyle(SkPaint::kFill_Style);
+
+        SkScalar sign = 1;
+        while (r.width() > strokeWidth * 2) {
+            SkAutoCanvasRestore acr(canvas, true);
+            canvas->rotate(fRotate * sign);
+            paint.setColor(sk_tool_utils::color_to_565(rand.nextU() | (0xFF << 24)));
+            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,
                             SkScalar end, bool ccw) {
     SkRect bounds = { x - r, y - r, x + r, y + r };