Flutter Engine
The Flutter Engine
|
#include <SkData.h>
Public Types | |
typedef void(* | ReleaseProc) (const void *ptr, void *context) |
Public Member Functions | |
size_t | size () const |
bool | isEmpty () const |
const void * | data () const |
const uint8_t * | bytes () const |
void * | writable_data () |
size_t | copyRange (size_t offset, size_t length, void *buffer) const |
bool | equals (const SkData *other) const |
Public Member Functions inherited from SkNVRefCnt< SkData > | |
SkNVRefCnt () | |
~SkNVRefCnt () | |
bool | unique () const |
void | ref () const |
void | unref () const |
void | deref () const |
bool | refCntGreaterThan (int32_t threadIsolatedTestCnt) const |
Static Public Member Functions | |
static sk_sp< SkData > | MakeWithCopy (const void *data, size_t length) |
static sk_sp< SkData > | MakeUninitialized (size_t length) |
static sk_sp< SkData > | MakeZeroInitialized (size_t length) |
static sk_sp< SkData > | MakeWithCString (const char cstr[]) |
static sk_sp< SkData > | MakeWithProc (const void *ptr, size_t length, ReleaseProc proc, void *ctx) |
static sk_sp< SkData > | MakeWithoutCopy (const void *data, size_t length) |
static sk_sp< SkData > | MakeFromMalloc (const void *data, size_t length) |
static sk_sp< SkData > | MakeFromFileName (const char path[]) |
static sk_sp< SkData > | MakeFromFILE (FILE *f) |
static sk_sp< SkData > | MakeFromFD (int fd) |
static sk_sp< SkData > | MakeFromStream (SkStream *, size_t size) |
static sk_sp< SkData > | MakeSubset (const SkData *src, size_t offset, size_t length) |
static sk_sp< SkData > | MakeEmpty () |
Friends | |
class | SkNVRefCnt< SkData > |
SkData holds an immutable data buffer. Not only is the data immutable, but the actual ptr that is returned (by data() or bytes()) is guaranteed to always be the same for the life of this instance.
typedef void(* SkData::ReleaseProc) (const void *ptr, void *context) |
|
inline |
size_t SkData::copyRange | ( | size_t | offset, |
size_t | length, | ||
void * | buffer | ||
) | const |
Helper to copy a range of the data into a caller-provided buffer. Returns the actual number of bytes copied, after clamping offset and length to the size of the data. If buffer is NULL, it is ignored, and only the computed number of bytes is returned.
Definition at line 53 of file SkData.cpp.
|
inline |
bool SkData::equals | ( | const SkData * | other | ) | const |
Returns true if these two objects have the same length and contents, effectively returning 0 == memcmp(...)
Definition at line 43 of file SkData.cpp.
|
inline |
Returns a new empty dataref (or a reference to a shared empty dataref). New or shared, the caller must see that unref() is eventually called.
Definition at line 94 of file SkData.cpp.
Create a new dataref from a file descriptor. This does not take ownership of the file descriptor, nor close it. The caller is free to close the file descriptor at its convenience. The file descriptor must be open for reading only. Returns NULL on failure.
Definition at line 158 of file SkData.cpp.
Create a new dataref from a stdio FILE. This does not take ownership of the FILE, nor close it. The caller is free to close the FILE at its convenience. The FILE must be open for reading only. Returns NULL on failure.
Definition at line 138 of file SkData.cpp.
Create a new dataref the file with the specified path. If the file cannot be opened, this returns NULL.
Definition at line 148 of file SkData.cpp.
Create a new dataref from a pointer allocated by malloc. The Data object takes ownership of that allocation, and will handling calling sk_free.
Definition at line 107 of file SkData.cpp.
Attempt to read size bytes into a SkData. If the read succeeds, return the data, else return NULL. Either way the stream's cursor may have been changed as a result of calling read().
Definition at line 208 of file SkData.cpp.
Create a new dataref using a subset of the data in the specified src dataref.
Definition at line 173 of file SkData.cpp.
Create a new data with uninitialized contents. The caller should call writable_data() to write into the buffer, but this must be done before another ref() is made.
Definition at line 116 of file SkData.cpp.
Create a new dataref by copying the specified c-string (a null-terminated array of bytes). The returned SkData will have size() equal to strlen(cstr) + 1. If cstr is NULL, it will be treated the same as "".
Definition at line 195 of file SkData.cpp.
|
static |
Create a new dataref, taking the ptr as is, and using the releaseproc to free it. The proc may be NULL.
Definition at line 128 of file SkData.cpp.
Create a new data with zero-initialized contents. The caller should call writable_data() to write into the buffer, but this must be done before another ref() is made.
Definition at line 120 of file SkData.cpp.
|
inline |
|
inline |
USE WITH CAUTION. This call will assert that the refcnt is 1, as a precaution against modifying the contents when another client/thread has access to the data.
Definition at line 52 of file SkData.h.
|
friend |