33 return this->
read(i,
sizeof(*
i)) ==
sizeof(*i);
37 return this->
read(i,
sizeof(*
i)) ==
sizeof(*i);
41 return this->
read(i,
sizeof(*
i)) ==
sizeof(*i);
45 return this->
read(i,
sizeof(*
i)) ==
sizeof(*i);
48#define SK_MAX_BYTE_FOR_U8 0xFD
49#define SK_BYTE_SENTINEL_FOR_U16 0xFE
50#define SK_BYTE_SENTINEL_FOR_U32 0xFF
54 if (!this->
read(&
byte, 1)) {
59 if (!this->
readU16(&i16)) {
return false; }
63 if (!this->
readU32(&i32)) {
return false; }
116 }
else if (
value <= 0xFFFF) {
128 }
else if (
value <= 0xFFFF) {
129 uint16_t value16 =
value;
131 memcpy(&
data[1], &value16, 2);
136 memcpy(&
data[1], &value32, 4);
144 const size_t MAX =
sizeof(scratch);
152 if (!this->
write(scratch, n)) {
166 , fCurrent(
SkTPin(current, fStart, fEnd))
206 if (
size > fEnd - fCurrent) {
207 size = fEnd - fCurrent;
209 size_t bytesRead =
size;
213 if (bytesRead == SIZE_MAX) {
216 fCurrent += bytesRead;
221 if (fCurrent == fEnd) {
238 return fCurrent - fStart;
249 !SkTFitsIn<size_t>(-
offset) ||
256 }
else if (!SkTFitsIn<size_t>(
offset)) {
262 SkASSERT(fCurrent >= fStart && fCurrent <= fEnd);
271 return fEnd - fStart;
300 if (
nullptr == fData) {
307 return std::make_unique<SkMemoryStream>(
data,
length,
true);
311 return std::make_unique<SkMemoryStream>(
data,
length,
false);
315 return std::make_unique<SkMemoryStream>(std::move(
data));
329 if (
nullptr ==
data) {
338 size_t dataSize = fData->
size();
341 if (
size > dataSize - fOffset) {
342 size = dataSize - fOffset;
354 const size_t currentOffset = fOffset;
357 nonConstThis->fOffset = currentOffset;
362 return fOffset == fData->
size();
379 fOffset = position > fData->
size()
390 std::unique_ptr<SkMemoryStream> that(this->
duplicate());
392 return that.release();
396 return fData->
size();
400 return fData->
data();
404 return fData->
bytes() + fOffset;
428 if (fFILE ==
nullptr) {
467#define SkDynamicMemoryWStream_MinBlockSize 4096
474 const char*
start()
const {
return (
const char*)(
this + 1); }
475 char*
start() {
return (
char*)(
this + 1); }
489 return (
const void*)((
const char*)
data +
size);
496 , fBytesWrittenBeforeTail(other.fBytesWrittenBeforeTail)
498 other.fHead =
nullptr;
499 other.fTail =
nullptr;
500 other.fBytesWrittenBeforeTail = 0;
504 if (
this != &other) {
516 Block* block = fHead;
517 while (block !=
nullptr) {
522 fHead = fTail =
nullptr;
523 fBytesWrittenBeforeTail = 0;
530 return fBytesWrittenBeforeTail + fTail->
written();
540 if (fTail && fTail->
avail() > 0) {
562 fBytesWrittenBeforeTail += fTail->
written();
563 fTail->
fNext = block;
565 fHead = fTail = block;
580 *
dst = std::move(*
this);
583 dst->fTail->fNext = fHead;
584 dst->fBytesWrittenBeforeTail += fBytesWrittenBeforeTail +
dst->fTail->written();
586 fHead = fTail =
nullptr;
587 fBytesWrittenBeforeTail = 0;
598 *
dst = std::move(*
this);
603 dst->fBytesWrittenBeforeTail += fBytesWrittenBeforeTail + fTail->
written();
604 fHead = fTail =
nullptr;
605 fBytesWrittenBeforeTail = 0;
613 Block* block = fHead;
614 while (block !=
nullptr) {
626 block = block->
fNext;
633 Block* block = fHead;
634 while (block !=
nullptr) {
638 block = block->
fNext;
644 for (
Block* block = fHead; block !=
nullptr; block = block->
fNext) {
645 if (!
dst->write(block->start(), block->written())) {
662 fTail->
append(&zero, padBytes);
675 char*
dst =
reinterpret_cast<char*
>(ptr);
676 Block* block = fHead;
677 while (block !=
nullptr) {
685 fHead = fTail =
nullptr;
686 fBytesWrittenBeforeTail = 0;
693 bool dstStreamGood =
true;
694 for (
Block* block = fHead; block !=
nullptr; ) {
695 if (dstStreamGood && !
dst->write(block->start(), block->written())) {
696 dstStreamGood =
false;
702 fHead = fTail =
nullptr;
703 fBytesWrittenBeforeTail = 0;
704 return dstStreamGood;
718void SkDynamicMemoryWStream::validate()
const {
721 SkASSERT(fBytesWrittenBeforeTail == 0);
727 const Block* block = fHead;
730 bytes += block->written();
732 block = block->fNext;
734 SkASSERT(bytes == fBytesWrittenBeforeTail);
746 while (block !=
nullptr) {
759 : fBlockMemory(
std::
move(headRef)), fCurrent(fBlockMemory->fHead)
760 , fSize(
size) , fOffset(0), fCurrentOffset(0) { }
763 size_t count = rawCount;
764 if (fOffset +
count > fSize) {
765 count = fSize - fOffset;
767 size_t bytesLeftToRead =
count;
768 while (fCurrent !=
nullptr) {
769 size_t bytesLeftInCurrent = fCurrent->
written() - fCurrentOffset;
770 size_t bytesFromCurrent =
std::min(bytesLeftToRead, bytesLeftInCurrent);
772 memcpy(
buffer, fCurrent->
start() + fCurrentOffset, bytesFromCurrent);
775 if (bytesLeftToRead <= bytesFromCurrent) {
776 fCurrentOffset += bytesFromCurrent;
780 bytesLeftToRead -= bytesFromCurrent;
781 fCurrent = fCurrent->
fNext;
789 return fOffset == fSize;
792 size_t peek(
void* buff,
size_t bytesToPeek)
const override {
795 bytesToPeek =
std::min(bytesToPeek, fSize - fOffset);
797 size_t bytesLeftToPeek = bytesToPeek;
798 char*
buffer =
static_cast<char*
>(buff);
800 size_t currentOffset = fCurrentOffset;
801 while (bytesLeftToPeek) {
803 size_t bytesFromCurrent =
std::min(current->
written() - currentOffset, bytesLeftToPeek);
804 memcpy(
buffer, current->
start() + currentOffset, bytesFromCurrent);
805 bytesLeftToPeek -= bytesFromCurrent;
806 buffer += bytesFromCurrent;
807 current = current->
fNext;
814 fCurrent = fBlockMemory->
fHead;
828 bool seek(
size_t position)
override {
830 if (position >= fOffset) {
831 size_t skipAmount = position - fOffset;
832 return this->
skip(skipAmount) == skipAmount;
835 size_t moveBackAmount = fOffset - position;
836 if (moveBackAmount <= fCurrentOffset) {
837 fCurrentOffset -= moveBackAmount;
838 fOffset -= moveBackAmount;
842 return this->
rewind() && this->
skip(position) == position;
851 that->fCurrent = this->fCurrent;
852 that->fOffset = this->fOffset;
853 that->fCurrentOffset = this->fCurrentOffset;
873 size_t fCurrentOffset;
877 if (
nullptr == fHead) {
881 if (fHead == fTail) {
882 ptrdiff_t used = fTail->
fCurr - (
char*)fTail;
884 fTail->
fStop = fTail->
fCurr = (
char*)fTail + used;
886 SkASSERT(0 == fBytesWrittenBeforeTail);
888 std::unique_ptr<SkStreamAsset>
stream
889 = std::make_unique<SkBlockMemoryStream>(sk_make_sp<SkBlockMemoryRefCnt>(fHead),
900 fBytesWritten +=
size;
905 return fBytesWritten;
913 if (
nullptr ==
file) {
925 return std::make_unique<SkMemoryStream>(std::move(
data));
929 auto stream = std::make_unique<SkFILEStream>(
path);
940 if (
stream->hasLength()) {
945 const size_t bufferSize = 4096;
950 }
while (!
stream->isAtEnd());
966 count = input->
read(scratch,
sizeof(scratch));
978 if (
stream->hasLength()) {
979 if (
stream->hasPosition()) {
980 size_t remainingBytes =
stream->getLength() -
stream->getPosition();
981 return remainingBytes <
len;
static float next(float f)
static constexpr T SkAlign4(T x)
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
SK_API void sk_free(void *)
static void * sk_careful_memcpy(void *dst, const void *src, size_t len)
static void * sk_malloc_canfail(size_t size)
SK_API void * sk_realloc_throw(void *buffer, size_t size)
FILE * sk_fopen(const char path[], SkFILE_Flags)
size_t sk_fwrite(const void *buffer, size_t byteCount, FILE *)
size_t sk_qread(FILE *, void *buffer, size_t count, size_t offset)
size_t sk_fgetsize(FILE *)
#define SkDynamicMemoryWStream_MinBlockSize
bool StreamRemainingLengthIsBelow(SkStream *stream, size_t len)
#define SK_MAX_BYTE_FOR_U8
static void sk_memcpy_4bytes(void *dst, const void *src, size_t size)
bool SkStreamCopy(SkWStream *out, SkStream *input)
sk_sp< SkData > SkCopyStreamToData(SkStream *stream)
#define SK_BYTE_SENTINEL_FOR_U16
static sk_sp< SkData > newFromParams(const void *src, size_t size, bool copyData)
#define SK_BYTE_SENTINEL_FOR_U32
static sk_sp< SkData > mmap_filename(const char path[])
static constexpr int kSkStrAppendS32_MaxSize
char * SkStrAppendU64(char buffer[], uint64_t, int minDigits)
char * SkStrAppendScalar(char buffer[], SkScalar)
static constexpr int kSkStrAppendScalar_MaxSize
static constexpr int kSkStrAppendU64_MaxSize
char * SkStrAppendS32(char buffer[], int32_t)
static constexpr const T & SkTPin(const T &x, const T &lo, const T &hi)
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
constexpr size_t SkToSizeT(S x)
constexpr uint32_t SkToU32(S x)
SkDynamicMemoryWStream::Block *const fHead
SkBlockMemoryRefCnt(SkDynamicMemoryWStream::Block *head)
~SkBlockMemoryRefCnt() override
const void * getMemoryBase() override
SkBlockMemoryStream * onDuplicate() const override
SkBlockMemoryStream * onFork() const override
size_t getLength() const override
size_t getPosition() const override
size_t peek(void *buff, size_t bytesToPeek) const override
SkBlockMemoryStream(sk_sp< SkBlockMemoryRefCnt > headRef, size_t size)
bool isAtEnd() const override
bool seek(size_t position) override
size_t read(void *buffer, size_t rawCount) override
bool move(long offset) override
static sk_sp< SkData > MakeWithoutCopy(const void *data, size_t length)
const uint8_t * bytes() const
static sk_sp< SkData > MakeFromMalloc(const void *data, size_t length)
static sk_sp< SkData > MakeUninitialized(size_t length)
const void * data() const
static sk_sp< SkData > MakeFromFILE(FILE *f)
static sk_sp< SkData > MakeWithCopy(const void *data, size_t length)
static sk_sp< SkData > MakeFromStream(SkStream *, size_t size)
static sk_sp< SkData > MakeEmpty()
size_t bytesWritten() const override
bool write(const void *buffer, size_t size) override
size_t bytesWritten() const override
~SkDynamicMemoryWStream() override
bool writeToStream(SkWStream *dst) const
bool writeToAndReset(SkWStream *dst)
void copyToAndReset(void *dst)
void copyTo(void *dst) const
SkDynamicMemoryWStream()=default
std::unique_ptr< SkStreamAsset > detachAsStream()
bool write(const void *buffer, size_t size) override
SkDynamicMemoryWStream & operator=(SkDynamicMemoryWStream &&)
bool read(void *buffer, size_t offset, size_t size)
void prependToAndReset(SkDynamicMemoryWStream *dst)
sk_sp< SkData > detachAsData()
bool move(long offset) override
bool seek(size_t position) override
size_t read(void *buffer, size_t size) override
bool isAtEnd() const override
size_t getLength() const override
size_t getPosition() const override
SkFILEStream(const char path[]=nullptr)
size_t bytesWritten() const override
bool write(const void *buffer, size_t size) override
~SkFILEWStream() override
SkFILEWStream(const char path[])
virtual void setMemory(const void *data, size_t length, bool copyData=false)
bool isAtEnd() const override
bool move(long offset) override
bool seek(size_t position) override
size_t read(void *buffer, size_t size) override
static std::unique_ptr< SkMemoryStream > Make(sk_sp< SkData > data)
void setMemoryOwned(const void *data, size_t length)
static std::unique_ptr< SkMemoryStream > MakeDirect(const void *data, size_t length)
static std::unique_ptr< SkMemoryStream > MakeCopy(const void *data, size_t length)
size_t getLength() const override
size_t peek(void *buffer, size_t size) const override
const void * getMemoryBase() override
void setData(sk_sp< SkData > data)
size_t getPosition() const override
std::unique_ptr< SkMemoryStream > duplicate() const
static size_t Add(size_t x, size_t y)
bool readScalar(SkScalar *)
bool readPackedUInt(size_t *)
virtual bool hasPosition() const
virtual size_t getPosition() const
static std::unique_ptr< SkStreamAsset > MakeFromFile(const char path[])
bool readU16(uint16_t *i)
bool readU32(uint32_t *i)
virtual size_t getLength() const
virtual const void * getMemoryBase()
virtual bool hasLength() const
virtual size_t read(void *buffer, size_t size)=0
void appendHex(uint32_t value, int minDigits=0)
const char * c_str() const
static int SizeOfPackedUInt(size_t value)
bool writePackedUInt(size_t)
virtual bool write(const void *buffer, size_t size)=0
bool writeScalarAsText(SkScalar)
bool writeHexAsText(uint32_t, int minDigits=0)
bool writeStream(SkStream *input, size_t length)
bool writeDecAsText(int32_t)
bool writeBigDecAsText(int64_t, int minDigits=0)
bool writeScalar(SkScalar)
static float min(float r, float g, float b)
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
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
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
const void * append(const void *data, size_t size)
const char * start() const
std::shared_ptr< const fml::Mapping > data