Adds stages to implement this shader. To ensure that the correct input coords are present in r,g MatrixRec::apply() must be called (unless the shader doesn't require it's input coords). The default impl creates shadercontext and calls that (not very efficient).
516 {
518
519
523 }
524
527
529
530 if (mRec.totalMatrixIsValid()) {
531 if (!mRec.totalInverse(&baseInv)) {
532 return false;
533 }
535 }
536
539 if (!access) {
540 return false;
541 }
542
543 MipLevelHelper upper;
544 std::tie(upper.pm, upper.inv) = access->level();
545
547
548 if (mRec.totalMatrixIsValid()) {
550 }
551 }
552
553 if (!mRec.apply(rec, upper.inv)) {
554 return false;
555 }
556
557 upper.allocAndInit(alloc,
sampling, fTileModeX, fTileModeY);
558
559 MipLevelHelper
lower;
562 if (lowerWeight > 0) {
563 std::tie(
lower.pm,
lower.inv) = access->lowerLevel();
566 mipmapCtx->
scaleX =
static_cast<float>(
lower.pm.width()) / upper.pm.width();
567 mipmapCtx->
scaleY =
static_cast<float>(
lower.pm.height()) / upper.pm.height();
568
570
571 p->append(SkRasterPipelineOp::mipmap_linear_init, mipmapCtx);
572 }
573
575
576 auto append_tiling_and_gather = [&](
const MipLevelHelper*
level) {
577 if (decalBothAxes) {
578 p->append(SkRasterPipelineOp::decal_x_and_y,
level->decalCtx);
579 } else {
580 switch (fTileModeX) {
582 break;
584 p->append(SkRasterPipelineOp::mirror_x,
level->limitX);
585 break;
587 p->append(SkRasterPipelineOp::repeat_x,
level->limitX);
588 break;
590 p->append(SkRasterPipelineOp::decal_x,
level->decalCtx);
591 break;
592 }
593 switch (fTileModeY) {
595 break;
597 p->append(SkRasterPipelineOp::mirror_y,
level->limitY);
598 break;
600 p->append(SkRasterPipelineOp::repeat_y,
level->limitY);
601 break;
603 p->append(SkRasterPipelineOp::decal_y,
level->decalCtx);
604 break;
605 }
606 }
607
608 void* ctx =
level->gather;
609 switch (
level->pm.colorType()) {
619
621 p->append(SkRasterPipelineOp::gather_1010102, ctx);
622 break;
623
625 p->append(SkRasterPipelineOp::gather_16161616, ctx);
626 break;
627
632 p->append(SkRasterPipelineOp::gather_10101010_xr, ctx);
633 p->append(SkRasterPipelineOp::swap_rb);
634 break;
636
638 p->append(SkRasterPipelineOp::alpha_to_gray );
break;
639
641 p->append(SkRasterPipelineOp::alpha_to_red );
break;
642
644 p->append(SkRasterPipelineOp::force_opaque );
break;
645
647 p->append(SkRasterPipelineOp::gather_1010102, ctx);
648 p->append(SkRasterPipelineOp::swap_rb);
649 break;
650
652 p->append(SkRasterPipelineOp::gather_1010102, ctx);
653 p->append(SkRasterPipelineOp::force_opaque);
654 break;
655
657 p->append(SkRasterPipelineOp::gather_1010102_xr, ctx);
658 p->append(SkRasterPipelineOp::force_opaque);
659 p->append(SkRasterPipelineOp::swap_rb);
660 break;
661
663 p->append(SkRasterPipelineOp::gather_1010102, ctx);
664 p->append(SkRasterPipelineOp::force_opaque);
665 p->append(SkRasterPipelineOp::swap_rb);
666 break;
667
669 p->append(SkRasterPipelineOp::gather_8888, ctx);
670 p->append(SkRasterPipelineOp::swap_rb);
671 break;
672
674 p->append(SkRasterPipelineOp::gather_8888, ctx);
676 break;
677
679 }
680 if (
level->decalCtx) {
681 p->append(SkRasterPipelineOp::check_decal_mask,
level->decalCtx);
682 }
683 };
684
685 auto append_misc = [&] {
688
689
690
691
693 p->appendSetRGB(alloc, rec.fPaintColor);
694
695 cs = rec.fDstCS;
697 }
698
699
702 ? SkRasterPipelineOp::clamp_01
704 }
705
706
707 if (!fRaw) {
709 }
710
711 return true;
712 };
713
714
715
717 if (true
722
723 p->append(SkRasterPipelineOp::bilerp_clamp_8888, upper.gather);
725 p->append(SkRasterPipelineOp::swap_rb);
726 }
727 return append_misc();
728 }
729 if (true
733
734 p->append(SkRasterPipelineOp::bicubic_clamp_8888, upper.gather);
736 p->append(SkRasterPipelineOp::swap_rb);
737 }
738 return append_misc();
739 }
740
741
743
746 const MipLevelHelper*
level) {
747 p->append(setup_x, sampler);
748 p->append(setup_y, sampler);
749 append_tiling_and_gather(level);
750 p->append(SkRasterPipelineOp::accumulate, sampler);
751 };
752
753 auto sample_level = [&](
const MipLevelHelper*
level) {
756
757 p->append(SkRasterPipelineOp::bicubic_setup, sampler);
758
759 sample(SkRasterPipelineOp::bicubic_n3x, SkRasterPipelineOp::bicubic_n3y, level);
760 sample(SkRasterPipelineOp::bicubic_n1x, SkRasterPipelineOp::bicubic_n3y, level);
761 sample(SkRasterPipelineOp::bicubic_p1x, SkRasterPipelineOp::bicubic_n3y, level);
762 sample(SkRasterPipelineOp::bicubic_p3x, SkRasterPipelineOp::bicubic_n3y, level);
763
764 sample(SkRasterPipelineOp::bicubic_n3x, SkRasterPipelineOp::bicubic_n1y, level);
765 sample(SkRasterPipelineOp::bicubic_n1x, SkRasterPipelineOp::bicubic_n1y, level);
766 sample(SkRasterPipelineOp::bicubic_p1x, SkRasterPipelineOp::bicubic_n1y, level);
767 sample(SkRasterPipelineOp::bicubic_p3x, SkRasterPipelineOp::bicubic_n1y, level);
768
769 sample(SkRasterPipelineOp::bicubic_n3x, SkRasterPipelineOp::bicubic_p1y, level);
770 sample(SkRasterPipelineOp::bicubic_n1x, SkRasterPipelineOp::bicubic_p1y, level);
771 sample(SkRasterPipelineOp::bicubic_p1x, SkRasterPipelineOp::bicubic_p1y, level);
772 sample(SkRasterPipelineOp::bicubic_p3x, SkRasterPipelineOp::bicubic_p1y, level);
773
774 sample(SkRasterPipelineOp::bicubic_n3x, SkRasterPipelineOp::bicubic_p3y, level);
775 sample(SkRasterPipelineOp::bicubic_n1x, SkRasterPipelineOp::bicubic_p3y, level);
776 sample(SkRasterPipelineOp::bicubic_p1x, SkRasterPipelineOp::bicubic_p3y, level);
777 sample(SkRasterPipelineOp::bicubic_p3x, SkRasterPipelineOp::bicubic_p3y, level);
778
779 p->append(SkRasterPipelineOp::move_dst_src);
781 p->append(SkRasterPipelineOp::bilinear_setup, sampler);
782
783 sample(SkRasterPipelineOp::bilinear_nx, SkRasterPipelineOp::bilinear_ny, level);
784 sample(SkRasterPipelineOp::bilinear_px, SkRasterPipelineOp::bilinear_ny, level);
785 sample(SkRasterPipelineOp::bilinear_nx, SkRasterPipelineOp::bilinear_py, level);
786 sample(SkRasterPipelineOp::bilinear_px, SkRasterPipelineOp::bilinear_py, level);
787
788 p->append(SkRasterPipelineOp::move_dst_src);
789 } else {
790 append_tiling_and_gather(level);
791 }
792 };
793
794 sample_level(&upper);
795
796 if (mipmapCtx) {
797 p->append(SkRasterPipelineOp::mipmap_linear_update, mipmapCtx);
798 sample_level(&lower);
799 p->append(SkRasterPipelineOp::mipmap_linear_finish, mipmapCtx);
800 }
801
802 return append_misc();
803}
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ 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 bool SkColorTypeIsAlphaOnly(SkColorType ct)
static SkSamplingOptions tweak_sampling(SkSamplingOptions sampling, const SkMatrix &matrix)
static bool apply(Pass *pass, SkRecord *record)
auto make(Ctor &&ctor) -> decltype(ctor(nullptr))
static SkM44 CubicResamplerMatrix(float B, float C)
void getColMajor(SkScalar v[]) const
static SkMatrix Concat(const SkMatrix &a, const SkMatrix &b)
void normalizePerspective()
static SkMipmapAccessor * Make(SkArenaAlloc *, const SkImage *, const SkMatrix &inv, SkMipmapMode)
static SkSamplingOptions AnisoFallback(bool imageIsMipped)
const skcms_TransferFunction * skcms_sRGB_TransferFunction()
const SkCubicResampler cubic
const SkFilterMode filter
const SkMipmapMode mipmap