Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
SkA8_Blitter Class Reference
Inheritance diagram for SkA8_Blitter:
SkBlitter

Public Member Functions

 SkA8_Blitter (const SkPixmap &device, const SkPaint &paint)
 
void blitH (int x, int y, int width) override
 Blit a horizontal run of one or more pixels. More...
 
void blitAntiH (int x, int y, const SkAlpha antialias[], const int16_t runs[]) override
 
void blitV (int x, int y, int height, SkAlpha alpha) override
 Blit a vertical run of pixels with a constant alpha value. More...
 
void blitRect (int x, int y, int width, int height) override
 Blit a solid rectangle one or more pixels wide. More...
 
void blitMask (const SkMask &, const SkIRect &) override
 
- Public Member Functions inherited from SkBlitter
virtual ~SkBlitter ()
 
virtual void blitH (int x, int y, int width)=0
 Blit a horizontal run of one or more pixels. More...
 
virtual void blitAntiH (int x, int y, const SkAlpha antialias[], const int16_t runs[])=0
 
virtual void blitV (int x, int y, int height, SkAlpha alpha)
 Blit a vertical run of pixels with a constant alpha value. More...
 
virtual void blitRect (int x, int y, int width, int height)
 Blit a solid rectangle one or more pixels wide. More...
 
virtual void blitAntiRect (int x, int y, int width, int height, SkAlpha leftAlpha, SkAlpha rightAlpha)
 
void blitFatAntiRect (const SkRect &rect)
 
virtual void blitMask (const SkMask &, const SkIRect &clip)
 
virtual void blitAntiH2 (int x, int y, U8CPU a0, U8CPU a1)
 
virtual void blitAntiV2 (int x, int y, U8CPU a0, U8CPU a1)
 
virtual bool isNullBlitter () const
 
virtual int requestRowsPreserved () const
 
virtual void * allocBlitMemory (size_t sz)
 
void blitRectRegion (const SkIRect &rect, const SkRegion &clip)
 
void blitRegion (const SkRegion &clip)
 

Additional Inherited Members

- Static Public Member Functions inherited from SkBlitter
static bool UseLegacyBlitter (const SkPixmap &, const SkPaint &, const SkMatrix &)
 
static SkBlitterChoose (const SkPixmap &dst, const SkMatrix &ctm, const SkPaint &paint, SkArenaAlloc *, bool drawCoverage, sk_sp< SkShader > clipShader, const SkSurfaceProps &props)
 
static SkBlitterChooseSprite (const SkPixmap &dst, const SkPaint &, const SkPixmap &src, int left, int top, SkArenaAlloc *, sk_sp< SkShader > clipShader)
 
- Protected Attributes inherited from SkBlitter
SkAutoMalloc fBlitMemory
 

Detailed Description

Definition at line 168 of file SkBlitter_A8.cpp.

Constructor & Destructor Documentation

◆ SkA8_Blitter()

SkA8_Blitter::SkA8_Blitter ( const SkPixmap device,
const SkPaint paint 
)

Definition at line 187 of file SkBlitter_A8.cpp.

188 : fDevice(device) {
189 SkASSERT(nullptr == paint.getShader());
190 SkASSERT(nullptr == paint.getColorFilter());
191 auto mode = paint.asBlendMode();
192 SkASSERT(mode);
193 auto pair = find_a8_rowproc_pair(*mode);
194 SkASSERT(pair);
195
196 fOneProc = pair->oneProc;
197 fBWProc = pair->bwProc;
198 fAAProc = pair->aaProc;
199 fSrc = paint.getAlpha();
200}
#define SkASSERT(cond)
Definition: SkAssert.h:116
static const A8_RowBlitBWPair * find_a8_rowproc_pair(SkBlendMode bm)
const Paint & paint
Definition: color_source.cc:38
VkDevice device
Definition: main.cc:53
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

Member Function Documentation

◆ blitAntiH()

void SkA8_Blitter::blitAntiH ( int  x,
int  y,
const SkAlpha  antialias[],
const int16_t  runs[] 
)
overridevirtual

Blit a horizontal run of antialiased pixels; runs[] is a sparse zero-terminated run-length encoding of spans of constant alpha values. The runs[] and antialias[] work together to represent long runs of pixels with the same alphas. The runs[] contains the number of pixels with the same alpha, and antialias[] contain the coverage value for that number of pixels. The runs[] (and antialias[]) are encoded in a clever way. The runs array is zero terminated, and has enough entries for each pixel plus one, in most cases some of the entries will not contain valid data. An entry in the runs array contains the number of pixels (np) that have the same alpha value. The next np value is found np entries away. For example, if runs[0] = 7, then the next valid entry will by at runs[7]. The runs array and antialias[] are coupled by index. So, if the np entry is at runs[45] = 12 then the alpha value can be found at antialias[45] = 0x88. This would mean to use an alpha value of 0x88 for the next 12 pixels starting at pixel 45.

