Skia
2D Graphics Library
SkRGBA4f< kAT > Struct Template Reference

#include <SkColor.h>

Public Member Functions

bool operator== (const SkRGBA4f &other) const
 Compares SkRGBA4f with other, and returns true if all components are equal. More...
 
bool operator!= (const SkRGBA4f &other) const
 Compares SkRGBA4f with other, and returns true if not all components are equal. More...
 
SkRGBA4f operator* (float scale) const
 Returns SkRGBA4f multiplied by scale. More...
 
SkRGBA4f operator* (const SkRGBA4f &scale) const
 Returns SkRGBA4f multiplied component-wise by scale. More...
 
const float * vec () const
 Returns a pointer to components of SkRGBA4f, for array access. More...
 
float * vec ()
 Returns a pointer to components of SkRGBA4f, for array access. More...
 
std::array< float, 4 > array () const
 As a std::array<float, 4> More...
 
float operator[] (int index) const
 Returns one component. More...
 
float & operator[] (int index)
 Returns one component. More...
 
bool isOpaque () const
 Returns true if SkRGBA4f is an opaque color. More...
 
bool fitsInBytes () const
 Returns true if all channels are in [0, 1]. More...
 
SkColor toSkColor () const
 Returns closest SkColor to SkRGBA4f. More...
 
SkRGBA4f< kPremul_SkAlphaTypepremul () const
 Returns SkRGBA4f premultiplied by alpha. More...
 
SkRGBA4f< kUnpremul_SkAlphaTypeunpremul () const
 Returns SkRGBA4f unpremultiplied by alpha. More...
 
uint32_t toBytes_RGBA () const
 
SkRGBA4f makeOpaque () const
 

Static Public Member Functions

static SkRGBA4f FromColor (SkColor color)
 Returns closest SkRGBA4f to SkColor. More...
 
static SkRGBA4f FromPMColor (SkPMColor)
 Returns closest SkRGBA4f to SkPMColor. More...
 
static SkRGBA4f FromBytes_RGBA (uint32_t color)
 

Public Attributes

float fR
 red component More...
 
float fG
 green component More...
 
float fB
 blue component More...
 
float fA
 alpha component More...
 

Detailed Description

template<SkAlphaType kAT>
struct SkRGBA4f< kAT >

RGBA color value, holding four floating point components. Color components are always in a known order. kAT determines if the SkRGBA4f's R, G, and B components are premultiplied by alpha or not.

Skia's public API always uses unpremultiplied colors, which can be stored as SkRGBA4f<kUnpremul_SkAlphaType>. For convenience, this type can also be referred to as SkColor4f.

Member Function Documentation

◆ array()

template<SkAlphaType kAT>
std::array<float, 4> SkRGBA4f< kAT >::array ( ) const
inline

As a std::array<float, 4>

◆ fitsInBytes()

template<SkAlphaType kAT>
bool SkRGBA4f< kAT >::fitsInBytes ( ) const
inline

Returns true if all channels are in [0, 1].

◆ FromBytes_RGBA()

template<SkAlphaType kAT>
static SkRGBA4f SkRGBA4f< kAT >::FromBytes_RGBA ( uint32_t  color)
static

◆ FromColor()

template<SkAlphaType kAT>
static SkRGBA4f SkRGBA4f< kAT >::FromColor ( SkColor  color)
static

Returns closest SkRGBA4f to SkColor.

Only allowed if SkRGBA4f is unpremultiplied.

Parameters
colorColor with Alpha, red, blue, and green components
Returns
SkColor as SkRGBA4f

example: https://fiddle.skia.org/c/@RGBA4f_FromColor

◆ FromPMColor()

template<SkAlphaType kAT>
static SkRGBA4f SkRGBA4f< kAT >::FromPMColor ( SkPMColor  )
static

Returns closest SkRGBA4f to SkPMColor.

Only allowed if SkRGBA4f is premultiplied.

Returns
SkPMColor as SkRGBA4f

◆ isOpaque()

template<SkAlphaType kAT>
bool SkRGBA4f< kAT >::isOpaque ( ) const
inline

Returns true if SkRGBA4f is an opaque color.

Asserts if fA is out of range and SK_DEBUG is defined.

Returns
true if SkRGBA4f is opaque

◆ makeOpaque()

template<SkAlphaType kAT>
SkRGBA4f SkRGBA4f< kAT >::makeOpaque ( ) const
inline

