Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
SkWStream Class Referenceabstract

#include <SkStream.h>

Inheritance diagram for SkWStream:
SkDebugfStream SkDeflateWStream SkDynamicMemoryWStream SkFILEWStream SkMD5 SkNullWStream SkRawLimitedDynamicMemoryWStream

Public Member Functions

virtual ~SkWStream ()
 
 SkWStream ()
 
virtual bool write (const void *buffer, size_t size)=0
 
virtual void flush ()
 
virtual size_t bytesWritten () const =0
 
bool write8 (U8CPU value)
 
bool write16 (U16CPU value)
 
bool write32 (uint32_t v)
 
bool writeText (const char text[])
 
bool newline ()
 
bool writeDecAsText (int32_t)
 
bool writeBigDecAsText (int64_t, int minDigits=0)
 
bool writeHexAsText (uint32_t, int minDigits=0)
 
bool writeScalarAsText (SkScalar)
 
bool writeBool (bool v)
 
bool writeScalar (SkScalar)
 
bool writePackedUInt (size_t)
 
bool writeStream (SkStream *input, size_t length)
 

Static Public Member Functions

static int SizeOfPackedUInt (size_t value)
 

Detailed Description

Definition at line 218 of file SkStream.h.

Constructor & Destructor Documentation

◆ ~SkWStream()

SkWStream::~SkWStream ( )
virtual

Definition at line 73 of file SkStream.cpp.

74{
75}

◆ SkWStream()

SkWStream::SkWStream ( )
inline

Definition at line 221 of file SkStream.h.

221{}

Member Function Documentation

◆ bytesWritten()

virtual size_t SkWStream::bytesWritten ( ) const
pure virtual

◆ flush()

void SkWStream::flush ( )
virtual

Reimplemented in SkNullWStream, and SkFILEWStream.

Definition at line 77 of file SkStream.cpp.

78{
79}

◆ newline()

bool SkWStream::newline ( )
inline

Definition at line 252 of file SkStream.h.

252{ return this->write("\n", std::strlen("\n")); }
virtual bool write(const void *buffer, size_t size)=0

◆ SizeOfPackedUInt()

int SkWStream::SizeOfPackedUInt ( size_t  value)
static

This returns the number of bytes in the stream required to store 'value'.

Definition at line 113 of file SkStream.cpp.

113 {
114 if (value <= SK_MAX_BYTE_FOR_U8) {
115 return 1;
116 } else if (value <= 0xFFFF) {
117 return 3;
118 }
119 return 5;
120}
#define SK_MAX_BYTE_FOR_U8
Definition: SkStream.cpp:48
uint8_t value

◆ write()

virtual bool SkWStream::write ( const void *  buffer,
size_t  size 
)
pure virtual

Called to write bytes to a SkWStream. Returns true on success

Parameters
bufferthe address of at least size bytes to be written to the stream
sizeThe number of bytes in buffer to write to the stream
Returns
true on success

Implemented in SkNullWStream, SkDeflateWStream, SkMD5, SkFILEWStream, SkDynamicMemoryWStream, SkRawLimitedDynamicMemoryWStream, and SkDebugfStream.

◆ write16()

bool SkWStream::write16 ( U16CPU  value)
inline

Definition at line 239 of file SkStream.h.

239 {
240 uint16_t v = SkToU16(value);
241 return this->write(&v, 2);
242 }
constexpr uint16_t SkToU16(S x)
Definition: SkTo.h:24

◆ write32()

bool SkWStream::write32 ( uint32_t  v)
inline

Definition at line 243 of file SkStream.h.

243 {
244 return this->write(&v, 4);
245 }

◆ write8()

bool SkWStream::write8 ( U8CPU  value)
inline

Definition at line 235 of file SkStream.h.

235 {
236 uint8_t v = SkToU8(value);
237 return this->write(&v, 1);
238 }
constexpr uint8_t SkToU8(S x)
Definition: SkTo.h:22

◆ writeBigDecAsText()

bool SkWStream::writeBigDecAsText ( int64_t  dec,
int  minDigits = 0 
)

