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

#include <SkCoreBlitters.h>

Inheritance diagram for SkARGB32_Shader_Blitter:
SkShaderBlitter SkRasterBlitter SkBlitter

Public Member Functions

 SkARGB32_Shader_Blitter (const SkPixmap &device, const SkPaint &paint, SkShaderBase::Context *shaderContext)
 
 ~SkARGB32_Shader_Blitter () override
 
void blitH (int x, int y, int width) override
 Blit a horizontal run of one or more pixels. More...
 
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 blitAntiH (int x, int y, const SkAlpha[], const int16_t[]) override
 
void blitMask (const SkMask &, const SkIRect &) override
 
- Public Member Functions inherited from SkShaderBlitter
 SkShaderBlitter (const SkPixmap &device, const SkPaint &paint, SkShaderBase::Context *shaderContext)
 
 ~SkShaderBlitter () override
 
- Public Member Functions inherited from SkRasterBlitter
 SkRasterBlitter (const SkPixmap &device)
 
- 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 SkShaderBlitter
sk_sp< SkShaderfShader
 
SkShaderBase::ContextfShaderContext
 
- Protected Attributes inherited from SkRasterBlitter
const SkPixmap fDevice
 
- Protected Attributes inherited from SkBlitter
SkAutoMalloc fBlitMemory
 

Detailed Description

Definition at line 114 of file SkCoreBlitters.h.

Constructor & Destructor Documentation

◆ SkARGB32_Shader_Blitter()

SkARGB32_Shader_Blitter::SkARGB32_Shader_Blitter ( const SkPixmap device,
const SkPaint paint,
SkShaderBase::Context shaderContext 
)

Definition at line 1719 of file SkBlitter_ARGB32.cpp.

1721 : INHERITED(device, paint, shaderContext)
1722{
1723 fBuffer = (SkPMColor*)sk_malloc_throw(device.width() * (sizeof(SkPMColor)));
1724
1725 SkASSERT(paint.isSrcOver());
1726
1727 int flags = 0;
1728 if (!(shaderContext->getFlags() & SkShaderBase::kOpaqueAlpha_Flag)) {
1730 }
1731 // we call this on the output from the shader
1732 fProc32 = SkBlitRow::Factory32(flags);
1733 // we call this on the output from the shader + alpha from the aa buffer
1735
1736 fShadeDirectlyIntoDevice =
1738}
#define SkASSERT(cond)
Definition: SkAssert.h:116
uint32_t SkPMColor
Definition: SkColor.h:205
static void * sk_malloc_throw(size_t size)
Definition: SkMalloc.h:67
static constexpr bool SkToBool(const T &x)
Definition: SkTo.h:35
static Proc32 Factory32(unsigned flags32)
@ kSrcPixelAlpha_Flag32
Definition: SkBlitRow.h:18
@ kGlobalAlpha_Flag32
Definition: SkBlitRow.h:17
virtual uint32_t getFlags() const
Definition: SkShaderBase.h:310
@ kOpaqueAlpha_Flag
set if all of the colors will be opaque
Definition: SkShaderBase.h:262
const Paint & paint
Definition: color_source.cc:38
VkDevice device
Definition: main.cc:53
FlutterSemanticsFlag flags

◆ ~SkARGB32_Shader_Blitter()

SkARGB32_Shader_Blitter::~SkARGB32_Shader_Blitter ( )
override

Definition at line 1740 of file SkBlitter_ARGB32.cpp.

1740 {
1741 sk_free(fBuffer);
1742}
SK_API void sk_free(void *)

Member Function Documentation

◆ blitAntiH()

