63 , fColorPipeline(alloc)
64 , fBlendPipeline(alloc)
67 void blitH (
int x,
int y,
int w)
override;
76 void blitRectWithTrace(
int x,
int y,
int w,
int h,
bool trace);
89 std::optional<SkBlendMode> fBlendMode;
91 void* fClipShaderBuffer =
nullptr;
94 fDstPtr = {
nullptr,0},
95 fMaskPtr = {
nullptr,0};
100 uint64_t fMemsetColor = 0;
103 std::function<void(
size_t,
size_t,
size_t,
size_t)> fBlitRect,
111 float fCurrentCoverage = 0.0f;
112 float fDitherRate = 0.0f;
140 bool is_opaque = dstPaintColor.fA == 1.0f,
143 is_opaque, is_constant, clipShader.
get());
146 bool is_opaque = shader->isOpaque() && dstPaintColor.fA == 1.0f;
147 bool is_constant = shader->isConstant();
149 if (shader->appendRootStages({&shaderPipeline, alloc, dstCT, dstCS, dstPaintColor, props},
151 if (dstPaintColor.fA != 1.0f) {
152 shaderPipeline.
append(SkRasterPipelineOp::scale_1_float,
153 alloc->
make<
float>(dstPaintColor.fA));
156 is_opaque, is_constant, clipShader.
get());
169 bool is_constant =
false;
171 shaderPipeline, is_opaque, is_constant,
194 auto colorPipeline = &blitter->fColorPipeline;
197 auto clipP = colorPipeline;
207 auto storage = alloc->
make<Storage>();
208 clipP->append(SkRasterPipelineOp::store_src_a, storage->fA);
209 blitter->fClipShaderBuffer = storage->fA;
217 colorPipeline->extend(shaderPipeline);
220 if (
auto colorFilter =
paint.getColorFilter()) {
223 colorPipeline, alloc,
dst.colorType(),
dst.colorSpace(), dstPaintColor, props};
232 if (
paint.isDither() && !is_constant) {
233 switch (
dst.info().colorType()) {
235 blitter->fDitherRate = 1 / 15.0f;
238 blitter->fDitherRate = 1 / 63.0f;
246 blitter->fDitherRate = 1 / 255.0f;
254 blitter->fDitherRate = 1 / 1023.0f;
269 blitter->fDitherRate = 0.0f;
272 if (blitter->fDitherRate > 0.0f) {
273 colorPipeline->append(SkRasterPipelineOp::dither, &blitter->fDitherRate);
284 colorPipeline->appendClampIfNormalized(
dst.info());
285 colorPipeline->append(SkRasterPipelineOp::store_f32, &constantColorPtr);
286 colorPipeline->run(0,0,1,1);
287 colorPipeline->reset();
288 colorPipeline->appendConstantColor(alloc, constantColor);
290 is_opaque = constantColor.fA == 1.0f;
294 auto blendPipeline = &blitter->fBlendPipeline;
309 dst.info().bytesPerPixel() <=
static_cast<int>(
sizeof(blitter->fMemsetColor))) {
313 p.extend(*colorPipeline);
315 blitter->appendStore(&
p);
318 switch (blitter->fDst.shiftPerPixel()) {
319 case 0: blitter->fMemset2D = [](
SkPixmap*
dst,
int x,
int y,
int w,
int h, uint64_t c) {
320 void*
p =
dst->writable_addr(
x,
y);
323 p = SkTAddOffset<void>(
p,
dst->rowBytes());
327 case 1: blitter->fMemset2D = [](
SkPixmap*
dst,
int x,
int y,
int w,
int h, uint64_t c) {
331 case 2: blitter->fMemset2D = [](
SkPixmap*
dst,
int x,
int y,
int w,
int h, uint64_t c) {
335 case 3: blitter->fMemset2D = [](
SkPixmap*
dst,
int x,
int y,
int w,
int h, uint64_t c) {
346 blendPipeline, alloc,
dst.colorType(),
dst.colorSpace(), dstPaintColor, props};
347 if (!
as_BB(blender)->appendStages(rec)) {
354 blitter->fDst.writable_addr(),
355 blitter->fDst.rowBytesAsPixels(),
364 p->append(SkRasterPipelineOp::premul_dst);
370 p->append(SkRasterPipelineOp::unpremul);
376 if (fClipShaderBuffer) {
377 p->append(SkRasterPipelineOp::scale_native, fClipShaderBuffer);
382 if (fClipShaderBuffer) {
383 p->append(SkRasterPipelineOp::lerp_native, fClipShaderBuffer);
392 this->blitRectWithTrace(
x,
y,
w,
h,
true);
395void SkRasterPipelineBlitter::blitRectWithTrace(
int x,
int y,
int w,
int h,
bool trace) {
397 fMemset2D(&fDst,
x,
y,
w,
h, fMemsetColor);
403 p.extend(fColorPipeline);
404 p.appendClampIfNormalized(fDst.
info());
410 && fDitherRate == 0.0f) {
412 p.append(SkRasterPipelineOp::swap_rb);
414 this->appendClipScale(&
p);
415 p.append(SkRasterPipelineOp::srcover_rgba_8888, &fDstPtr);
418 this->appendLoadDst(&
p);
419 p.extend(fBlendPipeline);
420 this->appendClipLerp(&
p);
421 }
else if (fClipShaderBuffer) {
422 this->appendLoadDst(&
p);
423 this->appendClipLerp(&
p);
425 this->appendStore(&
p);
427 fBlitRect =
p.compile();
436 p.extend(fColorPipeline);
437 p.appendClampIfNormalized(fDst.
info());
438 if (fBlendMode.has_value() &&
440 p.append(SkRasterPipelineOp::scale_1_float, &fCurrentCoverage);
441 this->appendClipScale(&
p);
442 this->appendLoadDst(&
p);
443 p.extend(fBlendPipeline);
445 this->appendLoadDst(&
p);
446 p.extend(fBlendPipeline);
447 p.append(SkRasterPipelineOp::lerp_1_float, &fCurrentCoverage);
448 this->appendClipLerp(&
p);
451 this->appendStore(&
p);
452 fBlitAntiH =
p.compile();
455 for (int16_t
run = *runs;
run > 0;
run = *runs) {
458 case 0xff:this->blitRectWithTrace(
x,
y,
run, 1,
false);
break;
460 fCurrentCoverage = *aa * (1/255.0f);
461 fBlitAntiH(
x,
y,
run,1);
471 uint8_t
coverage[] = { (uint8_t)a0, (uint8_t)a1 };
478 uint8_t
coverage[] = { (uint8_t)a0, (uint8_t)a1 };
507 auto ptr = (uintptr_t)mask.
fImage
514 ctx->stride = rowBytes / bpp;
515 ctx->pixels = (
void*)(ptr - mask.
fBounds.
left() * bpp
519 extract_mask_plane(0, &fMaskPtr);
521 extract_mask_plane(1, &fEmbossCtx.
mul);
522 extract_mask_plane(2, &fEmbossCtx.
add);
528 p.extend(fColorPipeline);
529 p.appendClampIfNormalized(fDst.
info());
530 if (fBlendMode.has_value() &&
532 p.append(SkRasterPipelineOp::scale_u8, &fMaskPtr);
533 this->appendClipScale(&
p);
534 this->appendLoadDst(&
p);
535 p.extend(fBlendPipeline);
537 this->appendLoadDst(&
p);
538 p.extend(fBlendPipeline);
539 p.append(SkRasterPipelineOp::lerp_u8, &fMaskPtr);
540 this->appendClipLerp(&
p);
542 this->appendStore(&
p);
543 fBlitMaskA8 =
p.compile();
547 p.extend(fColorPipeline);
548 p.appendClampIfNormalized(fDst.
info());
549 if (fBlendMode.has_value() &&
552 this->appendLoadDst(&
p);
553 p.append(SkRasterPipelineOp::scale_565, &fMaskPtr);
554 this->appendClipScale(&
p);
555 p.extend(fBlendPipeline);
557 this->appendLoadDst(&
p);
558 p.extend(fBlendPipeline);
559 p.append(SkRasterPipelineOp::lerp_565, &fMaskPtr);
560 this->appendClipLerp(&
p);
562 this->appendStore(&
p);
563 fBlitMaskLCD16 =
p.compile();
567 p.extend(fColorPipeline);
569 p.append(SkRasterPipelineOp::emboss, &fEmbossCtx);
571 p.appendClampIfNormalized(fDst.
info());
572 if (fBlendMode.has_value() &&
574 p.append(SkRasterPipelineOp::scale_u8, &fMaskPtr);
575 this->appendClipScale(&
p);
576 this->appendLoadDst(&
p);
577 p.extend(fBlendPipeline);
579 this->appendLoadDst(&
p);
580 p.extend(fBlendPipeline);
581 p.append(SkRasterPipelineOp::lerp_u8, &fMaskPtr);
582 this->appendClipLerp(&
p);
584 this->appendStore(&
p);
585 fBlitMask3D =
p.compile();
588 std::function<void(
size_t,
size_t,
size_t,
size_t)>* blitter =
nullptr;
bool SkBlendMode_ShouldPreScaleCoverage(SkBlendMode mode, bool rgb_coverage)
@ kSrcOver
r = s + (1-sa)*d
SkBlenderBase * as_BB(SkBlender *blend)
static SkColorFilterBase * as_CFB(SkColorFilter *filter)
SkColorSpace * sk_srgb_singleton()
@ kR16G16B16A16_unorm_SkColorType
pixel with a little endian uint16_t for red, green, blue
@ kRGBA_10x6_SkColorType
pixel with 10 used bits (most significant) followed by 6 unused
@ kBGR_101010x_SkColorType
pixel with 10 bits each for blue, green, red; in 32-bit word
@ kARGB_4444_SkColorType
pixel with 4 bits for alpha, red, green, blue; in 16-bit word
@ kR8G8_unorm_SkColorType
pixel with a uint8_t for red and green
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
@ kA16_unorm_SkColorType
pixel with a little endian uint16_t for alpha
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
@ kAlpha_8_SkColorType
pixel with alpha in 8-bit byte
@ kRGB_101010x_SkColorType
pixel with 10 bits each for red, green, blue; in 32-bit word
@ kSRGBA_8888_SkColorType
@ kGray_8_SkColorType
pixel with grayscale level in 8-bit byte
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
@ kBGRA_10101010_XR_SkColorType
pixel with 10 bits each for blue, green, red, alpha; in 64-bit word, extended range
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
@ kRGB_888x_SkColorType
pixel with 8 bits each for red, green, blue; in 32-bit word
@ kBGRA_1010102_SkColorType
10 bits for blue, green, red; 2 bits for alpha; in 32-bit word
@ kA16_float_SkColorType
pixel with a half float for alpha
@ kRGBA_F32_SkColorType
pixel using C float for red, green, blue, alpha; in 128-bit word
@ kRGBA_1010102_SkColorType
10 bits for red, green, blue; 2 bits for alpha; in 32-bit word
@ kBGR_101010x_XR_SkColorType
pixel with 10 bits each for blue, green, red; in 32-bit word, extended range
@ kR16G16_unorm_SkColorType
pixel with a little endian uint16_t for red and green
@ kRGBA_F16Norm_SkColorType
pixel with half floats in [0,1] for red, green, blue, alpha;
@ kUnknown_SkColorType
uninitialized
@ kR16G16_float_SkColorType
pixel with a half float for red and green
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
static SkColor4f paint_color_to_dst(const SkPaint &paint, const SkPixmap &dst)
SkBlitter * SkCreateRasterPipelineBlitter(const SkPixmap &dst, const SkPaint &paint, const SkMatrix &ctm, SkArenaAlloc *alloc, sk_sp< SkShader > clipShader, const SkSurfaceProps &props)
static constexpr int SkRasterPipeline_kMaxStride
SkShaderBase * as_SB(SkShader *shader)
auto make(Ctor &&ctor) -> decltype(ctor(nullptr))
virtual std::optional< SkBlendMode > asBlendMode() const
static sk_sp< SkBlender > Mode(SkBlendMode mode)
virtual void blitMask(const SkMask &, const SkIRect &clip)
virtual bool appendStages(const SkStageRec &rec, bool shaderIsOpaque) const =0
bool isAlphaUnchanged() const
static const SkMatrix & I()
SkColorSpace * colorSpace() const
const SkImageInfo & info() const
void blitV(int x, int y, int height, SkAlpha alpha) override
Blit a vertical run of pixels with a constant alpha value.
SkRasterPipelineBlitter(SkPixmap dst, SkArenaAlloc *alloc)
static SkBlitter * Create(const SkPixmap &dst, const SkPaint &paint, const SkColor4f &dstPaintColor, SkArenaAlloc *alloc, const SkRasterPipeline &shaderPipeline, bool is_opaque, bool is_constant, const SkShader *clipShader)
void blitAntiH(int x, int y, const SkAlpha[], const int16_t[]) override
void blitH(int x, int y, int w) override
Blit a horizontal run of one or more pixels.
void blitMask(const SkMask &, const SkIRect &clip) override
void blitAntiV2(int x, int y, U8CPU a0, U8CPU a1) override
void blitRect(int x, int y, int width, int height) override
Blit a solid rectangle one or more pixels wide.
void blitAntiH2(int x, int y, U8CPU a0, U8CPU a1) override
void append(SkRasterPipelineOp, void *=nullptr)
void appendConstantColor(SkArenaAlloc *, const float rgba[4])
bool appendRootStages(const SkStageRec &rec, const SkMatrix &ctm) const
Dart_NativeFunction function
constexpr SkColor4f kBlack
void(* rect_memset32)(uint32_t[], uint32_t, int, size_t, int)
void(* rect_memset16)(uint16_t[], uint16_t, int, size_t, int)
void(* rect_memset64)(uint64_t[], uint64_t, int, size_t, int)
constexpr int32_t top() const
constexpr int32_t left() const
SkAlphaType alphaType() const
SkColorType colorType() const
@ k3D_Format
3 8bit per pixl planes: alpha, mul, add
@ kA8_Format
8bits per pixel mask (e.g. antialiasing)
@ kLCD16_Format
565 alpha for r/g/b
@ kBW_Format
1bit per pixel mask (e.g. monochrome)
uint8_t const *const fImage
size_t computeImageSize() const
SkRasterPipeline_MemoryCtx add
SkRasterPipeline_MemoryCtx mul