/src/skia/fuzz/FuzzTriangulation.cpp
Line | Count | Source |
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" |
11 | | #include "src/gpu/ganesh/GrEagerVertexAllocator.h" |
12 | | #include "src/gpu/ganesh/geometry/GrPathUtils.h" |
13 | | #include "src/gpu/ganesh/geometry/GrTriangulator.h" |
14 | | |
15 | | |
16 | 1.63k | DEF_FUZZ(Triangulation, fuzz) { |
17 | 1.63k | #if !defined(SK_ENABLE_OPTIMIZE_SIZE) |
18 | 1.63k | SkPath path; |
19 | 1.63k | FuzzEvilPath(fuzz, &path, SkPath::Verb::kDone_Verb); |
20 | | |
21 | 1.63k | SkScalar tol = GrPathUtils::scaleToleranceToSrc(GrPathUtils::kDefaultTolerance, |
22 | 1.63k | 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 | 1.63k | SkRect clipBounds = path.getBounds(); |
28 | | |
29 | 1.63k | GrCpuVertexAllocator allocator; |
30 | 1.63k | bool isLinear; |
31 | | |
32 | 1.63k | int count = GrTriangulator::PathToTriangles(path, tol, clipBounds, &allocator, &isLinear); |
33 | 1.63k | if (count > 0) { |
34 | 1.15k | allocator.detachVertexData(); // normally handled by the triangulating path renderer. |
35 | 1.15k | } |
36 | 1.63k | #endif // SK_ENABLE_OPTIMIZE_SIZE |
37 | 1.63k | } |