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

#include <SkStream.h>

Inheritance diagram for SkStream:
HaltingStream LimitedPeekingMemStream LimitedRewindingStream NotAssetMemStream SkStreamRewindable NonseekableStream SkStreamSeekable SkStreamAsset SkBlockMemoryStream SkFILEStream SkStreamMemory SkDWriteFontFileStream SkMemoryStream

Public Member Functions

virtual ~SkStream ()
 
 SkStream ()
 
virtual size_t read (void *buffer, size_t size)=0
 
size_t skip (size_t size)
 
virtual size_t peek (void *, size_t) const
 
virtual bool isAtEnd () const =0
 
bool readS8 (int8_t *)
 
bool readS16 (int16_t *)
 
bool readS32 (int32_t *)
 
bool readU8 (uint8_t *i)
 
bool readU16 (uint16_t *i)
 
bool readU32 (uint32_t *i)
 
bool readBool (bool *b)
 
bool readScalar (SkScalar *)
 
bool readPackedUInt (size_t *)
 
virtual bool rewind ()
 
std::unique_ptr< SkStreamduplicate () const
 
std::unique_ptr< SkStreamfork () const
 
virtual bool hasPosition () const
 
virtual size_t getPosition () const
 
virtual bool seek (size_t)
 
virtual bool move (long)
 
virtual bool hasLength () const
 
virtual size_t getLength () const
 
virtual const void * getMemoryBase ()
 
virtual sk_sp< SkDatagetData () const
 

Static Public Member Functions

static std::unique_ptr< SkStreamAssetMakeFromFile (const char path[])
 

Private Member Functions

virtual SkStreamonDuplicate () const
 
virtual SkStreamonFork () const
 

Detailed Description

SkStream – abstraction for a source of bytes. Subclasses can be backed by memory, or a file, or something else.

Definition at line 29 of file SkStream.h.

Constructor & Destructor Documentation

◆ ~SkStream()

virtual SkStream::~SkStream ( )
inlinevirtual

Definition at line 31 of file SkStream.h.

31{}

◆ SkStream()

SkStream::SkStream ( )
inline

Definition at line 32 of file SkStream.h.

32{}

Member Function Documentation

◆ duplicate()

std::unique_ptr< SkStream > SkStream::duplicate ( ) const
inline

Duplicates this stream. If this cannot be done, returns NULL. The returned stream will be positioned at the beginning of its data.

Definition at line 105 of file SkStream.h.

105 {
106 return std::unique_ptr<SkStream>(this->onDuplicate());
107 }
virtual SkStream * onDuplicate() const
Definition: SkStream.h:145

◆ fork()

std::unique_ptr< SkStream > SkStream::fork ( ) const
inline

Duplicates this stream. If this cannot be done, returns NULL. The returned stream will be positioned the same as this stream.

Definition at line 111 of file SkStream.h.

111 {
112 return std::unique_ptr<SkStream>(this->onFork());
113 }
virtual SkStream * onFork() const
Definition: SkStream.h:146

◆ getData()

virtual sk_sp< SkData > SkStream::getData ( ) const
inlinevirtual

Reimplemented in SkMemoryStream.

Definition at line 142 of file SkStream.h.

142{ return nullptr; }

◆ getLength()

virtual size_t SkStream::getLength ( ) const
inlinevirtual

Returns the total length of the stream. If this cannot be done, returns 0.

Reimplemented in SkFILEStream, SkMemoryStream, SkBlockMemoryStream, SkDWriteFontFileStream, HaltingStream, and SkStreamAsset.

Definition at line 137 of file SkStream.h.

137{ return 0; }

◆ getMemoryBase()

virtual const void * SkStream::getMemoryBase ( )
inlinevirtual

Returns the starting address for the data. If this cannot be done, returns NULL.

Reimplemented in SkMemoryStream, SkBlockMemoryStream, SkDWriteFontFileStream, and SkStreamMemory.

Definition at line 141 of file SkStream.h.

141{ return nullptr; }

◆ getPosition()

virtual size_t SkStream::getPosition ( ) const
inlinevirtual

Returns the current position in the stream. If this cannot be done, returns 0.

Reimplemented in SkFILEStream, SkMemoryStream, SkBlockMemoryStream, SkDWriteFontFileStream, HaltingStream, and SkStreamSeekable.

Definition at line 119 of file SkStream.h.

119{ return 0; }

◆ hasLength()