◆ operator!=()

template<SkAlphaType kAT>
bool SkRGBA4f< kAT >::operator!= ( const SkRGBA4f< kAT > &  other) const
inline

Compares SkRGBA4f with other, and returns true if not all components are equal.

Parameters
otherSkRGBA4f to compare
Returns
true if SkRGBA4f is not equal to other

◆ operator*() [1/2]

template<SkAlphaType kAT>
SkRGBA4f SkRGBA4f< kAT >::operator* ( const SkRGBA4f< kAT > &  scale) const
inline

Returns SkRGBA4f multiplied component-wise by scale.

Parameters
scaleSkRGBA4f to multiply by
Returns
SkRGBA4f as (fR * scale.fR, fG * scale.fG, fB * scale.fB, fA * scale.fA)

◆ operator*() [2/2]

template<SkAlphaType kAT>
SkRGBA4f SkRGBA4f< kAT >::operator* ( float  scale) const
inline

Returns SkRGBA4f multiplied by scale.

Parameters
scalevalue to multiply by
Returns
SkRGBA4f as (fR * scale, fG * scale, fB * scale, fA * scale)

◆ operator==()

template<SkAlphaType kAT>
bool SkRGBA4f< kAT >::operator== ( const SkRGBA4f< kAT > &  other) const
inline

Compares SkRGBA4f with other, and returns true if all components are equal.

Parameters
otherSkRGBA4f to compare
Returns
true if SkRGBA4f equals other

◆ operator[]() [1/2]

template<SkAlphaType kAT>
float& SkRGBA4f< kAT >::operator[] ( int  index)
inline

Returns one component.

Asserts if index is out of range and SK_DEBUG is defined.

Parameters
indexone of: 0 (fR), 1 (fG), 2 (fB), 3 (fA)
Returns
value corresponding to index

◆ operator[]() [2/2]

template<SkAlphaType kAT>
float SkRGBA4f< kAT >::operator[] ( int  index) const
inline

Returns one component.

Asserts if index is out of range and SK_DEBUG is defined.

Parameters
indexone of: 0 (fR), 1 (fG), 2 (fB), 3 (fA)
Returns
value corresponding to index

◆ premul()

template<SkAlphaType kAT>
SkRGBA4f<kPremul_SkAlphaType> SkRGBA4f< kAT >::premul ( ) const
inline

Returns SkRGBA4f premultiplied by alpha.

Asserts at compile time if SkRGBA4f is already premultiplied.

Returns
premultiplied color

◆ toBytes_RGBA()

template<SkAlphaType kAT>
uint32_t SkRGBA4f< kAT >::toBytes_RGBA ( ) const

◆ toSkColor()

template<SkAlphaType kAT>
SkColor SkRGBA4f< kAT >::toSkColor ( ) const

Returns closest SkColor to SkRGBA4f.

Only allowed if SkRGBA4f is unpremultiplied.

Returns
color as SkColor

example: https://fiddle.skia.org/c/@RGBA4f_toSkColor

◆ unpremul()

template<SkAlphaType kAT>
SkRGBA4f<kUnpremul_SkAlphaType> SkRGBA4f< kAT >::unpremul ( ) const
inline

Returns SkRGBA4f unpremultiplied by alpha.

Asserts at compile time if SkRGBA4f is already unpremultiplied.

Returns
unpremultiplied color

◆ vec() [1/2]

template<SkAlphaType kAT>
float* SkRGBA4f< kAT >::vec ( )
inline

Returns a pointer to components of SkRGBA4f, for array access.

Returns
pointer to array [fR, fG, fB, fA]

◆ vec() [2/2]

template<SkAlphaType kAT>
const float* SkRGBA4f< kAT >::vec ( ) const
inline

Returns a pointer to components of SkRGBA4f, for array access.

Returns
pointer to array [fR, fG, fB, fA]

Member Data Documentation

◆ fA

template<SkAlphaType kAT>
float SkRGBA4f< kAT >::fA

alpha component

◆ fB

template<SkAlphaType kAT>
float SkRGBA4f< kAT >::fB

blue component

◆ fG

template<SkAlphaType kAT>
float SkRGBA4f< kAT >::fG

green component

◆ fR

template<SkAlphaType kAT>
float SkRGBA4f< kAT >::fR

red component


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