Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
SkTMaskGamma< R_LUM_BITS, G_LUM_BITS, B_LUM_BITS > Class Template Reference

#include <SkMaskGamma.h>

Inheritance diagram for SkTMaskGamma< R_LUM_BITS, G_LUM_BITS, B_LUM_BITS >:
SkRefCnt SkRefCntBase

Public Types

typedef SkTMaskPreBlend< R_LUM_BITS, G_LUM_BITS, B_LUM_BITS > PreBlend
 

Public Member Functions

 SkTMaskGamma ()
 
 SkTMaskGamma (SkScalar contrast, SkScalar paintGamma, SkScalar deviceGamma)
 
PreBlend preBlend (SkColor color) const
 
void getGammaTableDimensions (int *tableWidth, int *numTables) const
 
const uint8_t * getGammaTables () const
 
- Public Member Functions inherited from SkRefCntBase
 SkRefCntBase ()
 
virtual ~SkRefCntBase ()
 
bool unique () const
 
void ref () const
 
void unref () const
 

Static Public Member Functions

static SkColor CanonicalColor (SkColor color)
 

Detailed Description

template<int R_LUM_BITS, int G_LUM_BITS, int B_LUM_BITS>
class SkTMaskGamma< R_LUM_BITS, G_LUM_BITS, B_LUM_BITS >

A regular mask contains linear alpha values. A gamma correcting mask contains non-linear alpha values in an attempt to create gamma correct blits in the presence of a gamma incorrect (linear) blend in the blitter.

SkMaskGamma creates and maintains tables which convert linear alpha values to gamma correcting alpha values.

Parameters
RThe number of luminance bits to use [1, 8] from the red channel.
GThe number of luminance bits to use [1, 8] from the green channel.
BThe number of luminance bits to use [1, 8] from the blue channel.

Definition at line 100 of file SkMaskGamma.h.

Member Typedef Documentation

◆ PreBlend

template<int R_LUM_BITS, int G_LUM_BITS, int B_LUM_BITS>
typedef SkTMaskPreBlend<R_LUM_BITS, G_LUM_BITS, B_LUM_BITS> SkTMaskGamma< R_LUM_BITS, G_LUM_BITS, B_LUM_BITS >::PreBlend

The type of the mask pre-blend which will be returned from preBlend(SkColor).

Definition at line 136 of file SkMaskGamma.h.

Constructor & Destructor Documentation

◆ SkTMaskGamma() [1/2]

template<int R_LUM_BITS, int G_LUM_BITS, int B_LUM_BITS>
SkTMaskGamma< R_LUM_BITS, G_LUM_BITS, B_LUM_BITS >::SkTMaskGamma ( )
inline

Creates a linear SkTMaskGamma.

Definition at line 105 of file SkMaskGamma.h.

105: fIsLinear(true) { }

◆ SkTMaskGamma() [2/2]

template<int R_LUM_BITS, int G_LUM_BITS, int B_LUM_BITS>
SkTMaskGamma< R_LUM_BITS, G_LUM_BITS, B_LUM_BITS >::SkTMaskGamma ( SkScalar  contrast,
SkScalar  paintGamma,
SkScalar  deviceGamma 
)
inline

Creates tables to convert linear alpha values to gamma correcting alpha values.

Parameters
contrastA value in the range [0.0, 1.0] which indicates the amount of artificial contrast to add.
paintThe color space in which the paint color was chosen.
deviceThe color space of the target device.

Definition at line 116 of file SkMaskGamma.h.

