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

Unified Diff: gm/addarc.cpp

Issue 912203002: add gm for stroked circles that are zoomed (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 | 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 aef7916da5318001e759e1159d518925c63153f9..67d752aeb1f32224122b9fe05774b56b5205a8b9 100644
--- a/gm/addarc.cpp
+++ b/gm/addarc.cpp
@@ -111,3 +111,54 @@ private:
typedef skiagm::GM INHERITED;
};
DEF_GM( return new AddArcMeasGM; )
+
+///////////////////////////////////////////////////
+
+// Emphasize drawing a stroked oval (containing conics) and then scaling the results up,
+// to ensure that we compute the stroke taking the CTM into account
+//
+class StrokeCircleGM : public skiagm::GM {
+public:
+ StrokeCircleGM() : fRotate(0) {}
+
+protected:
+ SkString onShortName() SK_OVERRIDE { return SkString("strokecircle"); }
+
+ SkISize onISize() SK_OVERRIDE { return SkISize::Make(520, 520); }
+
+ void onDraw(SkCanvas* canvas) SK_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(rand.nextU() | (0xFF << 24));
+ canvas->drawOval(r, paint);
+ r.inset(delta, delta);
+ sign = -sign;
+ }
+ }
+
+ bool onAnimate(const SkAnimTimer& timer) SK_OVERRIDE {
+ fRotate = timer.scaled(60, 360);
+ return true;
+ }
+
+private:
+ SkScalar fRotate;
+
+ typedef skiagm::GM INHERITED;
+};
+DEF_GM( return new StrokeCircleGM; )
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698