skia2/fuzz/oss_fuzz/FuzzSKP.cpp
Zepeng Hu fcb7ba035a updated skp fuzzer
Change-Id: If7f770c25e9a2cd9b8f3feb07c1756889f870431
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/306338
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Zepeng Hu <zepenghu@google.com>
2020-07-31 21:27:13 +00:00

37 lines
1.1 KiB
C++

/*
* 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(IS_FUZZING_WITH_LIBFUZZER)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
auto bytes = SkData::MakeWithoutCopy(data, size);
FuzzSKP(bytes);
return 0;
}
#endif