skia2/fuzz/FuzzTriangulation.cpp
Robert Phillips 98b066cbe8 Add fuzzer for Triangulating Path Renderer
Bug: skia:11892
Change-Id: I3f8145516f8fd23eb05c29517cd5c1553c9b1df1
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/399296
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Reviewed-by: Brian Salomon <bsalomon@google.com>
2021-04-22 15:35:29 +00:00

33 lines
955 B
C++

/*
* 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/GrTriangulator.h"
#include "src/gpu/geometry/GrPathUtils.h"
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;
GrTriangulator::PathToTriangles(path, tol, clipBounds, &allocator, &isLinear);
}