#include <SkReadBuffer.h>
|
| SkReadBuffer ()=default |
|
| SkReadBuffer (const void *data, size_t size) |
|
void | setMemory (const void *, size_t) |
|
bool | isVersionLT (SkPicturePriv::Version targetVersion) const |
|
uint32_t | getVersion () const |
|
void | setVersion (int version) |
|
size_t | size () const |
|
size_t | offset () const |
|
bool | eof () |
|
const void * | skip (size_t size) |
|
const void * | skip (size_t count, size_t size) |
|
size_t | available () const |
|
template<typename T > |
const T * | skipT () |
|
template<typename T > |
const T * | skipT (size_t count) |
|
bool | readBool () |
|
SkColor | readColor () |
|
int32_t | readInt () |
|
SkScalar | readScalar () |
|
uint32_t | readUInt () |
|
int32_t | read32 () |
|
template<typename T > |
T | read32LE (T max) |
|
uint8_t | peekByte () |
|
void | readString (SkString *string) |
|
void | readColor4f (SkColor4f *color) |
|
void | readPoint (SkPoint *point) |
|
SkPoint | readPoint () |
|
void | readPoint3 (SkPoint3 *point) |
|
void | read (SkM44 *) |
|
void | readMatrix (SkMatrix *matrix) |
|
void | readIRect (SkIRect *rect) |
|
void | readRect (SkRect *rect) |
|
SkRect | readRect () |
|
void | readRRect (SkRRect *rrect) |
|
void | readRegion (SkRegion *region) |
|
void | readPath (SkPath *path) |
|
SkPaint | readPaint () |
|
SkFlattenable * | readRawFlattenable () |
|
SkFlattenable * | readFlattenable (SkFlattenable::Type) |
|
template<typename T > |
sk_sp< T > | readFlattenable () |
|
sk_sp< SkColorFilter > | readColorFilter () |
|
sk_sp< SkImageFilter > | readImageFilter () |
|
sk_sp< SkBlender > | readBlender () |
|
sk_sp< SkMaskFilter > | readMaskFilter () |
|
sk_sp< SkPathEffect > | readPathEffect () |
|
sk_sp< SkShader > | readShader () |
|
bool | readPad32 (void *buffer, size_t bytes) |
|
bool | readByteArray (void *value, size_t size) |
|
bool | readColorArray (SkColor *colors, size_t size) |
|
bool | readColor4fArray (SkColor4f *colors, size_t size) |
|
bool | readIntArray (int32_t *values, size_t size) |
|
bool | readPointArray (SkPoint *points, size_t size) |
|
bool | readScalarArray (SkScalar *values, size_t size) |
|
const void * | skipByteArray (size_t *size) |
|
sk_sp< SkData > | readByteArrayAsData () |
|
uint32_t | getArrayCount () |
|
sk_sp< SkImage > | readImage () |
|
sk_sp< SkTypeface > | readTypeface () |
|
void | setTypefaceArray (sk_sp< SkTypeface > array[], int count) |
|
void | setFactoryPlayback (SkFlattenable::Factory array[], int count) |
|
void | setDeserialProcs (const SkDeserialProcs &procs) |
|
const SkDeserialProcs & | getDeserialProcs () const |
|
bool | allowSkSL () const |
|
void | setAllowSkSL (bool allow) |
|
bool | validate (bool isValid) |
|
template<typename T > |
bool | validateCanReadN (size_t n) |
|
bool | isValid () const |
|
bool | validateIndex (int index, int count) |
|
int32_t | checkInt (int min, int max) |
|
template<typename T > |
T | checkRange (T min, T max) |
|
SkLegacyFQ | checkFilterQuality () |
|
SkSamplingOptions | readSampling () |
|
Definition at line 52 of file SkReadBuffer.h.
◆ SkReadBuffer() [1/2]
SkReadBuffer::SkReadBuffer |
( |
| ) |
|
|
default |
◆ SkReadBuffer() [2/2]
SkReadBuffer::SkReadBuffer |
( |
const void * |
data, |
|
|
size_t |
size |
|
) |
| |
|
inline |
Definition at line 55 of file SkReadBuffer.h.
55 {
57 }
void setMemory(const void *, size_t)
std::shared_ptr< const fml::Mapping > data
◆ allowSkSL()
bool SkReadBuffer::allowSkSL |
( |
| ) |
const |
|
inline |
◆ available()
size_t SkReadBuffer::available |
( |
| ) |
const |
|
inline |
◆ checkFilterQuality()
Definition at line 563 of file SkReadBuffer.cpp.
563 {
565}
@ kNone_SkLegacyFQ
nearest-neighbor; fastest but lowest quality
◆ checkInt()
int32_t SkReadBuffer::checkInt |
( |
int |
min, |
|
|
int |
max |
|
) |
| |
Definition at line 553 of file SkReadBuffer.cpp.
553 {
556 if (value < min || value >
max) {
559 }
561}
bool validate(bool isValid)
static float max(float r, float g, float b)
static float min(float r, float g, float b)
◆ checkRange()
T SkReadBuffer::checkRange |
( |
T |
min, |
|
|
T |
max |
|
) |
| |
|
inline |
Definition at line 219 of file SkReadBuffer.h.
219 {
220 return static_cast<T>(this->
checkInt(
static_cast<int32_t
>(
min),
221 static_cast<int32_t
>(
max)));
222 }
int32_t checkInt(int min, int max)
◆ eof()
bool SkReadBuffer::eof |
( |
| ) |
|
|
inline |
◆ getArrayCount()
uint32_t SkReadBuffer::getArrayCount |
( |
| ) |
|
Definition at line 330 of file SkReadBuffer.cpp.
330 {
331 const size_t inc = sizeof(uint32_t);
332 if (!this->
validate(IsPtrAlign4(fCurr) && this->isAvailable(inc))) {
333 return 0;
334 }
335 return *((const uint32_t*)fCurr);
336}
◆ getDeserialProcs()
◆ getVersion()
uint32_t SkReadBuffer::getVersion |
( |
| ) |
const |
|
inline |
◆ isValid()
bool SkReadBuffer::isValid |
( |
| ) |
const |
|
inline |
◆ isVersionLT()
Returns true IFF the version is older than the specified version.
Definition at line 64 of file SkReadBuffer.h.
64 {
66 return fVersion > 0 && fVersion < targetVersion;
67 }
◆ offset()
size_t SkReadBuffer::offset |
( |
| ) |
const |
|
inline |
◆ peekByte()
uint8_t SkReadBuffer::peekByte |
( |
| ) |
|
Definition at line 130 of file SkReadBuffer.cpp.
130 {
132 fError = true;
133 return 0;
134 }
135 return *((const uint8_t*)fCurr);
136}
◆ read()
void SkReadBuffer::read |
( |
SkM44 * |
matrix | ) |
|
Definition at line 184 of file SkReadBuffer.cpp.
184 {
186 if (
const float*
m = (
const float*)this->
skip(
sizeof(
float) * 16)) {
188 }
189 }
192 }
193}
static SkM44 ColMajor(const SkScalar c[16])
const void * skip(size_t size)
◆ read32()
int32_t SkReadBuffer::read32 |
( |
| ) |
|
◆ read32LE()
T SkReadBuffer::read32LE |
( |
T |
max | ) |
|
|
inline |
◆ readBlender()
Definition at line 138 of file SkReadBuffer.h.
138{ return this->readFlattenable<SkBlenderBase>(); }
◆ readBool()
bool SkReadBuffer::readBool |
( |
| ) |
|
◆ readByteArray()
bool SkReadBuffer::readByteArray |
( |
void * |
value, |
|
|
size_t |
size |
|
) |
| |
◆ readByteArrayAsData()
Definition at line 317 of file SkReadBuffer.cpp.
317 {
319 if (!this->
validate(this->isAvailable(numBytes))) {
320 return nullptr;
321 }
322
325 return nullptr;
326 }
328}
static sk_sp< SkData > MakeFromMalloc(const void *data, size_t length)
bool readByteArray(void *value, size_t size)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
◆ readColor()
SkColor SkReadBuffer::readColor |
( |
| ) |
|
◆ readColor4f()
void SkReadBuffer::readColor4f |
( |
SkColor4f * |
color | ) |
|
Definition at line 169 of file SkReadBuffer.cpp.
169 {
171 *
color = {0, 0, 0, 0};
172 }
173}
bool readPad32(void *buffer, size_t bytes)
◆ readColor4fArray()
bool SkReadBuffer::readColor4fArray |
( |
SkColor4f * |
colors, |
|
|
size_t |
size |
|
) |
| |
◆ readColorArray()
bool SkReadBuffer::readColorArray |
( |
SkColor * |
colors, |
|
|
size_t |
size |
|
) |
| |
◆ readColorFilter()
Definition at line 136 of file SkReadBuffer.h.
136{ return this->readFlattenable<SkColorFilterBase>(); }
◆ readFlattenable() [1/2]
sk_sp< T > SkReadBuffer::readFlattenable |
( |
| ) |
|
|
inline |
Definition at line 133 of file SkReadBuffer.h.
133 {
135 }
sk_sp< T > readFlattenable()
◆ readFlattenable() [2/2]
Definition at line 541 of file SkReadBuffer.cpp.
541 {
546 return nullptr;
547 }
548 return obj;
549}
virtual Type getFlattenableType() const =0
SkFlattenable * readRawFlattenable()
◆ readImage()
Definition at line 411 of file SkReadBuffer.cpp.
411 {
413
414 std::optional<SkAlphaType> alphaType = std::nullopt;
417 }
419 {
421 if (!data) {
423 return nullptr;
424 }
426 }
427
428
434 }
435 }
436
439 if (!data) {
441 return nullptr;
442 }
443 if (image) {
445 }
446 }
448}
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)
virtual sk_sp< SkImage > makeSubset(GrDirectContext *direct, const SkIRect &subset) const =0
sk_sp< SkData > readByteArrayAsData()
void readIRect(SkIRect *rect)
FlutterSemanticsFlag flags
sk_sp< const SkImage > image
◆ readImageFilter()
Definition at line 137 of file SkReadBuffer.h.
137{ return this->readFlattenable<SkImageFilter_Base>(); }
◆ readInt()
int32_t SkReadBuffer::readInt |
( |
| ) |
|
Definition at line 102 of file SkReadBuffer.cpp.
102 {
103 const size_t inc = sizeof(int32_t);
104 if (!this->
validate(IsPtrAlign4(fCurr) && this->isAvailable(inc))) {
105 return 0;
106 }
107 int32_t
value = *((
const int32_t*)fCurr);
108 fCurr += inc;
110}
◆ readIntArray()
bool SkReadBuffer::readIntArray |
( |
int32_t * |
values, |
|
|
size_t |
size |
|
) |
| |
◆ readIRect()
void SkReadBuffer::readIRect |
( |
SkIRect * |
rect | ) |
|
Definition at line 207 of file SkReadBuffer.cpp.
207 {
210 }
211}
sk_sp< SkBlender > blender SkRect rect
◆ readMaskFilter()
Definition at line 139 of file SkReadBuffer.h.
139{ return this->readFlattenable<SkMaskFilterBase>(); }
◆ readMatrix()
void SkReadBuffer::readMatrix |
( |
SkMatrix * |
matrix | ) |
|
Definition at line 195 of file SkReadBuffer.cpp.
195 {
200 }
203 }
204 (void)this->
skip(size);
205}
static constexpr T SkAlign4(T x)
static size_t ReadFromMemory(SkMatrix *matrix, const void *buffer, size_t length)
unsigned useCenter Optional< SkMatrix > matrix
◆ readPad32()
bool SkReadBuffer::readPad32 |
( |
void * |
buffer, |
|
|
size_t |
bytes |
|
) |
| |
Definition at line 138 of file SkReadBuffer.cpp.
138 {
139 if (
const void*
src = this->
skip(bytes)) {
140
141
143 return true;
144 }
145 return false;
146}
static void * sk_careful_memcpy(void *dst, const void *src, size_t len)
◆ readPaint()
SkPaint SkReadBuffer::readPaint |
( |
| ) |
|
|
inline |
Definition at line 127 of file SkReadBuffer.h.
127 {
129 }
static SkPaint Unflatten(SkReadBuffer &buffer)
◆ readPath()
void SkReadBuffer::readPath |
( |
SkPath * |
path | ) |
|
Definition at line 267 of file SkReadBuffer.cpp.
267 {
269 if (!fError) {
273 }
274 }
275 (void)this->
skip(size);
276}
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
◆ readPathEffect()
Definition at line 140 of file SkReadBuffer.h.
140{ return this->readFlattenable<SkPathEffect>(); }
◆ readPoint() [1/2]
SkPoint SkReadBuffer::readPoint |
( |
| ) |
|
|
inline |
◆ readPoint() [2/2]
void SkReadBuffer::readPoint |
( |
SkPoint * |
point | ) |
|
◆ readPoint3()
void SkReadBuffer::readPoint3 |
( |
SkPoint3 * |
point | ) |
|
◆ readPointArray()
bool SkReadBuffer::readPointArray |
( |
SkPoint * |
points, |
|
|
size_t |
size |
|
) |
| |
◆ readRawFlattenable()
Definition at line 474 of file SkReadBuffer.cpp.
474 {
476
477 if (fFactoryCount > 0) {
478 int32_t index = this->
read32();
479 if (0 == index || !this->
isValid()) {
480 return nullptr;
481 }
482 if (index < 0) {
484 return nullptr;
485 }
486 index -= 1;
487 if ((unsigned)index >= (unsigned)fFactoryCount) {
489 return nullptr;
490 }
491 factory = fFactoryArray[index];
492 } else {
494
495 size_t ignored_length;
498 fFlattenableDict.
set(fFlattenableDict.
count() + 1, factory);
499 }
500 } else {
501
502
503 uint32_t index = this->
readUInt() >> 8;
504 if (index == 0) {
505 return nullptr;
506 }
507
509 factory = *found;
510 }
511 }
512
513 if (!this->
validate(factory !=
nullptr)) {
514 return nullptr;
515 }
516 }
517
518
519
521 uint32_t sizeRecorded = this->
read32();
522 if (factory) {
524 obj = (*factory)(*this);
525
527 if (sizeRecorded != sizeRead) {
529 return nullptr;
530 }
531 } else {
532
533 this->
skip(sizeRecorded);
534 }
536 return nullptr;
537 }
539}
sk_sp< SkFlattenable >(* Factory)(SkReadBuffer &)
static Factory NameToFactory(const char name[])
void readString(SkString *string)
V * find(const K &key) const
DEF_SWITCHES_START aot vmservice shared library name
◆ readRect() [1/2]
SkRect SkReadBuffer::readRect |
( |
| ) |
|
◆ readRect() [2/2]
void SkReadBuffer::readRect |
( |
SkRect * |
rect | ) |
|
◆ readRegion()
void SkReadBuffer::readRegion |
( |
SkRegion * |
region | ) |
|
Definition at line 256 of file SkReadBuffer.cpp.
256 {
258 if (!fError) {
262 }
263 }
264 (void)this->
skip(size);
265}
size_t readFromMemory(const void *buffer, size_t length)
ClipOpAndAA opAA SkRegion region
◆ readRRect()
void SkReadBuffer::readRRect |
( |
SkRRect * |
rrect | ) |
|
Definition at line 245 of file SkReadBuffer.cpp.
245 {
247 if (!fError) {
251 }
252 }
253 (void)this->
skip(size);
254}
size_t readFromMemory(const void *buffer, size_t length)
◆ readSampling()
Definition at line 227 of file SkReadBuffer.cpp.
227 {
229 int maxAniso = this->
readInt();
230 if (maxAniso != 0) {
232 }
233 }
238 } else {
242 }
243}
bool isVersionLT(SkPicturePriv::Version targetVersion) const
SkSamplingOptions(SkFilterMode::kLinear))
static constexpr SkSamplingOptions Aniso(int maxAniso)
◆ readScalar()
Definition at line 112 of file SkReadBuffer.cpp.
112 {
113 const size_t inc =
sizeof(
SkScalar);
114 if (!this->
validate(IsPtrAlign4(fCurr) && this->isAvailable(inc))) {
115 return 0;
116 }
118 fCurr += inc;
120}
◆ readScalarArray()
bool SkReadBuffer::readScalarArray |
( |
SkScalar * |
values, |
|
|
size_t |
size |
|
) |
| |
◆ readShader()
Definition at line 141 of file SkReadBuffer.h.
141{ return this->readFlattenable<SkShaderBase>(); }
◆ readString()
void SkReadBuffer::readString |
( |
SkString * |
string | ) |
|
Definition at line 160 of file SkReadBuffer.cpp.
160 {
162 if (
const char* c_str = this->
readString(&len)) {
163 string->set(c_str,
len);
164 return;
165 }
166 string->reset();
167}
◆ readTypeface()
Definition at line 450 of file SkReadBuffer.cpp.
450 {
451
452
453
454
455
456 int32_t index = this->
read32();
457 if (index == 0) {
458 return nullptr;
459 } else if (index > 0) {
460 if (!this->
validate(index <= fTFCount)) {
461 return nullptr;
462 }
463 return fTFArray[index - 1];
464 } else {
466 const void*
data = this->
skip(size);
468 return nullptr;
469 }
471 }
472}
static size_t sk_negate_to_size_t(int32_t value)
SkDeserialTypefaceProc fTypefaceProc
◆ readUInt()
uint32_t SkReadBuffer::readUInt |
( |
| ) |
|
◆ setAllowSkSL()
void SkReadBuffer::setAllowSkSL |
( |
bool |
allow | ) |
|
|
inline |
◆ setDeserialProcs()
Definition at line 86 of file SkReadBuffer.cpp.
86 {
87 fProcs = procs;
89}
void setAllowSkSL(bool allow)
◆ setFactoryPlayback()
Call this with a pre-loaded array of Factories, in the same order as were created/written by the writer. SkPicture uses this.
Definition at line 176 of file SkReadBuffer.h.
176 {
177 fFactoryArray = array;
178 fFactoryCount =
count;
179 }
◆ setMemory()
void SkReadBuffer::setMemory |
( |
const void * |
data, |
|
|
size_t |
size |
|
) |
| |
Definition at line 53 of file SkReadBuffer.cpp.
53 {
55 if (!fError) {
56 fBase = fCurr = (
const char*)
data;
58 }
59}
◆ setTypefaceArray()
◆ setVersion()
void SkReadBuffer::setVersion |
( |
int |
version | ) |
|
|
inline |
◆ size()
size_t SkReadBuffer::size |
( |
| ) |
const |
|
inline |
◆ skip() [1/2]
const void * SkReadBuffer::skip |
( |
size_t |
count, |
|
|
size_t |
size |
|
) |
| |
Definition at line 82 of file SkReadBuffer.cpp.
82 {
84}
static size_t Mul(size_t x, size_t y)
◆ skip() [2/2]
const void * SkReadBuffer::skip |
( |
size_t |
size | ) |
|
Definition at line 69 of file SkReadBuffer.cpp.
69 {
72 const void*
addr = fCurr;
73 this->
validate(IsPtrAlign4(
addr) && this->isAvailable(inc));
74 if (fError) {
75 return nullptr;
76 }
77
78 fCurr += inc;
80}
◆ skipByteArray()
const void * SkReadBuffer::skipByteArray |
( |
size_t * |
size | ) |
|
Definition at line 308 of file SkReadBuffer.cpp.
308 {
310 const void* buf = this->
skip(count);
313 }
314 return buf;
315}
◆ skipT() [1/2]
const T * SkReadBuffer::skipT |
( |
| ) |
|
|
inline |
Definition at line 84 of file SkReadBuffer.h.
84 {
85 return static_cast<const T*
>(this->
skip(
sizeof(
T)));
86 }
◆ skipT() [2/2]
const T * SkReadBuffer::skipT |
( |
size_t |
count | ) |
|
|
inline |
◆ validate()
bool SkReadBuffer::validate |
( |
bool |
isValid | ) |
|
|
inline |
If isValid is false, sets the buffer to be "invalid". Returns true if the buffer is still valid.
Definition at line 191 of file SkReadBuffer.h.
191 {
193 this->setInvalid();
194 }
195 return !fError;
196 }
◆ validateCanReadN()
bool SkReadBuffer::validateCanReadN |
( |
size_t |
n | ) |
|
|
inline |
Helper function to do a preflight check before a large allocation or read. Returns true if there is enough bytes in the buffer to read n elements of T. If not, the buffer will be "invalid" and false will be returned.
Definition at line 204 of file SkReadBuffer.h.
◆ validateIndex()
bool SkReadBuffer::validateIndex |
( |
int |
index, |
|
|
int |
count |
|
) |
| |
|
inline |
The documentation for this class was generated from the following files: