You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.1 KiB
37 lines
1.1 KiB
/*
|
|
* Copyright 2020 Google, LLC
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "include/core/SkCanvas.h"
|
|
#include "include/core/SkData.h"
|
|
#include "include/core/SkPicture.h"
|
|
#include "include/core/SkStream.h"
|
|
#include "include/core/SkSurface.h"
|
|
|
|
constexpr static SkISize kCanvasSize= {128, 160};
|
|
|
|
void FuzzSKP(sk_sp<SkData> bytes) {
|
|
sk_sp<SkPicture> pic = SkPicture::MakeFromData(bytes->data(), bytes->size());
|
|
if (!pic) {
|
|
SkDebugf("[terminated] Couldn't decode as a picture.\n");
|
|
return;
|
|
}
|
|
sk_sp<SkSurface> surface = SkSurface::MakeRasterN32Premul(kCanvasSize.width(),
|
|
kCanvasSize.height());
|
|
surface->getCanvas()->drawPicture(pic);
|
|
pic->approximateBytesUsed();
|
|
pic->approximateOpCount();
|
|
return;
|
|
}
|
|
|
|
#if defined(SK_BUILD_FOR_LIBFUZZER)
|
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|
auto bytes = SkData::MakeWithoutCopy(data, size);
|
|
FuzzSKP(bytes);
|
|
return 0;
|
|
}
|
|
#endif
|