Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
SkARGB32_Blitter Class Reference

#include <SkCoreBlitters.h>

Inheritance diagram for SkARGB32_Blitter:
SkRasterBlitter SkBlitter SkARGB32_Opaque_Blitter SkARGB32_Black_Blitter

Public Member Functions

 SkARGB32_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.
 
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.
 
void blitRect (int x, int y, int width, int height) override
 Blit a solid rectangle one or more pixels wide.
 
void blitMask (const SkMask &, const SkIRect &) override
 
void blitAntiH2 (int x, int y, U8CPU a0, U8CPU a1) override
 
void blitAntiV2 (int x, int y, U8CPU a0, U8CPU a1) override
 
- Public Member Functions inherited from SkRasterBlitter
 SkRasterBlitter (const SkPixmap &device)
 
- Public Member Functions inherited from SkBlitter
virtual ~SkBlitter ()
 
virtual void blitAntiRect (int x, int y, int width, int height, SkAlpha leftAlpha, SkAlpha rightAlpha)
 
void blitFatAntiRect (const SkRect &rect)
 
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)
 

Protected Attributes

SkColor fColor
 
SkPMColor fPMColor
 
- Protected Attributes inherited from SkRasterBlitter
const SkPixmap fDevice
 
- Protected Attributes inherited from SkBlitter
SkAutoMalloc fBlitMemory
 

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)
 

Detailed Description

Definition at line 66 of file SkCoreBlitters.h.

Constructor & Destructor Documentation

◆ SkARGB32_Blitter()

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

Definition at line 1445 of file SkBlitter_ARGB32.cpp.

1446 : INHERITED(device) {
1447 SkColor color = paint.getColor();
1448 fColor = color;
1449
1450 fSrcA = SkColorGetA(color);
1451 unsigned scale = SkAlpha255To256(fSrcA);
1452 fSrcR = SkAlphaMul(SkColorGetR(color), scale);
1453 fSrcG = SkAlphaMul(SkColorGetG(color), scale);
1454 fSrcB = SkAlphaMul(SkColorGetB(color), scale);
1455
1456 fPMColor = SkPackARGB32(fSrcA, fSrcR, fSrcG, fSrcB);
1457}
SkColor4f color
#define SkAlphaMul(value, alpha256)
Definition SkColorPriv.h:34
static unsigned SkAlpha255To256(U8CPU alpha)
Definition SkColorPriv.h:24
static SkPMColor SkPackARGB32(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
#define SkColorGetR(color)
Definition SkColor.h:65
#define SkColorGetG(color)
Definition SkColor.h:69
uint32_t SkColor
Definition SkColor.h:37
#define SkColorGetA(color)
Definition SkColor.h:61
#define SkColorGetB(color)
Definition SkColor.h:73
const Paint & paint
VkDevice device
Definition main.cc:53
const Scalar scale

Member Function Documentation

◆ blitAntiH()

void SkARGB32_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 1471 of file SkBlitter_ARGB32.cpp.

1472 {
1473 if (fSrcA == 0) {
1474 return;
1475 }
1476
1477 uint32_t color = fPMColor;
1478 uint32_t* device = fDevice.writable_addr32(x, y);
1479 unsigned opaqueMask = fSrcA; // if fSrcA is 0xFF, then we will catch the fast opaque case
1480
1481 for (;;) {
1482 int count = runs[0];
1483 SkASSERT(count >= 0);
1484 if (count <= 0) {
1485 return;
1486 }
1487 unsigned aa = antialias[0];
1488 if (aa) {
1489 if ((opaqueMask & aa) == 255) {
1491 } else {
1492 uint32_t sc = SkAlphaMulQ(color, SkAlpha255To256(aa));
1494 }
1495 }
1496 runs += count;
1497 antialias += count;
1498 device += count;
1499 }
1500}
int count
#define SkASSERT(cond)
Definition SkAssert.h:116
static SK_ALWAYS_INLINE uint32_t SkAlphaMulQ(uint32_t c, unsigned scale)
static void Color32(SkPMColor dst[], int count, SkPMColor color)
uint32_t * writable_addr32(int x, int y) const
Definition SkPixmap.h:537
const SkPixmap fDevice
double y
double x
void(* memset32)(uint32_t[], uint32_t, int)

◆ blitAntiH2()

void SkARGB32_Blitter::blitAntiH2 ( int  x,
int  y,
U8CPU  a0,
U8CPU  a1 
)
overridevirtual

Reimplemented from SkBlitter.

Reimplemented in SkARGB32_Opaque_Blitter.

Definition at line 1502 of file SkBlitter_ARGB32.cpp.

1502 {
1503 uint32_t* device = fDevice.writable_addr32(x, y);
1504 SkDEBUGCODE((void)fDevice.writable_addr32(x + 1, y);)
1505
1506 device[0] = SkBlendARGB32(fPMColor, device[0], a0);
1507 device[1] = SkBlendARGB32(fPMColor, device[1], a1);
1508}
static SkPMColor SkBlendARGB32(SkPMColor src, SkPMColor dst, U8CPU aa)
#define SkDEBUGCODE(...)
Definition SkDebug.h:23

◆ blitAntiV2()

void SkARGB32_Blitter::blitAntiV2 ( int  x,
int  y,
U8CPU  a0,
U8CPU  a1 
)
overridevirtual

Reimplemented from SkBlitter.

Reimplemented in SkARGB32_Opaque_Blitter.

Definition at line 1510 of file SkBlitter_ARGB32.cpp.

1510 {
1511 uint32_t* device = fDevice.writable_addr32(x, y);
1512 SkDEBUGCODE((void)fDevice.writable_addr32(x, y + 1);)
1513
1514 device[0] = SkBlendARGB32(fPMColor, device[0], a0);
1515 device = (uint32_t*)((char*)device + fDevice.rowBytes());
1516 device[0] = SkBlendARGB32(fPMColor, device[0], a1);
1517}
size_t rowBytes() const
Definition SkPixmap.h:145

◆ blitH()

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

Blit a horizontal run of one or more pixels.

Implements SkBlitter.

Definition at line 1464 of file SkBlitter_ARGB32.cpp.

1464 {
1465 SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width());
1466
1467 uint32_t* device = fDevice.writable_addr32(x, y);
1469}
int width() const
Definition SkPixmap.h:160
int32_t width

