1 /* 2 * Copyright 2020 Google, LLC 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #include "include/core/SkCanvas.h" 9 #include "include/core/SkPicture.h" 10 #include "include/core/SkStream.h" 11 #include "include/core/SkSurface.h" 12 13 constexpr static SkISize kCanvasSize= {128, 160}; 14 FuzzSKP(const uint8_t * data,size_t size)15void FuzzSKP(const uint8_t *data, size_t size) { 16 sk_sp<SkPicture> pic = SkPicture::MakeFromData(data, size); 17 if (!pic) { 18 return; 19 } 20 sk_sp<SkSurface> surface = SkSurfaces::Raster( 21 SkImageInfo::MakeN32Premul(kCanvasSize.width(), kCanvasSize.height())); 22 surface->getCanvas()->drawPicture(pic); 23 pic->approximateBytesUsed(); 24 pic->approximateOpCount(); 25 return; 26 } 27 28 #if defined(SK_BUILD_FOR_LIBFUZZER) LLVMFuzzerTestOneInput(const uint8_t * data,size_t size)29extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { 30 FuzzSKP(data, size); 31 return 0; 32 } 33 #endif 34