Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
SkRBuffer Class Reference

#include <SkBuffer.h>

Inheritance diagram for SkRBuffer:
SkNoncopyable

Public Member Functions

 SkRBuffer ()
 
 SkRBuffer (const void *data, size_t size)
 
size_t pos () const
 
size_t size () const
 
bool eof () const
 
size_t available () const
 
bool isValid () const
 
bool read (void *buffer, size_t size)
 
bool skipToAlign4 ()
 
bool readU8 (uint8_t *x)
 
bool readS32 (int32_t *x)
 
bool readU32 (uint32_t *x)
 
const void * skip (size_t bytes)
 
template<typename T >
const TskipCount (size_t count)
 

Detailed Description

Light weight class for reading data from a memory block. The RBuffer is given the buffer to read from, with either a specified size or no size (in which case no range checking is performed). It is iillegal to attempt to read a value from an empty RBuffer (data == null).

Definition at line 27 of file SkBuffer.h.

Constructor & Destructor Documentation

◆ SkRBuffer() [1/2]

SkRBuffer::SkRBuffer ( )
inline

Definition at line 29 of file SkBuffer.h.

29: fData(nullptr), fPos(nullptr), fStop(nullptr) {}

◆ SkRBuffer() [2/2]

SkRBuffer::SkRBuffer ( const void *  data,
size_t  size 
)
inline

Initialize RBuffer with a data point and length.

Definition at line 33 of file SkBuffer.h.

33 {
34 SkASSERT(data != nullptr || size == 0);
35 fData = (const char*)data;
36 fPos = (const char*)data;
37 fStop = (const char*)data + size;
38 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
size_t size() const
Definition: SkBuffer.h:47
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

Member Function Documentation

◆ available()

size_t SkRBuffer::available ( ) const
inline

Definition at line 54 of file SkBuffer.h.

54{ return fStop - fPos; }

◆ eof()

bool SkRBuffer::eof ( ) const
inline

Return true if the buffer has read to the end of the data pointer. Only defined if the length was specified in the constructor or in a call to reset(). Always returns true if the length was not specified.

Definition at line 52 of file SkBuffer.h.

52{ return fPos >= fStop; }

◆ isValid()

bool SkRBuffer::isValid ( ) const
inline

Definition at line 56 of file SkBuffer.h.

56{ return fValid; }

◆ pos()

size_t SkRBuffer::pos ( ) const
inline

Return the number of bytes that have been read from the beginning of the data pointer.

Definition at line 43 of file SkBuffer.h.

43{ return fPos - fData; }

◆ read()

bool SkRBuffer::read ( void *  buffer,
size_t  size 
)

Read the specified number of bytes from the data pointer. If buffer is not null, copy those bytes into buffer.

Definition at line 27 of file SkBuffer.cpp.

27 {
28 if (const void* src = this->skip(size)) {
30 return true;
31 }
32 return false;
33}
static void * sk_careful_memcpy(void *dst, const void *src, size_t len)
Definition: SkMalloc.h:125
const void * skip(size_t bytes)
Definition: SkBuffer.cpp:17
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

◆ readS32()

bool SkRBuffer::readS32 ( int32_t *  x)
inline

Definition at line 65 of file SkBuffer.h.

65{ return this->read(x, 4); }
bool read(void *buffer, size_t size)
Definition: SkBuffer.cpp:27
double x

◆ readU32()

bool SkRBuffer::readU32 ( uint32_t *  x)
inline

Definition at line 66 of file SkBuffer.h.

66{ return this->read(x, 4); }

◆ readU8()

bool SkRBuffer::readU8 ( uint8_t *  x)
inline

Definition at line 64 of file SkBuffer.h.

64{ return this->read(x, 1); }

◆ size()

size_t SkRBuffer::size ( ) const
inline

Return the total size of the data pointer. Only defined if the length was specified in the constructor or in a call to reset().

Definition at line 47 of file SkBuffer.h.

47{ return fStop - fData; }

◆ skip()

const void * SkRBuffer::skip ( size_t  bytes)

Definition at line 17 of file SkBuffer.cpp.

17 {
18 if (fValid && size <= this->available()) {
19 const void* pos = fPos;
20 fPos += size;
21 return pos;
22 }
23 fValid = false;
24 return nullptr;
25}
size_t pos() const
Definition: SkBuffer.h:43
size_t available() const
Definition: SkBuffer.h:54

◆ skipCount()

template<typename T >
const T * SkRBuffer::skipCount ( size_t  count)
inline

Definition at line 70 of file SkBuffer.h.

70 {
71 return static_cast<const T*>(this->skip(SkSafeMath::Mul(count, sizeof(T))));
72 }
int count
Definition: FontMgrTest.cpp:50
static size_t Mul(size_t x, size_t y)
Definition: SkSafeMath.cpp:16
#define T
Definition: precompiler.cc:65

◆ skipToAlign4()

bool SkRBuffer::skipToAlign4 ( )

Definition at line 35 of file SkBuffer.cpp.

35 {
36 intptr_t pos = reinterpret_cast<intptr_t>(fPos);
37 size_t n = SkAlign4(pos) - pos;
38 if (fValid && n <= this->available()) {
39 fPos += n;
40 return true;
41 } else {
42 fValid = false;
43 return false;
44 }
45}
static constexpr T SkAlign4(T x)
Definition: SkAlign.h:16

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