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

#include <SkAAClip.h>

Inheritance diagram for SkAAClipBlitter:
SkBlitter

Public Member Functions

 SkAAClipBlitter ()
 
 ~SkAAClipBlitter () override
 
void init (SkBlitter *blitter, const SkAAClip *aaclip)
 
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[], 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 &clip) 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 92 of file SkAAClip.h.

Constructor & Destructor Documentation

◆ SkAAClipBlitter()

SkAAClipBlitter::SkAAClipBlitter ( )
inline

Definition at line 94 of file SkAAClip.h.

94: fScanlineScratch(nullptr) {}

◆ ~SkAAClipBlitter()

SkAAClipBlitter::~SkAAClipBlitter ( )
override

Definition at line 1649 of file SkAAClip.cpp.

1649 {
1650 sk_free(fScanlineScratch);
1651}
SK_API void sk_free(void *)

Member Function Documentation

◆ blitAntiH()

void SkAAClipBlitter::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 1735 of file SkAAClip.cpp.

1736 {
1737
1738 const uint8_t* row = fAAClip->findRow(y);
1739 int initialCount;
1740 row = fAAClip->findX(row, x, &initialCount);
1741
1742 this->ensureRunsAndAA();
1743
1744 merge(row, initialCount, aa, runs, fAA, fRuns, fAAClipBounds.width());
1745 fBlitter->blitAntiH(x, y, fAA, fRuns);
1746}
static void merge(const uint8_t *SK_RESTRICT row, int rowN, const SkAlpha *SK_RESTRICT srcAA, const int16_t *SK_RESTRICT srcRuns, SkAlpha *SK_RESTRICT dstAA, int16_t *SK_RESTRICT dstRuns, int width)
Definition: SkAAClip.cpp:1691
virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[])=0
double y
double x
constexpr int32_t width() const
Definition: SkRect.h:158

◆ blitH()

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

Blit a horizontal run of one or more pixels.

Implements SkBlitter.

Definition at line 1665 of file SkAAClip.cpp.

1665 {
1666 SkASSERT(width > 0);
1667 SkASSERT(fAAClipBounds.contains(x, y));
1668 SkASSERT(fAAClipBounds.contains(x + width - 1, y));
1669
1670 const uint8_t* row = fAAClip->findRow(y);
1671 int initialCount;
1672 row = fAAClip->findX(row, x, &initialCount);
1673
1674 if (initialCount >= width) {
1675 SkAlpha alpha = row[1];
1676 if (0 == alpha) {
1677 return;
1678 }
1679 if (0xFF == alpha) {
1680 fBlitter->blitH(x, y, width);
1681 return;
1682 }
1683 }
1684
1685 this->ensureRunsAndAA();
1686 expandToRuns(row, initialCount, width, fRuns, fAA);
1687
1688 fBlitter->blitAntiH(x, y, fAA, fRuns);
1689}
static void expandToRuns(const uint8_t *SK_RESTRICT data, int initialCount, int width, int16_t *SK_RESTRICT runs, SkAlpha *SK_RESTRICT aa)
Definition: SkAAClip.cpp:1622
#define SkASSERT(cond)
Definition: SkAssert.h:116
uint8_t SkAlpha
Definition: SkColor.h:26
virtual void blitH(int x, int y, int width)=0
Blit a horizontal run of one or more pixels.
int32_t width
bool contains(int32_t x, int32_t y) const
Definition: SkRect.h:463

◆ blitMask()

void SkAAClipBlitter::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 1909 of file SkAAClip.cpp.