◆ blitMask()

void SkARGB32_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.

Reimplemented in SkARGB32_Opaque_Blitter.

Definition at line 1559 of file SkBlitter_ARGB32.cpp.

1559 {
1561 SkASSERT(fSrcA != 0xFF);
1562
1563 if (fSrcA == 0) {
1564 return;
1565 }
1566
1567 if (blit_color(fDevice, mask, clip, fColor)) {
1568 return;
1569 }
1570
1571 switch (mask.fFormat) {
1572 case SkMask::kBW_Format:
1573 SkARGB32_BlendBW(fDevice, mask, clip, fPMColor, SkAlpha255To256(255 - fSrcA));
1574 break;
1577 break;
1578 default:
1579 SK_ABORT("Mask format not handled.");
1580 }
1581}
#define SK_ABORT(message,...)
Definition SkAssert.h:70
static void SkARGB32_Blit32(const SkPixmap &device, const SkMask &mask, const SkIRect &clip, SkPMColor srcColor)
static bool blit_color(const SkPixmap &device, const SkMask &mask, const SkIRect &clip, SkColor color)
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition SkPath.cpp:3824
bool contains(int32_t x, int32_t y) const
Definition SkRect.h:463
@ kARGB32_Format
SkPMColor.
Definition SkMask.h:30
@ kBW_Format
1bit per pixel mask (e.g. monochrome)
Definition SkMask.h:27
const SkIRect fBounds
Definition SkMask.h:42
const Format fFormat
Definition SkMask.h:44

◆ blitRect()

void SkARGB32_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 1642 of file SkBlitter_ARGB32.cpp.

1642 {
1643 SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width() && y + height <= fDevice.height());
1644
1645 if (fSrcA == 0) {
1646 return;
1647 }
1648
1649 uint32_t* device = fDevice.writable_addr32(x, y);
1650 uint32_t color = fPMColor;
1651 size_t rowBytes = fDevice.rowBytes();
1652
1653 if (SkGetPackedA32(fPMColor) == 0xFF) {
1655 } else {
1656 while (height --> 0) {
1658 device = (uint32_t*)((char*)device + rowBytes);
1659 }
1660 }
1661}
#define SkGetPackedA32(packed)
Definition SkColorPriv.h:92
int height() const
Definition SkPixmap.h:166
void(* rect_memset32)(uint32_t[], uint32_t, int, size_t, int)
int32_t height

◆ blitV()

void SkARGB32_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 1622 of file SkBlitter_ARGB32.cpp.

1622 {
1623 if (alpha == 0 || fSrcA == 0) {
1624 return;
1625 }
1626
1627 uint32_t* device = fDevice.writable_addr32(x, y);
1628 uint32_t color = fPMColor;
1629
1630 if (alpha != 255) {
1632 }
1633
1634 unsigned dst_scale = SkAlpha255To256(255 - SkGetPackedA32(color));
1635 size_t rowBytes = fDevice.rowBytes();
1636 while (--height >= 0) {
1637 device[0] = color + SkAlphaMulQ(device[0], dst_scale);
1638 device = (uint32_t*)((char*)device + rowBytes);
1639 }
1640}

Member Data Documentation

◆ fColor

SkColor SkARGB32_Blitter::fColor
protected

Definition at line 78 of file SkCoreBlitters.h.

◆ fPMColor

SkPMColor SkARGB32_Blitter::fPMColor
protected

Definition at line 79 of file SkCoreBlitters.h.


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