1 /*
2 * Copyright 2020 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "include/utils/SkRandom.h"
9 #include "src/core/SkGeometry.h"
10 #include "src/gpu/tessellate/WangsFormula.h"
11 #include "tests/Test.h"
12
13 namespace skgpu {
14
15 constexpr static float kPrecision = 4; // 1/4 pixel max error.
16
17 const SkPoint kSerp[4] = {
18 {285.625f, 499.687f}, {411.625f, 808.188f}, {1064.62f, 135.688f}, {1042.63f, 585.187f}};
19
20 const SkPoint kLoop[4] = {
21 {635.625f, 614.687f}, {171.625f, 236.188f}, {1064.62f, 135.688f}, {516.625f, 570.187f}};
22
23 const SkPoint kQuad[4] = {
24 {460.625f, 557.187f}, {707.121f, 209.688f}, {779.628f, 577.687f}};
25
wangs_formula_quadratic_reference_impl(float precision,const SkPoint p[3])26 static float wangs_formula_quadratic_reference_impl(float precision, const SkPoint p[3]) {
27 float k = (2 * 1) / 8.f * precision;
28 return sqrtf(k * (p[0] - p[1]*2 + p[2]).length());
29 }
30
wangs_formula_cubic_reference_impl(float precision,const SkPoint p[4])31 static float wangs_formula_cubic_reference_impl(float precision, const SkPoint p[4]) {
32 float k = (3 * 2) / 8.f * precision;
33 return sqrtf(k * std::max((p[0] - p[1]*2 + p[2]).length(),
34 (p[1] - p[2]*2 + p[3]).length()));
35 }
36
37 // Returns number of segments for linearized quadratic rational. This is an analogue
38 // to Wang's formula, taken from:
39 //
40 // J. Zheng, T. Sederberg. "Estimating Tessellation Parameter Intervals for
41 // Rational Curves and Surfaces." ACM Transactions on Graphics 19(1). 2000.
42 // See Thm 3, Corollary 1.
43 //
44 // Input points should be in projected space.
wangs_formula_conic_reference_impl(float precision,const SkPoint P[3],const float w)45 static float wangs_formula_conic_reference_impl(float precision,
46 const SkPoint P[3],
47 const float w) {
48 // Compute center of bounding box in projected space
49 float min_x = P[0].fX, max_x = min_x,
50 min_y = P[0].fY, max_y = min_y;
51 for (int i = 1; i < 3; i++) {
52 min_x = std::min(min_x, P[i].fX);
53 max_x = std::max(max_x, P[i].fX);
54 min_y = std::min(min_y, P[i].fY);
55 max_y = std::max(max_y, P[i].fY);
56 }
57 const SkPoint C = SkPoint::Make(0.5f * (min_x + max_x), 0.5f * (min_y + max_y));
58
59 // Translate control points and compute max length
60 SkPoint tP[3] = {P[0] - C, P[1] - C, P[2] - C};
61 float max_len = 0;
62 for (int i = 0; i < 3; i++) {
63 max_len = std::max(max_len, tP[i].length());
64 }
65 SkASSERT(max_len > 0);
66
67 // Compute delta = parametric step size of linearization
68 const float eps = 1 / precision;
69 const float r_minus_eps = std::max(0.f, max_len - eps);
70 const float min_w = std::min(w, 1.f);
71 const float numer = 4 * min_w * eps;
72 const float denom =
73 (tP[2] - tP[1] * 2 * w + tP[0]).length() + r_minus_eps * std::abs(1 - 2 * w + 1);
74 const float delta = sqrtf(numer / denom);
75
76 // Return corresponding num segments in the interval [tmin,tmax]
77 constexpr float tmin = 0, tmax = 1;
78 SkASSERT(delta > 0);
79 return (tmax - tmin) / delta;
80 }
81
for_random_matrices(SkRandom * rand,std::function<void (const SkMatrix &)> f)82 static void for_random_matrices(SkRandom* rand, std::function<void(const SkMatrix&)> f) {
83 SkMatrix m;
84 m.setIdentity();
85 f(m);
86
87 for (int i = -10; i <= 30; ++i) {
88 for (int j = -10; j <= 30; ++j) {
89 m.setScaleX(std::ldexp(1 + rand->nextF(), i));
90 m.setSkewX(0);
91 m.setSkewY(0);
92 m.setScaleY(std::ldexp(1 + rand->nextF(), j));
93 f(m);
94
95 m.setScaleX(std::ldexp(1 + rand->nextF(), i));
96 m.setSkewX(std::ldexp(1 + rand->nextF(), (j + i) / 2));
97 m.setSkewY(std::ldexp(1 + rand->nextF(), (j + i) / 2));
98 m.setScaleY(std::ldexp(1 + rand->nextF(), j));
99 f(m);
100 }
101 }
102 }
103
for_random_beziers(int numPoints,SkRandom * rand,std::function<void (const SkPoint[])> f,int maxExponent=30)104 static void for_random_beziers(int numPoints, SkRandom* rand,
105 std::function<void(const SkPoint[])> f,
106 int maxExponent = 30) {
107 SkASSERT(numPoints <= 4);
108 SkPoint pts[4];
109 for (int i = -10; i <= maxExponent; ++i) {
110 for (int j = 0; j < numPoints; ++j) {
111 pts[j].set(std::ldexp(1 + rand->nextF(), i), std::ldexp(1 + rand->nextF(), i));
112 }
113 f(pts);
114 }
115 }
116
117 // Ensure the optimized "*_log2" versions return the same value as ceil(std::log2(f)).
DEF_TEST(wangs_formula_log2,r)118 DEF_TEST(wangs_formula_log2, r) {
119 // Constructs a cubic such that the 'length' term in wang's formula == term.
120 //
121 // f = sqrt(k * length(max(abs(p0 - p1*2 + p2),
122 // abs(p1 - p2*2 + p3))));
123 auto setupCubicLengthTerm = [](int seed, SkPoint pts[], float term) {
124 memset(pts, 0, sizeof(SkPoint) * 4);
125
126 SkPoint term2d = (seed & 1) ?
127 SkPoint::Make(term, 0) : SkPoint::Make(.5f, std::sqrt(3)/2) * term;
128 seed >>= 1;
129
130 if (seed & 1) {
131 term2d.fX = -term2d.fX;
132 }
133 seed >>= 1;
134
135 if (seed & 1) {
136 std::swap(term2d.fX, term2d.fY);
137 }
138 seed >>= 1;
139
140 switch (seed % 4) {
141 case 0:
142 pts[0] = term2d;
143 pts[3] = term2d * .75f;
144 return;
145 case 1:
146 pts[1] = term2d * -.5f;
147 return;
148 case 2:
149 pts[1] = term2d * -.5f;
150 return;
151 case 3:
152 pts[3] = term2d;
153 pts[0] = term2d * .75f;
154 return;
155 }
156 };
157
158 // Constructs a quadratic such that the 'length' term in wang's formula == term.
159 //
160 // f = sqrt(k * length(p0 - p1*2 + p2));
161 auto setupQuadraticLengthTerm = [](int seed, SkPoint pts[], float term) {
162 memset(pts, 0, sizeof(SkPoint) * 3);
163
164 SkPoint term2d = (seed & 1) ?
165 SkPoint::Make(term, 0) : SkPoint::Make(.5f, std::sqrt(3)/2) * term;
166 seed >>= 1;
167
168 if (seed & 1) {
169 term2d.fX = -term2d.fX;
170 }
171 seed >>= 1;
172
173 if (seed & 1) {
174 std::swap(term2d.fX, term2d.fY);
175 }
176 seed >>= 1;
177
178 switch (seed % 3) {
179 case 0:
180 pts[0] = term2d;
181 return;
182 case 1:
183 pts[1] = term2d * -.5f;
184 return;
185 case 2:
186 pts[2] = term2d;
187 return;
188 }
189 };
190
191 // wangs_formula_cubic and wangs_formula_quadratic both use rsqrt instead of sqrt for speed.
192 // Linearization is all approximate anyway, so as long as we are within ~1/2 tessellation
193 // segment of the reference value we are good enough.
194 constexpr static float kTessellationTolerance = 1/128.f;
195
196 for (int level = 0; level < 30; ++level) {
197 float epsilon = std::ldexp(SK_ScalarNearlyZero, level * 2);
198 SkPoint pts[4];
199
200 {
201 // Test cubic boundaries.
202 // f = sqrt(k * length(max(abs(p0 - p1*2 + p2),
203 // abs(p1 - p2*2 + p3))));
204 constexpr static float k = (3 * 2) / (8 * (1.f/kPrecision));
205 float x = std::ldexp(1, level * 2) / k;
206 setupCubicLengthTerm(level << 1, pts, x - epsilon);
207 float referenceValue = wangs_formula_cubic_reference_impl(kPrecision, pts);
208 REPORTER_ASSERT(r, std::ceil(std::log2(referenceValue)) == level);
209 float c = wangs_formula::cubic(kPrecision, pts);
210 REPORTER_ASSERT(r, SkScalarNearlyEqual(c/referenceValue, 1, kTessellationTolerance));
211 REPORTER_ASSERT(r, wangs_formula::cubic_log2(kPrecision, pts) == level);
212 setupCubicLengthTerm(level << 1, pts, x + epsilon);
213 referenceValue = wangs_formula_cubic_reference_impl(kPrecision, pts);
214 REPORTER_ASSERT(r, std::ceil(std::log2(referenceValue)) == level + 1);
215 c = wangs_formula::cubic(kPrecision, pts);
216 REPORTER_ASSERT(r, SkScalarNearlyEqual(c/referenceValue, 1, kTessellationTolerance));
217 REPORTER_ASSERT(r, wangs_formula::cubic_log2(kPrecision, pts) == level + 1);
218 }
219
220 {
221 // Test quadratic boundaries.
222 // f = std::sqrt(k * Length(p0 - p1*2 + p2));
223 constexpr static float k = 2 / (8 * (1.f/kPrecision));
224 float x = std::ldexp(1, level * 2) / k;
225 setupQuadraticLengthTerm(level << 1, pts, x - epsilon);
226 float referenceValue = wangs_formula_quadratic_reference_impl(kPrecision, pts);
227 REPORTER_ASSERT(r, std::ceil(std::log2(referenceValue)) == level);
228 float q = wangs_formula::quadratic(kPrecision, pts);
229 REPORTER_ASSERT(r, SkScalarNearlyEqual(q/referenceValue, 1, kTessellationTolerance));
230 REPORTER_ASSERT(r, wangs_formula::quadratic_log2(kPrecision, pts) == level);
231 setupQuadraticLengthTerm(level << 1, pts, x + epsilon);
232 referenceValue = wangs_formula_quadratic_reference_impl(kPrecision, pts);
233 REPORTER_ASSERT(r, std::ceil(std::log2(referenceValue)) == level+1);
234 q = wangs_formula::quadratic(kPrecision, pts);
235 REPORTER_ASSERT(r, SkScalarNearlyEqual(q/referenceValue, 1, kTessellationTolerance));
236 REPORTER_ASSERT(r, wangs_formula::quadratic_log2(kPrecision, pts) == level + 1);
237 }
238 }
239
240 auto check_cubic_log2 = [&](const SkPoint* pts) {
241 float f = std::max(1.f, wangs_formula_cubic_reference_impl(kPrecision, pts));
242 int f_log2 = wangs_formula::cubic_log2(kPrecision, pts);
243 REPORTER_ASSERT(r, SkScalarCeilToInt(std::log2(f)) == f_log2);
244 float c = std::max(1.f, wangs_formula::cubic(kPrecision, pts));
245 REPORTER_ASSERT(r, SkScalarNearlyEqual(c/f, 1, kTessellationTolerance));
246 };
247
248 auto check_quadratic_log2 = [&](const SkPoint* pts) {
249 float f = std::max(1.f, wangs_formula_quadratic_reference_impl(kPrecision, pts));
250 int f_log2 = wangs_formula::quadratic_log2(kPrecision, pts);
251 REPORTER_ASSERT(r, SkScalarCeilToInt(std::log2(f)) == f_log2);
252 float q = std::max(1.f, wangs_formula::quadratic(kPrecision, pts));
253 REPORTER_ASSERT(r, SkScalarNearlyEqual(q/f, 1, kTessellationTolerance));
254 };
255
256 SkRandom rand;
257
258 for_random_matrices(&rand, [&](const SkMatrix& m) {
259 SkPoint pts[4];
260 m.mapPoints(pts, kSerp, 4);
261 check_cubic_log2(pts);
262
263 m.mapPoints(pts, kLoop, 4);
264 check_cubic_log2(pts);
265
266 m.mapPoints(pts, kQuad, 3);
267 check_quadratic_log2(pts);
268 });
269
270 for_random_beziers(4, &rand, [&](const SkPoint pts[]) {
271 check_cubic_log2(pts);
272 });
273
274 for_random_beziers(3, &rand, [&](const SkPoint pts[]) {
275 check_quadratic_log2(pts);
276 });
277 }
278
279 // Ensure using transformations gives the same result as pre-transforming all points.
DEF_TEST(wangs_formula_vectorXforms,r)280 DEF_TEST(wangs_formula_vectorXforms, r) {
281 auto check_cubic_log2_with_transform = [&](const SkPoint* pts, const SkMatrix& m){
282 SkPoint ptsXformed[4];
283 m.mapPoints(ptsXformed, pts, 4);
284 int expected = wangs_formula::cubic_log2(kPrecision, ptsXformed);
285 int actual = wangs_formula::cubic_log2(kPrecision, pts, wangs_formula::VectorXform(m));
286 REPORTER_ASSERT(r, actual == expected);
287 };
288
289 auto check_quadratic_log2_with_transform = [&](const SkPoint* pts, const SkMatrix& m) {
290 SkPoint ptsXformed[3];
291 m.mapPoints(ptsXformed, pts, 3);
292 int expected = wangs_formula::quadratic_log2(kPrecision, ptsXformed);
293 int actual = wangs_formula::quadratic_log2(kPrecision, pts, wangs_formula::VectorXform(m));
294 REPORTER_ASSERT(r, actual == expected);
295 };
296
297 SkRandom rand;
298
299 for_random_matrices(&rand, [&](const SkMatrix& m) {
300 check_cubic_log2_with_transform(kSerp, m);
301 check_cubic_log2_with_transform(kLoop, m);
302 check_quadratic_log2_with_transform(kQuad, m);
303
304 for_random_beziers(4, &rand, [&](const SkPoint pts[]) {
305 check_cubic_log2_with_transform(pts, m);
306 });
307
308 for_random_beziers(3, &rand, [&](const SkPoint pts[]) {
309 check_quadratic_log2_with_transform(pts, m);
310 });
311 });
312 }
313
DEF_TEST(wangs_formula_worst_case_cubic,r)314 DEF_TEST(wangs_formula_worst_case_cubic, r) {
315 {
316 SkPoint worstP[] = {{0,0}, {100,100}, {0,0}, {0,0}};
317 REPORTER_ASSERT(r, wangs_formula::worst_case_cubic(kPrecision, 100, 100) ==
318 wangs_formula_cubic_reference_impl(kPrecision, worstP));
319 REPORTER_ASSERT(r, wangs_formula::worst_case_cubic_log2(kPrecision, 100, 100) ==
320 wangs_formula::cubic_log2(kPrecision, worstP));
321 }
322 {
323 SkPoint worstP[] = {{100,100}, {100,100}, {200,200}, {100,100}};
324 REPORTER_ASSERT(r, wangs_formula::worst_case_cubic(kPrecision, 100, 100) ==
325 wangs_formula_cubic_reference_impl(kPrecision, worstP));
326 REPORTER_ASSERT(r, wangs_formula::worst_case_cubic_log2(kPrecision, 100, 100) ==
327 wangs_formula::cubic_log2(kPrecision, worstP));
328 }
329 auto check_worst_case_cubic = [&](const SkPoint* pts) {
330 SkRect bbox;
331 bbox.setBoundsNoCheck(pts, 4);
332 float worst = wangs_formula::worst_case_cubic(kPrecision, bbox.width(), bbox.height());
333 int worst_log2 = wangs_formula::worst_case_cubic_log2(kPrecision, bbox.width(),
334 bbox.height());
335 float actual = wangs_formula_cubic_reference_impl(kPrecision, pts);
336 REPORTER_ASSERT(r, worst >= actual);
337 REPORTER_ASSERT(r, std::ceil(std::log2(std::max(1.f, worst))) == worst_log2);
338 };
339 SkRandom rand;
340 for (int i = 0; i < 100; ++i) {
341 for_random_beziers(4, &rand, [&](const SkPoint pts[]) {
342 check_worst_case_cubic(pts);
343 });
344 }
345 // Make sure overflow saturates at infinity (not NaN).
346 constexpr static float inf = std::numeric_limits<float>::infinity();
347 REPORTER_ASSERT(r, wangs_formula::worst_case_cubic_pow4(kPrecision, inf, inf) == inf);
348 REPORTER_ASSERT(r, wangs_formula::worst_case_cubic(kPrecision, inf, inf) == inf);
349 }
350
351 // Ensure Wang's formula for quads produces max error within tolerance.
DEF_TEST(wangs_formula_quad_within_tol,r)352 DEF_TEST(wangs_formula_quad_within_tol, r) {
353 // Wang's formula and the quad math starts to lose precision with very large
354 // coordinate values, so limit the magnitude a bit to prevent test failures
355 // due to loss of precision.
356 constexpr int maxExponent = 15;
357 SkRandom rand;
358 for_random_beziers(3, &rand, [&r](const SkPoint pts[]) {
359 const int nsegs = static_cast<int>(
360 std::ceil(wangs_formula_quadratic_reference_impl(kPrecision, pts)));
361
362 const float tdelta = 1.f / nsegs;
363 for (int j = 0; j < nsegs; ++j) {
364 const float tmin = j * tdelta, tmax = (j + 1) * tdelta;
365
366 // Get section of quad in [tmin,tmax]
367 const SkPoint* sectionPts;
368 SkPoint tmp0[5];
369 SkPoint tmp1[5];
370 if (tmin == 0) {
371 if (tmax == 1) {
372 sectionPts = pts;
373 } else {
374 SkChopQuadAt(pts, tmp0, tmax);
375 sectionPts = tmp0;
376 }
377 } else {
378 SkChopQuadAt(pts, tmp0, tmin);
379 if (tmax == 1) {
380 sectionPts = tmp0 + 2;
381 } else {
382 SkChopQuadAt(tmp0 + 2, tmp1, (tmax - tmin) / (1 - tmin));
383 sectionPts = tmp1;
384 }
385 }
386
387 // For quads, max distance from baseline is always at t=0.5.
388 SkPoint p;
389 p = SkEvalQuadAt(sectionPts, 0.5f);
390
391 // Get distance of p to baseline
392 const SkPoint n = {sectionPts[2].fY - sectionPts[0].fY,
393 sectionPts[0].fX - sectionPts[2].fX};
394 const float d = std::abs((p - sectionPts[0]).dot(n)) / n.length();
395
396 // Check distance is within specified tolerance
397 REPORTER_ASSERT(r, d <= (1.f / kPrecision) + SK_ScalarNearlyZero);
398 }
399 }, maxExponent);
400 }
401
402 // Ensure the specialized version for rational quads reduces to regular Wang's
403 // formula when all weights are equal to one
DEF_TEST(wangs_formula_rational_quad_reduces,r)404 DEF_TEST(wangs_formula_rational_quad_reduces, r) {
405 constexpr static float kTessellationTolerance = 1 / 128.f;
406
407 SkRandom rand;
408 for (int i = 0; i < 100; ++i) {
409 for_random_beziers(3, &rand, [&r](const SkPoint pts[]) {
410 const float rational_nsegs = wangs_formula::conic(kPrecision, pts, 1.f);
411 const float integral_nsegs = wangs_formula_quadratic_reference_impl(kPrecision, pts);
412 REPORTER_ASSERT(
413 r, SkScalarNearlyEqual(rational_nsegs, integral_nsegs, kTessellationTolerance));
414 });
415 }
416 }
417
418 // Ensure the rational quad version (used for conics) produces max error within tolerance.
DEF_TEST(wangs_formula_conic_within_tol,r)419 DEF_TEST(wangs_formula_conic_within_tol, r) {
420 constexpr int maxExponent = 24;
421
422 // Single-precision functions in SkConic/SkGeometry lose too much accuracy with
423 // large-magnitude curves and large weights for this test to pass.
424 using Sk2d = skvx::Vec<2, double>;
425 const auto eval_conic = [](const SkPoint pts[3], float w, float t) -> Sk2d {
426 const auto eval = [](Sk2d A, Sk2d B, Sk2d C, float t) -> Sk2d {
427 return (A * t + B) * t + C;
428 };
429
430 const Sk2d p0 = {pts[0].fX, pts[0].fY};
431 const Sk2d p1 = {pts[1].fX, pts[1].fY};
432 const Sk2d p1w = p1 * w;
433 const Sk2d p2 = {pts[2].fX, pts[2].fY};
434 Sk2d numer = eval(p2 - p1w * 2 + p0, (p1w - p0) * 2, p0, t);
435
436 Sk2d denomC = {1, 1};
437 Sk2d denomB = {2 * (w - 1), 2 * (w - 1)};
438 Sk2d denomA = {-2 * (w - 1), -2 * (w - 1)};
439 Sk2d denom = eval(denomA, denomB, denomC, t);
440 return numer / denom;
441 };
442
443 const auto dot = [](const Sk2d& a, const Sk2d& b) -> double {
444 return a[0] * b[0] + a[1] * b[1];
445 };
446
447 const auto length = [](const Sk2d& p) -> double { return sqrt(p[0] * p[0] + p[1] * p[1]); };
448
449 SkRandom rand;
450 for (int i = -10; i <= 10; ++i) {
451 const float w = std::ldexp(1 + rand.nextF(), i);
452 for_random_beziers(
453 3, &rand,
454 [&](const SkPoint pts[]) {
455 const int nsegs = SkScalarCeilToInt(wangs_formula::conic(kPrecision, pts, w));
456
457 const float tdelta = 1.f / nsegs;
458 for (int j = 0; j < nsegs; ++j) {
459 const float tmin = j * tdelta, tmax = (j + 1) * tdelta,
460 tmid = 0.5f * (tmin + tmax);
461
462 Sk2d p0, p1, p2;
463 p0 = eval_conic(pts, w, tmin);
464 p1 = eval_conic(pts, w, tmid);
465 p2 = eval_conic(pts, w, tmax);
466
467 // Get distance of p1 to baseline (p0, p2).
468 const Sk2d n = {p2[1] - p0[1], p0[0] - p2[0]};
469 SkASSERT(length(n) != 0);
470 const double d = std::abs(dot(p1 - p0, n)) / length(n);
471
472 // Check distance is within tolerance
473 REPORTER_ASSERT(r, d <= (1.0 / kPrecision) + SK_ScalarNearlyZero);
474 }
475 },
476 maxExponent);
477 }
478 }
479
480 // Ensure the vectorized conic version equals the reference implementation
DEF_TEST(wangs_formula_conic_matches_reference,r)481 DEF_TEST(wangs_formula_conic_matches_reference, r) {
482 SkRandom rand;
483 for (int i = -10; i <= 10; ++i) {
484 const float w = std::ldexp(1 + rand.nextF(), i);
485 for_random_beziers(3, &rand, [&r, w](const SkPoint pts[]) {
486 const float ref_nsegs = wangs_formula_conic_reference_impl(kPrecision, pts, w);
487 const float nsegs = wangs_formula::conic(kPrecision, pts, w);
488
489 // Because the Gr version may implement the math differently for performance,
490 // allow different slack in the comparison based on the rough scale of the answer.
491 const float cmpThresh = ref_nsegs * (1.f / (1 << 20));
492 REPORTER_ASSERT(r, SkScalarNearlyEqual(ref_nsegs, nsegs, cmpThresh));
493 });
494 }
495 }
496
497 // Ensure using transformations gives the same result as pre-transforming all points.
DEF_TEST(wangs_formula_conic_vectorXforms,r)498 DEF_TEST(wangs_formula_conic_vectorXforms, r) {
499 auto check_conic_with_transform = [&](const SkPoint* pts, float w, const SkMatrix& m) {
500 SkPoint ptsXformed[3];
501 m.mapPoints(ptsXformed, pts, 3);
502 float expected = wangs_formula::conic(kPrecision, ptsXformed, w);
503 float actual = wangs_formula::conic(kPrecision, pts, w, wangs_formula::VectorXform(m));
504 REPORTER_ASSERT(r, SkScalarNearlyEqual(actual, expected));
505 };
506
507 SkRandom rand;
508 for (int i = -10; i <= 10; ++i) {
509 const float w = std::ldexp(1 + rand.nextF(), i);
510 for_random_beziers(3, &rand, [&](const SkPoint pts[]) {
511 check_conic_with_transform(pts, w, SkMatrix::I());
512 check_conic_with_transform(
513 pts, w, SkMatrix::Scale(rand.nextRangeF(-10, 10), rand.nextRangeF(-10, 10)));
514
515 // Random 2x2 matrix
516 SkMatrix m;
517 m.setScaleX(rand.nextRangeF(-10, 10));
518 m.setSkewX(rand.nextRangeF(-10, 10));
519 m.setSkewY(rand.nextRangeF(-10, 10));
520 m.setScaleY(rand.nextRangeF(-10, 10));
521 check_conic_with_transform(pts, w, m);
522 });
523 }
524 }
525
526 } // namespace skgpu
527