Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
 
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.
 
void blitH (int x, int y, int width) override
 Blit a horizontal run of one or more pixels.
 
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
 
- 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)
 

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

Constructor & Destructor Documentation

◆ RunBasedAdditiveBlitter()

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

Definition at line 368 of file SkScan_AAAPath.cpp.

371 {
372 fRealBlitter = realBlitter;
373
374 SkIRect sectBounds;
375 if (isInverse) {
376 // We use the clip bounds instead of the ir, since we may be asked to
377 // draw outside of the rect when we're a inverse filltype
378 sectBounds = clipBounds;
379 } else {
380 if (!sectBounds.intersect(ir, clipBounds)) {
381 sectBounds.setEmpty();
382 }
383 }
384
385 const int left = sectBounds.left();
386 const int right = sectBounds.right();
387
388 fLeft = left;
389 fWidth = right - left;
390 fTop = sectBounds.top();
391 fCurrY = fTop - 1;
392
393 fRunsToBuffer = realBlitter->requestRowsPreserved();
394 fRunsBuffer = realBlitter->allocBlitMemory(fRunsToBuffer * this->getRunsSz());
395 fCurrentRun = -1;
396
397 this->advanceRuns();
398
399 fOffsetX = 0;
400}
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:121
virtual void * allocBlitMemory(size_t sz)
Definition SkBlitter.h:129
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 288 of file SkScan_AAAPath.cpp.

288{ this->flush(); }

Member Function Documentation

◆ advanceRuns()

void RunBasedAdditiveBlitter::advanceRuns ( )
inlineprotected

Definition at line 331 of file SkScan_AAAPath.cpp.

331 {
332 const size_t kRunsSz = this->getRunsSz();
334 fRuns.fRuns = reinterpret_cast<int16_t*>(reinterpret_cast<uint8_t*>(fRunsBuffer) +
335 fCurrentRun * kRunsSz);
336 fRuns.fAlpha = reinterpret_cast<SkAlpha*>(fRuns.fRuns + fWidth + 1);
338 }
uint8_t SkAlpha
Definition SkColor.h:26
uint8_t * fAlpha
Definition SkAlphaRuns.h:27
void reset(int width)
Reinitialize for a new scanline.
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 431 of file SkScan_AAAPath.cpp.

431 {
432 checkY(y);
433 x -= fLeft;
434
435 if (x < fOffsetX) {
436 fOffsetX = 0;
437 }
438
439 if (this->check(x, 1)) {
440 fOffsetX = fRuns.add(x, 0, 1, 0, alpha, fOffsetX);
441 }
442}
#define check(reporter, ref, unref, make, kill)
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 402 of file SkScan_AAAPath.cpp.

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

◆ blitAntiH() [3/3]

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

Implements AdditiveBlitter.

Reimplemented in SafeRLEAdditiveBlitter.

Definition at line 444 of file SkScan_AAAPath.cpp.

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

◆ check()

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

Definition at line 323 of file SkScan_AAAPath.cpp.

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

◆ checkY()

void RunBasedAdditiveBlitter::checkY ( int  y)
inlineprotected

Definition at line 360 of file SkScan_AAAPath.cpp.

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

◆ flush()

void RunBasedAdditiveBlitter::flush ( )
inlineprotected

Definition at line 343 of file SkScan_AAAPath.cpp.

343 {
344 if (fCurrY >= fTop) {
346 for (int x = 0; fRuns.fRuns[x]; x += fRuns.fRuns[x]) {
347 // It seems that blitting 255 or 0 is much faster than blitting 254 or 1
349 }
350 if (!fRuns.empty()) {
351 // SkDEBUGCODE(fRuns.dump();)
353 this->advanceRuns();
354 fOffsetX = 0;
355 }
356 fCurrY = fTop - 1;
357 }
358 }
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 298 of file SkScan_AAAPath.cpp.

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

◆ getRealBlitter()

SkBlitter * RunBasedAdditiveBlitter::getRealBlitter ( bool  forceRealBlitter)
inlineoverridevirtual

Implements AdditiveBlitter.

Definition at line 290 of file SkScan_AAAPath.cpp.

290{ return fRealBlitter; }

◆ getRunsSz()

int RunBasedAdditiveBlitter::getRunsSz ( ) const
inlineprotected

Definition at line 326 of file SkScan_AAAPath.cpp.

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

◆ getWidth()

int RunBasedAdditiveBlitter::getWidth ( )
inlineoverridevirtual

Implements AdditiveBlitter.

Definition at line 296 of file SkScan_AAAPath.cpp.

296{ return fWidth; }

◆ snapAlpha()

SkAlpha RunBasedAdditiveBlitter::snapAlpha ( SkAlpha  alpha)
inlineprotected

Definition at line 341 of file SkScan_AAAPath.cpp.

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

Member Data Documentation

◆ fCurrentRun

int RunBasedAdditiveBlitter::fCurrentRun
protected

Definition at line 318 of file SkScan_AAAPath.cpp.

◆ fCurrY

int RunBasedAdditiveBlitter::fCurrY
protected

Definition at line 307 of file SkScan_AAAPath.cpp.

◆ fLeft

int RunBasedAdditiveBlitter::fLeft
protected

Definition at line 309 of file SkScan_AAAPath.cpp.

◆ fOffsetX

int RunBasedAdditiveBlitter::fOffsetX
protected

Definition at line 321 of file SkScan_AAAPath.cpp.

◆ fRealBlitter

SkBlitter* RunBasedAdditiveBlitter::fRealBlitter
protected

Definition at line 305 of file SkScan_AAAPath.cpp.

◆ fRuns

SkAlphaRuns RunBasedAdditiveBlitter::fRuns
protected

Definition at line 319 of file SkScan_AAAPath.cpp.

◆ fRunsBuffer

void* RunBasedAdditiveBlitter::fRunsBuffer
protected

Definition at line 317 of file SkScan_AAAPath.cpp.

◆ fRunsToBuffer

int RunBasedAdditiveBlitter::fRunsToBuffer
protected

Definition at line 316 of file SkScan_AAAPath.cpp.

◆ fTop

int RunBasedAdditiveBlitter::fTop
protected

Definition at line 310 of file SkScan_AAAPath.cpp.

◆ fWidth

int RunBasedAdditiveBlitter::fWidth
protected

Definition at line 308 of file SkScan_AAAPath.cpp.


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