38#ifdef SK_ENABLE_LEGACY_SHADERCONTEXT
50 constexpr SkM44 kMitchell =
SkM44( 1.f/18.f, -9.f/18.f, 15.f/18.f, -7.f/18.f,
51 16.f/18.f, 0.f/18.f, -36.f/18.f, 21.f/18.f,
52 1.f/18.f, 9.f/18.f, 27.f/18.f, -21.f/18.f,
53 0.f/18.f, 0.f/18.f, -6.f/18.f, 7.f/18.f);
55 constexpr SkM44 kCatmull =
SkM44(0.0f, -0.5f, 1.0f, -0.5f,
56 1.0f, 0.0f, -2.5f, 1.5f,
57 0.0f, 0.5f, 2.0f, -1.5f,
58 0.0f, 0.0f, -0.5f, 0.5f);
60 if (
B == 1.0f/3 &&
C == 1.0f/3) {
63 if (
B == 0 &&
C == 0.5f) {
67 return SkM44( (1.f/6)*
B, -(3.f/6)*
B -
C, (3.f/6)*
B + 2*
C, - (1.f/6)*
B -
C,
68 1 - (2.f/6)*
B, 0, -3 + (12.f/6)*
B +
C, 2 - (9.f/6)*
B -
C,
69 (1.f/6)*
B, (3.f/6)*
B +
C, 3 - (15.f/6)*
B - 2*
C, -2 + (9.f/6)*
B +
C,
70 0, 0, -
C, (1.f/6)*
B +
C);
78#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
100 bool clampAsIfUnpremul)
101 : fImage(
std::move(img))
107 , fClampAsIfUnpremul(clampAsIfUnpremul) {
109 SkASSERT(!fRaw || !fClampAsIfUnpremul);
139 bool readSampling =
true;
143 readSampling =
false;
151 if (
buffer.isVersionLT(SkPicturePriv::Version::kNoShaderLocalMatrix)) {
152 buffer.readMatrix(&localMatrix);
159 bool raw =
buffer.isVersionLT(SkPicturePriv::Version::kRawImageShaders) ?
false
170 buffer.writeUInt((
unsigned)fTileModeX);
171 buffer.writeUInt((
unsigned)fTileModeY);
173 buffer.writeSampling(fSampling);
176 SkASSERT(fClampAsIfUnpremul ==
false);
190#ifdef SK_ENABLE_LEGACY_SHADERCONTEXT
192static bool legacy_shader_can_handle(
const SkMatrix&
inv) {
202 const SkScalar max_dev_coord = 32767.0f;
208 +max_fixed32dot32, +max_fixed32dot32).
contains(
src)) {
222 if (fImage->
colorType() != kN32_SkColorType) {
225 if (fTileModeX != fTileModeY) {
238 const std::tuple<SkFilterMode,SkMipmapMode> supported[] = {
243 for (
auto [
f,
m] : supported) {
264 if (fImage->
width() > 32767 ||
265 fImage->
height() > 32767) {
270 if (!rec.fMatrixRec.totalInverse(&
inv) || !legacy_shader_can_handle(
inv)) {
274 if (!rec.isLegacyCompatible(fImage->
colorSpace())) {
278 return SkBitmapProcLegacyShader::MakeContext(*
this, fTileModeX, fTileModeY,
sampling,
298 bool clampAsIfUnpremul) {
321 return s->makeWithLocalMatrix(localMatrix ? *localMatrix :
SkMatrix::I());
329 bool clampAsIfUnpremul) {
330 auto is_unit = [](
float x) {
331 return x >= 0 &&
x <= 1;
353 return s->makeWithLocalMatrix(localMatrix ? *localMatrix :
SkMatrix::I());
380 bool strictSrcSubset,
393 if (!
src.intersect(imgBounds)) {
403 if (strictSrcSubset) {
414 if (imageIsAlphaOnly &&
paint->getShader()) {
421 paint->setShader(std::move(imgShader));
429struct MipLevelHelper {
473 gather->roundDownAtInteger =
true;
485 if (
gather->roundDownAtInteger) {
501 matrix.getTranslateX() == (
int)
matrix.getTranslateX() &&
502 matrix.getTranslateY() == (
int)
matrix.getTranslateY()) {
536 MipLevelHelper upper;
537 std::tie(upper.pm, upper.inv) = access->level();
546 if (!mRec.
apply(rec, upper.inv)) {
550 upper.allocAndInit(alloc,
sampling, fTileModeX, fTileModeY);
552 MipLevelHelper
lower;
555 if (lowerWeight > 0) {
556 std::tie(
lower.pm,
lower.inv) = access->lowerLevel();
559 mipmapCtx->
scaleX =
static_cast<float>(
lower.pm.width()) / upper.pm.width();
560 mipmapCtx->
scaleY =
static_cast<float>(
lower.pm.height()) / upper.pm.height();
564 p->append(SkRasterPipelineOp::mipmap_linear_init, mipmapCtx);
569 auto append_tiling_and_gather = [&](
const MipLevelHelper*
level) {
571 p->append(SkRasterPipelineOp::decal_x_and_y,
level->decalCtx);
573 switch (fTileModeX) {
577 p->append(SkRasterPipelineOp::mirror_x,
level->limitX);
580 p->append(SkRasterPipelineOp::repeat_x,
level->limitX);
583 p->append(SkRasterPipelineOp::decal_x,
level->decalCtx);
586 switch (fTileModeY) {
590 p->append(SkRasterPipelineOp::mirror_y,
level->limitY);
593 p->append(SkRasterPipelineOp::repeat_y,
level->limitY);
596 p->append(SkRasterPipelineOp::decal_y,
level->decalCtx);
601 void* ctx =
level->gather;
602 switch (
level->pm.colorType()) {
614 p->append(SkRasterPipelineOp::gather_1010102, ctx);
618 p->append(SkRasterPipelineOp::gather_16161616, ctx);
625 p->append(SkRasterPipelineOp::gather_10101010_xr, ctx);
626 p->append(SkRasterPipelineOp::swap_rb);
631 p->append(SkRasterPipelineOp::alpha_to_gray );
break;
634 p->append(SkRasterPipelineOp::alpha_to_red );
break;
637 p->append(SkRasterPipelineOp::force_opaque );
break;
640 p->append(SkRasterPipelineOp::gather_1010102, ctx);
641 p->append(SkRasterPipelineOp::swap_rb);
645 p->append(SkRasterPipelineOp::gather_1010102, ctx);
646 p->append(SkRasterPipelineOp::force_opaque);
650 p->append(SkRasterPipelineOp::gather_1010102_xr, ctx);
651 p->append(SkRasterPipelineOp::force_opaque);
652 p->append(SkRasterPipelineOp::swap_rb);
656 p->append(SkRasterPipelineOp::gather_1010102, ctx);
657 p->append(SkRasterPipelineOp::force_opaque);
658 p->append(SkRasterPipelineOp::swap_rb);
662 p->append(SkRasterPipelineOp::gather_8888, ctx);
663 p->append(SkRasterPipelineOp::swap_rb);
667 p->append(SkRasterPipelineOp::gather_8888, ctx);
673 if (
level->decalCtx) {
674 p->append(SkRasterPipelineOp::check_decal_mask,
level->decalCtx);
678 auto append_misc = [&] {
695 ? SkRasterPipelineOp::clamp_01
696 : SkRasterPipelineOp::clamp_gamut);
716 p->append(SkRasterPipelineOp::bilerp_clamp_8888, upper.gather);
718 p->append(SkRasterPipelineOp::swap_rb);
720 return append_misc();
727 p->append(SkRasterPipelineOp::bicubic_clamp_8888, upper.gather);
729 p->append(SkRasterPipelineOp::swap_rb);
731 return append_misc();
739 const MipLevelHelper*
level) {
740 p->append(setup_x, sampler);
741 p->append(setup_y, sampler);
742 append_tiling_and_gather(
level);
743 p->append(SkRasterPipelineOp::accumulate, sampler);
746 auto sample_level = [&](
const MipLevelHelper*
level) {
750 p->append(SkRasterPipelineOp::bicubic_setup, sampler);
752 sample(SkRasterPipelineOp::bicubic_n3x, SkRasterPipelineOp::bicubic_n3y,
level);
753 sample(SkRasterPipelineOp::bicubic_n1x, SkRasterPipelineOp::bicubic_n3y,
level);
754 sample(SkRasterPipelineOp::bicubic_p1x, SkRasterPipelineOp::bicubic_n3y,
level);
755 sample(SkRasterPipelineOp::bicubic_p3x, SkRasterPipelineOp::bicubic_n3y,
level);
757 sample(SkRasterPipelineOp::bicubic_n3x, SkRasterPipelineOp::bicubic_n1y,
level);
758 sample(SkRasterPipelineOp::bicubic_n1x, SkRasterPipelineOp::bicubic_n1y,
level);
759 sample(SkRasterPipelineOp::bicubic_p1x, SkRasterPipelineOp::bicubic_n1y,
level);
760 sample(SkRasterPipelineOp::bicubic_p3x, SkRasterPipelineOp::bicubic_n1y,
level);
762 sample(SkRasterPipelineOp::bicubic_n3x, SkRasterPipelineOp::bicubic_p1y,
level);
763 sample(SkRasterPipelineOp::bicubic_n1x, SkRasterPipelineOp::bicubic_p1y,
level);
764 sample(SkRasterPipelineOp::bicubic_p1x, SkRasterPipelineOp::bicubic_p1y,
level);
765 sample(SkRasterPipelineOp::bicubic_p3x, SkRasterPipelineOp::bicubic_p1y,
level);
767 sample(SkRasterPipelineOp::bicubic_n3x, SkRasterPipelineOp::bicubic_p3y,
level);
768 sample(SkRasterPipelineOp::bicubic_n1x, SkRasterPipelineOp::bicubic_p3y,
level);
769 sample(SkRasterPipelineOp::bicubic_p1x, SkRasterPipelineOp::bicubic_p3y,
level);
770 sample(SkRasterPipelineOp::bicubic_p3x, SkRasterPipelineOp::bicubic_p3y,
level);
772 p->append(SkRasterPipelineOp::move_dst_src);
774 p->append(SkRasterPipelineOp::bilinear_setup, sampler);
776 sample(SkRasterPipelineOp::bilinear_nx, SkRasterPipelineOp::bilinear_ny,
level);
777 sample(SkRasterPipelineOp::bilinear_px, SkRasterPipelineOp::bilinear_ny,
level);
778 sample(SkRasterPipelineOp::bilinear_nx, SkRasterPipelineOp::bilinear_py,
level);
779 sample(SkRasterPipelineOp::bilinear_px, SkRasterPipelineOp::bilinear_py,
level);
781 p->append(SkRasterPipelineOp::move_dst_src);
783 append_tiling_and_gather(
level);
787 sample_level(&upper);
790 p->append(SkRasterPipelineOp::mipmap_linear_update, mipmapCtx);
791 sample_level(&
lower);
792 p->append(SkRasterPipelineOp::mipmap_linear_finish, mipmapCtx);
795 return append_misc();
static SkM44 inv(const SkM44 &m)
@ 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
#define SK_REGISTER_FLATTENABLE(type)
static bool SkColorTypeIsAlphaOnly(SkColorType ct)
SK_SPI sk_sp< SkImage > SkMakeImageFromRasterBitmap(const SkBitmap &, SkCopyPixelsMode)
static SkSamplingOptions tweak_sampling(SkSamplingOptions sampling, const SkMatrix &matrix)
static SkTileMode optimize(SkTileMode tm, int dimension)
SkRect SkModifyPaintAndDstForDrawImageRect(const SkImage *image, const SkSamplingOptions &sampling, SkRect src, SkRect dst, bool strictSrcSubset, SkPaint *paint)
sk_sp< SkShader > SkMakeBitmapShaderForPaint(const SkPaint &paint, const SkBitmap &src, SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &sampling, const SkMatrix *localMatrix, SkCopyPixelsMode mode)
static SkImage_Base * as_IB(SkImage *image)
static constexpr int32_t SK_MaxS32
static bool apply(Pass *pass, SkRecord *record)
sk_sp< T > sk_ref_sp(T *obj)
auto make(Ctor &&ctor) -> decltype(ctor(nullptr))
SkSamplingOptions sampling() const
static sk_sp< SkShader > Make(sk_sp< SkImage >, SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix, bool clampAsIfUnpremul=false)
static SkM44 CubicResamplerMatrix(float B, float C)
bool isOpaque() const override
static sk_sp< SkShader > MakeSubset(sk_sp< SkImage >, const SkRect &subset, SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix, bool clampAsIfUnpremul=false)
sk_sp< SkImage > image() const
SkImageShader(sk_sp< SkImage >, const SkRect &subset, SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, bool raw, bool clampAsIfUnpremul)
static sk_sp< SkShader > MakeRaw(sk_sp< SkImage >, SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix)
SkColorSpace * colorSpace() const
SkISize dimensions() const
SkAlphaType alphaType() const
sk_sp< SkShader > makeShader(SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix=nullptr) const
SkColorType colorType() const
void getColMajor(SkScalar v[]) const
static SkMatrix RectToRect(const SkRect &src, const SkRect &dst, ScaleToFit mode=kFill_ScaleToFit)
static SkMatrix Concat(const SkMatrix &a, const SkMatrix &b)
static const SkMatrix & I()
void normalizePerspective()
bool mapRect(SkRect *dst, const SkRect &src, SkApplyPerspectiveClip pc=SkApplyPerspectiveClip::kYes) const
@ kTranslate_Mask
translation SkMatrix
static SkMipmapAccessor * Make(SkArenaAlloc *, const SkImage *, const SkMatrix &inv, SkMipmapMode)
@ kFill_Style
set to fill geometry
@ kNoFilterQualityShaders_Version
int rowBytesAsPixels() const
const void * addr() const
static SkSamplingOptions AnisoFallback(bool imageIsMipped)
static void RegisterFlattenables()
std::optional< MatrixRec > apply(const SkStageRec &rec, const SkMatrix &postInv={}) const
bool totalInverse(SkMatrix *out) const
bool totalMatrixIsValid() const
static bool needs_subset(sk_sp< const SkImage > img, const SkRect &subset)
SI T gather(const T *p, U32 ix)
void(* S32_alpha_D32_filter_DXDY)(const SkBitmapProcState &, const uint32_t *xy, int count, SkPMColor *)
unsigned useCenter Optional< SkMatrix > matrix
sk_sp< const SkImage > image
SkSamplingOptions sampling
SK_API sk_sp< SkShader > Blend(SkBlendMode mode, sk_sp< SkShader > dst, sk_sp< SkShader > src)
SK_API sk_sp< SkShader > RawImage(sk_sp< SkImage > image, SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &options, const SkMatrix *localMatrix=nullptr)
SK_API sk_sp< SkShader > Image(sk_sp< SkImage > image, SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &options, const SkMatrix *localMatrix=nullptr)
SK_API sk_sp< SkShader > Empty()
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
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
SkSamplingOptions(SkFilterMode::kLinear))
constexpr bool contains(std::string_view str, std::string_view needle)
const skcms_TransferFunction * skcms_sRGB_TransferFunction()
static SkRect Make(const SkISize &size)
static constexpr SkRect MakeEmpty()
bool contains(SkScalar x, SkScalar y) const
static constexpr SkRect MakeWH(float w, float h)
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
const SkCubicResampler cubic
const SkFilterMode filter
const SkMipmapMode mipmap
SkRasterPipeline * fPipeline