Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
SkColorPalette Class Reference

#include <SkColorPalette.h>

Inheritance diagram for SkColorPalette:
SkRefCnt SkRefCntBase

Public Member Functions

 SkColorPalette (const SkPMColor colors[], int count)
 
 ~SkColorPalette () override
 
int count () const
 
SkPMColor operator[] (int index) const
 
const SkPMColorreadColors () const
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Detailed Description

SkColorPalette holds an array of SkPMColors (premultiplied 32-bit colors) used by 8-bit bitmaps, where the bitmap bytes are interpreted as indices into the colortable.

SkColorPalette is thread-safe.

Definition at line 22 of file SkColorPalette.h.

Constructor & Destructor Documentation

◆ SkColorPalette()

SkColorPalette::SkColorPalette ( const SkPMColor  colors[],
int  count 
)

Copy up to 256 colors into a new SkColorPalette.

Definition at line 13 of file SkColorPalette.cpp.

13 {
14 SkASSERT(0 == count || colors);
15 SkASSERT(count >= 0 && count <= 256);
16
17 fCount = count;
18 fColors = reinterpret_cast<SkPMColor*>(sk_malloc_throw(count * sizeof(SkPMColor)));
19
20 memcpy(fColors, colors, count * sizeof(SkPMColor));
21}
#define SkASSERT(cond)
Definition: SkAssert.h:116
uint32_t SkPMColor
Definition: SkColor.h:205
static void * sk_malloc_throw(size_t size)
Definition: SkMalloc.h:67
int count() const
PODArray< SkColor > colors
Definition: SkRecords.h:276

◆ ~SkColorPalette()

SkColorPalette::~SkColorPalette ( )
override

Definition at line 23 of file SkColorPalette.cpp.

23 {
24 sk_free(fColors);
25}
SK_API void sk_free(void *)

Member Function Documentation

◆ count()

int SkColorPalette::count ( ) const
inline

Returns the number of colors in the table.

Definition at line 31 of file SkColorPalette.h.

31{ return fCount; }

◆ operator[]()

SkPMColor SkColorPalette::operator[] ( int  index) const
inline

Returns the specified color from the table. In the debug build, this asserts that the index is in range (0 <= index < count).

Definition at line 36 of file SkColorPalette.h.

36 {
37 SkASSERT(fColors != nullptr && (unsigned)index < (unsigned)fCount);
38 return fColors[index];
39 }

◆ readColors()

const SkPMColor * SkColorPalette::readColors ( ) const
inline

Return the array of colors for reading.

Definition at line 42 of file SkColorPalette.h.

42{ return fColors; }

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