12 #include "include/private/base/SkAPI.h"
13 #include "include/private/base/SkAssert.h"
30 size_t size()
const {
return fSize; }
32 bool isEmpty()
const {
return 0 == fSize; }
37 const void*
data()
const {
return fPtr; }
44 return reinterpret_cast<const uint8_t*
>(fPtr);
57 return const_cast<void*
>(fPtr);
66 size_t copyRange(
size_t offset,
size_t length,
void* buffer)
const;
78 typedef void (*ReleaseProc)(
const void* ptr,
void* context);
117 return MakeWithProc(data, length, NoopReleaseProc,
nullptr);
171 ReleaseProc fReleaseProc;
172 void* fReleaseProcContext;
176 SkData(
const void* ptr,
size_t size, ReleaseProc,
void* context);
177 explicit SkData(
size_t size);
181 void operator delete(
void* p);
184 static sk_sp<SkData> PrivateNewWithCopy(
const void* srcOrNull,
size_t length);
186 static void NoopReleaseProc(
const void*,
void*);
SkData holds an immutable data buffer.
Definition: SkData.h:25
static sk_sp< SkData > MakeZeroInitialized(size_t length)
Create a new data with zero-initialized contents.
static sk_sp< SkData > MakeFromStream(SkStream *, size_t size)
Attempt to read size bytes into a SkData.
size_t copyRange(size_t offset, size_t length, void *buffer) const
Helper to copy a range of the data into a caller-provided buffer.
static sk_sp< SkData > MakeFromMalloc(const void *data, size_t length)
Create a new dataref from a pointer allocated by malloc.
bool equals(const SkData *other) const
Returns true if these two objects have the same length and contents, effectively returning 0 == memcm...
static sk_sp< SkData > MakeFromFILE(FILE *f)
Create a new dataref from a stdio FILE.
static sk_sp< SkData > MakeWithProc(const void *ptr, size_t length, ReleaseProc proc, void *ctx)
Create a new dataref, taking the ptr as is, and using the releaseproc to free it.
static sk_sp< SkData > MakeWithoutCopy(const void *data, size_t length)
Call this when the data parameter is already const and will outlive the lifetime of the SkData.
Definition: SkData.h:116
static sk_sp< SkData > MakeUninitialized(size_t length)
Create a new data with uninitialized contents.
static sk_sp< SkData > MakeEmpty()
Returns a new empty dataref (or a reference to a shared empty dataref).
const void * data() const
Returns the ptr to the data.
Definition: SkData.h:37
static sk_sp< SkData > MakeWithCString(const char cstr[])
Create a new dataref by copying the specified c-string (a null-terminated array of bytes).
void * writable_data()
USE WITH CAUTION.
Definition: SkData.h:52
static sk_sp< SkData > MakeFromFileName(const char path[])
Create a new dataref the file with the specified path.
const uint8_t * bytes() const
Like data(), returns a read-only ptr into the data, but in this case it is cast to uint8_t*,...
Definition: SkData.h:43
static sk_sp< SkData > MakeFromFD(int fd)
Create a new dataref from a file descriptor.
static sk_sp< SkData > MakeSubset(const SkData *src, size_t offset, size_t length)
Create a new dataref using a subset of the data in the specified src dataref.
size_t size() const
Returns the number of bytes stored.
Definition: SkData.h:30
bool isEmpty() const
Definition: SkData.h:32
static sk_sp< SkData > MakeWithCopy(const void *data, size_t length)
Create a new dataref by copying the specified data.
Definition: SkRefCnt.h:160
bool unique() const
Definition: SkRefCnt.h:175
Definition: SkRefCnt.h:119
SkStream – abstraction for a source of bytes.
Definition: SkStream.h:29