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 { |
reed | c1fb8e8 | 2016-08-18 19:35:52 -0700 | [diff] [blame] | 25 | return SkISize::Make(800, 800); |
reed | 5e0d927 | 2016-08-18 15:01:10 -0700 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | void onDraw(SkCanvas* canvas) override { |
reed | 577e012 | 2016-08-21 15:03:47 -0700 | [diff] [blame] | 29 | canvas->translate(1, 1); // want to exercise non-identity ctm performance |
| 30 | |
reed | 5e0d927 | 2016-08-18 15:01:10 -0700 | [diff] [blame] | 31 | const SkScalar min = -20; |
| 32 | const SkScalar max = 800; |
| 33 | const SkScalar size = 20; |
| 34 | |
| 35 | SkRandom rand; |
| 36 | SkPaint paint; |
| 37 | for (int i = 0; i < 10000; i++) { |
| 38 | paint.setColor(sk_tool_utils::color_to_565(rand.nextU() | (0xFF << 24))); |
reed | c1fb8e8 | 2016-08-18 19:35:52 -0700 | [diff] [blame] | 39 | SkScalar x = rand.nextRangeScalar(min, max); |
| 40 | SkScalar y = rand.nextRangeScalar(min, max); |
| 41 | SkScalar w = rand.nextRangeScalar(0, size); |
| 42 | SkScalar h = rand.nextRangeScalar(0, size); |
| 43 | canvas->drawRect(SkRect::MakeXYWH(x, y, w, h), paint); |
reed | 5e0d927 | 2016-08-18 15:01:10 -0700 | [diff] [blame] | 44 | } |
| 45 | } |
| 46 | |
| 47 | bool onAnimate(const SkAnimTimer& timer) override { |
| 48 | return true; |
| 49 | } |
| 50 | |
| 51 | private: |
| 52 | |
| 53 | typedef GM INHERITED; |
| 54 | }; |
| 55 | DEF_GM(return new SimpleRectGM;) |