void SkARGB32_Shader_Blitter::blitAntiH ( int  x,
int  y,
const  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 1784 of file SkBlitter_ARGB32.cpp.

1785 {
1786 SkPMColor* span = fBuffer;
1787 uint32_t* device = fDevice.writable_addr32(x, y);
1788 auto* shaderContext = fShaderContext;
1789
1790 if (fShadeDirectlyIntoDevice || (shaderContext->getFlags() & SkShaderBase::kOpaqueAlpha_Flag)) {
1791 for (;;) {
1792 int count = *runs;
1793 if (count <= 0) {
1794 break;
1795 }
1796 int aa = *antialias;
1797 if (aa) {
1798 if (aa == 255) {
1799 // cool, have the shader draw right into the device
1800 shaderContext->shadeSpan(x, y, device, count);
1801 } else {
1802 shaderContext->shadeSpan(x, y, span, count);
1803 fProc32Blend(device, span, count, aa);
1804 }
1805 }
1806 device += count;
1807 runs += count;
1808 antialias += count;
1809 x += count;
1810 }
1811 } else {
1812 for (;;) {
1813 int count = *runs;
1814 if (count <= 0) {
1815 break;
1816 }
1817 int aa = *antialias;
1818 if (aa) {
1819 shaderContext->shadeSpan(x, y, span, count);
1820 if (aa == 255) {
1821 fProc32(device, span, count, 255);
1822 } else {
1823 fProc32Blend(device, span, count, aa);
1824 }
1825 }
1826 device += count;
1827 runs += count;
1828 antialias += count;
1829 x += count;
1830 }
1831 }
1832}
int count
Definition: FontMgrTest.cpp:50
uint32_t * writable_addr32(int x, int y) const
Definition: SkPixmap.h:537
const SkPixmap fDevice
SkShaderBase::Context * fShaderContext
double y
double x

◆ blitH()

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

Blit a horizontal run of one or more pixels.

Implements SkBlitter.

Definition at line 1744 of file SkBlitter_ARGB32.cpp.

1744 {
1745 SkASSERT(x >= 0 && y >= 0 && x + width <= fDevice.width());
1746
1747 uint32_t* device = fDevice.writable_addr32(x, y);
1748
1749 if (fShadeDirectlyIntoDevice) {
1751 } else {
1752 SkPMColor* span = fBuffer;
1753 fShaderContext->shadeSpan(x, y, span, width);
1754 fProc32(device, span, width, 255);
1755 }
1756}
int width() const
Definition: SkPixmap.h:160
virtual void shadeSpan(int x, int y, SkPMColor[], int count)=0
int32_t width

◆ blitMask()

void SkARGB32_Shader_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 1957 of file SkBlitter_ARGB32.cpp.

1957 {
1959
1960 void (*blend_row)(SkPMColor*, const void* mask, const SkPMColor*, int) = nullptr;
1961
1963
1964 if (mask.fFormat == SkMask::kA8_Format && opaque) {
1965 blend_row = blend_row_A8_opaque;
1966 } else if (mask.fFormat == SkMask::kA8_Format) {
1967 blend_row = blend_row_A8;
1968 } else if (mask.fFormat == SkMask::kLCD16_Format && opaque) {
1969 blend_row = blend_row_LCD16_opaque;
1970 } else if (mask.fFormat == SkMask::kLCD16_Format) {
1971 blend_row = blend_row_lcd16;
1972 } else {
1973 this->INHERITED::blitMask(mask, clip);
1974 return;
1975 }
1976
1977 const int x = clip.fLeft;
1978 const int width = clip.width();
1979 int y = clip.fTop;
1980 int height = clip.height();
1981
1982 char* dstRow = (char*)fDevice.writable_addr32(x, y);
1983 const size_t dstRB = fDevice.rowBytes();
1984 const uint8_t* maskRow = (const uint8_t*)mask.getAddr(x, y);
1985 const size_t maskRB = mask.fRowBytes;
1986
1987 SkPMColor* span = fBuffer;
1988 SkASSERT(blend_row);
1989 do {
1990 fShaderContext->shadeSpan(x, y, span, width);
1991 blend_row(reinterpret_cast<SkPMColor*>(dstRow), maskRow, span, width);
1992 dstRow += dstRB;
1993 maskRow += maskRB;
1994 y += 1;
1995 } while (--height > 0);
1996}
static void blend_row_A8_opaque(SkPMColor *dst, const void *mask, const SkPMColor *src, int n)
static void blend_row_lcd16(SkPMColor *dst, const void *vmask, const SkPMColor *src, int n)
static void blend_row_LCD16_opaque(SkPMColor *dst, const void *vmask, const SkPMColor *src, int n)
static void blend_row_A8(SkPMColor *dst, const void *mask, const SkPMColor *src, int n)
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
int32_t height
bool contains(int32_t x, int32_t y) const
Definition: SkRect.h:463
@ kA8_Format
8bits per pixel mask (e.g. antialiasing)
Definition: SkMask.h:28
@ kLCD16_Format
565 alpha for r/g/b
Definition: SkMask.h:31
const SkIRect fBounds
Definition: SkMask.h:42

◆ blitRect()

void SkARGB32_Shader_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 1758 of file SkBlitter_ARGB32.cpp.

1758 {
1759 SkASSERT(x >= 0 && y >= 0 &&
1760 x + width <= fDevice.width() && y + height <= fDevice.height());
1761
1762 uint32_t* device = fDevice.writable_addr32(x, y);
1763 size_t deviceRB = fDevice.rowBytes();
1764 auto* shaderContext = fShaderContext;
1765 SkPMColor* span = fBuffer;
1766
1767 if (fShadeDirectlyIntoDevice) {
1768 do {
1769 shaderContext->shadeSpan(x, y, device, width);
1770 y += 1;
1771 device = (uint32_t*)((char*)device + deviceRB);
1772 } while (--height > 0);
1773 } else {
1774 SkBlitRow::Proc32 proc = fProc32;
1775 do {
1776 shaderContext->shadeSpan(x, y, span, width);
1777 proc(device, span, width, 255);
1778 y += 1;
1779 device = (uint32_t*)((char*)device + deviceRB);
1780 } while (--height > 0);
1781 }
1782}
void(* Proc32)(uint32_t dst[], const SkPMColor src[], int count, U8CPU alpha)
Definition: SkBlitRow.h:27
int height() const
Definition: SkPixmap.h:166

◆ blitV()

void SkARGB32_Shader_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 1998 of file SkBlitter_ARGB32.cpp.

1998 {
1999 SkASSERT(x >= 0 && y >= 0 && y + height <= fDevice.height());
2000
2001 uint32_t* device = fDevice.writable_addr32(x, y);
2002 size_t deviceRB = fDevice.rowBytes();
2003
2004 if (fShadeDirectlyIntoDevice) {
2005 if (255 == alpha) {
2006 do {
2008 y += 1;
2009 device = (uint32_t*)((char*)device + deviceRB);
2010 } while (--height > 0);
2011 } else {
2012 do {
2013 SkPMColor c;
2014 fShaderContext->shadeSpan(x, y, &c, 1);
2015 *device = SkFourByteInterp(c, *device, alpha);
2016 y += 1;
2017 device = (uint32_t*)((char*)device + deviceRB);
2018 } while (--height > 0);
2019 }
2020 } else {
2021 SkPMColor* span = fBuffer;
2022 SkBlitRow::Proc32 proc = (255 == alpha) ? fProc32 : fProc32Blend;
2023 do {
2024 fShaderContext->shadeSpan(x, y, span, 1);
2025 proc(device, span, 1, alpha);
2026 y += 1;
2027 device = (uint32_t*)((char*)device + deviceRB);
2028 } while (--height > 0);
2029 }
2030}
static SkPMColor SkFourByteInterp(SkPMColor src, SkPMColor dst, U8CPU srcWeight)
Definition: SkColorData.h:177

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