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

This class is the smart container for pixel memory, and is used with SkBitmap. More...

#include <SkPixelRef.h>

Inheritance diagram for SkPixelRef:
SkRefCnt SkRefCntBase SkMallocPixelRef

Classes

struct  GenIDChangeListener
 

Public Member Functions

 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

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...
 

Private Types

enum  { kMutable, kTemporarilyImmutable, kImmutable }
 
typedef SkRefCnt INHERITED
 

Private Member Functions

bool genIDIsUnique () const
 
void needsNewGenID ()
 
void callGenIDChangeListeners ()
 
void setTemporarilyImmutable ()
 
void restoreMutability ()
 
void setImmutableWithID (uint32_t genID)
 

Private Attributes

int fWidth
 
int fHeight
 
sk_sp< SkColorTablefCTable
 
void * fPixels
 
size_t fRowBytes
 
SkAtomic< uint32_t > fTaggedGenID
 
SkTDArray< GenIDChangeListener * > fGenIDChangeListeners
 
SkAtomic< bool > fAddedToCache
 
enum SkPixelRef:: { ... }  fMutability
 

Friends

class SkSurface_Raster
 
class SkImage_Raster
 
class SkSpecialImage_Raster
 
class SkImage_Gpu
 
class SkImage_Lazy
 
class SkSpecialImage_Gpu
 
void SkBitmapCache_setImmutableWithID (SkPixelRef *, uint32_t)
 

Detailed Description

This class is the smart container for pixel memory, and is used with SkBitmap.

This class can be shared/accessed between multiple threads.

Member Function Documentation

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.

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().

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.


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