Skia
2D Graphics Library
SkColorSpace Class Reference

#include <SkColorSpace.h>

Inheritance diagram for SkColorSpace:

Public Member Functions

void toProfile (skcms_ICCProfile *) const
 Convert this color space to an skcms ICC profile struct. More...
 
bool gammaCloseToSRGB () const
 Returns true if the color space gamma is near enough to be approximated as sRGB. More...
 
bool gammaIsLinear () const
 Returns true if the color space gamma is linear. More...
 
bool isNumericalTransferFn (skcms_TransferFunction *fn) const
 Sets |fn| to the transfer function from this color space. More...
 
bool toXYZD50 (skcms_Matrix3x3 *toXYZD50) const
 Returns true and sets |toXYZD50|. More...
 
uint32_t toXYZD50Hash () const
 Returns a hash of the gamut transformation to XYZ D50. More...
 
sk_sp< SkColorSpacemakeLinearGamma () const
 Returns a color space with the same gamut as this one, but with a linear gamma. More...
 
sk_sp< SkColorSpacemakeSRGBGamma () const
 Returns a color space with the same gamut as this one, but with the sRGB transfer function. More...
 
sk_sp< SkColorSpacemakeColorSpin () const
 Returns a color space with the same transfer function as this one, but with the primary colors rotated. More...
 
bool isSRGB () const
 Returns true if the color space is sRGB. More...
 
sk_sp< SkDataserialize () const
 Returns a serialized representation of this color space. More...
 
size_t writeToMemory (void *memory) const
 If |memory| is nullptr, returns the size required to serialize. More...
 
void transferFn (float gabcdef[7]) const
 
void transferFn (skcms_TransferFunction *fn) const
 
void invTransferFn (skcms_TransferFunction *fn) const
 
void gamutTransformTo (const SkColorSpace *dst, skcms_Matrix3x3 *src_to_dst) const
 
uint32_t transferFnHash () const
 
uint64_t hash () const
 
bool unique () const
 
void ref () const
 
void unref () const
 
void deref () const
 
bool refCntGreaterThan (int32_t threadIsolatedTestCnt) const
 

Static Public Member Functions

static sk_sp< SkColorSpaceMakeSRGB ()
 Create the sRGB color space. More...
 
static sk_sp< SkColorSpaceMakeSRGBLinear ()
 Colorspace with the sRGB primaries, but a linear (1.0) gamma. More...
 
static sk_sp< SkColorSpaceMakeRGB (const skcms_TransferFunction &transferFn, const skcms_Matrix3x3 &toXYZ)
 Create an SkColorSpace from a transfer function and a row-major 3x3 transformation to XYZ. More...
 
static sk_sp< SkColorSpaceMake (const skcms_ICCProfile &)
 Create an SkColorSpace from a parsed (skcms) ICC profile. More...
 
static sk_sp< SkColorSpaceDeserialize (const void *data, size_t length)
 
static bool Equals (const SkColorSpace *, const SkColorSpace *)
 If both are null, we return true. More...
 

Friends

class SkColorSpaceSingletonFactory
 

Member Function Documentation

◆ deref()

void SkNVRefCnt< SkColorSpace >::deref ( ) const
inlineinherited

◆ Deserialize()

static sk_sp<SkColorSpace> SkColorSpace::Deserialize ( const void *  data,
size_t  length 
)
static

◆ Equals()

static bool SkColorSpace::Equals ( const SkColorSpace ,
const SkColorSpace  
)
static

If both are null, we return true.

If one is null and the other is not, we return false. If both are non-null, we do a deeper compare.

◆ gammaCloseToSRGB()

bool SkColorSpace::gammaCloseToSRGB ( ) const

Returns true if the color space gamma is near enough to be approximated as sRGB.

◆ gammaIsLinear()

bool SkColorSpace::gammaIsLinear ( ) const

Returns true if the color space gamma is linear.

◆ gamutTransformTo()

void SkColorSpace::gamutTransformTo ( const SkColorSpace dst,
skcms_Matrix3x3 *  src_to_dst 
) const

◆ hash()

uint64_t SkColorSpace::hash ( ) const
inline

◆ invTransferFn()

void SkColorSpace::invTransferFn ( skcms_TransferFunction *  fn) const

