Index: gm/addarc.cpp |
diff --git a/gm/addarc.cpp b/gm/addarc.cpp |
index 9280140794af70413a949847c64fde74d9171efd..0a1876b2dc9367cf591867dd0ef674028ec6905e 100644 |
--- a/gm/addarc.cpp |
+++ b/gm/addarc.cpp |
@@ -165,6 +165,59 @@ DEF_GM( return new StrokeCircleGM; ) |
////////////////////// |
+// 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); |
+ |
robertphillips
2016/10/07 14:12:46
Don't we just know strokeWidth is SK_Scalar1 / 2 (
liyuqian
2016/10/07 14:15:50
Yes, I was just copying from the StrokeCircleGM wh
|
+ 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 }; |