blob: d1a33f9fed821149a2b99a6c2d2ef645d1837baa [file] [log] [blame]
Chris Daltonc7a84932021-11-18 01:04:04 -07001/*
2 * Copyright 2021 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 "src/gpu/tessellate/Tessellation.h"
9#include "tests/Test.h"
10
11DEF_TEST(PreChopPathCurves, reporter) {
12 // These particular test cases can get stuck in infinite recursion due to limited fp32
13 // precision. (Although they will not with the provided tessellationPrecision values; we had to
14 // lower precision in order to avoid the "viewport size" assert in PreChopPathCurves.) Bump the
15 // tessellationPreciion up to 4 and run these tests in order to verify our bail condition for
16 // infinite recursion caused by bad fp32 precision. If the test completes, it passed.
17 SkPath p = SkPath().moveTo(11.171727877046647f, -11.78621173228717f)
18 .quadTo(11.171727877046647f, -11.78621173228717f,
19 8.33583747124031f, 77.27177002747368f)
20 .cubicTo(8.33583747124031f, 77.27177002747368f,
21 8.33583747124031f, 77.27177002747368f,
22 11.171727877046647f, -11.78621173228717f)
23 .conicTo(11.171727877046647f, -11.78621173228717f,
24 8.33583747124031f, 77.27177002747368f,
25 1e-6f)
26 .conicTo(8.33583747124031f, 77.27177002747368f,
27 11.171727877046647f, -11.78621173228717f,
28 1e6f);
29
30 SkMatrix m = SkMatrix::Scale(138.68622826903837f, 74192976757580.44189f);
31 skgpu::PreChopPathCurves(1/16.f, p, m, {1000, -74088852800000.f, 3000, -74088852700000.f});
32
33 m = SkMatrix::Scale(138.68622826903837f, 74192976757580.44189f*.3f);
34 skgpu::PreChopPathCurves(.25f, p, m, {1000, -22226658140000.f, 3000, -22226658130000.f});
35
36 m = SkMatrix::Scale(138.68622826903837f, 74192976757580.44189f/4);
37 skgpu::PreChopPathCurves(.25f, p, m, {1000, -18522213200000.f, 3000, -18522213100000.f});
38}