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

Public Member Functions

 MaskAdditiveBlitter (SkBlitter *realBlitter, const SkIRect &ir, const SkIRect &clipBounds, bool isInverse)
 
 ~MaskAdditiveBlitter () override
 
SkBlittergetRealBlitter (bool forceRealBlitter) override
 
void blitAntiH (int x, int y, const SkAlpha antialias[], int len) override
 
void blitAntiH (int x, int y, const SkAlpha alpha) override
 
void blitAntiH (int x, int y, int width, const SkAlpha alpha) 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 blitAntiRect (int x, int y, int width, int height, SkAlpha leftAlpha, SkAlpha rightAlpha) override
 
void flush_if_y_changed (SkFixed y, SkFixed nextY) override
 
int getWidth () override
 
uint8_t * getRow (int y)
 
- Public Member Functions inherited from AdditiveBlitter
 ~AdditiveBlitter () override
 
virtual SkBlittergetRealBlitter (bool forceRealBlitter=false)=0
 
virtual void blitAntiH (int x, int y, const SkAlpha antialias[], int len)=0
 
virtual void blitAntiH (int x, int y, const SkAlpha alpha)=0
 
virtual void blitAntiH (int x, int y, int width, const SkAlpha alpha)=0
 
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 blitH (int x, int y, int width) override
 Blit a horizontal run of one or more pixels. More...
 
void blitRect (int x, int y, int width, int height) override
 Blit a solid rectangle one or more pixels wide. More...
 
void blitAntiRect (int x, int y, int width, int height, SkAlpha leftAlpha, SkAlpha rightAlpha) override
 
virtual int getWidth ()=0
 
virtual void flush_if_y_changed (SkFixed y, SkFixed nextY)=0
 
- 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)
 

Static Public Member Functions

static bool CanHandleRect (const SkIRect &bounds)
 
- 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)
 

Additional Inherited Members

- Protected Attributes inherited from SkBlitter
SkAutoMalloc fBlitMemory
 

Detailed Description

Definition at line 139 of file SkScan_AAAPath.cpp.

Constructor & Destructor Documentation

◆ MaskAdditiveBlitter()

MaskAdditiveBlitter::MaskAdditiveBlitter ( SkBlitter realBlitter,
const SkIRect ir,
const SkIRect clipBounds,
bool  isInverse 
)

Definition at line 208 of file SkScan_AAAPath.cpp.

212 : fRealBlitter(realBlitter)
213 , fMask((uint8_t*)fStorage + 1, ir, ir.width(), SkMask::kA8_Format)
214 , fRow(nullptr)
215 , fY(ir.fTop - 1)
216 {
218 SkASSERT(!isInverse);
219
220 fClipRect = ir;
221 if (!fClipRect.intersect(clipBounds)) {
222 SkASSERT(0);
223 fClipRect.setEmpty();
224 }
225
226 memset(fStorage, 0, fMask.fBounds.height() * fMask.fRowBytes + 2);
227}
#define SkASSERT(cond)
Definition: SkAssert.h:116
static bool CanHandleRect(const SkIRect &bounds)
bool intersect(const SkIRect &r)
Definition: SkRect.h:513
constexpr int32_t height() const
Definition: SkRect.h:165
int32_t fTop
smaller y-axis bounds
Definition: SkRect.h:34
constexpr int32_t width() const
Definition: SkRect.h:158
void setEmpty()
Definition: SkRect.h:242
const uint32_t fRowBytes
Definition: SkMask.h:43
@ kA8_Format
8bits per pixel mask (e.g. antialiasing)
Definition: SkMask.h:28
const SkIRect fBounds
Definition: SkMask.h:42

◆ ~MaskAdditiveBlitter()

MaskAdditiveBlitter::~MaskAdditiveBlitter ( )
inlineoverride

Definition at line 145 of file SkScan_AAAPath.cpp.

145{ fRealBlitter->blitMask(fMask, fClipRect); }
virtual void blitMask(const SkMask &, const SkIRect &clip)
Definition: SkBlitter.cpp:201

Member Function Documentation

◆ blitAntiH() [1/3]

void MaskAdditiveBlitter::blitAntiH ( int  x,
int  y,
const SkAlpha  alpha 
)
overridevirtual

Implements AdditiveBlitter.

Definition at line 233 of file SkScan_AAAPath.cpp.

233 {
234 SkASSERT(x >= fMask.fBounds.fLeft - 1);
235 add_alpha(&this->getRow(y)[x], alpha);
236}
static void add_alpha(SkAlpha *alpha, SkAlpha delta)
uint8_t * getRow(int y)
double y
double x
int32_t fLeft
smaller x-axis bounds
Definition: SkRect.h:33

◆ blitAntiH() [2/3]

void MaskAdditiveBlitter::blitAntiH ( int  x,
int  y,
const SkAlpha  antialias[],
int  len 
)
overridevirtual

