Skia
2DGraphicsLibrary
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkMallocPixelRef Class Reference

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>

Inheritance diagram for SkMallocPixelRef:
SkPixelRef SkRefCnt SkRefCntBase

Public Types

typedef void(* ReleaseProc )(void *addr, void *context)
 Return a new SkMallocPixelRef with the provided pixel storage, rowBytes, and optional colortable. More...
 

Static Public Member Functions

static sk_sp< SkPixelRefMakeDirect (const SkImageInfo &, void *addr, size_t rowBytes, sk_sp< SkColorTable >)
 Return a new SkMallocPixelRef with the provided pixel storage, rowBytes, and optional colortable. More...
 
static sk_sp< SkPixelRefMakeAllocate (const SkImageInfo &, size_t rowBytes, sk_sp< SkColorTable >)
 Return a new SkMallocPixelRef, automatically allocating storage for the pixels. More...
 
static sk_sp< SkPixelRefMakeZeroed (const SkImageInfo &, size_t rowBytes, sk_sp< SkColorTable >)
 Identical to MakeAllocate, except all pixel bytes are zeroed.
 
static sk_sp< SkPixelRefMakeWithProc (const SkImageInfo &info, size_t rowBytes, sk_sp< SkColorTable >, void *addr, ReleaseProc proc, void *context)
 
static sk_sp< SkPixelRefMakeWithData (const SkImageInfo &info, size_t rowBytes, sk_sp< SkColorTable >, sk_sp< SkData > data)
 Return a new SkMallocPixelRef that will use the provided SkData, rowBytes, and optional colortable as pixel storage. More...
 

Private Types

typedef SkPixelRef INHERITED
 

Private Member Functions

 SkMallocPixelRef (const SkImageInfo &, void *addr, size_t rb, sk_sp< SkColorTable >, ReleaseProc proc, void *context)
 

Static Private Member Functions

static sk_sp< SkPixelRefMakeUsing (void *(*alloc)(size_t), const SkImageInfo &, size_t rowBytes, sk_sp< SkColorTable >)
 

Private Attributes

ReleaseProc fReleaseProc
 
void * fReleaseProcContext
 

Additional Inherited Members

- Public Member Functions inherited from SkPixelRef
 SkPixelRef (int width, int height, void *addr, size_t rowBytes, sk_sp< SkColorTable >=nullptr)
 
int width () const
 
int height () const
 
void * pixels () const
 
SkColorTablecolorTable () const
 
size_t rowBytes () const
 
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...
 
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...
 
void addGenIDChangeListener (GenIDChangeListener *listener)
 
void notifyAddedToCache ()
 
virtual SkDiscardableMemory * diagnostic_only_getDiscardable () const
 
- 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...
 
- Protected Member Functions inherited from SkPixelRef
virtual void onNotifyPixelsChanged ()
 
- 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...
 

Detailed Description

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.

Member Typedef Documentation

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.

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.

Member Function Documentation

static sk_sp<SkPixelRef> SkMallocPixelRef::MakeAllocate ( const SkImageInfo ,
size_t  rowBytes,
sk_sp< SkColorTable  
)
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 sk_sp<SkPixelRef> SkMallocPixelRef::MakeDirect ( const SkImageInfo ,
void *  addr,
size_t  rowBytes,
sk_sp< SkColorTable  
)
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.

Returns NULL on failure.

static sk_sp<SkPixelRef> SkMallocPixelRef::MakeWithData ( const SkImageInfo info,
size_t  rowBytes,
sk_sp< SkColorTable ,
sk_sp< SkData data 
)
static

Return a new SkMallocPixelRef that will use the provided SkData, rowBytes, and optional colortable as pixel storage.

The SkData will be ref()ed and on destruction of the PielRef, the SkData will be unref()ed.

Returns NULL on failure.


The documentation for this class was generated from the following file: