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