Implements SkBlitter.

Definition at line 202 of file SkBlitter_A8.cpp.

202 {
203 uint8_t* device = fDevice.writable_addr8(x, y);
204 SkDEBUGCODE(int totalCount = 0;)
205
206 for (;;) {
207 int count = runs[0];
208 SkASSERT(count >= 0);
209 if (count == 0) {
210 return;
211 }
212
213 if (antialias[0] == 0xFF) {
214 fBWProc(device, fSrc, count);
215 } else if (antialias[0] != 0) {
216 fAAProc(device, fSrc, count, antialias[0]);
217 }
218
219 runs += count;
220 antialias += count;
221 device += count;
222
223 SkDEBUGCODE(totalCount += count;)
224 }
225 SkASSERT(fDevice.width() == totalCount);
226}
int count
Definition: FontMgrTest.cpp:50
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
int width() const
Definition: SkPixmap.h:160
uint8_t * writable_addr8(int x, int y) const
Definition: SkPixmap.h:508
double y
double x

◆ blitH()

void SkA8_Blitter::blitH ( int  x,
int  y,
int  width 
)
overridevirtual

Blit a horizontal run of one or more pixels.

Implements SkBlitter.

Definition at line 228 of file SkBlitter_A8.cpp.

228 {
229 fBWProc(fDevice.writable_addr8(x, y), fSrc, width);
230}
int32_t width

◆ blitMask()

void SkA8_Blitter::blitMask ( const SkMask mask,
const SkIRect clip 
)
overridevirtual

Blit a pattern of pixels defined by a rectangle-clipped mask; typically used for text.

Reimplemented from SkBlitter.

Definition at line 259 of file SkBlitter_A8.cpp.

259 {
260 if (SkMask::kA8_Format != mask.fFormat) {
261 this->INHERITED::blitMask(mask, clip);
262 return;
263 }
264
265 int x = clip.fLeft;
266 int y = clip.fTop;
267 int width = clip.width();
268 int height = clip.height();
269
270 uint8_t* dst = fDevice.writable_addr8(x, y);
271 const uint8_t* src = mask.getAddr8(x, y);
272 const size_t srcRB = mask.fRowBytes;
273 const size_t dstRB = fDevice.rowBytes();
274
275 while (--height >= 0) {
276 for (int i = 0; i < width; ++i) {
277 dst[i] = u8_lerp(dst[i], fOneProc(fSrc, dst[i]), src[i]);
278 }
279 dst += dstRB;
280 src += srcRB;
281 }
282}
static unsigned u8_lerp(uint8_t a, uint8_t b, uint8_t t)
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
virtual void blitMask(const SkMask &, const SkIRect &clip)
Definition: SkBlitter.cpp:201
size_t rowBytes() const
Definition: SkPixmap.h:145
dst
Definition: cp.py:12
int32_t height
const uint32_t fRowBytes
Definition: SkMask.h:43
@ kA8_Format
8bits per pixel mask (e.g. antialiasing)
Definition: SkMask.h:28
const uint8_t * getAddr8(int x, int y) const
Definition: SkMask.h:79
const Format fFormat
Definition: SkMask.h:44

◆ blitRect()

void SkA8_Blitter::blitRect ( int  x,
int  y,
int  width,
int  height 
)
overridevirtual

Blit a solid rectangle one or more pixels wide.

Reimplemented from SkBlitter.

Definition at line 249 of file SkBlitter_A8.cpp.

249 {
250 uint8_t* device = fDevice.writable_addr8(x, y);
251 const size_t dstRB = fDevice.rowBytes();
252
253 while (--height >= 0) {
254 fBWProc(device, fSrc, width);
255 device += dstRB;
256 }
257}

◆ blitV()

void SkA8_Blitter::blitV ( int  x,
int  y,
int  height,
SkAlpha  alpha 
)
overridevirtual

Blit a vertical run of pixels with a constant alpha value.

Reimplemented from SkBlitter.

Definition at line 232 of file SkBlitter_A8.cpp.

232 {
233 uint8_t* device = fDevice.writable_addr8(x, y);
234 const size_t dstRB = fDevice.rowBytes();
235
236 if (aa == 0xFF) {
237 while (--height >= 0) {
238 *device = fOneProc(fSrc, *device);
239 device += dstRB;
240 }
241 } else if (aa != 0) {
242 while (--height >= 0) {
243 fAAProc(device, fSrc, 1, aa);
244 device += dstRB;
245 }
246 }
247}

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