Implements AdditiveBlitter.

Definition at line 229 of file SkScan_AAAPath.cpp.

229 {
230 SK_ABORT("Don't use this; directly add alphas to the mask.");
231}
#define SK_ABORT(message,...)
Definition: SkAssert.h:70

◆ blitAntiH() [3/3]

void MaskAdditiveBlitter::blitAntiH ( int  x,
int  y,
int  width,
const SkAlpha  alpha 
)
overridevirtual

Implements AdditiveBlitter.

Definition at line 238 of file SkScan_AAAPath.cpp.

238 {
239 SkASSERT(x >= fMask.fBounds.fLeft - 1);
240 uint8_t* row = this->getRow(y);
241 for (int i = 0; i < width; ++i) {
242 add_alpha(&row[x + i], alpha);
243 }
244}
int32_t width

◆ blitAntiRect()

void MaskAdditiveBlitter::blitAntiRect ( int  x,
int  y,
int  width,
int  height,
SkAlpha  leftAlpha,
SkAlpha  rightAlpha 
)
overridevirtual

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 AdditiveBlitter.

Definition at line 271 of file SkScan_AAAPath.cpp.

276 {
277 blitV(x, y, height, leftAlpha);
278 blitV(x + 1 + width, y, height, rightAlpha);
279 blitRect(x + 1, y, width, height);
280}
void blitRect(int x, int y, int width, int height) override
Blit a solid rectangle one or more pixels wide.
void blitV(int x, int y, int height, SkAlpha alpha) override
Blit a vertical run of pixels with a constant alpha value.
int32_t height

◆ blitRect()

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

Blit a solid rectangle one or more pixels wide.

Reimplemented from AdditiveBlitter.

Definition at line 260 of file SkScan_AAAPath.cpp.

260 {
261 SkASSERT(x >= fMask.fBounds.fLeft - 1);
262 // This must be called as if this is a real blitter.
263 // So we directly set alpha rather than adding it.
264 uint8_t* row = this->getRow(y);
265 for (int i = 0; i < height; ++i) {
266 memset(row + x, 0xFF, width);
267 row += fMask.fRowBytes;
268 }
269}

◆ blitV()

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

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

Reimplemented from AdditiveBlitter.

Definition at line 246 of file SkScan_AAAPath.cpp.

246 {
247 if (alpha == 0) {
248 return;
249 }
250 SkASSERT(x >= fMask.fBounds.fLeft - 1);
251 // This must be called as if this is a real blitter.
252 // So we directly set alpha rather than adding it.
253 uint8_t* row = this->getRow(y);
254 for (int i = 0; i < height; ++i) {
255 row[x] = alpha;
256 row += fMask.fRowBytes;
257 }
258}

◆ CanHandleRect()

static bool MaskAdditiveBlitter::CanHandleRect ( const SkIRect bounds)
inlinestatic

Definition at line 171 of file SkScan_AAAPath.cpp.

171 {
172 int width = bounds.width();
173 if (width > MaskAdditiveBlitter::kMAX_WIDTH) {
174 return false;
175 }
176 int64_t rb = SkAlign4(width);
177 // use 64bits to detect overflow
178 int64_t storage = rb * bounds.height();
179
180 return (width <= MaskAdditiveBlitter::kMAX_WIDTH) &&
181 (storage <= MaskAdditiveBlitter::kMAX_STORAGE);
182 }
static constexpr T SkAlign4(T x)
Definition: SkAlign.h:16
Optional< SkRect > bounds
Definition: SkRecords.h:189

◆ flush_if_y_changed()

void MaskAdditiveBlitter::flush_if_y_changed ( SkFixed  y,
SkFixed  nextY 
)
inlineoverridevirtual

Implements AdditiveBlitter.

Definition at line 167 of file SkScan_AAAPath.cpp.

167{}

◆ getRealBlitter()

SkBlitter * MaskAdditiveBlitter::getRealBlitter ( bool  forceRealBlitter)
inlineoverridevirtual

Implements AdditiveBlitter.

Definition at line 150 of file SkScan_AAAPath.cpp.

150 {
151 return forceRealBlitter ? fRealBlitter : this;
152 }

◆ getRow()

uint8_t * MaskAdditiveBlitter::getRow ( int  y)
inline

Definition at line 185 of file SkScan_AAAPath.cpp.

185 {
186 if (y != fY) {
187 fY = y;
188 fRow = fMask.image() + (y - fMask.fBounds.fTop) * fMask.fRowBytes - fMask.fBounds.fLeft;
189 }
190 return fRow;
191 }
uint8_t *& image()
Definition: SkMask.h:236

◆ getWidth()

int MaskAdditiveBlitter::getWidth ( )
inlineoverridevirtual

Implements AdditiveBlitter.

Definition at line 169 of file SkScan_AAAPath.cpp.

169{ return fClipRect.width(); }

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