◆ isNumericalTransferFn()

bool SkColorSpace::isNumericalTransferFn ( skcms_TransferFunction *  fn) const

Sets |fn| to the transfer function from this color space.

Returns true if the transfer function can be represented as coefficients to the standard ICC 7-parameter equation. Returns false otherwise (eg, PQ, HLG).

◆ isSRGB()

bool SkColorSpace::isSRGB ( ) const

Returns true if the color space is sRGB.

Returns false otherwise.

This allows a little bit of tolerance, given that we might see small numerical error in some cases: converting ICC fixed point to float, converting white point to D50, rounding decisions on transfer function and matrix.

This does not consider a 2.2f exponential transfer function to be sRGB. While these functions are similar (and it is sometimes useful to consider them together), this function checks for logical equality.

◆ Make()

static sk_sp<SkColorSpace> SkColorSpace::Make ( const skcms_ICCProfile &  )
static

Create an SkColorSpace from a parsed (skcms) ICC profile.

◆ makeColorSpin()

sk_sp<SkColorSpace> SkColorSpace::makeColorSpin ( ) const

Returns a color space with the same transfer function as this one, but with the primary colors rotated.

In other words, this produces a new color space that maps RGB to GBR (when applied to a source), and maps RGB to BRG (when applied to a destination).

This is used for testing, to construct color spaces that have severe and testable behavior.

◆ makeLinearGamma()

sk_sp<SkColorSpace> SkColorSpace::makeLinearGamma ( ) const

Returns a color space with the same gamut as this one, but with a linear gamma.

◆ MakeRGB()

static sk_sp<SkColorSpace> SkColorSpace::MakeRGB ( const skcms_TransferFunction &  transferFn,
const skcms_Matrix3x3 &  toXYZ 
)
static

Create an SkColorSpace from a transfer function and a row-major 3x3 transformation to XYZ.

◆ MakeSRGB()

static sk_sp<SkColorSpace> SkColorSpace::MakeSRGB ( )
static

Create the sRGB color space.

◆ makeSRGBGamma()

sk_sp<SkColorSpace> SkColorSpace::makeSRGBGamma ( ) const

Returns a color space with the same gamut as this one, but with the sRGB transfer function.

◆ MakeSRGBLinear()

static sk_sp<SkColorSpace> SkColorSpace::MakeSRGBLinear ( )
static

Colorspace with the sRGB primaries, but a linear (1.0) gamma.

◆ ref()

void SkNVRefCnt< SkColorSpace >::ref ( ) const
inlineinherited

◆ refCntGreaterThan()

bool SkNVRefCnt< SkColorSpace >::refCntGreaterThan ( int32_t  threadIsolatedTestCnt) const
inlineinherited

◆ serialize()

sk_sp<SkData> SkColorSpace::serialize ( ) const

Returns a serialized representation of this color space.

◆ toProfile()

void SkColorSpace::toProfile ( skcms_ICCProfile *  ) const

Convert this color space to an skcms ICC profile struct.

◆ toXYZD50()

bool SkColorSpace::toXYZD50 ( skcms_Matrix3x3 *  toXYZD50) const

Returns true and sets |toXYZD50|.

◆ toXYZD50Hash()

uint32_t SkColorSpace::toXYZD50Hash ( ) const
inline

Returns a hash of the gamut transformation to XYZ D50.

Allows for fast equality checking of gamuts, at the (very small) risk of collision.

◆ transferFn() [1/2]

void SkColorSpace::transferFn ( float  gabcdef[7]) const

◆ transferFn() [2/2]

void SkColorSpace::transferFn ( skcms_TransferFunction *  fn) const

◆ transferFnHash()

uint32_t SkColorSpace::transferFnHash ( ) const
inline

◆ unique()

bool SkNVRefCnt< SkColorSpace >::unique ( ) const
inlineinherited

◆ unref()

void SkNVRefCnt< SkColorSpace >::unref ( ) const
inlineinherited

◆ writeToMemory()

size_t SkColorSpace::writeToMemory ( void *  memory) const

If |memory| is nullptr, returns the size required to serialize.

Otherwise, serializes into |memory| and returns the size.

Friends And Related Function Documentation

◆ SkColorSpaceSingletonFactory

friend class SkColorSpaceSingletonFactory
friend

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