Skia
2DGraphicsLibrary
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkRWBuffer Class Reference

Accumulates bytes of memory that are "appended" to it, growing internal storage as needed. More...

#include <SkRWBuffer.h>

Public Member Functions

 SkRWBuffer (size_t initialCapacity=0)
 
size_t size () const
 
void append (const void *buffer, size_t length, size_t reserve=0)
 Append |length| bytes from |buffer|. More...
 
sk_sp< SkROBuffermakeROBufferSnapshot () const
 
std::unique_ptr< SkStreamAssetmakeStreamSnapshot () const
 
void validate () const
 

Private Attributes

SkBufferHead * fHead
 
SkBufferBlock * fTail
 
size_t fTotalUsed
 

Detailed Description

Accumulates bytes of memory that are "appended" to it, growing internal storage as needed.

The growth is done such that at any time in the writer's thread, an RBuffer or StreamAsset can be snapped off (and safely passed to another thread). The RBuffer/StreamAsset snapshot can see the previously stored bytes, but will be unaware of any future writes.

Member Function Documentation

void SkRWBuffer::append ( const void *  buffer,
size_t  length,
size_t  reserve = 0 
)

Append |length| bytes from |buffer|.

If the caller knows in advance how much more data they are going to append, they can pass a |reserve| hint (representing the number of upcoming bytes in addition to the current append), to minimize the number of internal allocations.


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