2021-04-22 14:51:58 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2021 Google, LLC
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "fuzz/Fuzz.h"
|
|
|
|
#include "fuzz/FuzzCommon.h"
|
|
|
|
#include "include/core/SkPath.h"
|
|
|
|
#include "src/gpu/GrEagerVertexAllocator.h"
|
|
|
|
#include "src/gpu/geometry/GrPathUtils.h"
|
2021-08-17 18:17:23 +00:00
|
|
|
#include "src/gpu/geometry/GrTriangulator.h"
|
2021-04-22 14:51:58 +00:00
|
|
|
|
|
|
|
DEF_FUZZ(Triangulation, fuzz) {
|
|
|
|
|
|
|
|
SkPath path;
|
|
|
|
FuzzEvilPath(fuzz, &path, SkPath::Verb::kDone_Verb);
|
|
|
|
|
|
|
|
SkScalar tol = GrPathUtils::scaleToleranceToSrc(GrPathUtils::kDefaultTolerance,
|
|
|
|
SkMatrix::I(), path.getBounds());
|
|
|
|
|
|
|
|
|
|
|
|
// TODO(robertphillips): messing w/ the clipBounds might be another axis to fuzz.
|
|
|
|
// afaict it only affects inverse filled paths.
|
|
|
|
SkRect clipBounds = path.getBounds();
|
|
|
|
|
|
|
|
GrCpuVertexAllocator allocator;
|
|
|
|
bool isLinear;
|
|
|
|
|
2021-09-16 15:46:13 +00:00
|
|
|
int count = GrTriangulator::PathToTriangles(path, tol, clipBounds, &allocator, &isLinear);
|
|
|
|
if (count > 0) {
|
|
|
|
allocator.detachVertexData(); // normally handled by the triangulating path renderer.
|
|
|
|
}
|
2021-04-22 14:51:58 +00:00
|
|
|
}
|