116 : fIsLinear(false) {
117 const SkColorSpaceLuminance& paintConvert = SkColorSpaceLuminance::Fetch(paintGamma);
118 const SkColorSpaceLuminance& deviceConvert = SkColorSpaceLuminance::Fetch(deviceGamma);
119 for (U8CPU i = 0; i < (1 << MAX_LUM_BITS); ++i) {
120 U8CPU lum = sk_t_scale255<MAX_LUM_BITS>(i);
121 SkTMaskGamma_build_correcting_lut(fGammaTables[i], lum, contrast,
122 paintConvert, paintGamma,
123 deviceConvert, deviceGamma);
124 }
125 }
unsigned U8CPU
Definition SkCPUTypes.h:18
void SkTMaskGamma_build_correcting_lut(uint8_t table[256], U8CPU srcI, SkScalar contrast, const SkColorSpaceLuminance &srcConvert, SkScalar srcGamma, const SkColorSpaceLuminance &dstConvert, SkScalar dstGamma)
static const SkColorSpaceLuminance & Fetch(SkScalar gamma)
static float lum(float r, float g, float b)
Definition hsl.cpp:52

Member Function Documentation

◆ CanonicalColor()

template<int R_LUM_BITS, int G_LUM_BITS, int B_LUM_BITS>
static SkColor SkTMaskGamma< R_LUM_BITS, G_LUM_BITS, B_LUM_BITS >::CanonicalColor ( SkColor  color)
inlinestatic

Given a color, returns the closest canonical color.

Definition at line 128 of file SkMaskGamma.h.

128 {
129 return SkColorSetRGB(
130 sk_t_scale255<R_LUM_BITS>(SkColorGetR(color) >> (8 - R_LUM_BITS)),
131 sk_t_scale255<G_LUM_BITS>(SkColorGetG(color) >> (8 - G_LUM_BITS)),
132 sk_t_scale255<B_LUM_BITS>(SkColorGetB(color) >> (8 - B_LUM_BITS)));
133 }
SkColor4f color
#define SkColorGetR(color)
Definition SkColor.h:65
#define SkColorGetG(color)
Definition SkColor.h:69
#define SkColorSetRGB(r, g, b)
Definition SkColor.h:57
#define SkColorGetB(color)
Definition SkColor.h:73

◆ getGammaTableDimensions()

template<int R_LUM_BITS, int G_LUM_BITS, int B_LUM_BITS>
void SkTMaskGamma< R_LUM_BITS, G_LUM_BITS, B_LUM_BITS >::getGammaTableDimensions ( int tableWidth,
int numTables 
) const
inline

Get dimensions for the full table set, so it can be allocated as a block.

Definition at line 148 of file SkMaskGamma.h.

148 {
149 *tableWidth = 256;
150 *numTables = (1 << MAX_LUM_BITS);
151 }

◆ getGammaTables()

template<int R_LUM_BITS, int G_LUM_BITS, int B_LUM_BITS>
const uint8_t * SkTMaskGamma< R_LUM_BITS, G_LUM_BITS, B_LUM_BITS >::getGammaTables ( ) const
inline

Provides direct access to the full table set, so it can be uploaded into a texture or analyzed in other ways. Returns nullptr if fGammaTables hasn't been initialized.

Definition at line 158 of file SkMaskGamma.h.

158 {
159 return fIsLinear ? nullptr : (const uint8_t*) fGammaTables;
160 }

◆ preBlend()

template<int R_LUM_BITS, int G_LUM_BITS, int B_LUM_BITS>
SkTMaskPreBlend< R_LUM_BITS, G_LUM_BITS, B_LUM_BITS > SkTMaskGamma< R_LUM_BITS, G_LUM_BITS, B_LUM_BITS >::preBlend ( SkColor  color) const

Provides access to the tables appropriate for converting linear alpha values into gamma correcting alpha values when drawing the given color through the mask. The destination color will be approximated.

Definition at line 213 of file SkMaskGamma.h.

213 {
215 : SkTMaskPreBlend<R_LUM_BITS, G_LUM_BITS, B_LUM_BITS>(sk_ref_sp(this),
216 fGammaTables[SkColorGetR(color) >> (8 - MAX_LUM_BITS)],
217 fGammaTables[SkColorGetG(color) >> (8 - MAX_LUM_BITS)],
218 fGammaTables[SkColorGetB(color) >> (8 - MAX_LUM_BITS)]);
219}
sk_sp< T > sk_ref_sp(T *obj)
Definition SkRefCnt.h:381

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