Flutter Engine
The Flutter Engine
Functions
FuzzSkRuntimeBlender.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 FuzzSkRuntimeBlender_Once (const SkString &shaderText, const SkRuntimeEffect::Options &options)
 
bool FuzzSkRuntimeBlender (const uint8_t *data, size_t size)
 

Function Documentation

◆ FuzzSkRuntimeBlender()

bool FuzzSkRuntimeBlender ( const uint8_t *  data,
size_t  size 
)

Definition at line 59 of file FuzzSkRuntimeBlender.cpp.

59 {
60 // Test once with optimization disabled...
61 SkString shaderText{reinterpret_cast<const char*>(data), size};
63 options.forceUnoptimized = true;
64 bool result = FuzzSkRuntimeBlender_Once(shaderText, options);
65
66 // ... and then with optimization enabled.
67 options.forceUnoptimized = false;
69
70 return result;
71}
const char * options
static bool FuzzSkRuntimeBlender_Once(const SkString &shaderText, const SkRuntimeEffect::Options &options)
GAsyncResult * result
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ FuzzSkRuntimeBlender_Once()

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

The fuzzer treats the input bytes as an SkSL blend 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 FuzzSkRuntimeBlender.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<SkBlender> blender = effect->makeBlender(uniformBytes, SkSpan(children));
43 if (!blender) {
44 return false;
45 }
47 paint.setColor(SK_ColorRED);
48 paint.setBlender(std::move(blender));
49
51 if (!s) {
52 return false;
53 }
54 s->getCanvas()->drawPaint(paint);
55
56 return true;
57}
void FuzzCreateValidInputsForRuntimeEffect(SkRuntimeEffect *effect, sk_sp< SkData > &uniformBytes, TArray< SkRuntimeEffect::ChildPtr > &children)
Definition: FuzzCommon.cpp:352
constexpr SkColor SK_ColorRED
Definition: SkColor.h:126
SkSpan(Container &&) -> SkSpan< std::remove_pointer_t< decltype(std::data(std::declval< Container >()))> >
sk_sp< SkBlender > makeBlender(sk_sp< const SkData > uniforms, SkSpan< const ChildPtr > children={}) const
static Result MakeForBlender(SkString sksl, const Options &)
const Paint & paint
Definition: color_source.cc:38
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)