6943689ab4
Prepare SkRegion.h, SkShader.h, SkStream.h for documentation. Name params, add trailing commas to enum member list, move or remove some public SkRegion.h stuff. SkRegion gets a minor overhaul to move some pieces to private: or SkRegionPriv. The intent is to preserve the current code so that the fixes for documentation do not impact performance or code size. R=djsollen@google.com,reed@google.com Docs-Preview: https://skia.org/?cl=141284 Bug: skia:6818 Change-Id: I0d82794081b8739a9e8af0d1cd4a0e5d32d04f04 Reviewed-on: https://skia-review.googlesource.com/141284 Commit-Queue: Cary Clark <caryclark@skia.org> Reviewed-by: Mike Reed <reed@google.com>
44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
/*
|
|
* Copyright 2018 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
|
|
#include "SkCanvas.h"
|
|
#include "SkPaint.h"
|
|
#include "SkRegionPriv.h"
|
|
#include "SkSurface.h"
|
|
|
|
bool FuzzRegionDeserialize(sk_sp<SkData> bytes) {
|
|
SkRegion region;
|
|
if (!region.readFromMemory(bytes->data(), bytes->size())) {
|
|
return false;
|
|
}
|
|
region.computeRegionComplexity();
|
|
region.isComplex();
|
|
SkRegion r2;
|
|
if (region == r2) {
|
|
region.contains(0,0);
|
|
} else {
|
|
region.contains(1,1);
|
|
}
|
|
auto s = SkSurface::MakeRasterN32Premul(128, 128);
|
|
if (!s) {
|
|
// May return nullptr in memory-constrained fuzzing environments
|
|
return false;
|
|
}
|
|
s->getCanvas()->drawRegion(region, SkPaint());
|
|
SkDEBUGCODE(SkRegionPriv::Validate(region));
|
|
return true;
|
|
}
|
|
|
|
#if defined(IS_FUZZING_WITH_LIBFUZZER)
|
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|
auto bytes = SkData::MakeWithoutCopy(data, size);
|
|
FuzzRegionDeserialize(bytes);
|
|
return 0;
|
|
}
|
|
#endif
|