reed | 5e0d927 | 2016-08-18 15:01:10 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2016 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
| 8 | #include "gm.h" |
| 9 | #include "SkBlurMask.h" |
| 10 | #include "SkBlurMaskFilter.h" |
| 11 | #include "SkPath.h" |
| 12 | |
| 13 | class SimpleRectGM : public skiagm::GM { |
| 14 | public: |
| 15 | SimpleRectGM() {} |
| 16 | |
| 17 | protected: |
| 18 | SkString onShortName() override { |
| 19 | SkString name; |
| 20 | name.printf("simplerect"); |
| 21 | return name; |
| 22 | } |
| 23 | |
| 24 | SkISize onISize() override { |
| 25 | return SkISize::Make(800, 600); |
| 26 | } |
| 27 | |
| 28 | void onDraw(SkCanvas* canvas) override { |
| 29 | const SkScalar min = -20; |
| 30 | const SkScalar max = 800; |
| 31 | const SkScalar size = 20; |
| 32 | |
| 33 | SkRandom rand; |
| 34 | SkPaint paint; |
| 35 | for (int i = 0; i < 10000; i++) { |
| 36 | paint.setColor(sk_tool_utils::color_to_565(rand.nextU() | (0xFF << 24))); |
| 37 | canvas->drawRect(SkRect::MakeXYWH(rand.nextRangeScalar(min, max), |
| 38 | rand.nextRangeScalar(min, max), |
| 39 | rand.nextRangeScalar(0, size), |
| 40 | rand.nextRangeScalar(0, size)), |
| 41 | paint); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | bool onAnimate(const SkAnimTimer& timer) override { |
| 46 | return true; |
| 47 | } |
| 48 | |
| 49 | private: |
| 50 | |
| 51 | typedef GM INHERITED; |
| 52 | }; |
| 53 | DEF_GM(return new SimpleRectGM;) |