add 2 dom api to fuzz
This commit is contained in:
parent
8aa83f89cc
commit
a79784e5ec
@ -283,6 +283,7 @@ static std::map<std::string, std::string> cf_map = {
|
||||
#if defined(SK_ENABLE_SKOTTIE)
|
||||
{"skottie_json", "skottie_json"},
|
||||
#endif
|
||||
{"svg_dom", "svg_dom"},
|
||||
{"textblob_deserialize", "textblob"}
|
||||
};
|
||||
|
||||
|
@ -8,12 +8,36 @@
|
||||
#include "experimental/svg/model/SkSVGDOM.h"
|
||||
#include "include/core/SkData.h"
|
||||
#include "include/core/SkStream.h"
|
||||
#include "include/core/SkSurface.h"
|
||||
|
||||
void FuzzSVG(sk_sp<SkData> bytes) {
|
||||
const uint8_t* data = bytes->bytes();
|
||||
const size_t size = bytes->size();
|
||||
if (size < 2) {
|
||||
return;
|
||||
}
|
||||
uint8_t w;
|
||||
uint8_t h;
|
||||
std::memcpy(&w, data, sizeof(w));
|
||||
std::memcpy(&h, data, sizeof(w));
|
||||
w %= 128;
|
||||
h %= 128;
|
||||
|
||||
SkMemoryStream stream(bytes);
|
||||
auto dom = SkSVGDOM::MakeFromStream(stream);
|
||||
sk_sp<SkSVGDOM> dom = SkSVGDOM::MakeFromStream(stream);
|
||||
if (!dom) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto s = SkSurface::MakeRasterN32Premul(128, 128);
|
||||
if (!s) {
|
||||
return;
|
||||
}
|
||||
|
||||
SkSize winSize = SkSize::Make(w, h);
|
||||
dom->setContainerSize(winSize);
|
||||
dom->render(s->getCanvas());
|
||||
|
||||
}
|
||||
|
||||
#if defined(IS_FUZZING_WITH_LIBFUZZER)
|
||||
|
Loading…
Reference in New Issue
Block a user