34template <
typename T>
void* skia_alloc_func(
void*,
T items,
T size) {
38void skia_free_func(
void*,
void* address) {
sk_free(address); }
52 flateData.zalloc = &skia_alloc_func;
53 flateData.zfree = &skia_free_func;
54 flateData.opaque =
nullptr;
55 flateData.next_in =
nullptr;
56 flateData.avail_in = 0;
57 flateData.next_out = outputBuffer;
60 rc = inflateInit(&flateData);
65 const uint8_t* input = (
const uint8_t*)
src->getMemoryBase();
66 size_t inputLength =
src->getLength();
67 if (input ==
nullptr || inputLength == 0) {
69 flateData.next_in = inputBuffer;
70 flateData.avail_in = 0;
72 flateData.next_in =
const_cast<uint8_t*
>(input);
73 flateData.avail_in =
SkToUInt(inputLength);
79 if (!
dst->write(outputBuffer,
kBufferSize - flateData.avail_out)) {
83 flateData.next_out = outputBuffer;
88 if (flateData.avail_in == 0) {
94 flateData.next_in = inputBuffer;
97 rc = inflate(&flateData, Z_NO_FLUSH);
100 rc = inflate(&flateData, Z_FINISH);
102 if (!
dst->write(outputBuffer,
kBufferSize - flateData.avail_out)) {
106 flateData.next_out = outputBuffer;
111 inflateEnd(&flateData);
112 if (rc != Z_STREAM_END) {
122 for (
int loop = 0; loop < 50; ++loop) {
123 uint32_t
size = random.nextULessThan(10000);
125 for (uint32_t j = 0; j <
size; ++j) {
126 buffer[j] = random.nextU() & 0xff;
135 std::min(size - j, random.nextRangeU(1, 400));
136 if (!deflateWStream.write(&
buffer[j], writeSize)) {
137 ERRORF(r,
"something went wrong.");
144 std::unique_ptr<SkStreamAsset> compressed(dynamicMemoryWStream.
detachAsStream());
145 std::unique_ptr<SkStreamAsset> decompressed(stream_inflate(r, compressed.get()));
148 ERRORF(r,
"Decompression failed.");
151 if (decompressed->getLength() != size) {
152 ERRORF(r,
"Decompression failed to get right size [%d]. %u != %u",
153 loop, (
unsigned)(decompressed->getLength()), (
unsigned)size);
156 o.writeStream(compressed.get(), compressed->getLength());
157 compressed->rewind();
161 o2.write(&
buffer[0], size);
165 uint32_t minLength = std::min(size, (uint32_t)(decompressed->getLength()));
166 for (uint32_t i = 0; i < minLength; ++i) {
171 ERRORF(r,
"Decompression failed at byte %u.", (
unsigned)i);
static bool read(SkStream *stream, void *buffer, size_t amount)
static void * sk_calloc_throw(size_t size)
SK_API void sk_free(void *)
static const size_t kBufferSize
SK_API SkString static SkString SkStringPrintf()
constexpr size_t SkToSizeT(S x)
constexpr unsigned SkToUInt(S x)
#define DEF_TEST(name, reporter)
#define REPORTER_ASSERT(r, cond,...)
std::unique_ptr< SkStreamAsset > detachAsStream()
static const uint8_t buffer[]
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