aboutsummaryrefslogtreecommitdiffhomepage
path: root/fuzz/FuzzCommon.h
diff options
context:
space:
mode:
Diffstat (limited to 'fuzz/FuzzCommon.h')
-rw-r--r--fuzz/FuzzCommon.h26
1 files changed, 19 insertions, 7 deletions
diff --git a/fuzz/FuzzCommon.h b/fuzz/FuzzCommon.h
index bea5a30f86..7615fe723e 100644
--- a/fuzz/FuzzCommon.h
+++ b/fuzz/FuzzCommon.h
@@ -26,22 +26,34 @@ inline void fuzz_nice_float(Fuzz* fuzz, float* f, Args... rest) {
fuzz_nice_float(fuzz, rest...);
}
-template <>
-inline void Fuzz::next(SkRegion* region) {
+template <typename T, typename Min, typename Max>
+inline void fuzz_enum_range(Fuzz* fuzz, T* value, Min rmin, Max rmax) {
+ using U = skstd::underlying_type_t<T>;
+ fuzz->nextRange((U*)value, (U)rmin, (U)rmax);
+}
+
+inline void fuzz_region(Fuzz* fuzz, SkRegion* region, int maxN) {
uint8_t N;
- this->nextRange(&N, 0, 10);
+ fuzz->nextRange(&N, 0, maxN);
for (uint8_t i = 0; i < N; ++i) {
SkIRect r;
- uint8_t op;
- this->next(&r);
+ SkRegion::Op op;
+ // Avoid the sentinal value used by Region.
+ fuzz->nextRange(&r.fLeft, -2147483646, 2147483646);
+ fuzz->nextRange(&r.fTop, -2147483646, 2147483646);
+ fuzz->nextRange(&r.fRight, -2147483646, 2147483646);
+ fuzz->nextRange(&r.fBottom, -2147483646, 2147483646);
r.sort();
- this->nextRange(&op, 0, (uint8_t)SkRegion::kLastOp);
- if (!region->op(r, (SkRegion::Op)op)) {
+ fuzz_enum_range(fuzz, &op, (SkRegion::Op)0, SkRegion::kLastOp);
+ if (!region->op(r, op)) {
return;
}
}
}
+template <>
+inline void Fuzz::next(SkRegion* region) { fuzz_region(this, region, 10); }
+
// allows some float values for path points
void FuzzPath(Fuzz* fuzz, SkPath* path, int maxOps);
// allows all float values for path points