Coverage Report

Created: 2024-05-20 07:14

/src/skia/fuzz/oss_fuzz/FuzzSKP.cpp
Line
Count
Source
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
15
19.4k
void FuzzSKP(const uint8_t *data, size_t size) {
16
19.4k
    sk_sp<SkPicture> pic = SkPicture::MakeFromData(data, size);
17
19.4k
    if (!pic) {
18
13.5k
        return;
19
13.5k
    }
20
5.87k
    sk_sp<SkSurface> surface = SkSurfaces::Raster(
21
5.87k
            SkImageInfo::MakeN32Premul(kCanvasSize.width(), kCanvasSize.height()));
22
5.87k
    surface->getCanvas()->drawPicture(pic);
23
5.87k
    pic->approximateBytesUsed();
24
5.87k
    pic->approximateOpCount();
25
5.87k
    return;
26
19.4k
}
27
28
#if defined(SK_BUILD_FOR_LIBFUZZER)
29
31.5k
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
30
31.5k
    FuzzSKP(data, size);
31
31.5k
    return 0;
32
31.5k
}
33
#endif