Flutter Engine
The Flutter Engine
Classes | Macros | Typedefs | Functions | Variables
SkBlitter_A8.cpp File Reference
#include "src/core/SkBlitter_A8.h"
#include "include/core/SkBlendMode.h"
#include "include/core/SkColorType.h"
#include "include/core/SkPaint.h"
#include "include/core/SkRect.h"
#include "include/core/SkShader.h"
#include "include/core/SkTypes.h"
#include "include/private/base/SkDebug.h"
#include "src/base/SkArenaAlloc.h"
#include "src/core/SkMask.h"
#include <cstring>
#include <optional>

Go to the source code of this file.

Classes

struct  A8_RowBlitBWPair
 
class  SkA8_Blitter
 

Macros

#define WRAP_BLIT(proc, canFoldAA)
 

Typedefs

using AlphaProc = uint8_t(*)(uint8_t src, uint8_t dst)
 
using A8_RowBlitBW = void(*)(uint8_t[], uint8_t, int)
 
using A8_RowBlitAA = void(*)(uint8_t[], uint8_t, int, uint8_t aa)
 

Functions

static uint8_t div255 (unsigned prod)
 
static unsigned u8_lerp (uint8_t a, uint8_t b, uint8_t t)
 
static uint8_t srcover_p (uint8_t src, uint8_t dst)
 
static uint8_t src_p (uint8_t src, uint8_t dst)
 
template<typename Mode >
void A8_row_bw (uint8_t dst[], uint8_t src, int N, Mode proc)
 
template<typename Mode >
void A8_row_aa (uint8_t dst[], uint8_t src, int N, uint8_t aa, Mode proc, const bool canFoldAA)
 
static const A8_RowBlitBWPairfind_a8_rowproc_pair (SkBlendMode bm)
 
SkBlitterSkA8Blitter_Choose (const SkPixmap &dst, const SkMatrix &ctm, const SkPaint &paint, SkArenaAlloc *alloc, bool drawCoverage, sk_sp< SkShader > clipShader, const SkSurfaceProps &)
 

Variables

constexpr A8_RowBlitBWPair gA8_RowBlitPairs []
 

Macro Definition Documentation

◆ WRAP_BLIT

#define WRAP_BLIT (   proc,
  canFoldAA 
)
Value:
proc, \
[](uint8_t dst[], uint8_t src, int N) \
{ A8_row_bw(dst, src, N, proc); }, \
[](uint8_t dst[], uint8_t src, int N, uint8_t aa) \
{ A8_row_aa(dst, src, N, aa, proc, canFoldAA); }
void A8_row_bw(uint8_t dst[], uint8_t src, int N, Mode proc)
void A8_row_aa(uint8_t dst[], uint8_t src, int N, uint8_t aa, Mode proc, const bool canFoldAA)
#define N
Definition: beziers.cpp:19
dst
Definition: cp.py:12

Definition at line 140 of file SkBlitter_A8.cpp.

Typedef Documentation

◆ A8_RowBlitAA

using A8_RowBlitAA = void(*)(uint8_t[], uint8_t, int, uint8_t aa)

Definition at line 138 of file SkBlitter_A8.cpp.

◆ A8_RowBlitBW

using A8_RowBlitBW = void(*)(uint8_t[], uint8_t, int)

Definition at line 123 of file SkBlitter_A8.cpp.

◆ AlphaProc

using AlphaProc = uint8_t(*)(uint8_t src, uint8_t dst)

Definition at line 113 of file SkBlitter_A8.cpp.

Function Documentation

◆ A8_row_aa()

template<typename Mode >
void A8_row_aa ( uint8_t  dst[],
uint8_t  src,
int  N,
uint8_t  aa,
Mode  proc,
const bool  canFoldAA 
)

Definition at line 126 of file SkBlitter_A8.cpp.

126 {
127 if (canFoldAA) {
128 src = div255(src * aa);
129 for (int i = 0; i < N; ++i) {
130 dst[i] = proc(src, dst[i]);
131 }
132 } else {
133 for (int i = 0; i < N; ++i) {
134 dst[i] = u8_lerp(dst[i], proc(src, dst[i]), aa);
135 }
136 }
137}
static uint8_t div255(unsigned prod)
static unsigned u8_lerp(uint8_t a, uint8_t b, uint8_t t)

