64 return alpha > 247 ? 0xFF : alpha < 8 ? 0 : alpha;
78 if (
bounds.height() == 0) {
82 int runSize =
bounds.width() + 1;
84 int16_t* runs =
reinterpret_cast<int16_t*
>(storage);
88 runs[1] =
bounds.width() - 2;
89 runs[
bounds.width() - 1] = 1;
97 if (
bounds.height() == 1) {
106 if (
bounds.height() > 2) {
111 if (
bounds.height() > 1) {
153 if (rightAlpha > 0) {
161 const uint8_t
bits[],
162 uint8_t left_mask, ptrdiff_t rowBytes,
163 uint8_t right_mask) {
167 while (--rowBytes >= 0) {
168 uint8_t
b = *
bits++ & left_mask;
198 return static_cast<uint8_t
>((0xFF00U >> maskBitCount) & 0xFF);
224 ptrdiff_t rowBytes = (affectedRightBit >> 3) + 1;
228 bits += maskRowBytes;
235 int bitsLeft = cx - ((cx - maskLeft) & 7);
238 int leftEdge = cx - bitsLeft;
240 int rightEdge =
clip.fRight - bitsLeft;
244 const uint8_t* leftByte =
bits;
245 U8CPU leftMask = 0xFFU >> (leftEdge & 7);
248 int affectedRightBit = rightEdge - 1;
249 const uint8_t* rightByte =
bits + (affectedRightBit >> 3);
254 ptrdiff_t rowBytes = rightByte - leftByte + 1;
259 bits += maskRowBytes;
266 int16_t* runs = runStorage.
get();
284#if defined(SK_SUPPORT_LEGACY_ALPHA_BITMAP_AS_COVERAGE)
292 while (!clipper.done()) {
293 const SkIRect& cr = clipper.rect();
303 while (!clipper.
done()) {
321 const int16_t runs[]) {}
350 return (
unsigned)(
y -
rect.fTop) < (
unsigned)
rect.height();
354 return (
unsigned)(
x -
rect.fLeft) < (
unsigned)
rect.width();
380 const int16_t const_runs[]) {
382 int16_t* runs =
const_cast<int16_t*
>(const_runs);
391 if (x1 <= fClipRect.
fLeft) {
396 if (x0 < fClipRect.
fLeft) {
401 x0 = fClipRect.
fLeft;
404 SkASSERT(x0 < x1 && runs[x1 - x0] == 0);
405 if (x1 > fClipRect.
fRight) {
408 ((int16_t*)runs)[x1 - x0] = 0;
411 SkASSERT(x0 < x1 && runs[x1 - x0] == 0);
427 if (y0 < fClipRect.
fTop) {
435 fBlitter->
blitV(
x, y0, y1 - y0, alpha);
463 if (255 == leftAlpha && 255 == rightAlpha) {
465 }
else if (1 == r.
width()) {
474 leftAlpha, rightAlpha);
502 const int16_t const_runs[]) {
504 int16_t* runs =
const_cast<int16_t*
>(const_runs);
520 if (
left > prevRite) {
521 int index = prevRite -
x;
522 ((uint8_t*)aa)[index] = 0;
523 ((int16_t*)runs)[index] =
SkToS16(
left - prevRite);
530 ((int16_t*)runs)[prevRite -
x] = 0;
549 while (!iter.
done()) {
564 while (!iter.
done()) {
581 while (!iter.
done()) {
587 SkAlpha effectiveLeftAlpha = (r.
fLeft ==
x) ? leftAlpha : 255;
591 if (255 == effectiveLeftAlpha && 255 == effectiveRightAlpha) {
593 }
else if (1 == r.
width()) {
600 effectiveRightAlpha);
604 effectiveLeftAlpha, effectiveRightAlpha);
618 while (!iter.
done()) {
632 blitter = &fNullBlitter;
634 if (ir ==
nullptr || !clipR.
contains(*ir)) {
635 fRectBlitter.
init(blitter, clipR);
636 blitter = &fRectBlitter;
640 blitter = &fRgnBlitter;
654#if defined(SK_FORCE_RASTER_PIPELINE_BLITTER)
658 if (
paint.isDither()) {
666 !
paint.isSrcOver() ||
671 auto cs =
device.colorSpace();
674 if (cs && !
paint.getShader()) {
675 if (!
paint.getColor4f().fitsInBytes() || !cs->isSRGB()) {
681 return device.colorType() == kN32_SkColorType;
718 p->setShader(
nullptr);
719 p->setColorFilter(
nullptr);
721 p->setColor(0x00000000);
725 if (
paint->getColorFilter()) {
740 paint.writable()->setDither(
false);
743 auto CreateSkRPBlitter = [&]() ->
SkBlitter* {
745 return blitter ? blitter
751 return CreateSkRPBlitter();
762 if (
paint->getShader()) {
772 if (!shaderContext) {
773 return CreateSkRPBlitter();
781 }
else if (
paint->getAlpha() == 0xFF) {
793 , fShader(
paint.refShader())
794 , fShaderContext(shaderContext) {
805void SkRectClipCheckBlitter::blitH(
int x,
int y,
int width) {
810void SkRectClipCheckBlitter::blitAntiH(
int x,
int y,
const SkAlpha aa[],
const int16_t runs[]) {
811 const int16_t* iter = runs;
812 for (; *iter; iter += *iter)
814 int width = iter - runs;
816 fBlitter->blitAntiH(
x,
y, aa, runs);
819void SkRectClipCheckBlitter::blitV(
int x,
int y,
int height,
SkAlpha alpha) {
821 fBlitter->blitV(
x,
y,
height, alpha);
824void SkRectClipCheckBlitter::blitRect(
int x,
int y,
int width,
int height) {
829void SkRectClipCheckBlitter::blitAntiRect(
int x,
int y,
int width,
int height,
831 bool skipLeft = !leftAlpha;
832 bool skipRight = !rightAlpha;
835 fBlitter->blitAntiRect(
x,
y,
width,
height, leftAlpha, rightAlpha);
841 fBlitter->blitMask(mask,
clip);
844void SkRectClipCheckBlitter::blitAntiH2(
int x,
int y,
U8CPU a0,
U8CPU a1) {
846 fBlitter->blitAntiH2(
x,
y, a0, a1);
849void SkRectClipCheckBlitter::blitAntiV2(
int x,
int y,
U8CPU a0,
U8CPU a1) {
851 fBlitter->blitAntiV2(
x,
y, a0, a1);
SkBlendFastPath CheckFastPath(const SkPaint &paint, bool dstIsOpaque)
@ kSrcOver
r = s + (1-sa)*d
static int compute_anti_width(const int16_t runs[])
static void bits_to_runs(SkBlitter *blitter, int x, int y, const uint8_t bits[], uint8_t left_mask, ptrdiff_t rowBytes, uint8_t right_mask)
static bool x_in_rect(int x, const SkIRect &rect)
static bool y_in_rect(int y, const SkIRect &rect)
static uint8_t generate_right_mask(int maskBitCount)
bool gSkForceRasterPipelineBlitter
static SkAlpha ScalarToAlpha(SkScalar a)
@ kAlpha_8_SkColorType
pixel with alpha in 8-bit byte
@ kUnknown_SkColorType
uninitialized
constexpr SkColor SK_ColorBLACK
SkBlitter * SkCreateRasterPipelineBlitter(const SkPixmap &, const SkPaint &, const SkMatrix &ctm, SkArenaAlloc *, sk_sp< SkShader > clipShader, const SkSurfaceProps &props)
static bool skip(SkStream *stream, size_t amount)
SK_API bool SkColorTypeIsAlwaysOpaque(SkColorType ct)
SkMaskFilterBase * as_MFB(SkMaskFilter *mf)
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
static bool left(const SkPoint &p0, const SkPoint &p1)
static bool right(const SkPoint &p0, const SkPoint &p1)
SkShaderBase * as_SB(SkShader *shader)
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
constexpr int16_t SkToS16(S x)
static void Break(int16_t runs[], uint8_t alpha[], int x, int count)
static void BreakAt(int16_t runs[], uint8_t alpha[], int x)
auto make(Ctor &&ctor) -> decltype(ctor(nullptr))
SkBlitter * apply(SkBlitter *blitter, const SkRegion *clip, const SkIRect *bounds=nullptr)
void blitFatAntiRect(const SkRect &rect)
static SkBlitter * Choose(const SkPixmap &dst, const SkMatrix &ctm, const SkPaint &paint, SkArenaAlloc *, bool drawCoverage, sk_sp< SkShader > clipShader, const SkSurfaceProps &props)
virtual bool isNullBlitter() const
static bool UseLegacyBlitter(const SkPixmap &, const SkPaint &, const SkMatrix &)
void blitRectRegion(const SkIRect &rect, const SkRegion &clip)
virtual void blitMask(const SkMask &, const SkIRect &clip)
virtual void blitAntiRect(int x, int y, int width, int height, SkAlpha leftAlpha, SkAlpha rightAlpha)
virtual void * allocBlitMemory(size_t sz)
void blitRegion(const SkRegion &clip)
virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[])=0
virtual void blitH(int x, int y, int width)=0
Blit a horizontal run of one or more pixels.
virtual void blitV(int x, int y, int height, SkAlpha alpha)
Blit a vertical run of pixels with a constant alpha value.
virtual void blitRect(int x, int y, int width, int height)
Blit a solid rectangle one or more pixels wide.
virtual SkMask::Format getFormat() const =0
void blitMask(const SkMask &, const SkIRect &clip) 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.
bool isNullBlitter() const 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[], const int16_t runs[]) override
static void RemoveColorFilter(SkPaint *, SkColorSpace *dstCS)
static bool ShouldDither(const SkPaint &, SkColorType)
const SkRect & getBounds() const
bool isRect(SkRect *rect, bool *isClosed=nullptr, SkPathDirection *direction=nullptr) const
void blitAntiH(int x, int y, const SkAlpha[], const int16_t runs[]) override
void blitH(int x, int y, int width) override
Blit a horizontal run of one or more pixels.
void blitV(int x, int y, int height, SkAlpha alpha) override
Blit a vertical run of pixels with a constant alpha value.
void blitAntiRect(int x, int y, int width, int height, SkAlpha leftAlpha, SkAlpha rightAlpha) override
void blitMask(const SkMask &, const SkIRect &clip) override
void init(SkBlitter *blitter, const SkIRect &clipRect)
void blitRect(int x, int y, int width, int height) override
Blit a solid rectangle one or more pixels wide.
static void VisitSpans(const SkRegion &rgn, const std::function< void(const SkIRect &)> &)
const SkIRect & rect() const
bool next(int *left, int *right)
const SkIRect & getBounds() const
void blitMask(const SkMask &, const SkIRect &clip) override
void blitAntiH(int x, int y, const SkAlpha[], const int16_t runs[]) override
void init(SkBlitter *blitter, const SkRegion *clipRgn)
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.
void blitAntiRect(int x, int y, int width, int height, SkAlpha leftAlpha, SkAlpha rightAlpha) override
void blitH(int x, int y, int width) override
Blit a horizontal run of one or more pixels.
Context * makeContext(const ContextRec &, SkArenaAlloc *) const
SkShaderBase::Context * fShaderContext
~SkShaderBlitter() override
sk_sp< SkShader > fShader
SkShaderBlitter(const SkPixmap &device, const SkPaint &paint, SkShaderBase::Context *shaderContext)
void(* memset16)(uint16_t[], uint16_t, int)
unsigned useCenter Optional< SkMatrix > matrix
Optional< SkRect > bounds
sk_sp< SkBlender > blender SkRect rect
skia_private::AutoTArray< sk_sp< SkImageFilter > > filters TypedMatrix matrix TypedMatrix matrix SkScalar dx
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive mode
bool intersect(const SkIRect &r)
static bool Intersects(const SkIRect &a, const SkIRect &b)
int32_t fBottom
larger y-axis bounds
constexpr int32_t top() const
constexpr int32_t height() const
int32_t fTop
smaller y-axis bounds
constexpr int32_t width() const
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
int32_t fLeft
smaller x-axis bounds
constexpr int32_t left() const
void setLTRB(int32_t left, int32_t top, int32_t right, int32_t bottom)
bool contains(int32_t x, int32_t y) const
int32_t fRight
larger x-axis bounds
@ k3D_Format
3 8bit per pixl planes: alpha, mul, add
@ kLCD16_Format
565 alpha for r/g/b
@ kBW_Format
1bit per pixel mask (e.g. monochrome)
const uint8_t * getAddr8(int x, int y) const
const uint8_t * getAddr1(int x, int y) const
uint8_t const *const fImage