Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
SkTableMaskFilter Class Reference

#include <SkTableMaskFilter.h>

Public Member Functions

 SkTableMaskFilter ()=delete
 

Static Public Member Functions

static void MakeGammaTable (uint8_t table[256], SkScalar gamma)
 
static void MakeClipTable (uint8_t table[256], uint8_t min, uint8_t max)
 
static SkMaskFilterCreate (const uint8_t table[256])
 
static SkMaskFilterCreateGamma (SkScalar gamma)
 
static SkMaskFilterCreateClip (uint8_t min, uint8_t max)
 

Detailed Description

Applies a table lookup on each of the alpha values in the mask. Helper methods create some common tables (e.g. gamma, clipping)

Definition at line 25 of file SkTableMaskFilter.h.

Constructor & Destructor Documentation

◆ SkTableMaskFilter()

SkTableMaskFilter::SkTableMaskFilter ( )
delete

Member Function Documentation

◆ Create()

SkMaskFilter * SkTableMaskFilter::Create ( const uint8_t  table[256])
static

Definition at line 127 of file SkTableMaskFilter.cpp.

127 {
128 return new SkTableMaskFilterImpl(table);
129}
SI F table(const skcms_Curve *curve, F v)

◆ CreateClip()

SkMaskFilter * SkTableMaskFilter::CreateClip ( uint8_t  min,
uint8_t  max 
)
static

Definition at line 137 of file SkTableMaskFilter.cpp.

137 {
138 uint8_t table[256];
140 return new SkTableMaskFilterImpl(table);
141}
static void MakeClipTable(uint8_t table[256], uint8_t min, uint8_t max)
static float max(float r, float g, float b)
Definition: hsl.cpp:49
static float min(float r, float g, float b)
Definition: hsl.cpp:48

◆ CreateGamma()

SkMaskFilter * SkTableMaskFilter::CreateGamma ( SkScalar  gamma)
static

Definition at line 131 of file SkTableMaskFilter.cpp.

131 {
132 uint8_t table[256];
133 MakeGammaTable(table, gamma);
134 return new SkTableMaskFilterImpl(table);
135}
static void MakeGammaTable(uint8_t table[256], SkScalar gamma)

◆ MakeClipTable()

void SkTableMaskFilter::MakeClipTable ( uint8_t  table[256],
uint8_t  min,
uint8_t  max 
)
static

Utility that creates a clipping table: clamps values below min to 0 and above max to 255, and rescales the remaining into 0..255

Definition at line 155 of file SkTableMaskFilter.cpp.

156 {
157 if (0 == max) {
158 max = 1;
159 }
160 if (min >= max) {
161 min = max - 1;
162 }
163 SkASSERT(min < max);
164
165 SkFixed scale = (1 << 16) * 255 / (max - min);
166 memset(table, 0, min + 1);
167 for (int i = min + 1; i < max; i++) {
168 int value = SkFixedRoundToInt(scale * (i - min));
169 SkASSERT(value <= 255);
170 table[i] = value;
171 }
172 memset(table + max, 255, 256 - max);
173
174#if 0
175 int j;
176 for (j = 0; j < 256; j++) {
177 if (table[j]) {
178 break;
179 }
180 }
181 SkDebugf("%d %d start [%d]", min, max, j);
182 for (; j < 256; j++) {
183 SkDebugf(" %d", table[j]);
184 }
185 SkDebugf("\n\n");
186#endif
187}
#define SkASSERT(cond)
Definition: SkAssert.h:116
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
int32_t SkFixed
Definition: SkFixed.h:25
#define SkFixedRoundToInt(x)
Definition: SkFixed.h:76
uint8_t value
const Scalar scale

◆ MakeGammaTable()

void SkTableMaskFilter::MakeGammaTable ( uint8_t  table[256],
SkScalar  gamma 
)
static

Utility that sets the gamma table

Definition at line 143 of file SkTableMaskFilter.cpp.

143 {
144 const float dx = 1 / 255.0f;
145 const float g = gamma;
146
147 float x = 0;
148 for (int i = 0; i < 256; i++) {
149 // float ee = powf(x, g) * 255;
150 table[i] = SkTPin(sk_float_round2int(powf(x, g) * 255), 0, 255);
151 x += dx;
152 }
153}
#define sk_float_round2int(x)
static constexpr const T & SkTPin(const T &x, const T &lo, const T &hi)
Definition: SkTPin.h:19
double x
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
Definition: SkRecords.h:208

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