db285de247
Bug 36932: Adds a lower limit when fuzzing dash path effects, since it can produce paths with > 140k verbs. While this is not that much memory on its own, the triangulating path renderer can require 3+GB to complete its work (although it doesn't actually fail). Bug 36945, 37042: Also has PathToTriangles check for finite paths before starting any triangulation work. These paths were created with infinities and NaNs. Normally such a path would be rejected at a higher level in SkCanvas. Since the triangulator is being fuzzed directly, this emulates this. It's included in GrTriangulator and not the fuzzer's main function because it's a cheap test and theoretically we could encounter a path that was built lower down (e.g. dashing or transformed to device space) that then overflowed. Bug: oss-fuzz:36923, oss-fuzz:36945, oss-fuzz:37042 Change-Id: If97212bf410f771b42cebaedb5733af1abbfc4b2 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/449520 Reviewed-by: Greg Daniel <egdaniel@google.com> Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
36 lines
1.1 KiB
C++
36 lines
1.1 KiB
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/geometry/GrPathUtils.h"
|
|
#include "src/gpu/geometry/GrTriangulator.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;
|
|
|
|
int count = GrTriangulator::PathToTriangles(path, tol, clipBounds, &allocator, &isLinear);
|
|
if (count > 0) {
|
|
allocator.detachVertexData(); // normally handled by the triangulating path renderer.
|
|
}
|
|
}
|