Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
SkAAClip::Builder::Blitter Class Referencefinal
Inheritance diagram for SkAAClip::Builder::Blitter:
SkBlitter

Public Member Functions

 Blitter (Builder *builder)
 
void finish ()
 
void blitV (int x, int y, int height, SkAlpha alpha) override
 
void blitRect (int x, int y, int width, int height) override
 Blit a solid rectangle one or more pixels wide.
 
void blitAntiRect (int x, int y, int width, int height, SkAlpha leftAlpha, SkAlpha rightAlpha) override
 
void blitMask (const SkMask &, const SkIRect &clip) override
 
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 alpha[], const int16_t runs[]) override
 
- Public Member Functions inherited from SkBlitter
virtual ~SkBlitter ()
 
void blitFatAntiRect (const SkRect &rect)
 
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 685 of file SkAAClip.cpp.

Constructor & Destructor Documentation

◆ Blitter()

SkAAClip::Builder::Blitter::Blitter ( Builder builder)
inline

Definition at line 706 of file SkAAClip.cpp.

706 {
707 fBuilder = builder;
708 fLeft = builder->fBounds.fLeft;
709 fRight = builder->fBounds.fRight;
710 fMinY = SK_MaxS32;
711 fLastY = -SK_MaxS32; // sentinel
712 }
static constexpr int32_t SK_MaxS32
Definition SkMath.h:21

Member Function Documentation

◆ blitAntiH()

void SkAAClip::Builder::Blitter::blitAntiH ( int  x,
int  y,
const SkAlpha  antialias[],
const int16_t  runs[] 
)
inlineoverridevirtual

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 765 of file SkAAClip.cpp.

765 {
766 this->recordMinY(y);
767 this->checkForYGap(y);
768 for (;;) {
769 int count = *runs;
770 if (count <= 0) {
771 return;
772 }
773
774 // The supersampler's buffer can be the width of the device, so
775 // we may have to trim the run to our bounds. Previously, we assert that
776 // the extra spans are always alpha==0.
777 // However, the analytic AA is too sensitive to precision errors
778 // so it may have extra spans with very tiny alpha because after several
779 // arithmatic operations, the edge may bleed the path boundary a little bit.
780 // Therefore, instead of always asserting alpha==0, we assert alpha < 0x10.
781 int localX = x;
782 int localCount = count;
783 if (x < fLeft) {
784 SkASSERT(0x10 > *alpha);
785 int gap = fLeft - x;
786 SkASSERT(gap <= count);
787 localX += gap;
788 localCount -= gap;
789 }
790 int right = x + count;
791 if (right > fRight) {
792 SkASSERT(0x10 > *alpha);
793 localCount -= right - fRight;
794 SkASSERT(localCount >= 0);
795 }
796
797 if (localCount) {
798 fBuilder->addRun(localX, y, *alpha, localCount);
799 }
800 // Next run
801 runs += count;
802 alpha += count;
803 x += count;
804 }
805 }
int count
#define SkASSERT(cond)
Definition SkAssert.h:116
static bool right(const SkPoint &p0, const SkPoint &p1)
double y
double x

◆ blitAntiRect()

void SkAAClip::Builder::Blitter::blitAntiRect ( int  x,
int  y,
int  width,
int  height,
SkAlpha  leftAlpha,
SkAlpha  rightAlpha 
)
inlineoverridevirtual

Blit a rectangle with one alpha-blended column on the left, width (zero or more) opaque pixels, and one alpha-blended column on the right. The result will always be at least two pixels wide.

Default implementation doesn't check for easy optimizations such as alpha == 255; also uses blitV(), which some subclasses may not support.

Reimplemented from SkBlitter.

Definition at line 748 of file SkAAClip.cpp.

749 {
750 this->recordMinY(y);
751 this->checkForYGap(y);
752 fBuilder->addAntiRectRun(x, y, width, height, leftAlpha, rightAlpha);
753 fLastY = y + height - 1;
754 }
int32_t height
int32_t width

◆ blitH()

void SkAAClip::Builder::Blitter::blitH ( int  x,
int  y,
int  width 
)
inlineoverridevirtual

Blit a horizontal run of one or more pixels.

Implements SkBlitter.

Definition at line 759 of file SkAAClip.cpp.

759 {
760 this->recordMinY(y);
761 this->checkForYGap(y);
762 fBuilder->addRun(x, y, 0xFF, width);
763 }

◆ blitMask()

void SkAAClip::Builder::Blitter::blitMask ( const SkMask mask,
const SkIRect clip 
)
inlineoverridevirtual

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

Reimplemented from SkBlitter.

Definition at line 756 of file SkAAClip.cpp.

757 { unexpected(); }

◆ blitRect()

void SkAAClip::Builder::Blitter::blitRect ( int  x,
int  y,
int  width,
int  height 
)
inlineoverridevirtual

Blit a solid rectangle one or more pixels wide.

Reimplemented from SkBlitter.

Definition at line 741 of file SkAAClip.cpp.

741 {
742 this->recordMinY(y);
743 this->checkForYGap(y);
744 fBuilder->addRectRun(x, y, width, height);
745 fLastY = y + height - 1;
746 }

◆ blitV()

void SkAAClip::Builder::Blitter::blitV ( int  x,
int  y,
int  height,
SkAlpha  alpha 
)
inlineoverridevirtual

Must evaluate clips in scan-line order, so don't want to allow blitV(), but an AAClip can be clipped down to a single pixel wide, so we must support it (given AntiRect semantics: minimum width is 2). Instead we'll rely on the runtime asserts to guarantee Y monotonicity; any failure cases that misses may have minor artifacts.

Reimplemented from SkBlitter.

Definition at line 727 of file SkAAClip.cpp.

727 {
728 if (height == 1) {
729 // We're still in scan-line order if height is 1
730 // This is useful for Analytic AA
731 const SkAlpha alphas[2] = {alpha, 0};
732 const int16_t runs[2] = {1, 0};
733 this->blitAntiH(x, y, alphas, runs);
734 } else {
735 this->recordMinY(y);
736 fBuilder->addColumn(x, y, alpha, height);
737 fLastY = y + height - 1;
738 }
739 }
uint8_t SkAlpha
Definition SkColor.h:26
void blitAntiH(int x, int y, const SkAlpha alpha[], const int16_t runs[]) override
Definition SkAAClip.cpp:765

◆ finish()

void SkAAClip::Builder::Blitter::finish ( )
inline

Definition at line 714 of file SkAAClip.cpp.

714 {
715 if (fMinY < SK_MaxS32) {
716 fBuilder->fMinY = fMinY;
717 }
718 }

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