OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrTestUtils.h" | 8 #include "GrTestUtils.h" |
9 #include "SkMatrix.h" | 9 #include "SkMatrix.h" |
10 #include "SkPath.h" | 10 #include "SkPath.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 gPath[6].lineTo(5.0f, 5.0f); | 168 gPath[6].lineTo(5.0f, 5.0f); |
169 gPath[6].lineTo(10.0f, 0.0f); | 169 gPath[6].lineTo(10.0f, 0.0f); |
170 gPath[6].lineTo(10.0f, 10.0f); | 170 gPath[6].lineTo(10.0f, 10.0f); |
171 gPath[6].lineTo(0.0f, 10.0f); | 171 gPath[6].lineTo(0.0f, 10.0f); |
172 gPath[6].close(); | 172 gPath[6].close(); |
173 } | 173 } |
174 | 174 |
175 return gPath[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gPat
h)))]; | 175 return gPath[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gPat
h)))]; |
176 } | 176 } |
177 | 177 |
| 178 const SkPath& TestPathConvex(SkRandom* random) { |
| 179 static SkPath gPath[3]; |
| 180 static bool gOnce; |
| 181 if (!gOnce) { |
| 182 gOnce = true; |
| 183 // narrow rect |
| 184 gPath[0].moveTo(0.f, 0.f); |
| 185 gPath[0].lineTo(-1.5f, -50.0f); |
| 186 gPath[0].lineTo( 1.5f, -50.0f); |
| 187 gPath[0].lineTo( 1.5f, 50.0f); |
| 188 gPath[0].lineTo(-1.5f, 50.0f); |
| 189 // degenerate |
| 190 gPath[1].moveTo(0.f, 0.f); |
| 191 gPath[1].lineTo(-0.025f, -0.025f); |
| 192 gPath[1].lineTo( 0.025f, -0.025f); |
| 193 gPath[1].lineTo( 0.025f, 0.025f); |
| 194 gPath[1].lineTo(-0.025f, 0.025f); |
| 195 // clipped triangle |
| 196 gPath[2].moveTo(0.f, 0.f); |
| 197 gPath[2].lineTo(-10.0f, -50.0f); |
| 198 gPath[2].lineTo( 10.0f, -50.0f); |
| 199 gPath[2].lineTo( 50.0f, 31.0f); |
| 200 gPath[2].lineTo( 40.0f, 50.0f); |
| 201 gPath[2].lineTo(-40.0f, 50.0f); |
| 202 gPath[2].lineTo(-50.0f, 31.0f); |
| 203 } |
| 204 |
| 205 return gPath[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gPat
h)))]; |
| 206 } |
| 207 |
178 SkStrokeRec TestStrokeRec(SkRandom* random) { | 208 SkStrokeRec TestStrokeRec(SkRandom* random) { |
179 SkStrokeRec::InitStyle style = | 209 SkStrokeRec::InitStyle style = |
180 SkStrokeRec::InitStyle(random->nextULessThan(SkStrokeRec::kFill_Init
Style + 1)); | 210 SkStrokeRec::InitStyle(random->nextULessThan(SkStrokeRec::kFill_Init
Style + 1)); |
181 SkStrokeRec rec(style); | 211 SkStrokeRec rec(style); |
182 bool strokeAndFill = random->nextBool(); | 212 bool strokeAndFill = random->nextBool(); |
183 SkScalar strokeWidth = random->nextBool() ? 0.f : 1.f; | 213 SkScalar strokeWidth = random->nextBool() ? 0.f : 1.f; |
184 rec.setStrokeStyle(strokeWidth, strokeAndFill); | 214 rec.setStrokeStyle(strokeWidth, strokeAndFill); |
185 | 215 |
186 SkPaint::Cap cap = SkPaint::Cap(random->nextULessThan(SkPaint::kCapCount)); | 216 SkPaint::Cap cap = SkPaint::Cap(random->nextULessThan(SkPaint::kCapCount)); |
187 SkPaint::Join join = SkPaint::Join(random->nextULessThan(SkPaint::kJoinCount
)); | 217 SkPaint::Join join = SkPaint::Join(random->nextULessThan(SkPaint::kJoinCount
)); |
188 SkScalar miterLimit = random->nextRangeScalar(1.f, 5.f); | 218 SkScalar miterLimit = random->nextRangeScalar(1.f, 5.f); |
189 rec.setStrokeParams(cap, join, miterLimit); | 219 rec.setStrokeParams(cap, join, miterLimit); |
190 return rec; | 220 return rec; |
191 } | 221 } |
192 | 222 |
193 }; | 223 }; |
194 | 224 |
195 #endif | 225 #endif |
OLD | NEW |