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