Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
SkColorSpaceLuminance Class Referenceabstract

#include <SkMaskGamma.h>

Inheritance diagram for SkColorSpaceLuminance:
SkNoncopyable SkGammaColorSpaceLuminance SkLinearColorSpaceLuminance SkSRGBColorSpaceLuminance

Public Member Functions

virtual ~SkColorSpaceLuminance ()
 
virtual SkScalar toLuma (SkScalar gamma, SkScalar luminance) const =0
 
virtual SkScalar fromLuma (SkScalar gamma, SkScalar luma) const =0
 

Static Public Member Functions

static U8CPU computeLuminance (SkScalar gamma, SkColor c)
 
static const SkColorSpaceLuminanceFetch (SkScalar gamma)
 

Detailed Description

SkColorSpaceLuminance is used to convert luminances to and from linear and perceptual color spaces.

Luma is used to specify a linear luminance value [0.0, 1.0]. Luminance is used to specify a luminance value in an arbitrary color space [0.0, 1.0].

Definition at line 29 of file SkMaskGamma.h.

Constructor & Destructor Documentation

◆ ~SkColorSpaceLuminance()

virtual SkColorSpaceLuminance::~SkColorSpaceLuminance ( )
inlinevirtual

Definition at line 31 of file SkMaskGamma.h.

31{ }

Member Function Documentation

◆ computeLuminance()

static U8CPU SkColorSpaceLuminance::computeLuminance ( SkScalar  gamma,
SkColor  c 
)
inlinestatic

Converts a color to a luminance value.

Definition at line 39 of file SkMaskGamma.h.

39 {
40 const SkColorSpaceLuminance& luminance = Fetch(gamma);
41 SkScalar r = luminance.toLuma(gamma, SkIntToScalar(SkColorGetR(c)) / 255);
42 SkScalar g = luminance.toLuma(gamma, SkIntToScalar(SkColorGetG(c)) / 255);
43 SkScalar b = luminance.toLuma(gamma, SkIntToScalar(SkColorGetB(c)) / 255);
44 SkScalar luma = r * SK_LUM_COEFF_R +
45 g * SK_LUM_COEFF_G +
47 SkASSERT(luma <= SK_Scalar1);
48 return SkScalarRoundToInt(luminance.fromLuma(gamma, luma) * 255);
49 }
#define SkASSERT(cond)
Definition: SkAssert.h:116
#define SK_LUM_COEFF_B
Definition: SkColorData.h:112
#define SK_LUM_COEFF_R
Definition: SkColorData.h:110
#define SK_LUM_COEFF_G
Definition: SkColorData.h:111
#define SkColorGetR(color)
Definition: SkColor.h:65
#define SkColorGetG(color)
Definition: SkColor.h:69
#define SkColorGetB(color)
Definition: SkColor.h:73
#define SK_Scalar1
Definition: SkScalar.h:18
#define SkScalarRoundToInt(x)
Definition: SkScalar.h:37
#define SkIntToScalar(x)
Definition: SkScalar.h:57
virtual SkScalar fromLuma(SkScalar gamma, SkScalar luma) const =0
virtual SkScalar toLuma(SkScalar gamma, SkScalar luminance) const =0
static const SkColorSpaceLuminance & Fetch(SkScalar gamma)
Definition: SkMaskGamma.cpp:60
float SkScalar
Definition: extension.cpp:12
static bool b

◆ Fetch()

const SkColorSpaceLuminance & SkColorSpaceLuminance::Fetch ( SkScalar  gamma)
static

Retrieves the SkColorSpaceLuminance for the given gamma.

Definition at line 60 of file SkMaskGamma.cpp.

60 {
61 static SkLinearColorSpaceLuminance gSkLinearColorSpaceLuminance;
62 static SkGammaColorSpaceLuminance gSkGammaColorSpaceLuminance;
63 static SkSRGBColorSpaceLuminance gSkSRGBColorSpaceLuminance;
64
65 if (0 == gamma) {
66 return gSkSRGBColorSpaceLuminance;
67 } else if (SK_Scalar1 == gamma) {
68 return gSkLinearColorSpaceLuminance;
69 } else {
70 return gSkGammaColorSpaceLuminance;
71 }
72}

◆ fromLuma()

virtual SkScalar SkColorSpaceLuminance::fromLuma ( SkScalar  gamma,
SkScalar  luma 
) const
pure virtual

Converts a linear luma to a color component luminance in the color space.

◆ toLuma()

virtual SkScalar SkColorSpaceLuminance::toLuma ( SkScalar  gamma,
SkScalar  luminance 
) const
pure virtual

Converts a color component luminance in the color space to a linear luma.


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