#include <SkPixelRef.h>
Inherits SkRefCnt.
Inherited by SkMallocPixelRef.
Classes | |
class | Registrar |
Public Types | |
typedef SkPixelRef *(* | Factory )(SkFlattenableReadBuffer &) |
Public Member Functions | |
SkPixelRef (SkMutex *mutex=NULL) | |
void * | pixels () const |
SkColorTable * | colorTable () const |
int | getLockCount () const |
void | lockPixels () |
void | unlockPixels () |
uint32_t | getGenerationID () const |
void | notifyPixelsChanged () |
bool | isImmutable () const |
void | setImmutable () |
const char * | getURI () const |
void | setURI (const char uri[]) |
void | setURI (const char uri[], size_t len) |
void | setURI (const SkString &uri) |
virtual Factory | getFactory () const |
virtual void | flatten (SkFlattenableWriteBuffer &) const |
Static Public Member Functions | |
static Factory | NameToFactory (const char name[]) |
static const char * | FactoryToName (Factory) |
static void | Register (const char name[], Factory) |
Protected Member Functions | |
virtual void * | onLockPixels (SkColorTable **)=0 |
virtual void | onUnlockPixels ()=0 |
SkMutex * | mutex () const |
SkPixelRef (SkFlattenableReadBuffer &, SkMutex *) |
This class is the smart container for pixel memory, and is used with SkBitmap. A pixelref is installed into a bitmap, and then the bitmap can access the actual pixel memory by calling lockPixels/unlockPixels.
This class can be shared/accessed between multiple threads.
Definition at line 36 of file SkPixelRef.h.
typedef SkPixelRef*(* SkPixelRef::Factory)(SkFlattenableReadBuffer &) |
Definition at line 110 of file SkPixelRef.h.
SkPixelRef::SkPixelRef | ( | SkMutex * | mutex = NULL |
) | [explicit] |
SkPixelRef::SkPixelRef | ( | SkFlattenableReadBuffer & | , | |
SkMutex * | ||||
) | [protected] |
SkColorTable* SkPixelRef::colorTable | ( | ) | const [inline] |
Return the current colorTable (if any) if pixels are locked, or null.
Definition at line 47 of file SkPixelRef.h.
static const char* SkPixelRef::FactoryToName | ( | Factory | ) | [static] |
virtual void SkPixelRef::flatten | ( | SkFlattenableWriteBuffer & | ) | const [virtual] |
Reimplemented in SkMallocPixelRef.
virtual Factory SkPixelRef::getFactory | ( | ) | const [inline, virtual] |
Reimplemented in SkMallocPixelRef.
Definition at line 112 of file SkPixelRef.h.
uint32_t SkPixelRef::getGenerationID | ( | ) | const |
Returns a non-zero, unique value corresponding to the pixels in this pixelref. Each time the pixels are changed (and notifyPixelsChanged is called), a different generation ID will be returned.
int SkPixelRef::getLockCount | ( | ) | const [inline] |
Return the current lockcount (defaults to 0)
Definition at line 51 of file SkPixelRef.h.
const char* SkPixelRef::getURI | ( | ) | const [inline] |
Return the optional URI string associated with this pixelref. May be null.
Definition at line 90 of file SkPixelRef.h.
bool SkPixelRef::isImmutable | ( | ) | const [inline] |
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.
Definition at line 79 of file SkPixelRef.h.
void SkPixelRef::lockPixels | ( | ) |
Call to access the pixel memory, which is returned. Balance with a call to unlockPixels().
SkMutex* SkPixelRef::mutex | ( | ) | const [inline, protected] |
Return the mutex associated with this pixelref. This value is assigned in the constructor, and cannot change during the lifetime of the object.
Definition at line 140 of file SkPixelRef.h.
static Factory SkPixelRef::NameToFactory | ( | const char | name[] | ) | [static] |
void SkPixelRef::notifyPixelsChanged | ( | ) |
Call this if you have changed the contents of the pixels. This will in- turn cause a different generation ID value to be returned from getGenerationID().
virtual void* SkPixelRef::onLockPixels | ( | SkColorTable ** | ) | [protected, pure virtual] |
Called when the lockCount goes from 0 to 1. The caller will have already acquire a mutex for thread safety, so this method need not do that.
Implemented in SkMallocPixelRef.
virtual void SkPixelRef::onUnlockPixels | ( | ) | [protected, pure virtual] |
Called when the lock count goes from 1 to 0. The caller will have already acquire a mutex for thread safety, so this method need not do that.
Implemented in SkMallocPixelRef.
void* SkPixelRef::pixels | ( | ) | const [inline] |
Return the pixel memory returned from lockPixels, or null if the lockCount is 0.
Definition at line 43 of file SkPixelRef.h.
static void SkPixelRef::Register | ( | const char | name[], | |
Factory | ||||
) | [static] |
void SkPixelRef::setImmutable | ( | ) |
Marks this pixelref is immutable, meaning that the contents of its pixels will not change for the lifetime of the pixelref. This state can be set on a pixelref, but it cannot be cleared once it is set.
void SkPixelRef::setURI | ( | const SkString & | uri | ) | [inline] |
Assign a URI string to this pixelref.
Definition at line 106 of file SkPixelRef.h.
void SkPixelRef::setURI | ( | const char | uri[], | |
size_t | len | |||
) | [inline] |
Copy a URI string to this pixelref
Definition at line 100 of file SkPixelRef.h.
void SkPixelRef::setURI | ( | const char | uri[] | ) | [inline] |
Copy a URI string to this pixelref, or clear the URI if the uri is null
Definition at line 94 of file SkPixelRef.h.
void SkPixelRef::unlockPixels | ( | ) |
Call to balanace a previous call to lockPixels(). Returns the pixels (or null) after the unlock. NOTE: lock calls can be nested, but the matching number of unlock calls must be made in order to free the memory (if the subclass implements caching/deferred-decoding.)