OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 "SkCanvas.h" | 9 #include "SkCanvas.h" |
10 #include "SkPaint.h" | 10 #include "SkPaint.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 canvas->clipRect(clip); | 40 canvas->clipRect(clip); |
41 canvas->drawPath(path, paint); | 41 canvas->drawPath(path, paint); |
42 canvas->restore(); | 42 canvas->restore(); |
43 } | 43 } |
44 | 44 |
45 void onDraw(SkCanvas* canvas) override { | 45 void onDraw(SkCanvas* canvas) override { |
46 struct FillAndName { | 46 struct FillAndName { |
47 SkPath::FillType fFill; | 47 SkPath::FillType fFill; |
48 const char* fName; | 48 const char* fName; |
49 }; | 49 }; |
50 static const FillAndName gFills[] = { | 50 constexpr FillAndName gFills[] = { |
51 {SkPath::kWinding_FillType, "Winding"}, | 51 {SkPath::kWinding_FillType, "Winding"}, |
52 {SkPath::kEvenOdd_FillType, "Even / Odd"}, | 52 {SkPath::kEvenOdd_FillType, "Even / Odd"}, |
53 {SkPath::kInverseWinding_FillType, "Inverse Winding"}, | 53 {SkPath::kInverseWinding_FillType, "Inverse Winding"}, |
54 {SkPath::kInverseEvenOdd_FillType, "Inverse Even / Odd"}, | 54 {SkPath::kInverseEvenOdd_FillType, "Inverse Even / Odd"}, |
55 }; | 55 }; |
56 struct StyleAndName { | 56 struct StyleAndName { |
57 SkPaint::Style fStyle; | 57 SkPaint::Style fStyle; |
58 const char* fName; | 58 const char* fName; |
59 }; | 59 }; |
60 static const StyleAndName gStyles[] = { | 60 constexpr StyleAndName gStyles[] = { |
61 {SkPaint::kFill_Style, "Fill"}, | 61 {SkPaint::kFill_Style, "Fill"}, |
62 {SkPaint::kStroke_Style, "Stroke"}, | 62 {SkPaint::kStroke_Style, "Stroke"}, |
63 {SkPaint::kStrokeAndFill_Style, "Stroke And Fill"}, | 63 {SkPaint::kStrokeAndFill_Style, "Stroke And Fill"}, |
64 }; | 64 }; |
65 struct CapAndName { | 65 struct CapAndName { |
66 SkPaint::Cap fCap; | 66 SkPaint::Cap fCap; |
67 SkPaint::Join fJoin; | 67 SkPaint::Join fJoin; |
68 const char* fName; | 68 const char* fName; |
69 }; | 69 }; |
70 static const CapAndName gCaps[] = { | 70 constexpr CapAndName gCaps[] = { |
71 {SkPaint::kButt_Cap, SkPaint::kBevel_Join, "Butt"}, | 71 {SkPaint::kButt_Cap, SkPaint::kBevel_Join, "Butt"}, |
72 {SkPaint::kRound_Cap, SkPaint::kRound_Join, "Round"}, | 72 {SkPaint::kRound_Cap, SkPaint::kRound_Join, "Round"}, |
73 {SkPaint::kSquare_Cap, SkPaint::kBevel_Join, "Square"} | 73 {SkPaint::kSquare_Cap, SkPaint::kBevel_Join, "Square"} |
74 }; | 74 }; |
75 struct PathAndName { | 75 struct PathAndName { |
76 SkPath fPath; | 76 SkPath fPath; |
77 const char* fName; | 77 const char* fName; |
78 }; | 78 }; |
79 PathAndName path; | 79 PathAndName path; |
80 path.fPath.moveTo(25*SK_Scalar1, 10*SK_Scalar1); | 80 path.fPath.moveTo(25*SK_Scalar1, 10*SK_Scalar1); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 canvas->clipRect(clip); | 183 canvas->clipRect(clip); |
184 canvas->drawPath(path, paint); | 184 canvas->drawPath(path, paint); |
185 canvas->restore(); | 185 canvas->restore(); |
186 } | 186 } |
187 | 187 |
188 void onDraw(SkCanvas* canvas) override { | 188 void onDraw(SkCanvas* canvas) override { |
189 struct FillAndName { | 189 struct FillAndName { |
190 SkPath::FillType fFill; | 190 SkPath::FillType fFill; |
191 const char* fName; | 191 const char* fName; |
192 }; | 192 }; |
193 static const FillAndName gFills[] = { | 193 constexpr FillAndName gFills[] = { |
194 {SkPath::kWinding_FillType, "Winding"}, | 194 {SkPath::kWinding_FillType, "Winding"}, |
195 {SkPath::kEvenOdd_FillType, "Even / Odd"}, | 195 {SkPath::kEvenOdd_FillType, "Even / Odd"}, |
196 {SkPath::kInverseWinding_FillType, "Inverse Winding"}, | 196 {SkPath::kInverseWinding_FillType, "Inverse Winding"}, |
197 {SkPath::kInverseEvenOdd_FillType, "Inverse Even / Odd"}, | 197 {SkPath::kInverseEvenOdd_FillType, "Inverse Even / Odd"}, |
198 }; | 198 }; |
199 struct StyleAndName { | 199 struct StyleAndName { |
200 SkPaint::Style fStyle; | 200 SkPaint::Style fStyle; |
201 const char* fName; | 201 const char* fName; |
202 }; | 202 }; |
203 static const StyleAndName gStyles[] = { | 203 constexpr StyleAndName gStyles[] = { |
204 {SkPaint::kFill_Style, "Fill"}, | 204 {SkPaint::kFill_Style, "Fill"}, |
205 {SkPaint::kStroke_Style, "Stroke"}, | 205 {SkPaint::kStroke_Style, "Stroke"}, |
206 {SkPaint::kStrokeAndFill_Style, "Stroke And Fill"}, | 206 {SkPaint::kStrokeAndFill_Style, "Stroke And Fill"}, |
207 }; | 207 }; |
208 struct CapAndName { | 208 struct CapAndName { |
209 SkPaint::Cap fCap; | 209 SkPaint::Cap fCap; |
210 SkPaint::Join fJoin; | 210 SkPaint::Join fJoin; |
211 const char* fName; | 211 const char* fName; |
212 }; | 212 }; |
213 static const CapAndName gCaps[] = { | 213 constexpr CapAndName gCaps[] = { |
214 {SkPaint::kButt_Cap, SkPaint::kBevel_Join, "Butt"}, | 214 {SkPaint::kButt_Cap, SkPaint::kBevel_Join, "Butt"}, |
215 {SkPaint::kRound_Cap, SkPaint::kRound_Join, "Round"}, | 215 {SkPaint::kRound_Cap, SkPaint::kRound_Join, "Round"}, |
216 {SkPaint::kSquare_Cap, SkPaint::kBevel_Join, "Square"} | 216 {SkPaint::kSquare_Cap, SkPaint::kBevel_Join, "Square"} |
217 }; | 217 }; |
218 struct PathAndName { | 218 struct PathAndName { |
219 SkPath fPath; | 219 SkPath fPath; |
220 const char* fName; | 220 const char* fName; |
221 }; | 221 }; |
222 PathAndName path; | 222 PathAndName path; |
223 path.fPath.moveTo(25*SK_Scalar1, 10*SK_Scalar1); | 223 path.fPath.moveTo(25*SK_Scalar1, 10*SK_Scalar1); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 | 302 |
303 ////////////////////////////////////////////////////////////////////////////// | 303 ////////////////////////////////////////////////////////////////////////////// |
304 | 304 |
305 static GM* QuadPathFactory(void*) { return new QuadPathGM; } | 305 static GM* QuadPathFactory(void*) { return new QuadPathGM; } |
306 static GMRegistry regQuadPath(QuadPathFactory); | 306 static GMRegistry regQuadPath(QuadPathFactory); |
307 | 307 |
308 static GM* QuadClosePathFactory(void*) { return new QuadClosePathGM; } | 308 static GM* QuadClosePathFactory(void*) { return new QuadClosePathGM; } |
309 static GMRegistry regQuadClosePath(QuadClosePathFactory); | 309 static GMRegistry regQuadClosePath(QuadClosePathFactory); |
310 | 310 |
311 } | 311 } |
OLD | NEW |