virtual bool SkStream::hasLength ( ) const
inlinevirtual

Returns true if this stream can report its total length.

Reimplemented in SkStreamAsset, NotAssetMemStream, and HaltingStream.

Definition at line 135 of file SkStream.h.

135{ return false; }

◆ hasPosition()

virtual bool SkStream::hasPosition ( ) const
inlinevirtual

Returns true if this stream can report its current position.

Reimplemented in SkStreamSeekable, NotAssetMemStream, and HaltingStream.

Definition at line 117 of file SkStream.h.

117{ return false; }

◆ isAtEnd()

virtual bool SkStream::isAtEnd ( ) const
pure virtual

Returns true when all the bytes in the stream have been read. As SkStream represents synchronous I/O, isAtEnd returns false when the final stream length isn't known yet, even when all the bytes available so far have been read. This may return true early (when there are no more bytes to be read) or late (after the first unsuccessful read).

Implemented in SkFILEStream, SkMemoryStream, SkBlockMemoryStream, SkDWriteFontFileStream, LimitedPeekingMemStream, LimitedRewindingStream, NotAssetMemStream, and HaltingStream.

◆ MakeFromFile()

std::unique_ptr< SkStreamAsset > SkStream::MakeFromFile ( const char  path[])
static

Attempts to open the specified file as a stream, returns nullptr on failure.

Definition at line 922 of file SkStream.cpp.

922 {
923 auto data(mmap_filename(path));
924 if (data) {
925 return std::make_unique<SkMemoryStream>(std::move(data));
926 }
927
928 // If we get here, then our attempt at using mmap failed, so try normal file access.
929 auto stream = std::make_unique<SkFILEStream>(path);
930 if (!stream->isValid()) {
931 return nullptr;
932 }
933 return stream;
934}
static sk_sp< SkData > mmap_filename(const char path[])
Definition: SkStream.cpp:911
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
Definition: switches.h:57
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ move()

virtual bool SkStream::move ( long  )
inlinevirtual

Seeks to an relative offset in the stream. If this cannot be done, returns false. If an attempt is made to move to a position outside the stream, the position will be set to the closest point within the stream (beginning or end).

Reimplemented in SkFILEStream, SkMemoryStream, SkBlockMemoryStream, SkDWriteFontFileStream, HaltingStream, and SkStreamSeekable.

Definition at line 131 of file SkStream.h.

131{ return false; }

◆ onDuplicate()

virtual SkStream * SkStream::onDuplicate ( ) const
inlineprivatevirtual

Reimplemented in SkBlockMemoryStream, SkStreamRewindable, SkStreamSeekable, SkStreamAsset, and SkStreamMemory.

Definition at line 145 of file SkStream.h.

145{ return nullptr; }

◆ onFork()

virtual SkStream * SkStream::onFork ( ) const
inlineprivatevirtual

Reimplemented in SkBlockMemoryStream, SkStreamSeekable, SkStreamAsset, and SkStreamMemory.

Definition at line 146 of file SkStream.h.

146{ return nullptr; }

◆ peek()

virtual size_t SkStream::peek ( void *  ,
size_t   
) const
inlinevirtual

Attempt to peek at size bytes. If this stream supports peeking, copy min(size, peekable bytes) into buffer, and return the number of bytes copied. If the stream does not support peeking, or cannot peek any bytes, return 0 and leave buffer unchanged. The stream is guaranteed to be in the same visible state after this call, regardless of success or failure.

Parameters
bufferMust not be NULL, and must be at least size bytes. Destination to copy bytes.
sizeNumber of bytes to copy.
Returns
The number of bytes peeked/copied.

Reimplemented in LimitedPeekingMemStream, NotAssetMemStream, SkBlockMemoryStream, and SkMemoryStream.

Definition at line 68 of file SkStream.h.

68{ return 0; }

◆ read()

virtual size_t SkStream::read ( void *  buffer,
size_t  size 
)
pure virtual

Reads or skips size number of bytes. If buffer == NULL, skip size bytes, return how many were skipped. If buffer != NULL, copy size bytes into buffer, return how many were copied.

Parameters
bufferwhen NULL skip size bytes, otherwise copy size bytes into buffer
sizethe number of bytes to skip or copy
Returns
the number of bytes actually read.

Implemented in LimitedPeekingMemStream, NotAssetMemStream, SkBlockMemoryStream, SkFILEStream, SkMemoryStream, SkDWriteFontFileStream, LimitedRewindingStream, and HaltingStream.

