Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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.
 
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 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
 
void blitAntiH (int x, int y, const SkAlpha antialias[], const int16_t runs[]) override
 
void blitH (int x, int y, int width) override
 Blit a horizontal run of one or more pixels.
 
- Public Member Functions inherited from SkBlitter
virtual ~SkBlitter ()
 
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 138 of file SkScan_AAAPath.cpp.

Constructor & Destructor Documentation

◆ MaskAdditiveBlitter()

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

Definition at line 207 of file SkScan_AAAPath.cpp.

211 : fRealBlitter(realBlitter)
212 , fMask((uint8_t*)fStorage + 1, ir, ir.width(), SkMask::kA8_Format)
213 , fRow(nullptr)
214 , fY(ir.fTop - 1)
215 {
217 SkASSERT(!isInverse);
218
219 fClipRect = ir;
220 if (!fClipRect.intersect(clipBounds)) {
221 SkASSERT(0);
222 fClipRect.setEmpty();
223 }
224
225 memset(fStorage, 0, fMask.fBounds.height() * fMask.fRowBytes + 2);
226}
#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 144 of file SkScan_AAAPath.cpp.

144{ fRealBlitter->blitMask(fMask, fClipRect); }
virtual void blitMask(const SkMask &, const SkIRect &clip)

Member Function Documentation

◆ blitAntiH() [1/3]

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

Implements AdditiveBlitter.

Definition at line 232 of file SkScan_AAAPath.cpp.

232 {
233 SkASSERT(x >= fMask.fBounds.fLeft - 1);
234 add_alpha(&this->getRow(y)[x], alpha);
235}
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 228 of file SkScan_AAAPath.cpp.

228 {
229 SK_ABORT("Don't use this; directly add alphas to the mask.");
230}
#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 237 of file SkScan_AAAPath.cpp.

237 {
238 SkASSERT(x >= fMask.fBounds.fLeft - 1);
239 uint8_t* row = this->getRow(y);
240 for (int i = 0; i < width; ++i) {
241 add_alpha(&row[x + i], alpha);
242 }
243}
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 270 of file SkScan_AAAPath.cpp.

275 {
276 blitV(x, y, height, leftAlpha);
277 blitV(x + 1 + width, y, height, rightAlpha);
278 blitRect(x + 1, y, width, height);
279}
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 259 of file SkScan_AAAPath.cpp.

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

◆ 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 245 of file SkScan_AAAPath.cpp.

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

◆ CanHandleRect()

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

Definition at line 170 of file SkScan_AAAPath.cpp.

170 {
171 int width = bounds.width();
172 if (width > MaskAdditiveBlitter::kMAX_WIDTH) {
173 return false;
174 }
175 int64_t rb = SkAlign4(width);
176 // use 64bits to detect overflow
177 int64_t storage = rb * bounds.height();
178
179 return (width <= MaskAdditiveBlitter::kMAX_WIDTH) &&
180 (storage <= MaskAdditiveBlitter::kMAX_STORAGE);
181 }
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 166 of file SkScan_AAAPath.cpp.

166{}

◆ getRealBlitter()

SkBlitter * MaskAdditiveBlitter::getRealBlitter ( bool  forceRealBlitter)
inlineoverridevirtual

Implements AdditiveBlitter.

Definition at line 149 of file SkScan_AAAPath.cpp.

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

◆ getRow()

uint8_t * MaskAdditiveBlitter::getRow ( int  y)
inline

Definition at line 184 of file SkScan_AAAPath.cpp.

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

◆ getWidth()

int MaskAdditiveBlitter::getWidth ( )
inlineoverridevirtual

Implements AdditiveBlitter.

Definition at line 168 of file SkScan_AAAPath.cpp.

168{ return fClipRect.width(); }

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