Robert Phillips | 98b066c | 2021-04-22 10:51:58 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2021 Google, LLC |
| 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 "fuzz/Fuzz.h" |
| 9 | #include "fuzz/FuzzCommon.h" |
| 10 | #include "include/core/SkPath.h" |
Greg Daniel | 719239c | 2022-04-07 11:20:24 -0400 | [diff] [blame] | 11 | #include "src/gpu/ganesh/GrEagerVertexAllocator.h" |
| 12 | #include "src/gpu/ganesh/geometry/GrPathUtils.h" |
| 13 | #include "src/gpu/ganesh/geometry/GrTriangulator.h" |
Robert Phillips | 98b066c | 2021-04-22 10:51:58 -0400 | [diff] [blame] | 14 | |
Robert Phillips | 98b066c | 2021-04-22 10:51:58 -0400 | [diff] [blame] | 15 | |
Michael Ludwig | 146ffc9 | 2022-10-13 15:26:41 -0400 | [diff] [blame] | 16 | DEF_FUZZ(Triangulation, fuzz) { |
| 17 | #if !defined(SK_ENABLE_OPTIMIZE_SIZE) |
Robert Phillips | 98b066c | 2021-04-22 10:51:58 -0400 | [diff] [blame] | 18 | SkPath path; |
| 19 | FuzzEvilPath(fuzz, &path, SkPath::Verb::kDone_Verb); |
| 20 | |
| 21 | SkScalar tol = GrPathUtils::scaleToleranceToSrc(GrPathUtils::kDefaultTolerance, |
| 22 | SkMatrix::I(), path.getBounds()); |
| 23 | |
| 24 | |
| 25 | // TODO(robertphillips): messing w/ the clipBounds might be another axis to fuzz. |
| 26 | // afaict it only affects inverse filled paths. |
| 27 | SkRect clipBounds = path.getBounds(); |
| 28 | |
| 29 | GrCpuVertexAllocator allocator; |
| 30 | bool isLinear; |
| 31 | |
Michael Ludwig | db285de | 2021-09-16 11:46:13 -0400 | [diff] [blame] | 32 | int count = GrTriangulator::PathToTriangles(path, tol, clipBounds, &allocator, &isLinear); |
| 33 | if (count > 0) { |
| 34 | allocator.detachVertexData(); // normally handled by the triangulating path renderer. |
| 35 | } |
Michael Ludwig | 146ffc9 | 2022-10-13 15:26:41 -0400 | [diff] [blame] | 36 | #endif // SK_ENABLE_OPTIMIZE_SIZE |
Robert Phillips | 98b066c | 2021-04-22 10:51:58 -0400 | [diff] [blame] | 37 | } |