◆ readBool()

bool SkStream::readBool ( bool *  b)
inline

Definition at line 87 of file SkStream.h.

87 {
88 uint8_t i;
89 if (!this->readU8(&i)) { return false; }
90 *b = (i != 0);
91 return true;
92 }
bool readU8(uint8_t *i)
Definition: SkStream.h:83
static bool b

◆ readPackedUInt()

bool SkStream::readPackedUInt ( size_t *  i)

Definition at line 52 of file SkStream.cpp.

52 {
53 uint8_t byte;
54 if (!this->read(&byte, 1)) {
55 return false;
56 }
57 if (SK_BYTE_SENTINEL_FOR_U16 == byte) {
58 uint16_t i16;
59 if (!this->readU16(&i16)) { return false; }
60 *i = i16;
61 } else if (SK_BYTE_SENTINEL_FOR_U32 == byte) {
62 uint32_t i32;
63 if (!this->readU32(&i32)) { return false; }
64 *i = i32;
65 } else {
66 *i = byte;
67 }
68 return true;
69}
#define SK_BYTE_SENTINEL_FOR_U16
Definition: SkStream.cpp:49
#define SK_BYTE_SENTINEL_FOR_U32
Definition: SkStream.cpp:50
bool readU16(uint16_t *i)
Definition: SkStream.h:84
bool readU32(uint32_t *i)
Definition: SkStream.h:85
virtual size_t read(void *buffer, size_t size)=0

◆ readS16()

bool SkStream::readS16 ( int16_t *  i)

Definition at line 36 of file SkStream.cpp.

36 {
37 return this->read(i, sizeof(*i)) == sizeof(*i);
38}

◆ readS32()

bool SkStream::readS32 ( int32_t *  i)

Definition at line 40 of file SkStream.cpp.

40 {
41 return this->read(i, sizeof(*i)) == sizeof(*i);
42}

◆ readS8()

bool SkStream::readS8 ( int8_t *  i)

Definition at line 32 of file SkStream.cpp.

32 {
33 return this->read(i, sizeof(*i)) == sizeof(*i);
34}

◆ readScalar()

bool SkStream::readScalar ( SkScalar i)

Definition at line 44 of file SkStream.cpp.

44 {
45 return this->read(i, sizeof(*i)) == sizeof(*i);
46}

◆ readU16()

bool SkStream::readU16 ( uint16_t *  i)
inline

Definition at line 84 of file SkStream.h.

84{ return this->readS16((int16_t*)i); }
bool readS16(int16_t *)
Definition: SkStream.cpp:36

◆ readU32()

bool SkStream::readU32 ( uint32_t *  i)
inline

Definition at line 85 of file SkStream.h.

85{ return this->readS32((int32_t*)i); }
bool readS32(int32_t *)
Definition: SkStream.cpp:40

◆ readU8()

bool SkStream::readU8 ( uint8_t *  i)
inline

Definition at line 83 of file SkStream.h.

83{ return this->readS8((int8_t*)i); }
bool readS8(int8_t *)
Definition: SkStream.cpp:32

◆ rewind()

virtual bool SkStream::rewind ( )
inlinevirtual

Rewinds to the beginning of the stream. Returns true if the stream is known to be at the beginning after this call returns.

Reimplemented in SkFILEStream, SkMemoryStream, SkBlockMemoryStream, SkDWriteFontFileStream, LimitedPeekingMemStream, LimitedRewindingStream, NotAssetMemStream, NonseekableStream, HaltingStream, and SkStreamRewindable.

Definition at line 100 of file SkStream.h.

100{ return false; }

◆ seek()

virtual bool SkStream::seek ( size_t  )
inlinevirtual

Seeks to an absolute position in the stream. If this cannot be done, returns false. If an attempt is made to seek past the end of the stream, the position will be set to the end of the stream.

Reimplemented in SkFILEStream, SkMemoryStream, SkBlockMemoryStream, SkDWriteFontFileStream, HaltingStream, SkStreamSeekable, and NonseekableStream.

Definition at line 125 of file SkStream.h.

125{ return false; }

◆ skip()

size_t SkStream::skip ( size_t  size)
inline

Skip size number of bytes.

Returns
the actual number bytes that could be skipped.

Definition at line 51 of file SkStream.h.

51 {
52 return this->read(nullptr, size);
53 }
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
Definition: switches.h:259

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