| 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 "GrStrokeInfo.h" | |
| 9 #include "GrTestUtils.h" | 8 #include "GrTestUtils.h" |
| 9 #include "GrStyle.h" |
| 10 #include "SkMatrix.h" | 10 #include "SkMatrix.h" |
| 11 #include "SkPathEffect.h" | |
| 12 #include "SkPath.h" | 11 #include "SkPath.h" |
| 13 #include "SkRRect.h" | 12 #include "SkRRect.h" |
| 13 #include "SkTemplates.h" |
| 14 | 14 |
| 15 #ifdef GR_TEST_UTILS | 15 #ifdef GR_TEST_UTILS |
| 16 | 16 |
| 17 static const SkMatrix& test_matrix(SkRandom* random, bool includePerspective) { | 17 static const SkMatrix& test_matrix(SkRandom* random, bool includePerspective) { |
| 18 static SkMatrix gMatrices[5]; | 18 static SkMatrix gMatrices[5]; |
| 19 static const int kPerspectiveCount = 1; | 19 static const int kPerspectiveCount = 1; |
| 20 static bool gOnce; | 20 static bool gOnce; |
| 21 if (!gOnce) { | 21 if (!gOnce) { |
| 22 gOnce = true; | 22 gOnce = true; |
| 23 gMatrices[0].reset(); | 23 gMatrices[0].reset(); |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 } | 230 } |
| 231 | 231 |
| 232 SkStrokeRec TestStrokeRec(SkRandom* random) { | 232 SkStrokeRec TestStrokeRec(SkRandom* random) { |
| 233 SkStrokeRec::InitStyle style = | 233 SkStrokeRec::InitStyle style = |
| 234 SkStrokeRec::InitStyle(random->nextULessThan(SkStrokeRec::kFill_Init
Style + 1)); | 234 SkStrokeRec::InitStyle(random->nextULessThan(SkStrokeRec::kFill_Init
Style + 1)); |
| 235 SkStrokeRec rec(style); | 235 SkStrokeRec rec(style); |
| 236 randomize_stroke_rec(&rec, random); | 236 randomize_stroke_rec(&rec, random); |
| 237 return rec; | 237 return rec; |
| 238 } | 238 } |
| 239 | 239 |
| 240 GrStrokeInfo TestStrokeInfo(SkRandom* random) { | 240 void TestStyle(SkRandom* random, GrStyle* style) { |
| 241 SkStrokeRec::InitStyle style = | 241 SkStrokeRec::InitStyle initStyle = |
| 242 SkStrokeRec::InitStyle(random->nextULessThan(SkStrokeRec::kFill_Init
Style + 1)); | 242 SkStrokeRec::InitStyle(random->nextULessThan(SkStrokeRec::kFill_Init
Style + 1)); |
| 243 GrStrokeInfo strokeInfo(style); | 243 SkStrokeRec stroke(initStyle); |
| 244 randomize_stroke_rec(&strokeInfo, random); | 244 randomize_stroke_rec(&stroke, random); |
| 245 SkPathEffect::DashInfo dashInfo; | 245 sk_sp<SkPathEffect> pe; |
| 246 dashInfo.fCount = random->nextRangeU(1, 50) * 2; | 246 if (random->nextBool()) { |
| 247 dashInfo.fIntervals = new SkScalar[dashInfo.fCount]; | 247 int cnt = random->nextRangeU(1, 50) * 2; |
| 248 SkScalar sum = 0; | 248 SkAutoTDeleteArray<SkScalar> intervals(new SkScalar[cnt]); |
| 249 for (int i = 0; i < dashInfo.fCount; i++) { | 249 SkScalar sum = 0; |
| 250 dashInfo.fIntervals[i] = random->nextRangeScalar(SkDoubleToScalar(0.01), | 250 for (int i = 0; i < cnt; i++) { |
| 251 SkDoubleToScalar(10.0))
; | 251 intervals[i] = random->nextRangeScalar(SkDoubleToScalar(0.01), |
| 252 sum += dashInfo.fIntervals[i]; | 252 SkDoubleToScalar(10.0)); |
| 253 sum += intervals[i]; |
| 254 } |
| 255 SkScalar phase = random->nextRangeScalar(0, sum); |
| 256 pe = TestDashPathEffect::Make(intervals.get(), cnt, phase); |
| 253 } | 257 } |
| 254 dashInfo.fPhase = random->nextRangeScalar(0, sum); | 258 *style = GrStyle(stroke, pe.get()); |
| 255 strokeInfo.setDashInfo(dashInfo); | |
| 256 delete[] dashInfo.fIntervals; | |
| 257 return strokeInfo; | |
| 258 } | 259 } |
| 259 | 260 |
| 260 }; | 261 }; |
| 261 | 262 |
| 262 #endif | 263 #endif |
| OLD | NEW |