Definition at line 88 of file SkStream.cpp.

89{
91 char* stop = SkStrAppendU64(buffer, dec, minDigits);
92 return this->write(buffer, stop - buffer);
93}
char * SkStrAppendU64(char buffer[], uint64_t, int minDigits)
Definition: SkString.cpp:129
static constexpr int kSkStrAppendU64_MaxSize
Definition: SkString.h:86
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
Definition: switches.h:126

◆ writeBool()

bool SkWStream::writeBool ( bool  v)
inline

Definition at line 259 of file SkStream.h.

259{ return this->write8(v); }
bool write8(U8CPU value)
Definition: SkStream.h:235

◆ writeDecAsText()

bool SkWStream::writeDecAsText ( int32_t  dec)

Definition at line 81 of file SkStream.cpp.

82{
84 char* stop = SkStrAppendS32(buffer, dec);
85 return this->write(buffer, stop - buffer);
86}
static constexpr int kSkStrAppendS32_MaxSize
Definition: SkString.h:89
char * SkStrAppendS32(char buffer[], int32_t)
Definition: SkString.cpp:120

◆ writeHexAsText()

bool SkWStream::writeHexAsText ( uint32_t  hex,
int  minDigits = 0 
)

Definition at line 95 of file SkStream.cpp.

96{
97 SkString tmp;
98 tmp.appendHex(hex, digits);
99 return this->write(tmp.c_str(), tmp.size());
100}
size_t size() const
Definition: SkString.h:131
void appendHex(uint32_t value, int minDigits=0)
Definition: SkString.h:212
const char * c_str() const
Definition: SkString.h:133

◆ writePackedUInt()

bool SkWStream::writePackedUInt ( size_t  value)

Definition at line 122 of file SkStream.cpp.

122 {
123 uint8_t data[5];
124 size_t len = 1;
125 if (value <= SK_MAX_BYTE_FOR_U8) {
126 data[0] = value;
127 len = 1;
128 } else if (value <= 0xFFFF) {
129 uint16_t value16 = value;
131 memcpy(&data[1], &value16, 2);
132 len = 3;
133 } else {
134 uint32_t value32 = SkToU32(value);
136 memcpy(&data[1], &value32, 4);
137 len = 5;
138 }
139 return this->write(data, len);
140}
#define SK_BYTE_SENTINEL_FOR_U16
Definition: SkStream.cpp:49
#define SK_BYTE_SENTINEL_FOR_U32
Definition: SkStream.cpp:50
constexpr uint32_t SkToU32(S x)
Definition: SkTo.h:26
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ writeScalar()

bool SkWStream::writeScalar ( SkScalar  value)

Definition at line 109 of file SkStream.cpp.

109 {
110 return this->write(&value, sizeof(value));
111}

◆ writeScalarAsText()

bool SkWStream::writeScalarAsText ( SkScalar  value)

Definition at line 102 of file SkStream.cpp.

103{
105 char* stop = SkStrAppendScalar(buffer, value);
106 return this->write(buffer, stop - buffer);
107}
char * SkStrAppendScalar(char buffer[], SkScalar)
Definition: SkString.cpp:164
static constexpr int kSkStrAppendScalar_MaxSize
Definition: SkString.h:101

◆ writeStream()

bool SkWStream::writeStream ( SkStream input,
size_t  length 
)

Definition at line 142 of file SkStream.cpp.

142 {
143 char scratch[1024];
144 const size_t MAX = sizeof(scratch);
145
146 while (length != 0) {
147 size_t n = length;
148 if (n > MAX) {
149 n = MAX;
150 }
151 stream->read(scratch, n);
152 if (!this->write(scratch, n)) {
153 return false;
154 }
155 length -= n;
156 }
157 return true;
158}
size_t length

◆ writeText()

bool SkWStream::writeText ( const char  text[])
inline

Definition at line 247 of file SkStream.h.

247 {
248 SkASSERT(text);
249 return this->write(text, std::strlen(text));
250 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
std::u16string text

The documentation for this class was generated from the following files: