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

Unified Diff: gm/addarc.cpp

Issue 2386293002: Add GMs for Analytic Anti-Aliasing (Closed)
Patch Set: SkScalar 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') | no next file » | 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..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 };
« gm/aaa.cpp ('K') | « gm/aaa.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698