Skia
2DGraphicsLibrary
|
Public Types | |
enum | RenderTargetGamma : uint8_t { kLinear_RenderTargetGamma, kSRGB_RenderTargetGamma } |
enum | Gamut { kSRGB_Gamut, kAdobeRGB_Gamut, kDCIP3_D65_Gamut, kRec2020_Gamut } |
Public Member Functions | |
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. | |
bool | isNumericalTransferFn (SkColorSpaceTransferFn *fn) const |
If the transfer function can be represented as coefficients to the standard equation, returns true and sets |fn| to the proper values. More... | |
bool | toXYZD50 (SkMatrix44 *toXYZD50) const |
Returns true and sets |toXYZD50| if the color gamut can be described as a matrix. More... | |
bool | isSRGB () const |
Returns true if the color space is sRGB. More... | |
sk_sp< SkData > | serialize () const |
Returns nullptr on failure. More... | |
size_t | writeToMemory (void *memory) const |
If |memory| is nullptr, returns the size required to serialize. More... | |
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... | |
Static Public Member Functions | |
static sk_sp< SkColorSpace > | MakeSRGB () |
Create the sRGB color space. | |
static sk_sp< SkColorSpace > | MakeSRGBLinear () |
Colorspace with the sRGB primaries, but a linear (1.0) gamma. More... | |
static sk_sp< SkColorSpace > | MakeRGB (RenderTargetGamma gamma, Gamut gamut) |
Create an SkColorSpace from a transfer function and a color gamut. More... | |
static sk_sp< SkColorSpace > | MakeRGB (RenderTargetGamma gamma, const SkMatrix44 &toXYZD50) |
static sk_sp< SkColorSpace > | MakeRGB (const SkColorSpaceTransferFn &coeffs, Gamut gamut) |
static sk_sp< SkColorSpace > | MakeRGB (const SkColorSpaceTransferFn &coeffs, const SkMatrix44 &toXYZD50) |
static sk_sp< SkColorSpace > | MakeICC (const void *, size_t) |
Create an SkColorSpace from an ICC profile. | |
static sk_sp< SkColorSpace > | Deserialize (const void *data, size_t length) |
static bool | Equals (const SkColorSpace *src, const SkColorSpace *dst) |
If both are null, we return true. More... | |
Private Types | |
using | INHERITED = SkRefCnt |
Friends | |
class | SkColorSpace_Base |
Additional Inherited Members | |
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... | |
enum SkColorSpace::RenderTargetGamma : uint8_t |
|
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.
bool SkColorSpace::gammaCloseToSRGB | ( | ) | const |
Returns true if the color space gamma is near enough to be approximated as sRGB.
This includes the canonical sRGB transfer function as well as a 2.2f exponential transfer function.
bool SkColorSpace::isNumericalTransferFn | ( | SkColorSpaceTransferFn * | fn | ) | const |
If the transfer function can be represented as coefficients to the standard equation, returns true and sets |fn| to the proper values.
If not, returns false.
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.
|
static |
Create an SkColorSpace from a transfer function and a color gamut.
Transfer function can be specified as an enum or as the coefficients to an equation. Gamut can be specified as an enum or as the matrix transformation to XYZ D50.
|
static |
Colorspace with the sRGB primaries, but a linear (1.0) gamma.
Commonly used for half-float surfaces, and high precision individual colors (gradient stops, etc...)
Returns nullptr on failure.
Fails when we fallback to serializing ICC data and the data is too large to serialize.
bool SkColorSpace::toXYZD50 | ( | SkMatrix44 * | toXYZD50 | ) | const |
Returns true and sets |toXYZD50| if the color gamut can be described as a matrix.
Returns false otherwise.
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.