◆ A8_row_bw()

template<typename Mode >
void A8_row_bw ( uint8_t  dst[],
uint8_t  src,
int  N,
Mode  proc 
)

Definition at line 118 of file SkBlitter_A8.cpp.

118 {
119 for (int i = 0; i < N; ++i) {
120 dst[i] = proc(src, dst[i]);
121 }
122}

◆ div255()

static uint8_t div255 ( unsigned  prod)
inlinestatic

Definition at line 104 of file SkBlitter_A8.cpp.

104 {
105 SkASSERT(prod <= 255*255);
106 return (prod + 128) * 257 >> 16;
107}
#define SkASSERT(cond)
Definition: SkAssert.h:116

◆ find_a8_rowproc_pair()

static const A8_RowBlitBWPair * find_a8_rowproc_pair ( SkBlendMode  bm)
static

Definition at line 159 of file SkBlitter_A8.cpp.

159 {
160 for (auto& pair : gA8_RowBlitPairs) {
161 if (pair.mode == bm) {
162 return &pair;
163 }
164 }
165 return nullptr;
166}
constexpr A8_RowBlitBWPair gA8_RowBlitPairs[]

◆ SkA8Blitter_Choose()

SkBlitter * SkA8Blitter_Choose ( const SkPixmap dst,
const SkMatrix ctm,
const SkPaint paint,
SkArenaAlloc alloc,
bool  drawCoverage,
sk_sp< SkShader clipShader,
const SkSurfaceProps  
)

Definition at line 286 of file SkBlitter_A8.cpp.

292 {
293 if (dst.colorType() != SkColorType::kAlpha_8_SkColorType) {
294 return nullptr;
295 }
296 if (paint.getShader() || paint.getColorFilter()) {
297 return nullptr;
298 }
299 if (clipShader) {
300 return nullptr; // would not be hard to support ...?
301 }
302
303 if (drawCoverage) {
304 return alloc->make<SkA8_Coverage_Blitter>(dst, paint);
305 } else {
306 // we only support certain blendmodes...
307 auto mode = paint.asBlendMode();
308 if (mode && find_a8_rowproc_pair(*mode)) {
309 return alloc->make<SkA8_Blitter>(dst, paint);
310 }
311 }
312 return nullptr;
313}
static const A8_RowBlitBWPair * find_a8_rowproc_pair(SkBlendMode bm)
@ kAlpha_8_SkColorType
pixel with alpha in 8-bit byte
Definition: SkColorType.h:21
auto make(Ctor &&ctor) -> decltype(ctor(nullptr))
Definition: SkArenaAlloc.h:120
const Paint & paint
Definition: color_source.cc:38
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
Definition: switches.h:228

◆ src_p()

static uint8_t src_p ( uint8_t  src,
uint8_t  dst 
)
static

Definition at line 116 of file SkBlitter_A8.cpp.

116{ return src; }

◆ srcover_p()

static uint8_t srcover_p ( uint8_t  src,
uint8_t  dst 
)
static

Definition at line 115 of file SkBlitter_A8.cpp.

115{ return src + div255((255 - src) * dst); }

◆ u8_lerp()

static unsigned u8_lerp ( uint8_t  a,
uint8_t  b,
uint8_t  t 
)
inlinestatic

Definition at line 109 of file SkBlitter_A8.cpp.

109 {
110 return div255((255 - t) * a + t * b);
111}
static bool b
struct MyStruct a[10]

Variable Documentation

◆ gA8_RowBlitPairs

constexpr A8_RowBlitBWPair gA8_RowBlitPairs[]
constexpr
Initial value:
= {
}
@ kSrcOver
r = s + (1-sa)*d
static uint8_t srcover_p(uint8_t src, uint8_t dst)
#define WRAP_BLIT(proc, canFoldAA)
static uint8_t src_p(uint8_t src, uint8_t dst)

Definition at line 153 of file SkBlitter_A8.cpp.