blob: b62054c483b4843f1e5356fb1de09b81282d1839 [file] [log] [blame]
Robert Phillips98b066c2021-04-22 10:51:58 -04001/*
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/GrEagerVertexAllocator.h"
Robert Phillips98b066c2021-04-22 10:51:58 -040012#include "src/gpu/geometry/GrPathUtils.h"
Robert Phillips41ebbd72021-08-17 14:17:23 -040013#include "src/gpu/geometry/GrTriangulator.h"
Robert Phillips98b066c2021-04-22 10:51:58 -040014
15DEF_FUZZ(Triangulation, fuzz) {
16
17 SkPath path;
18 FuzzEvilPath(fuzz, &path, SkPath::Verb::kDone_Verb);
19
20 SkScalar tol = GrPathUtils::scaleToleranceToSrc(GrPathUtils::kDefaultTolerance,
21 SkMatrix::I(), path.getBounds());
22
23
24 // TODO(robertphillips): messing w/ the clipBounds might be another axis to fuzz.
25 // afaict it only affects inverse filled paths.
26 SkRect clipBounds = path.getBounds();
27
28 GrCpuVertexAllocator allocator;
29 bool isLinear;
30
Michael Ludwigdb285de2021-09-16 11:46:13 -040031 int count = GrTriangulator::PathToTriangles(path, tol, clipBounds, &allocator, &isLinear);
32 if (count > 0) {
33 allocator.detachVertexData(); // normally handled by the triangulating path renderer.
34 }
Robert Phillips98b066c2021-04-22 10:51:58 -040035}