1909 {
1910 SkASSERT(fAAClip->getBounds().contains(clip));
1911
1912 if (fAAClip->quickContains(clip)) {
1913 fBlitter->blitMask(origMask, clip);
1914 return;
1915 }
1916
1917 const SkMask* mask = &origMask;
1918
1919 // if we're BW, we need to upscale to A8 (ugh)
1920 SkMaskBuilder grayMask;
1921 if (SkMask::kBW_Format == origMask.fFormat) {
1922 grayMask.format() = SkMask::kA8_Format;
1923 grayMask.bounds() = origMask.fBounds;
1924 grayMask.rowBytes() = origMask.fBounds.width();
1925 size_t size = grayMask.computeImageSize();
1926 grayMask.image() = reinterpret_cast<uint8_t*>(
1927 fGrayMaskScratch.reset(size, SkAutoMalloc::kReuse_OnShrink));
1928
1929 upscaleBW2A8(&grayMask, origMask);
1930 mask = &grayMask;
1931 }
1932
1933 this->ensureRunsAndAA();
1934
1935 // HACK -- we are devolving 3D into A8, need to copy the rest of the 3D
1936 // data into a temp block to support it better (ugh)
1937
1938 const void* src = mask->getAddr(clip.fLeft, clip.fTop);
1939 const size_t srcRB = mask->fRowBytes;
1940 const int width = clip.width();
1941 MergeAAProc mergeProc = find_merge_aa_proc(mask->fFormat);
1942
1943 SkMaskBuilder rowMask;
1944 rowMask.format() = SkMask::k3D_Format == mask->fFormat ? SkMask::kA8_Format : mask->fFormat;
1945 rowMask.bounds().fLeft = clip.fLeft;
1946 rowMask.bounds().fRight = clip.fRight;
1947 rowMask.rowBytes() = mask->fRowBytes; // doesn't matter, since our height==1
1948 rowMask.image() = (uint8_t*)fScanlineScratch;
1949
1950 int y = clip.fTop;
1951 const int stopY = y + clip.height();
1952
1953 do {
1954 int localStopY SK_INIT_TO_AVOID_WARNING;
1955 const uint8_t* row = fAAClip->findRow(y, &localStopY);
1956 // findRow returns last Y, not stop, so we add 1
1957 localStopY = std::min(localStopY + 1, stopY);
1958
1959 int initialCount;
1960 row = fAAClip->findX(row, clip.fLeft, &initialCount);
1961 do {
1962 mergeProc(src, width, row, initialCount, rowMask.image());
1963 rowMask.bounds().fTop = y;
1964 rowMask.bounds().fBottom = y + 1;
1965 fBlitter->blitMask(rowMask, rowMask.fBounds);
1966 src = (const void*)((const char*)src + srcRB);
1967 } while (++y < localStopY);
1968 } while (y < stopY);
1969}
static MergeAAProc find_merge_aa_proc(SkMask::Format format)
Definition: SkAAClip.cpp:1845
static void upscaleBW2A8(SkMask *dstMask, const SkMask &srcMask)
Definition: SkAAClip.cpp:1868
void(* MergeAAProc)(const void *src, int width, const uint8_t *row, int initialRowCount, void *dst)
Definition: SkAAClip.cpp:1788
#define SK_INIT_TO_AVOID_WARNING
Definition: SkMacros.h:58
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
const SkIRect & getBounds() const
Definition: SkAAClip.h:34
bool quickContains(const SkIRect &r) const
Definition: SkAAClip.h:57
void * reset(size_t size, SkAutoMalloc::OnShrink shrink=SkAutoMalloc::kAlloc_OnShrink, bool *didChangeAlloc=nullptr)
Definition: SkAutoMalloc.h:133
virtual void blitMask(const SkMask &, const SkIRect &clip)
Definition: SkBlitter.cpp:201
static float min(float r, float g, float b)
Definition: hsl.cpp:48
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 keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259
int32_t fBottom
larger y-axis bounds
Definition: SkRect.h:36
int32_t fTop
smaller y-axis bounds
Definition: SkRect.h:34
int32_t fLeft
smaller x-axis bounds
Definition: SkRect.h:33
int32_t fRight
larger x-axis bounds
Definition: SkRect.h:35
Format & format()
Definition: SkMask.h:239
uint32_t & rowBytes()
Definition: SkMask.h:238
SkIRect & bounds()
Definition: SkMask.h:237
uint8_t *& image()
Definition: SkMask.h:236
Definition: SkMask.h:25
const uint32_t fRowBytes
Definition: SkMask.h:43
@ k3D_Format
3 8bit per pixl planes: alpha, mul, add
Definition: SkMask.h:29
@ kA8_Format
8bits per pixel mask (e.g. antialiasing)
Definition: SkMask.h:28
@ kBW_Format
1bit per pixel mask (e.g. monochrome)
Definition: SkMask.h:27
const void * getAddr(int x, int y) const
Definition: SkMask.cpp:112
const SkIRect fBounds
Definition: SkMask.h:42
size_t computeImageSize() const
Definition: SkMask.cpp:30
const Format fFormat
Definition: SkMask.h:44

◆ blitRect()

void SkAAClipBlitter::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 1776 of file SkAAClip.cpp.

1776 {
1777 if (fAAClip->quickContains(x, y, x + width, y + height)) {
1778 fBlitter->blitRect(x, y, width, height);
1779 return;
1780 }
1781
1782 while (--height >= 0) {
1783 this->blitH(x, y, width);
1784 y += 1;
1785 }
1786}
void blitH(int x, int y, int width) override
Blit a horizontal run of one or more pixels.
Definition: SkAAClip.cpp:1665
virtual void blitRect(int x, int y, int width, int height)
Blit a solid rectangle one or more pixels wide.
Definition: SkBlitter.cpp:133
int32_t height

◆ blitV()

void SkAAClipBlitter::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 1748 of file SkAAClip.cpp.

1748 {
1749 if (fAAClip->quickContains(x, y, x + 1, y + height)) {
1750 fBlitter->blitV(x, y, height, alpha);
1751 return;
1752 }
1753
1754 for (;;) {
1755 int lastY SK_INIT_TO_AVOID_WARNING;
1756 const uint8_t* row = fAAClip->findRow(y, &lastY);
1757 int dy = lastY - y + 1;
1758 if (dy > height) {
1759 dy = height;
1760 }
1761 height -= dy;
1762
1763 row = fAAClip->findX(row, x);
1764 SkAlpha newAlpha = SkMulDiv255Round(alpha, row[1]);
1765 if (newAlpha) {
1766 fBlitter->blitV(x, y, dy, newAlpha);
1767 }
1768 SkASSERT(height >= 0);
1769 if (height <= 0) {
1770 break;
1771 }
1772 y = lastY + 1;
1773 }
1774}
static U8CPU SkMulDiv255Round(U16CPU a, U16CPU b)
Definition: SkMath.h:73
virtual void blitV(int x, int y, int height, SkAlpha alpha)
Blit a vertical run of pixels with a constant alpha value.
Definition: SkBlitter.cpp:119

◆ init()

void SkAAClipBlitter::init ( SkBlitter blitter,
const SkAAClip aaclip 
)
inline

Definition at line 97 of file SkAAClip.h.

97 {
98 SkASSERT(aaclip && !aaclip->isEmpty());
99 fBlitter = blitter;
100 fAAClip = aaclip;
101 fAAClipBounds = aaclip->getBounds();
102 }
bool isEmpty() const
Definition: SkAAClip.h:33

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