diff options
author | reed <reed@chromium.org> | 2015-02-10 17:44:26 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-10 17:44:26 -0800 |
commit | 8ed666d230231c7280069236f265a61edb8a9a20 (patch) | |
tree | a58f6052bc07de0f8dc8d97fe900f9b8b2179f49 /gm/addarc.cpp | |
parent | 8432808ad8898ac7137bc7ce1d9df6005e866401 (diff) |
add gm for stroked circles that are zoomed
BUG=skia:
TBR=
Review URL: https://codereview.chromium.org/912203002
Diffstat (limited to 'gm/addarc.cpp')
-rw-r--r-- | gm/addarc.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/gm/addarc.cpp b/gm/addarc.cpp index aef7916da5..67d752aeb1 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; ) |