Skia
2D Graphics Library
SkStream.h
Go to the documentation of this file.
1 /*
2  * Copyright 2006 The Android Open Source Project
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkStream_DEFINED
9 #define SkStream_DEFINED
10 
11 #include "include/core/SkData.h"
12 #include "include/core/SkRefCnt.h"
13 #include "include/core/SkScalar.h"
14 #include "include/private/SkTo.h"
15 
16 #include <memory.h>
17 
18 class SkStream;
19 class SkStreamRewindable;
20 class SkStreamSeekable;
21 class SkStreamAsset;
22 class SkStreamMemory;
23 
42 public:
43  virtual ~SkStream() {}
44  SkStream() {}
45 
49  static std::unique_ptr<SkStreamAsset> MakeFromFile(const char path[]);
50 
58  virtual size_t read(void* buffer, size_t size) = 0;
59 
63  size_t skip(size_t size) {
64  return this->read(nullptr, size);
65  }
66 
80  virtual size_t peek(void* /*buffer*/, size_t /*size*/) const { return 0; }
81 
86  virtual bool isAtEnd() const = 0;
87 
91 
92  bool SK_WARN_UNUSED_RESULT readU8(uint8_t* i) { return this->readS8((int8_t*)i); }
93  bool SK_WARN_UNUSED_RESULT readU16(uint16_t* i) { return this->readS16((int16_t*)i); }
94  bool SK_WARN_UNUSED_RESULT readU32(uint32_t* i) { return this->readS32((int32_t*)i); }
95 
97  uint8_t i;
98  if (!this->readU8(&i)) { return false; }
99  *b = (i != 0);
100  return true;
101  }
104 
105 //SkStreamRewindable
109  virtual bool rewind() { return false; }
110 
114  std::unique_ptr<SkStream> duplicate() const {
115  return std::unique_ptr<SkStream>(this->onDuplicate());
116  }
120  std::unique_ptr<SkStream> fork() const {
121  return std::unique_ptr<SkStream>(this->onFork());
122  }
123 
124 //SkStreamSeekable
126  virtual bool hasPosition() const { return false; }
128  virtual size_t getPosition() const { return 0; }
129 
134  virtual bool seek(size_t /*position*/) { return false; }
135 
140  virtual bool move(long /*offset*/) { return false; }
141 
142 //SkStreamAsset
144  virtual bool hasLength() const { return false; }
146  virtual size_t getLength() const { return 0; }
147 
148 //SkStreamMemory
150  //TODO: replace with virtual const SkData* getData()
151  virtual const void* getMemoryBase() { return nullptr; }
152 
153 private:
154  virtual SkStream* onDuplicate() const { return nullptr; }
155  virtual SkStream* onFork() const { return nullptr; }
156 
157  SkStream(SkStream&&) = delete;
158  SkStream(const SkStream&) = delete;
159  SkStream& operator=(SkStream&&) = delete;
160  SkStream& operator=(const SkStream&) = delete;
161 };
162 
165 public:
166  bool rewind() override = 0;
167  std::unique_ptr<SkStreamRewindable> duplicate() const {
168  return std::unique_ptr<SkStreamRewindable>(this->onDuplicate());
169  }
170 private:
171  SkStreamRewindable* onDuplicate() const override = 0;
172 };
173 
176 public:
177  std::unique_ptr<SkStreamSeekable> duplicate() const {
178  return std::unique_ptr<SkStreamSeekable>(this->onDuplicate());
179  }
180 
181  bool hasPosition() const override { return true; }
182  size_t getPosition() const override = 0;
183  bool seek(size_t position) override = 0;
184  bool move(long offset) override = 0;
185 
186  std::unique_ptr<SkStreamSeekable> fork() const {
187  return std::unique_ptr<SkStreamSeekable>(this->onFork());
188  }
189 private:
190  SkStreamSeekable* onDuplicate() const override = 0;
191  SkStreamSeekable* onFork() const override = 0;
192 };
193 
196 public:
197  bool hasLength() const override { return true; }
198  size_t getLength() const override = 0;
199 
200  std::unique_ptr<SkStreamAsset> duplicate() const {
201  return std::unique_ptr<SkStreamAsset>(this->onDuplicate());
202  }
203  std::unique_ptr<SkStreamAsset> fork() const {
204  return std::unique_ptr<SkStreamAsset>(this->onFork());
205  }
206 private:
207  SkStreamAsset* onDuplicate() const override = 0;
208  SkStreamAsset* onFork() const override = 0;
209 };
210 
213 public:
214  const void* getMemoryBase() override = 0;
215 
216  std::unique_ptr<SkStreamMemory> duplicate() const {
217  return std::unique_ptr<SkStreamMemory>(this->onDuplicate());
218  }
219  std::unique_ptr<SkStreamMemory> fork() const {
220  return std::unique_ptr<SkStreamMemory>(this->onFork());
221  }
222 private:
223  SkStreamMemory* onDuplicate() const override = 0;
224  SkStreamMemory* onFork() const override = 0;
225 };
226 
228 public:
229  virtual ~SkWStream();
231 
237  virtual bool write(const void* buffer, size_t size) = 0;
238  virtual void flush();
239 
240  virtual size_t bytesWritten() const = 0;
241 
242  // helpers
243 
244  bool write8(U8CPU value) {
245  uint8_t v = SkToU8(value);
246  return this->write(&v, 1);
247  }
248  bool write16(U16CPU value) {
249  uint16_t v = SkToU16(value);
250  return this->write(&v, 2);
251  }
252  bool write32(uint32_t v) {
253  return this->write(&v, 4);
254  }
255 
256  bool writeText(const char text[]) {
257  SkASSERT(text);
258  return this->write(text, strlen(text));
259  }
260 
261  bool newline() { return this->write("\n", strlen("\n")); }
262 
263  bool writeDecAsText(int32_t);
264  bool writeBigDecAsText(int64_t, int minDigits = 0);
265  bool writeHexAsText(uint32_t, int minDigits = 0);
267 
268  bool writeBool(bool v) { return this->write8(v); }
270  bool writePackedUInt(size_t);
271 
272  bool writeStream(SkStream* input, size_t length);
273 
278  static int SizeOfPackedUInt(size_t value);
279 
280 private:
281  SkWStream(const SkWStream&) = delete;
282  SkWStream& operator=(const SkWStream&) = delete;
283 };
284 
286 public:
287  SkNullWStream() : fBytesWritten(0) {}
288 
289  bool write(const void* , size_t n) override { fBytesWritten += n; return true; }
290  void flush() override {}
291  size_t bytesWritten() const override { return fBytesWritten; }
292 
293 private:
294  size_t fBytesWritten;
295 };
296 
298 
299 #include <stdio.h>
300 
303 public:
307  explicit SkFILEStream(const char path[] = nullptr);
308 
314  explicit SkFILEStream(FILE* file);
315 
321  explicit SkFILEStream(FILE* file, size_t size);
322 
323  ~SkFILEStream() override;
324 
325  static std::unique_ptr<SkFILEStream> Make(const char path[]) {
326  std::unique_ptr<SkFILEStream> stream(new SkFILEStream(path));
327  return stream->isValid() ? std::move(stream) : nullptr;
328  }
329 
331  bool isValid() const { return fFILE != nullptr; }
332 
334  void close();
335 
336  size_t read(void* buffer, size_t size) override;
337  bool isAtEnd() const override;
338 
339  bool rewind() override;
340  std::unique_ptr<SkStreamAsset> duplicate() const {
341  return std::unique_ptr<SkStreamAsset>(this->onDuplicate());
342  }
343 
344  size_t getPosition() const override;
345  bool seek(size_t position) override;
346  bool move(long offset) override;
347 
348  std::unique_ptr<SkStreamAsset> fork() const {
349  return std::unique_ptr<SkStreamAsset>(this->onFork());
350  }
351 
352  size_t getLength() const override;
353 
354 private:
355  explicit SkFILEStream(FILE*, size_t size, size_t start);
356  explicit SkFILEStream(std::shared_ptr<FILE>, size_t end, size_t start);
357  explicit SkFILEStream(std::shared_ptr<FILE>, size_t end, size_t start, size_t current);
358 
359  SkStreamAsset* onDuplicate() const override;
360  SkStreamAsset* onFork() const override;
361 
362  std::shared_ptr<FILE> fFILE;
363  // My own council will I keep on sizes and offsets.
364  // These are seek positions in the underling FILE, not offsets into the stream.
365  size_t fEnd;
366  size_t fStart;
367  size_t fCurrent;
368 
369  using INHERITED = SkStreamAsset;
370 };
371 
373 public:
375 
377  SkMemoryStream(size_t length);
378 
380  SkMemoryStream(const void* data, size_t length, bool copyData = false);
381 
384 
386  static std::unique_ptr<SkMemoryStream> MakeCopy(const void* data, size_t length);
387 
389  static std::unique_ptr<SkMemoryStream> MakeDirect(const void* data, size_t length);
390 
392  static std::unique_ptr<SkMemoryStream> Make(sk_sp<SkData> data);
393 
398  virtual void setMemory(const void* data, size_t length,
399  bool copyData = false);
404  void setMemoryOwned(const void* data, size_t length);
405 
406  sk_sp<SkData> asData() const { return fData; }
407  void setData(sk_sp<SkData> data);
408 
409  void skipToAlign4();
410  const void* getAtPos();
411 
412  size_t read(void* buffer, size_t size) override;
413  bool isAtEnd() const override;
414 
415  size_t peek(void* buffer, size_t size) const override;
416 
417  bool rewind() override;
418 
419  std::unique_ptr<SkMemoryStream> duplicate() const {
420  return std::unique_ptr<SkMemoryStream>(this->onDuplicate());
421  }
422 
423  size_t getPosition() const override;
424  bool seek(size_t position) override;
425  bool move(long offset) override;
426 
427  std::unique_ptr<SkMemoryStream> fork() const {
428  return std::unique_ptr<SkMemoryStream>(this->onFork());
429  }
430 
431  size_t getLength() const override;
432 
433  const void* getMemoryBase() override;
434 
435 private:
436  SkMemoryStream* onDuplicate() const override;
437  SkMemoryStream* onFork() const override;
438 
439  sk_sp<SkData> fData;
440  size_t fOffset;
441 
442  using INHERITED = SkStreamMemory;
443 };
444 
446 
448 public:
449  SkFILEWStream(const char path[]);
450  ~SkFILEWStream() override;
451 
454  bool isValid() const { return fFILE != nullptr; }
455 
456  bool write(const void* buffer, size_t size) override;
457  void flush() override;
458  void fsync();
459  size_t bytesWritten() const override;
460 
461 private:
462  FILE* fFILE;
463 
464  using INHERITED = SkWStream;
465 };
466 
468 public:
473 
474  bool write(const void* buffer, size_t size) override;
475  size_t bytesWritten() const override;
476 
477  bool read(void* buffer, size_t offset, size_t size);
478 
480  void copyTo(void* dst) const;
481  bool writeToStream(SkWStream* dst) const;
482 
484  void copyToAndReset(void* dst);
485 
488 
492 
495 
498 
500  std::unique_ptr<SkStreamAsset> detachAsStream();
501 
503  void reset();
504  void padToAlign4();
505 private:
506  struct Block;
507  Block* fHead = nullptr;
508  Block* fTail = nullptr;
509  size_t fBytesWrittenBeforeTail = 0;
510 
511 #ifdef SK_DEBUG
512  void validate() const;
513 #else
514  void validate() const {}
515 #endif
516 
517  // For access to the Block type.
518  friend class SkBlockMemoryStream;
519  friend class SkBlockMemoryRefCnt;
520 
521  using INHERITED = SkWStream;
522 };
523 
524 #endif
SkStream::seek
virtual bool seek(size_t)
Seeks to an absolute position in the stream.
Definition: SkStream.h:134
SkStream::readS8
bool SK_WARN_UNUSED_RESULT readS8(int8_t *)
SkStreamSeekable::fork
std::unique_ptr< SkStreamSeekable > fork() const
Definition: SkStream.h:186
SkStream::read
virtual size_t read(void *buffer, size_t size)=0
Reads or skips size number of bytes.
SkFILEWStream::flush
void flush() override
SkMemoryStream::SkMemoryStream
SkMemoryStream(size_t length)
We allocate (and free) the memory.
SkFILEStream::isValid
bool isValid() const
Returns true if the current path could be opened.
Definition: SkStream.h:331
SkStreamSeekable::getPosition
size_t getPosition() const override=0
Returns the current position in the stream.
SkNullWStream
Definition: SkStream.h:285
SkWStream::writeDecAsText
bool writeDecAsText(int32_t)
SkWStream::writeText
bool writeText(const char text[])
Definition: SkStream.h:256
SkDynamicMemoryWStream::SkDynamicMemoryWStream
SkDynamicMemoryWStream(SkDynamicMemoryWStream &&)
SkDynamicMemoryWStream::padToAlign4
void padToAlign4()
SkMemoryStream
Definition: SkStream.h:372
SkStream::readBool
bool SK_WARN_UNUSED_RESULT readBool(bool *b)
Definition: SkStream.h:96
SkStream::readU8
bool SK_WARN_UNUSED_RESULT readU8(uint8_t *i)
Definition: SkStream.h:92
SkMemoryStream::duplicate
std::unique_ptr< SkMemoryStream > duplicate() const
Definition: SkStream.h:419
SkMemoryStream::setData
void setData(sk_sp< SkData > data)
SkDynamicMemoryWStream::detachAsData
sk_sp< SkData > detachAsData()
Return the contents as SkData, and then reset the stream.
SkFILEStream::SkFILEStream
SkFILEStream(FILE *file, size_t size)
Initialize the stream with an existing C FILE stream.
SkDynamicMemoryWStream::operator=
SkDynamicMemoryWStream & operator=(SkDynamicMemoryWStream &&)
SkStreamSeekable::move
bool move(long offset) override=0
Seeks to an relative offset in the stream.
SkMemoryStream::move
bool move(long offset) override
Seeks to an relative offset in the stream.
SkStream::readU16
bool SK_WARN_UNUSED_RESULT readU16(uint16_t *i)
Definition: SkStream.h:93
SkDynamicMemoryWStream::detachAsStream
std::unique_ptr< SkStreamAsset > detachAsStream()
Reset, returning a reader stream with the current content.
SkWStream::flush
virtual void flush()
SkFILEStream::close
void close()
Close this SkFILEStream.
SkMemoryStream::isAtEnd
bool isAtEnd() const override
Returns true when all the bytes in the stream have been read.
SkDynamicMemoryWStream::reset
void reset()
Reset the stream to its original, empty, state.
SkWStream::SkWStream
SkWStream()
Definition: SkStream.h:230
SkWStream::writeScalarAsText
bool writeScalarAsText(SkScalar)
SkDynamicMemoryWStream::copyToAndReset
void copyToAndReset(void *dst)
Equivalent to copyTo() followed by reset(), but may save memory use.
SkStreamAsset::hasLength
bool hasLength() const override
Returns true if this stream can report it's total length.
Definition: SkStream.h:197
SkNullWStream::SkNullWStream
SkNullWStream()
Definition: SkStream.h:287
SkStream::peek
virtual size_t peek(void *, size_t) const
Attempt to peek at size bytes.
Definition: SkStream.h:80
SkFILEStream::getLength
size_t getLength() const override
Returns the total length of the stream.
SkDynamicMemoryWStream::write
bool write(const void *buffer, size_t size) override
Called to write bytes to a SkWStream.
SkStream
SkStream – abstraction for a source of bytes.
Definition: SkStream.h:41
SkDynamicMemoryWStream::SkDynamicMemoryWStream
SkDynamicMemoryWStream()=default
SkFILEStream::rewind
bool rewind() override
Rewinds to the beginning of the stream.
SkStreamRewindable::rewind
bool rewind() override=0
Rewinds to the beginning of the stream.
SkStreamSeekable::hasPosition
bool hasPosition() const override
Returns true if this stream can report it's current position.
Definition: SkStream.h:181
SkFILEWStream::fsync
void fsync()
SkRefCnt.h
SkWStream::write32
bool write32(uint32_t v)
Definition: SkStream.h:252
SkStream::MakeFromFile
static std::unique_ptr< SkStreamAsset > MakeFromFile(const char path[])
Attempts to open the specified file as a stream, returns nullptr on failure.
SkScalar.h
SkNullWStream::bytesWritten
size_t bytesWritten() const override
Definition: SkStream.h:291
SkWStream::writePackedUInt
bool writePackedUInt(size_t)
sk_sp< SkData >
SkFILEWStream::bytesWritten
size_t bytesWritten() const override
SkDynamicMemoryWStream::~SkDynamicMemoryWStream
~SkDynamicMemoryWStream() override
SkNullWStream::write
bool write(const void *, size_t n) override
Called to write bytes to a SkWStream.
Definition: SkStream.h:289
SkWStream::bytesWritten
virtual size_t bytesWritten() const =0
SkFILEWStream::write
bool write(const void *buffer, size_t size) override
Called to write bytes to a SkWStream.
SkFILEWStream::~SkFILEWStream
~SkFILEWStream() override
SK_API
#define SK_API
Definition: SkTypes.h:181
SkFILEStream
A stream that wraps a C FILE* file stream.
Definition: SkStream.h:302
SkASSERT
#define SkASSERT(cond)
Definition: SkTypes.h:460
SkFILEStream::SkFILEStream
SkFILEStream(FILE *file)
Initialize the stream with an existing C FILE stream.
SkMemoryStream::fork
std::unique_ptr< SkMemoryStream > fork() const
Definition: SkStream.h:427
SkNullWStream::flush
void flush() override
Definition: SkStream.h:290
SkStreamAsset::getLength
size_t getLength() const override=0
Returns the total length of the stream.
SkMemoryStream::read
size_t read(void *buffer, size_t size) override
Reads or skips size number of bytes.
SkFILEStream::isAtEnd
bool isAtEnd() const override
Returns true when all the bytes in the stream have been read.
SkDynamicMemoryWStream::writeToAndReset
bool writeToAndReset(SkWStream *dst)
Equivalent to writeToStream() followed by reset(), but may save memory use.
SkStream::SkStream
SkStream()
Definition: SkStream.h:44
SkStream::hasLength
virtual bool hasLength() const
Returns true if this stream can report it's total length.
Definition: SkStream.h:144
SkDynamicMemoryWStream
Definition: SkStream.h:467
SkStream::readPackedUInt
bool SK_WARN_UNUSED_RESULT readPackedUInt(size_t *)
SkStream::duplicate
std::unique_ptr< SkStream > duplicate() const
Duplicates this stream.
Definition: SkStream.h:114
SkStream::move
virtual bool move(long)
Seeks to an relative offset in the stream.
Definition: SkStream.h:140
SkMemoryStream::MakeCopy
static std::unique_ptr< SkMemoryStream > MakeCopy(const void *data, size_t length)
Returns a stream with a copy of the input data.
SkData.h
SkFILEWStream
Definition: SkStream.h:447
SkFILEStream::seek
bool seek(size_t position) override
Seeks to an absolute position in the stream.
SkStream::readS32
bool SK_WARN_UNUSED_RESULT readS32(int32_t *)
SkStream::getLength
virtual size_t getLength() const
Returns the total length of the stream.
Definition: SkStream.h:146
SkStream::getPosition
virtual size_t getPosition() const
Returns the current position in the stream.
Definition: SkStream.h:128
SkMemoryStream::Make
static std::unique_ptr< SkMemoryStream > Make(sk_sp< SkData > data)
Returns a stream with a shared reference to the input data.
SkMemoryStream::asData
sk_sp< SkData > asData() const
Definition: SkStream.h:406
U16CPU
unsigned U16CPU
Fast type for unsigned 16 bits.
Definition: SkTypes.h:493
SkStream::getMemoryBase
virtual const void * getMemoryBase()
Returns the starting address for the data.
Definition: SkStream.h:151
SkStreamMemory::getMemoryBase
const void * getMemoryBase() override=0
Returns the starting address for the data.
SkMemoryStream::getPosition
size_t getPosition() const override
Returns the current position in the stream.
SkDynamicMemoryWStream::writeToAndReset
bool writeToAndReset(SkDynamicMemoryWStream *dst)
Equivalent to writeToStream() followed by reset(), but may save memory use.
SkStream::~SkStream
virtual ~SkStream()
Definition: SkStream.h:43
SkScalar
float SkScalar
Definition: SkScalar.h:16
SkMemoryStream::setMemory
virtual void setMemory(const void *data, size_t length, bool copyData=false)
Resets the stream to the specified data and length, just like the constructor.
SkMemoryStream::getLength
size_t getLength() const override
Returns the total length of the stream.
SkMemoryStream::rewind
bool rewind() override
Rewinds to the beginning of the stream.
SkFILEStream::fork
std::unique_ptr< SkStreamAsset > fork() const
Definition: SkStream.h:348
SkWStream::writeBigDecAsText
bool writeBigDecAsText(int64_t, int minDigits=0)
SkWStream::writeBool
bool writeBool(bool v)
Definition: SkStream.h:268
SkStreamAsset
SkStreamAsset is a SkStreamSeekable for which getLength is required.
Definition: SkStream.h:195
SkStream::readS16
bool SK_WARN_UNUSED_RESULT readS16(int16_t *)
SkFILEStream::duplicate
std::unique_ptr< SkStreamAsset > duplicate() const
Definition: SkStream.h:340
SkDynamicMemoryWStream::prependToAndReset
void prependToAndReset(SkDynamicMemoryWStream *dst)
Prepend this stream to dst, resetting this.
SkStream::readU32
bool SK_WARN_UNUSED_RESULT readU32(uint32_t *i)
Definition: SkStream.h:94
SkMemoryStream::SkMemoryStream
SkMemoryStream(const void *data, size_t length, bool copyData=false)
If copyData is true, the stream makes a private copy of the data.
SkWStream::writeHexAsText
bool writeHexAsText(uint32_t, int minDigits=0)
SkStreamAsset::fork
std::unique_ptr< SkStreamAsset > fork() const
Definition: SkStream.h:203
SkMemoryStream::getAtPos
const void * getAtPos()
SkMemoryStream::seek
bool seek(size_t position) override
Seeks to an absolute position in the stream.
SkFILEStream::SkFILEStream
SkFILEStream(const char path[]=nullptr)
Initialize the stream by calling sk_fopen on the specified path.
SkFILEStream::~SkFILEStream
~SkFILEStream() override
SkStream::rewind
virtual bool rewind()
Rewinds to the beginning of the stream.
Definition: SkStream.h:109
SkStreamRewindable::duplicate
std::unique_ptr< SkStreamRewindable > duplicate() const
Definition: SkStream.h:167
SkDynamicMemoryWStream::read
bool read(void *buffer, size_t offset, size_t size)
SkStreamMemory
SkStreamMemory is a SkStreamAsset for which getMemoryBase is required.
Definition: SkStream.h:212
SkFILEWStream::SkFILEWStream
SkFILEWStream(const char path[])
SkMemoryStream::setMemoryOwned
void setMemoryOwned(const void *data, size_t length)
Replace any memory buffer with the specified buffer.
SkMemoryStream::MakeDirect
static std::unique_ptr< SkMemoryStream > MakeDirect(const void *data, size_t length)
Returns a stream with a bare pointer reference to the input data.
SkStream::hasPosition
virtual bool hasPosition() const
Returns true if this stream can report it's current position.
Definition: SkStream.h:126
SK_WARN_UNUSED_RESULT
#define SK_WARN_UNUSED_RESULT
Definition: SkTypes.h:60
SkFILEStream::getPosition
size_t getPosition() const override
Returns the current position in the stream.
SkStream::fork
std::unique_ptr< SkStream > fork() const
Duplicates this stream.
Definition: SkStream.h:120
SkStreamMemory::duplicate
std::unique_ptr< SkStreamMemory > duplicate() const
Definition: SkStream.h:216
SkMemoryStream::skipToAlign4
void skipToAlign4()
SkFILEWStream::isValid
bool isValid() const
Returns true if the current path could be opened.
Definition: SkStream.h:454
SkStreamRewindable
SkStreamRewindable is a SkStream for which rewind and duplicate are required.
Definition: SkStream.h:164
SkWStream::writeStream
bool writeStream(SkStream *input, size_t length)
SkStreamSeekable::seek
bool seek(size_t position) override=0
Seeks to an absolute position in the stream.
SkWStream
Definition: SkStream.h:227
SkMemoryStream::peek
size_t peek(void *buffer, size_t size) const override
Attempt to peek at size bytes.
SkFILEStream::move
bool move(long offset) override
Seeks to an relative offset in the stream.
SkStreamMemory::fork
std::unique_ptr< SkStreamMemory > fork() const
Definition: SkStream.h:219
SkFILEStream::Make
static std::unique_ptr< SkFILEStream > Make(const char path[])
Definition: SkStream.h:325
SkMemoryStream::SkMemoryStream
SkMemoryStream()
SkStream::isAtEnd
virtual bool isAtEnd() const =0
Returns true when all the bytes in the stream have been read.
SkStreamAsset::duplicate
std::unique_ptr< SkStreamAsset > duplicate() const
Definition: SkStream.h:200
SkMemoryStream::SkMemoryStream
SkMemoryStream(sk_sp< SkData > data)
Creates the stream to read from the specified data.
SkWStream::write16
bool write16(U16CPU value)
Definition: SkStream.h:248
SkStreamSeekable
SkStreamSeekable is a SkStreamRewindable for which position, seek, move, and fork are required.
Definition: SkStream.h:175
U8CPU
unsigned U8CPU
Fast type for unsigned 8 bits.
Definition: SkTypes.h:488
SkWStream::writeScalar
bool writeScalar(SkScalar)
SkStream::skip
size_t skip(size_t size)
Skip size number of bytes.
Definition: SkStream.h:63
SkWStream::newline
bool newline()
Definition: SkStream.h:261
SkWStream::~SkWStream
virtual ~SkWStream()
SkDynamicMemoryWStream::bytesWritten
size_t bytesWritten() const override
SkStream::readScalar
bool SK_WARN_UNUSED_RESULT readScalar(SkScalar *)
SkWStream::write8
bool write8(U8CPU value)
Definition: SkStream.h:244
SkWStream::write
virtual bool write(const void *buffer, size_t size)=0
Called to write bytes to a SkWStream.
SkWStream::SizeOfPackedUInt
static int SizeOfPackedUInt(size_t value)
This returns the number of bytes in the stream required to store 'value'.
SkDynamicMemoryWStream::writeToStream
bool writeToStream(SkWStream *dst) const
SkDynamicMemoryWStream::copyTo
void copyTo(void *dst) const
More efficient version of read(dst, 0, bytesWritten()).
SkFILEStream::read
size_t read(void *buffer, size_t size) override
Reads or skips size number of bytes.
SkMemoryStream::getMemoryBase
const void * getMemoryBase() override
Returns the starting address for the data.
SkStreamSeekable::duplicate
std::unique_ptr< SkStreamSeekable > duplicate() const
Definition: SkStream.h:177