56 fBase = fCurr = (
const char*)data;
61void SkReadBuffer::setInvalid() {
72 const void* addr = fCurr;
73 this->
validate(IsPtrAlign4(addr) && this->isAvailable(inc));
103 const size_t inc =
sizeof(int32_t);
104 if (!this->
validate(IsPtrAlign4(fCurr) && this->isAvailable(inc))) {
107 int32_t
value = *((
const int32_t*)fCurr);
113 const size_t inc =
sizeof(
SkScalar);
114 if (!this->
validate(IsPtrAlign4(fCurr) && this->isAvailable(inc))) {
135 return *((
const uint8_t*)fCurr);
139 if (
const void* src = this->
skip(bytes)) {
152 const char* c_str = this->skipT<char>(*len+1);
154 if (this->
validate(c_str && c_str[*len] ==
'\0')) {
162 if (
const char* c_str = this->
readString(&len)) {
163 string->set(c_str, len);
171 *
color = {0, 0, 0, 0};
186 if (
const float* m = (
const float*)this->
skip(
sizeof(
float) * 16)) {
204 (void)this->
skip(size);
229 int maxAniso = this->
readInt();
253 (void)this->
skip(size);
264 (void)this->
skip(size);
275 (void)this->
skip(size);
278bool SkReadBuffer::readArray(
void* value,
size_t size,
size_t elementSize) {
285 return this->readArray(
value,
size,
sizeof(uint8_t));
289 return this->readArray(colors,
size,
sizeof(
SkColor));
297 return this->readArray(values,
size,
sizeof(int32_t));
310 const void* buf = this->
skip(count);
319 if (!this->
validate(this->isAvailable(numBytes))) {
331 const size_t inc =
sizeof(uint32_t);
332 if (!this->
validate(IsPtrAlign4(fCurr) && this->isAvailable(inc))) {
335 return *((
const uint32_t*)fCurr);
339 std::optional<SkAlphaType> alphaType) {
344#if !defined(SK_LEGACY_DESERIAL_IMAGE_PROC)
353#if !defined(SK_DISABLE_LEGACY_IMAGE_READBUFFER)
359 SkDEBUGFAIL(
"Need to set image proc in SkDeserialProcs");
370 if (builder.countLevels() !=
count) {
373 for (
int i = 0; i <
count; ++i) {
374 size_t size =
buffer.read32();
375 const void* ptr =
buffer.skip(size);
392 if (!mip->readPixels(
nullptr, pm, 0, 0)) {
405 return rasterWithMips;
414 std::optional<SkAlphaType> alphaType = std::nullopt;
456 int32_t index = this->
read32();
459 }
else if (index > 0) {
460 if (!this->
validate(index <= fTFCount)) {
463 return fTFArray[index - 1];
466 const void* data = this->
skip(size);
477 if (fFactoryCount > 0) {
478 int32_t index = this->
read32();
479 if (0 == index || !this->
isValid()) {
487 if ((
unsigned)index >= (
unsigned)fFactoryCount) {
491 factory = fFactoryArray[index];
495 size_t ignored_length;
498 fFlattenableDict.
set(fFlattenableDict.
count() + 1, factory);
503 uint32_t index = this->
readUInt() >> 8;
513 if (!this->
validate(factory !=
nullptr)) {
521 uint32_t sizeRecorded = this->
read32();
524 obj = (*factory)(*this);
527 if (sizeRecorded != sizeRead) {
533 this->
skip(sizeRecorded);
556 if (value < min || value >
max) {
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static const int points[]
static constexpr T SkAlign4(T x)
#define SkDEBUGFAIL(message)
static void * sk_careful_memcpy(void *dst, const void *src, size_t len)
static size_t sk_negate_to_size_t(int32_t value)
static sk_sp< SkImage > add_mipmaps(sk_sp< SkImage > img, sk_sp< SkData > data, SkDeserialProcs dProcs, std::optional< SkAlphaType > alphaType)
static sk_sp< SkImage > deserialize_image(sk_sp< SkData > data, SkDeserialProcs dProcs, std::optional< SkAlphaType > alphaType)
@ kNone_SkLegacyFQ
nearest-neighbor; fastest but lowest quality
static sk_sp< SkData > MakeWithoutCopy(const void *data, size_t length)
static sk_sp< SkData > MakeFromMalloc(const void *data, size_t length)
sk_sp< SkFlattenable >(* Factory)(SkReadBuffer &)
virtual Type getFlattenableType() const =0
static Factory NameToFactory(const char name[])
virtual sk_sp< SkImage > makeSubset(GrDirectContext *direct, const SkIRect &subset) const =0
static SkM44 ColMajor(const SkScalar c[16])
static size_t ReadFromMemory(SkMatrix *matrix, const void *buffer, size_t length)
SkISize dimensions() const
size_t readFromMemory(const void *buffer, size_t length)
bool readColor4fArray(SkColor4f *colors, size_t size)
void readColor4f(SkColor4f *color)
SkLegacyFQ checkFilterQuality()
SkFlattenable * readRawFlattenable()
const void * skipByteArray(size_t *size)
void readMatrix(SkMatrix *matrix)
void setMemory(const void *, size_t)
bool readByteArray(void *value, size_t size)
bool validate(bool isValid)
bool readIntArray(int32_t *values, size_t size)
const void * skip(size_t size)
sk_sp< SkData > readByteArrayAsData()
void readIRect(SkIRect *rect)
void setAllowSkSL(bool allow)
void setDeserialProcs(const SkDeserialProcs &procs)
SkSamplingOptions readSampling()
bool readPointArray(SkPoint *points, size_t size)
sk_sp< SkTypeface > readTypeface()
void readString(SkString *string)
bool readColorArray(SkColor *colors, size_t size)
bool readPad32(void *buffer, size_t bytes)
int32_t checkInt(int min, int max)
sk_sp< T > readFlattenable()
bool readScalarArray(SkScalar *values, size_t size)
void readPoint3(SkPoint3 *point)
sk_sp< SkImage > readImage()
void readRRect(SkRRect *rrect)
void readRegion(SkRegion *region)
void readPath(SkPath *path)
bool isVersionLT(SkPicturePriv::Version targetVersion) const
size_t readFromMemory(const void *buffer, size_t length)
static size_t Mul(size_t x, size_t y)
V * find(const K &key) const
FlutterSemanticsFlag flags
static const uint8_t buffer[]
static float max(float r, float g, float b)
static float min(float r, float g, float b)
SK_API sk_sp< SkImage > DeferredFromEncodedData(sk_sp< SkData > encoded, std::optional< SkAlphaType > alphaType=std::nullopt)
SK_API sk_sp< SkImage > DeferredFromGenerator(std::unique_ptr< SkImageGenerator > imageGenerator)
SkDeserialTypefaceProc fTypefaceProc
SkDeserialImageProc fImageProc
SkDeserialImageFromDataProc fImageDataProc
static SkImageInfo MakeN32Premul(int width, int height)
static constexpr SkSamplingOptions Aniso(int maxAniso)