skia2/fuzz/Fuzz.cpp
Michael Ludwig 747c31e296 Hide SkImageFilter::CropRect
Moves the (SkRect + flags) struct into SkImageFilter_Base with protected
access only. Base constructor and all src/effects/imagefilters Make
functions now take a "const SkRect*" instead. CropRect is still what's
stored and used by filter implementations during filterImage(), but it's
no longer publicly available.

The SkImageFilters factory implementations now can go straight to the
Make functions in src/effects/imagefilters instead of wrapping its
"const SkRect*" in an SkImageFilter::CropRect.

Bug: skia:9296, skia:11230
Change-Id: I2c62f42031910ec405623d4519c8a434cd2b3bdd
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/361496
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Reviewed-by: Mike Reed <reed@google.com>
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
2021-01-30 16:10:29 +00:00

43 lines
1.0 KiB
C++

/*
* Copyright 2016 Google Inc.
*
* 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"
// UBSAN reminds us that bool can only legally hold 0 or 1.
void Fuzz::next(bool* b) {
uint8_t n;
this->next(&n);
*b = (n & 1) == 1;
}
void Fuzz::nextBytes(void* n, size_t size) {
if ((fNextByte + size) > fBytes->size()) {
sk_bzero(n, size);
memcpy(n, fBytes->bytes() + fNextByte, fBytes->size() - fNextByte);
fNextByte = fBytes->size();
return;
}
memcpy(n, fBytes->bytes() + fNextByte, size);
fNextByte += size;
}
void Fuzz::next(SkRegion* region) {
// See FuzzCommon.h
FuzzNiceRegion(this, region, 10);
}
void Fuzz::nextRange(float* f, float min, float max) {
this->next(f);
if (!std::isnormal(*f) && *f != 0.0f) {
// Don't deal with infinity or other strange floats.
*f = max;
}
*f = min + std::fmod(std::abs(*f), (max - min + 1));
}