OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkRandom.h" | 9 #include "SkRandom.h" |
10 #include "SkRRect.h" | 10 #include "SkRRect.h" |
11 | 11 |
12 namespace skiagm { | 12 namespace skiagm { |
13 | 13 |
14 // Test out various combinations of nested rects, ovals and rrects. | 14 // Test out various combinations of nested rects, ovals and rrects. |
15 class NestedGM : public GM { | 15 class NestedGM : public GM { |
16 public: | 16 public: |
17 NestedGM(bool doAA) : fDoAA(doAA) { | 17 NestedGM(bool doAA) : fDoAA(doAA) { |
18 this->setBGColor(0xFFDDDDDD); | 18 this->setBGColor(0xFFDDDDDD); |
19 } | 19 } |
20 | 20 |
21 protected: | 21 protected: |
22 | 22 |
23 SkString onShortName() SK_OVERRIDE { | 23 SkString onShortName() override { |
24 SkString name("nested"); | 24 SkString name("nested"); |
25 if (fDoAA) { | 25 if (fDoAA) { |
26 name.append("_aa"); | 26 name.append("_aa"); |
27 } else { | 27 } else { |
28 name.append("_bw"); | 28 name.append("_bw"); |
29 } | 29 } |
30 return name; | 30 return name; |
31 } | 31 } |
32 | 32 |
33 SkISize onISize() SK_OVERRIDE { | 33 SkISize onISize() override { |
34 return SkISize::Make(kImageWidth, kImageHeight); | 34 return SkISize::Make(kImageWidth, kImageHeight); |
35 } | 35 } |
36 | 36 |
37 enum Shapes { | 37 enum Shapes { |
38 kRect_Shape = 0, | 38 kRect_Shape = 0, |
39 kRRect_Shape, | 39 kRRect_Shape, |
40 kOval_Shape, | 40 kOval_Shape, |
41 kShapeCount | 41 kShapeCount |
42 }; | 42 }; |
43 | 43 |
44 static void AddShape(SkPath* path, const SkRect& rect, Shapes shape, SkPath:
:Direction dir) { | 44 static void AddShape(SkPath* path, const SkRect& rect, Shapes shape, SkPath:
:Direction dir) { |
45 switch (shape) { | 45 switch (shape) { |
46 case kRect_Shape: | 46 case kRect_Shape: |
47 path->addRect(rect, dir); | 47 path->addRect(rect, dir); |
48 break; | 48 break; |
49 case kRRect_Shape: { | 49 case kRRect_Shape: { |
50 SkRRect rr; | 50 SkRRect rr; |
51 rr.setRectXY(rect, 5, 5); | 51 rr.setRectXY(rect, 5, 5); |
52 path->addRRect(rr, dir); | 52 path->addRRect(rr, dir); |
53 break; | 53 break; |
54 } | 54 } |
55 case kOval_Shape: | 55 case kOval_Shape: |
56 path->addOval(rect, dir); | 56 path->addOval(rect, dir); |
57 break; | 57 break; |
58 default: | 58 default: |
59 break; | 59 break; |
60 } | 60 } |
61 } | 61 } |
62 | 62 |
63 void onDraw(SkCanvas* canvas) SK_OVERRIDE { | 63 void onDraw(SkCanvas* canvas) override { |
64 | 64 |
65 SkPaint shapePaint; | 65 SkPaint shapePaint; |
66 shapePaint.setColor(SK_ColorBLACK); | 66 shapePaint.setColor(SK_ColorBLACK); |
67 shapePaint.setAntiAlias(fDoAA); | 67 shapePaint.setAntiAlias(fDoAA); |
68 | 68 |
69 SkRect outerRect = SkRect::MakeWH(40, 40); | 69 SkRect outerRect = SkRect::MakeWH(40, 40); |
70 | 70 |
71 SkRect innerRects[] = { | 71 SkRect innerRects[] = { |
72 { 10, 10, 30, 30 }, // small | 72 { 10, 10, 30, 30 }, // small |
73 { .5f, 18, 4.5f, 22 } // smaller and offset to left | 73 { .5f, 18, 4.5f, 22 } // smaller and offset to left |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 typedef GM INHERITED; | 117 typedef GM INHERITED; |
118 }; | 118 }; |
119 | 119 |
120 /////////////////////////////////////////////////////////////////////////////// | 120 /////////////////////////////////////////////////////////////////////////////// |
121 | 121 |
122 DEF_GM( return new NestedGM(true); ) | 122 DEF_GM( return new NestedGM(true); ) |
123 DEF_GM( return new NestedGM(false); ) | 123 DEF_GM( return new NestedGM(false); ) |
124 | 124 |
125 | 125 |
126 } | 126 } |
OLD | NEW |