Skia
2DGraphicsLibrary
|
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< SkROBuffer > | makeROBufferSnapshot () const |
std::unique_ptr< SkStreamAsset > | makeStreamSnapshot () const |
void | validate () const |
Private Attributes | |
SkBufferHead * | fHead |
SkBufferBlock * | fTail |
size_t | fTotalUsed |
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.
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.