Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
FuzzSkRuntimeEffect.cpp File Reference
#include "fuzz/Fuzz.h"
#include "fuzz/FuzzCommon.h"
#include "include/core/SkCanvas.h"
#include "include/core/SkPaint.h"
#include "include/core/SkShader.h"
#include "include/core/SkSurface.h"
#include "include/effects/SkRuntimeEffect.h"
#include "include/private/base/SkTArray.h"
#include "src/gpu/ganesh/GrShaderCaps.h"

Go to the source code of this file.

Functions

static bool FuzzSkRuntimeEffect_Once (const SkString &shaderText, const SkRuntimeEffect::Options &options)
 
bool FuzzSkRuntimeEffect (const uint8_t *data, size_t size)
 

Function Documentation

◆ FuzzSkRuntimeEffect()

bool FuzzSkRuntimeEffect ( const uint8_t *  data,
size_t  size 
)

Definition at line 58 of file FuzzSkRuntimeEffect.cpp.

58 {
59 // Test once with optimization disabled...
60 SkString shaderText{reinterpret_cast<const char*>(data), size};
63 bool result = FuzzSkRuntimeEffect_Once(shaderText, options);
64
65 // ... and then with optimization enabled.
66 options.forceUnoptimized = false;
68
69 return result;
70}
const char * options
static bool FuzzSkRuntimeEffect_Once(const SkString &shaderText, const SkRuntimeEffect::Options &options)
GAsyncResult * result
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot data
Definition switches.h:41

◆ FuzzSkRuntimeEffect_Once()

static bool FuzzSkRuntimeEffect_Once ( const SkString shaderText,
const SkRuntimeEffect::Options options 
)
static

The fuzzer treats the input bytes as an SkSL shader program. The requested number of uniforms and children are automatically synthesized to match the program's needs.

We fuzz twice, with two different settings for inlining in the SkSL compiler. By default, the compiler inlines most small to medium functions. This can hide bugs related to function-calling. So we run the fuzzer once with inlining disabled, and again with it enabled. This gives us better coverage, and eases the burden on the fuzzer to inject useless noise into functions to suppress inlining.

Definition at line 30 of file FuzzSkRuntimeEffect.cpp.

31 {
33 SkRuntimeEffect* effect = result.effect.get();
34 if (!effect) {
35 return false;
36 }
37
38 sk_sp<SkData> uniformBytes;
40 FuzzCreateValidInputsForRuntimeEffect(effect, uniformBytes, children);
41
42 sk_sp<SkShader> shader = effect->makeShader(uniformBytes, SkSpan(children));
43 if (!shader) {
44 return false;
45 }
47 paint.setShader(std::move(shader));
48
50 if (!s) {
51 return false;
52 }
53 s->getCanvas()->drawPaint(paint);
54
55 return true;
56}
void FuzzCreateValidInputsForRuntimeEffect(SkRuntimeEffect *effect, sk_sp< SkData > &uniformBytes, TArray< SkRuntimeEffect::ChildPtr > &children)
sk_sp< SkShader > makeShader(sk_sp< const SkData > uniforms, sk_sp< SkShader > children[], size_t childCount, const SkMatrix *localMatrix=nullptr) const
static Result MakeForShader(SkString sksl, const Options &)
const Paint & paint
struct MyStruct s
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
static SkImageInfo MakeN32Premul(int width, int height)