Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
RunBasedAdditiveBlitter Class Reference
Inheritance diagram for RunBasedAdditiveBlitter:
AdditiveBlitter SkBlitter SafeRLEAdditiveBlitter

Public Member Functions

 RunBasedAdditiveBlitter (SkBlitter *realBlitter, const SkIRect &ir, const SkIRect &clipBounds, bool isInverse)
 
 ~RunBasedAdditiveBlitter () 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
 
int getWidth () override
 
void flush_if_y_changed (SkFixed y, SkFixed nextY) override
 
- 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)
 

Protected Member Functions

bool check (int x, int width) const
 
int getRunsSz () const
 
void advanceRuns ()
 
SkAlpha snapAlpha (SkAlpha alpha)
 
void flush ()
 
void checkY (int y)
 

Protected Attributes

SkBlitterfRealBlitter
 
int fCurrY
 
int fWidth
 
int fLeft
 
int fTop
 
int fRunsToBuffer
 
void * fRunsBuffer
 
int fCurrentRun
 
SkAlphaRuns fRuns
 
int fOffsetX
 
- Protected Attributes inherited from SkBlitter
SkAutoMalloc fBlitMemory
 

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)
 

Detailed Description

Definition at line 282 of file SkScan_AAAPath.cpp.

Constructor & Destructor Documentation

◆ RunBasedAdditiveBlitter()

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

Definition at line 369 of file SkScan_AAAPath.cpp.

372 {
373 fRealBlitter = realBlitter;
374
375 SkIRect sectBounds;
376 if (isInverse) {
377 // We use the clip bounds instead of the ir, since we may be asked to
378 // draw outside of the rect when we're a inverse filltype
379 sectBounds = clipBounds;
380 } else {
381 if (!sectBounds.intersect(ir, clipBounds)) {
382 sectBounds.setEmpty();
383 }
384 }
385
386 const int left = sectBounds.left();
387 const int right = sectBounds.right();
388
389 fLeft = left;
390 fWidth = right - left;
391 fTop = sectBounds.top();
392 fCurrY = fTop - 1;
393
394 fRunsToBuffer = realBlitter->requestRowsPreserved();
395 fRunsBuffer = realBlitter->allocBlitMemory(fRunsToBuffer * this->getRunsSz());
396 fCurrentRun = -1;
397
398 this->advanceRuns();
399
400 fOffsetX = 0;
401}
static bool left(const SkPoint &p0, const SkPoint &p1)
static bool right(const SkPoint &p0, const SkPoint &p1)
virtual int requestRowsPreserved() const
Definition: SkBlitter.h:122
virtual void * allocBlitMemory(size_t sz)
Definition: SkBlitter.h:130
Definition: SkRect.h:32
bool intersect(const SkIRect &r)
Definition: SkRect.h:513
constexpr int32_t top() const
Definition: SkRect.h:120
constexpr int32_t right() const
Definition: SkRect.h:127
void setEmpty()
Definition: SkRect.h:242
constexpr int32_t left() const
Definition: SkRect.h:113

◆ ~RunBasedAdditiveBlitter()

RunBasedAdditiveBlitter::~RunBasedAdditiveBlitter ( )
inlineoverride

Definition at line 289 of file SkScan_AAAPath.cpp.

289{ this->flush(); }

Member Function Documentation

◆ advanceRuns()

void RunBasedAdditiveBlitter::advanceRuns ( )
inlineprotected

Definition at line 332 of file SkScan_AAAPath.cpp.

332 {
333 const size_t kRunsSz = this->getRunsSz();
335 fRuns.fRuns = reinterpret_cast<int16_t*>(reinterpret_cast<uint8_t*>(fRunsBuffer) +
336 fCurrentRun * kRunsSz);
337 fRuns.fAlpha = reinterpret_cast<SkAlpha*>(fRuns.fRuns + fWidth + 1);
339 }
uint8_t SkAlpha
Definition: SkColor.h:26
uint8_t * fAlpha
Definition: SkAlphaRuns.h:27
void reset(int width)
Reinitialize for a new scanline.
Definition: SkAlphaRuns.cpp:11
int16_t * fRuns
Definition: SkAlphaRuns.h:26

◆ blitAntiH() [1/3]

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

Implements AdditiveBlitter.

Reimplemented in SafeRLEAdditiveBlitter.

Definition at line 432 of file SkScan_AAAPath.cpp.

432 {
433 checkY(y);
434 x -= fLeft;
435
436 if (x < fOffsetX) {
437 fOffsetX = 0;
438 }
439
440 if (this->check(x, 1)) {
441 fOffsetX = fRuns.add(x, 0, 1, 0, alpha, fOffsetX);
442 }
443}
bool check(int x, int width) const
SK_ALWAYS_INLINE int add(int x, U8CPU startAlpha, int middleCount, U8CPU stopAlpha, U8CPU maxValue, int offsetX)
Definition: SkAlphaRuns.h:58
double y
double x

◆ blitAntiH() [2/3]

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

Implements AdditiveBlitter.

Reimplemented in SafeRLEAdditiveBlitter.

Definition at line 403 of file SkScan_AAAPath.cpp.

