Skia
2DGraphicsLibrary
|
We explicitly use the same allocator for our pixels that SkMask does, so that we can freely assign memory allocated by one class to the other. More...
#include <SkMallocPixelRef.h>
Classes | |
class | PRFactory |
class | ZeroedPRFactory |
Public Types | |
typedef void(* | ReleaseProc )(void *addr, void *context) |
Return a new SkMallocPixelRef with the provided pixel storage, rowBytes, and optional colortable. More... | |
Public Member Functions | |
void * | getAddr () const |
Public Member Functions inherited from SkPixelRef | |
SkPixelRef (const SkImageInfo &) | |
const SkImageInfo & | info () const |
void * | pixels () const |
Return the pixel memory returned from lockPixels, or null if the lockCount is 0. | |
SkColorTable * | colorTable () const |
Return the current colorTable (if any) if pixels are locked, or null. | |
size_t | rowBytes () const |
bool | isLocked () const |
int | getLockCount () const |
bool | lockPixels () |
Call to access the pixel memory. More... | |
bool | lockPixels (LockRec *rec) |
Call to access the pixel memory. More... | |
void | unlockPixels () |
Call to balanace a previous call to lockPixels(). More... | |
bool | lockPixelsAreWritable () const |
Some bitmaps can return a copy of their pixels for lockPixels(), but that copy, if modified, will not be pushed back. More... | |
uint32_t | getGenerationID () const |
Returns a non-zero, unique value corresponding to the pixels in this pixelref. More... | |
void | notifyPixelsChanged () |
Call this if you have changed the contents of the pixels. More... | |
void | changeAlphaType (SkAlphaType at) |
Change the info's AlphaType. More... | |
bool | isImmutable () const |
Returns true if this pixelref is marked as immutable, meaning that the contents of its pixels will not change for the lifetime of the pixelref. | |
void | setImmutable () |
Marks this pixelref is immutable, meaning that the contents of its pixels will not change for the lifetime of the pixelref. More... | |
const char * | getURI () const |
Return the optional URI string associated with this pixelref. More... | |
void | setURI (const char uri[]) |
Copy a URI string to this pixelref, or clear the URI if the uri is null. | |
void | setURI (const char uri[], size_t len) |
Copy a URI string to this pixelref. | |
void | setURI (const SkString &uri) |
Assign a URI string to this pixelref. | |
SkData * | refEncodedData () |
If the pixelRef has an encoded (i.e. More... | |
bool | requestLock (const LockRequest &, LockResult *) |
bool | queryYUV8 (SkYUVSizeInfo *sizeInfo, SkYUVColorSpace *colorSpace) const |
If this can efficiently return YUV data, this should return true. More... | |
bool | getYUV8Planes (const SkYUVSizeInfo &sizeInfo, void *planes[3]) |
Returns true on success and false on failure. More... | |
bool | readPixels (SkBitmap *dst, SkColorType colorType, const SkIRect *subset=NULL) |
Populates dst with the pixels of this pixelRef, converting them to colorType. More... | |
void | addGenIDChangeListener (GenIDChangeListener *listener) |
void | notifyAddedToCache () |
virtual SkDiscardableMemory * | diagnostic_only_getDiscardable () const |
bool | isLazyGenerated () const |
Returns true if the pixels are generated on-the-fly (when required). | |
Public Member Functions inherited from SkRefCntBase | |
SkRefCntBase () | |
Default construct, initializing the reference count to 1. | |
virtual | ~SkRefCntBase () |
Destruct, asserting that the reference count is 1. | |
int32_t | getRefCnt () const |
Return the reference count. More... | |
void | validate () const |
bool | unique () const |
May return true if the caller is the only owner. More... | |
void | ref () const |
Increment the reference count. More... | |
void | unref () const |
Decrement the reference count. More... | |
Static Public Member Functions | |
static SkMallocPixelRef * | NewDirect (const SkImageInfo &, void *addr, size_t rowBytes, SkColorTable *) |
Return a new SkMallocPixelRef with the provided pixel storage, rowBytes, and optional colortable. More... | |
static SkMallocPixelRef * | NewAllocate (const SkImageInfo &info, size_t rowBytes, SkColorTable *) |
Return a new SkMallocPixelRef, automatically allocating storage for the pixels. More... | |
static SkMallocPixelRef * | NewZeroed (const SkImageInfo &info, size_t rowBytes, SkColorTable *) |
Identical to NewAllocate, except all pixel bytes are zeroed. | |
static SkMallocPixelRef * | NewWithProc (const SkImageInfo &info, size_t rowBytes, SkColorTable *, void *addr, ReleaseProc proc, void *context) |
static SkMallocPixelRef * | NewWithData (const SkImageInfo &info, size_t rowBytes, SkColorTable *ctable, SkData *data) |
Return a new SkMallocPixelRef that will use the provided SkData, rowBytes, and optional colortable as pixel storage. More... | |
Protected Member Functions | |
SkMallocPixelRef (const SkImageInfo &, void *addr, size_t rb, SkColorTable *, bool ownPixels) | |
bool | onNewLockPixels (LockRec *) override |
On success, returns true and fills out the LockRec for the pixels. More... | |
void | onUnlockPixels () override |
Balancing the previous successful call to onNewLockPixels. More... | |
size_t | getAllocatedSizeInBytes () const override |
Returns the size (in bytes) of the internally allocated memory. More... | |
Protected Member Functions inherited from SkPixelRef | |
virtual bool | onLockPixelsAreWritable () const |
Default impl returns true. | |
virtual bool | onReadPixels (SkBitmap *dst, SkColorType colorType, const SkIRect *subsetOrNull) |
For pixelrefs that don't have access to their raw pixels, they may be able to make a copy of them (e.g. More... | |
virtual SkData * | onRefEncodedData () |
virtual void | onNotifyPixelsChanged () |
virtual bool | onQueryYUV8 (SkYUVSizeInfo *, SkYUVColorSpace *) const |
virtual bool | onGetYUV8Planes (const SkYUVSizeInfo &, void *[3]) |
virtual bool | onRequestLock (const LockRequest &, LockResult *) |
virtual bool | onIsLazyGenerated () const |
SkBaseMutex * | mutex () const |
Return the mutex associated with this pixelref. More... | |
void | setPreLocked (void *, size_t rowBytes, SkColorTable *) |
Protected Member Functions inherited from SkRefCntBase | |
void | internal_dispose_restore_refcnt_to_1 () const |
Allow subclasses to call this if they've overridden internal_dispose so they can reset fRefCnt before the destructor is called or if they choose not to call the destructor (e.g. More... | |
Private Types | |
typedef SkPixelRef | INHERITED |
Private Member Functions | |
SkMallocPixelRef (const SkImageInfo &, void *addr, size_t rb, SkColorTable *, ReleaseProc proc, void *context) | |
Static Private Member Functions | |
static SkMallocPixelRef * | NewUsing (void *(*alloc)(size_t), const SkImageInfo &, size_t rowBytes, SkColorTable *) |
Private Attributes | |
void * | fStorage |
SkColorTable * | fCTable |
size_t | fRB |
ReleaseProc | fReleaseProc |
void * | fReleaseProcContext |
We explicitly use the same allocator for our pixels that SkMask does, so that we can freely assign memory allocated by one class to the other.
typedef void(* SkMallocPixelRef::ReleaseProc)(void *addr, void *context) |
Return a new SkMallocPixelRef with the provided pixel storage, rowBytes, and optional colortable.
On destruction, ReleaseProc will be called.
This pixelref will ref() the specified colortable (if not NULL).
If ReleaseProc is NULL, the pixels will never be released. This can be useful if the pixels were stack allocated. However, such an SkMallocPixelRef must not live beyond its pixels (e.g. by copying an SkBitmap pointing to it, or drawing to an SkPicture).
Returns NULL on failure.
|
overrideprotectedvirtual |
Returns the size (in bytes) of the internally allocated memory.
This should be implemented in all serializable SkPixelRef derived classes. SkBitmap::fPixelRefOffset + SkBitmap::getSafeSize() should never overflow this value, otherwise the rendering code may attempt to read memory out of bounds.
Reimplemented from SkPixelRef.
|
static |
Return a new SkMallocPixelRef, automatically allocating storage for the pixels.
If rowBytes are 0, an optimal value will be chosen automatically. If rowBytes is > 0, then it will be respected, or NULL will be returned if rowBytes is invalid for the specified info.
This pixelref will ref() the specified colortable (if not NULL).
Returns NULL on failure.
|
static |
Return a new SkMallocPixelRef with the provided pixel storage, rowBytes, and optional colortable.
The caller is responsible for managing the lifetime of the pixel storage buffer, as this pixelref will not try to delete it.
The pixelref will ref() the colortable (if not NULL).
Returns NULL on failure.
|
static |
|
overrideprotectedvirtual |
On success, returns true and fills out the LockRec for the pixels.
On failure returns false and ignores the LockRec parameter.
The caller will have already acquired a mutex for thread safety, so this method need not do that.
Implements SkPixelRef.
|
overrideprotectedvirtual |
Balancing the previous successful call to onNewLockPixels.
The locked pixel address will no longer be referenced, so the subclass is free to move or discard that memory.
The caller will have already acquired a mutex for thread safety, so this method need not do that.
Implements SkPixelRef.