403 {
404 checkY(y);
405 x -= fLeft;
406
407 if (x < 0) {
408 len += x;
409 antialias -= x;
410 x = 0;
411 }
412 len = std::min(len, fWidth - x);
413 SkASSERT(check(x, len));
414
415 if (x < fOffsetX) {
416 fOffsetX = 0;
417 }
418
419 fOffsetX = fRuns.add(x, 0, len, 0, 0, fOffsetX); // Break the run
420 for (int i = 0; i < len; i += fRuns.fRuns[x + i]) {
421 for (int j = 1; j < fRuns.fRuns[x + i]; j++) {
422 fRuns.fRuns[x + i + j] = 1;
423 fRuns.fAlpha[x + i + j] = fRuns.fAlpha[x + i];
424 }
425 fRuns.fRuns[x + i] = 1;
426 }
427 for (int i = 0; i < len; ++i) {
428 add_alpha(&fRuns.fAlpha[x + i], antialias[i]);
429 }
430}
#define SkASSERT(cond)
Definition: SkAssert.h:116
static void add_alpha(SkAlpha *alpha, SkAlpha delta)
static float min(float r, float g, float b)
Definition: hsl.cpp:48

◆ blitAntiH() [3/3]

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

Implements AdditiveBlitter.

Reimplemented in SafeRLEAdditiveBlitter.

Definition at line 445 of file SkScan_AAAPath.cpp.

445 {
446 checkY(y);
447 x -= fLeft;
448
449 if (x < fOffsetX) {
450 fOffsetX = 0;
451 }
452
453 if (this->check(x, width)) {
454 fOffsetX = fRuns.add(x, 0, width, 0, alpha, fOffsetX);
455 }
456}
int32_t width

◆ check()

bool RunBasedAdditiveBlitter::check ( int  x,
int  width 
) const
inlineprotected

Definition at line 324 of file SkScan_AAAPath.cpp.

324{ return x >= 0 && x + width <= fWidth; }

◆ checkY()

void RunBasedAdditiveBlitter::checkY ( int  y)
inlineprotected

Definition at line 361 of file SkScan_AAAPath.cpp.

361 {
362 if (y != fCurrY) {
363 this->flush();
364 fCurrY = y;
365 }
366 }

◆ flush()

void RunBasedAdditiveBlitter::flush ( )
inlineprotected

Definition at line 344 of file SkScan_AAAPath.cpp.

344 {
345 if (fCurrY >= fTop) {
347 for (int x = 0; fRuns.fRuns[x]; x += fRuns.fRuns[x]) {
348 // It seems that blitting 255 or 0 is much faster than blitting 254 or 1
350 }
351 if (!fRuns.empty()) {
352 // SkDEBUGCODE(fRuns.dump();)
354 this->advanceRuns();
355 fOffsetX = 0;
356 }
357 fCurrY = fTop - 1;
358 }
359 }
SkAlpha snapAlpha(SkAlpha alpha)
bool empty() const
Definition: SkAlphaRuns.h:37
virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[])=0

◆ flush_if_y_changed()

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

Implements AdditiveBlitter.

Definition at line 299 of file SkScan_AAAPath.cpp.

299 {
300 if (SkFixedFloorToInt(y) != SkFixedFloorToInt(nextY)) {
301 this->flush();
302 }
303 }
#define SkFixedFloorToInt(x)
Definition: SkFixed.h:78

◆ getRealBlitter()

SkBlitter * RunBasedAdditiveBlitter::getRealBlitter ( bool  forceRealBlitter)
inlineoverridevirtual

Implements AdditiveBlitter.

Definition at line 291 of file SkScan_AAAPath.cpp.

291{ return fRealBlitter; }

◆ getRunsSz()

int RunBasedAdditiveBlitter::getRunsSz ( ) const
inlineprotected

Definition at line 327 of file SkScan_AAAPath.cpp.

327{ return (fWidth + 1 + (fWidth + 2) / 2) * sizeof(int16_t); }

◆ getWidth()

int RunBasedAdditiveBlitter::getWidth ( )
inlineoverridevirtual

Implements AdditiveBlitter.

Definition at line 297 of file SkScan_AAAPath.cpp.

297{ return fWidth; }

◆ snapAlpha()

SkAlpha RunBasedAdditiveBlitter::snapAlpha ( SkAlpha  alpha)
inlineprotected

Definition at line 342 of file SkScan_AAAPath.cpp.

342{ return alpha > 247 ? 0xFF : alpha < 8 ? 0x00 : alpha; }

Member Data Documentation

◆ fCurrentRun

int RunBasedAdditiveBlitter::fCurrentRun
protected

Definition at line 319 of file SkScan_AAAPath.cpp.

◆ fCurrY

int RunBasedAdditiveBlitter::fCurrY
protected

Definition at line 308 of file SkScan_AAAPath.cpp.

◆ fLeft

int RunBasedAdditiveBlitter::fLeft
protected

Definition at line 310 of file SkScan_AAAPath.cpp.

◆ fOffsetX

int RunBasedAdditiveBlitter::fOffsetX
protected

Definition at line 322 of file SkScan_AAAPath.cpp.

◆ fRealBlitter

SkBlitter* RunBasedAdditiveBlitter::fRealBlitter
protected

Definition at line 306 of file SkScan_AAAPath.cpp.

◆ fRuns

SkAlphaRuns RunBasedAdditiveBlitter::fRuns
protected

Definition at line 320 of file SkScan_AAAPath.cpp.

◆ fRunsBuffer

void* RunBasedAdditiveBlitter::fRunsBuffer
protected

Definition at line 318 of file SkScan_AAAPath.cpp.

◆ fRunsToBuffer

int RunBasedAdditiveBlitter::fRunsToBuffer
protected

Definition at line 317 of file SkScan_AAAPath.cpp.

◆ fTop

int RunBasedAdditiveBlitter::fTop
protected

Definition at line 311 of file SkScan_AAAPath.cpp.

◆ fWidth

int RunBasedAdditiveBlitter::fWidth
protected

Definition at line 309 of file SkScan_AAAPath.cpp.


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