106static std::unique_ptr<GrFragmentProcessor>
112 auto fp =
Make(shaderMF->shader().get(),
args, ctm);
122 auto mfb =
as_MFB(maskfilter);
123 switch (mfb->type()) {
139 auto mfb =
as_MFB(maskfilter);
140 switch (mfb->type()) {
155 std::optional<ChildType>
type = child.
type();
156 if (!
type.has_value()) {
197 std::unique_ptr<GrFragmentProcessor> inputFP,
198 std::unique_ptr<GrFragmentProcessor> destColorFP,
202 for (
const auto& child : children) {
203 auto [success, childFP] =
MakeChildFP(child, childArgs);
213 std::move(destColorFP),
222 std::unique_ptr<GrFragmentProcessor> srcFP,
223 std::unique_ptr<GrFragmentProcessor> dstFP,
247 return success ? std::move(
fp) :
nullptr;
252 std::unique_ptr<GrFragmentProcessor> srcFP,
253 std::unique_ptr<GrFragmentProcessor> dstFP,
260 std::unique_ptr<GrFragmentProcessor> srcFP,
261 std::unique_ptr<GrFragmentProcessor> dstFP,
266 switch (blender->
type()) {
268 case SkBlenderBase::BlenderType::k##type: \
269 return make_blender_fp(static_cast<const Sk##type##Blender*>(blender), \
286 std::unique_ptr<GrFragmentProcessor> inputFP,
295 SkDEBUGCODE(
const bool fpHasConstIO = !inputFP || inputFP->hasConstantOutputForConstantInput();)
303 if (xferFP ==
nullptr) {
306 SkDEBUGFAIL(
"GrBlendFragmentProcessor::Make returned null unexpectedly");
315 xferFP->hasConstantOutputForConstantInput() >= fpHasConstIO);
322 std::unique_ptr<GrFragmentProcessor> inputFP,
327 auto inputClone = inputFP ? inputFP->clone() :
nullptr;
329 auto [innerSuccess, innerFP] =
330 Make(context, filter->
inner().
get(), std::move(inputFP), dstColorInfo, props);
335 auto [outerSuccess, outerFP] =
336 Make(context, filter->
outer().
get(), std::move(innerFP), dstColorInfo, props);
346 std::unique_ptr<GrFragmentProcessor> inputFP,
352 std::move(inputFP), filter->
src().
get(), alphaType, filter->
dst().
get(), alphaType));
357 std::unique_ptr<GrFragmentProcessor> inputFP,
362 "half4 main(half4 inColor) {"
363 "half factor = 1 - inColor.a;"
364 "factor = exp(-factor * factor * 4) - 0.018;"
365 "return half4(factor);"
372static std::unique_ptr<GrFragmentProcessor>
rgb_to_hsl(std::unique_ptr<GrFragmentProcessor> child) {
375 "half4 main(half4 color) {"
376 "return $rgb_to_hsl(color.rgb, color.a);"
383static std::unique_ptr<GrFragmentProcessor>
hsl_to_rgb(std::unique_ptr<GrFragmentProcessor> child) {
386 "half4 main(half4 color) {"
387 "return $hsl_to_rgb(color.rgb, color.a);"
396 std::unique_ptr<GrFragmentProcessor> inputFP,
399 switch (filter->
domain()) {
422 std::unique_ptr<GrFragmentProcessor> inputFP,
431 "runtime_color_filter",
441 std::unique_ptr<GrFragmentProcessor> inputFP,
450 std::unique_ptr<GrFragmentProcessor> inputFP,
462 working = {dstColorInfo.
colorType(), workingAT, workingCS};
476 std::unique_ptr<GrFragmentProcessor> inputFP,
483 switch (cfb->type()) {
487 case SkColorFilterBase::Type::k##type: \
488 return make_colorfilter_fp(ctx, \
489 static_cast<const Sk##type##ColorFilter*>(cf), \
490 std::move(inputFP), \
529 return std::move(
fp);
543 args.fDstColorInfo->colorSpace(),
546 steps.apply(
color.vec());
557 "half4 main(float2 p) {"
558 "return c.eval(clamp(p, s.LT, s.RB));"
567 if (
fp->compatibleWithCoverageAsAlpha()) {
570 if (
fp->preservesOpaqueInput()) {
636 if (!shader->
isRaw()) {
640 args.fDstColorInfo->colorSpace(),
646 fp = GrBlendFragmentProcessor::Make<SkBlendMode::kDstIn>(std::move(
fp),
nullptr);
669 paintingData->generateBitmaps();
673 const SkBitmap& permutationsBitmap = paintingData->getPermutationsBitmap();
674 const SkBitmap& noiseBitmap = paintingData->getNoiseBitmap();
679 "PerlinNoiseShader_FragmentProcessor_PermutationsView"));
682 context, noiseBitmap,
"PerlinNoiseShader_FragmentProcessor_NoiseView"));
684 if (!permutationsView || !noiseView) {
688 std::unique_ptr<GrFragmentProcessor>
fp =
692 std::move(paintingData),
693 std::move(permutationsView),
694 std::move(noiseView),
709 auto ctx =
args.fContext;
715 if (
args.fDstColorInfo->colorSpace()) {
723 ctx->priv().caps()->maxTextureSize(),
730 if (!ctx->colorTypeSupportedAsSurface(
info.imageInfo.colorType())) {
738 static_cast<uint32_t
>(dstColorType),
744 &
key, kDomain,
sizeof(keyData) /
sizeof(uint32_t),
"Picture Shader Image");
745 memcpy(&
builder[0], &keyData,
sizeof(keyData));
753 const int msaaSampleCount = 0;
754 const bool createWithMips =
false;
755 const bool kUnprotected =
false;
797 args.fDstColorInfo->colorSpace());
801 std::unique_ptr<GrFragmentProcessor>
fp;
847 auto childFP =
Make(shader->
shader().
get(), workingArgs, mRec);
865 std::unique_ptr<GrFragmentProcessor>
fp;
872 "half4 main(float2 p) {"
875 "float t = r0_2 - p.y * p.y;"
881 "return half4(half(t), v, 0, 0);"
886 "TwoPointConicalStripLayout",
897 "uniform half lengthScale;"
898 "half4 main(float2 p) {"
901 "float t = length(p) * lengthScale - r0;"
902 "return half4(half(t), v, 0, 0);"
907 bool isRadiusIncreasing =
dr >= 0;
909 "TwoPointConicalRadialLayout",
915 isRadiusIncreasing ? 1.0f : -1.0f);
931 "uniform int isRadiusIncreasing;"
932 "uniform int isFocalOnCircle;"
933 "uniform int isWellBehaved;"
934 "uniform int isSwapped;"
935 "uniform int isNativelyFocal;"
937 "uniform half invR1;"
940 "half4 main(float2 p) {"
945 "if (bool(isFocalOnCircle)) {"
946 "x_t = dot(p, p) / p.x;"
947 "} else if (bool(isWellBehaved)) {"
948 "x_t = length(p) - p.x * invR1;"
950 "float temp = p.x * p.x - p.y * p.y;"
961 "if (bool(isSwapped) || !bool(isRadiusIncreasing)) {"
962 "x_t = -sqrt(temp) - p.x * invR1;"
964 "x_t = sqrt(temp) - p.x * invR1;"
972 "if (!bool(isWellBehaved)) {"
979 "if (bool(isRadiusIncreasing)) {"
980 "if (bool(isNativelyFocal)) {"
986 "if (bool(isNativelyFocal)) {"
993 "if (bool(isSwapped)) {"
997 "return half4(half(t), v, 0, 0);"
1002 bool isRadiusIncreasing = (1 - focalData.
fFocalX) > 0,
1009 "isRadiusIncreasing", GrSkSLFP::Specialize<int>(isRadiusIncreasing),
1010 "isFocalOnCircle", GrSkSLFP::Specialize<int>(isFocalOnCircle),
1011 "isWellBehaved", GrSkSLFP::Specialize<int>(isWellBehaved),
1012 "isSwapped", GrSkSLFP::Specialize<int>(isSwapped),
1013 "isNativelyFocal", GrSkSLFP::Specialize<int>(isNativelyFocal),
1014 "invR1", 1.0f / focalData.
fR1,
1019 *shader,
args, mRec, std::move(
fp),
matrix.getMaybeNull());
1033 "half4 main(float2 coord) {"
1034 "return half4(half(length(coord)), 1, 0, 0);"
1050 int useAtanWorkaround =
1051 args.fContext->priv().caps()->shaderCaps()->fAtan2ImplementedAsAtanYOverX;
1053 "uniform half bias;"
1054 "uniform half scale;"
1055 "uniform int useAtanWorkaround;"
1057 "half4 main(float2 coord) {"
1059 "if (bool(useAtanWorkaround)) {"
1060 "angle = half(2 * atan(-coord.y, length(coord) - coord.x));"
1064 "angle = (coord.x != 0) ? half(atan(-coord.y, -coord.x)) :"
1065 " sign(coord.y) * -1.5707963267949;"
1069 "half t = (angle * 0.1591549430918 + 0.5 + bias) * scale;"
1070 "return half4(t, 1, 0, 0);"
1077 "bias", shader->
tBias(),
1078 "scale", shader->
tScale(),
1090 case SkShaderBase::GradientType::k##type: \
1091 return make_gradient_fp(static_cast<const Sk##type##Gradient*>(shader), args, mRec);
1095 SkDEBUGFAIL(
"Gradient shader says its type is none");
1114 switch (
base->type()) {
1116 case SkShaderBase::ShaderType::k##type: \
1117 return make_shader_fp(static_cast<const Sk##type##Shader*>(base), args, mRec);
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static GrFPResult GrFPNullableSuccess(std::unique_ptr< GrFragmentProcessor > fp)
static GrFPResult GrFPSuccess(std::unique_ptr< GrFragmentProcessor > fp)
std::tuple< bool, std::unique_ptr< GrFragmentProcessor > > GrFPResult
static GrFPResult GrFPFailure(std::unique_ptr< GrFragmentProcessor > fp)
static constexpr SkColorType GrColorTypeToSkColorType(GrColorType ct)
@ kTopLeft_GrSurfaceOrigin
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
#define SkDEBUGFAIL(message)
@ kLastCoeffMode
last porter duff blend mode
#define SK_ALL_BLENDERS(M)
SkBlenderBase * as_BB(SkBlender *blend)
#define SK_ALL_COLOR_FILTERS(M)
static SkColorFilterBase * as_CFB(SkColorFilter *filter)
SkColorSpace * sk_srgb_singleton()
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
@ kUnknown_SkColorType
uninitialized
SkPMColor4f SkColorToPMColor4f(SkColor c, const GrColorInfo &colorInfo)
std::tuple< GrSurfaceProxyView, GrColorType > GrMakeCachedBitmapProxyView(GrRecordingContext *rContext, const SkBitmap &bitmap, std::string_view label, skgpu::Mipmapped mipmapped)
static bool ok(int result)
SkMaskFilterBase * as_MFB(SkMaskFilter *mf)
sk_sp< T > sk_ref_sp(T *obj)
SkRuntimeEffect * SkMakeRuntimeEffect(SkRuntimeEffect::Result(*make)(SkString, const SkRuntimeEffect::Options &), const char *sksl, SkRuntimeEffect::Options options=SkRuntimeEffect::Options{})
SkShaderBase * as_SB(SkShader *shader)
#define SK_ALL_GRADIENTS(M)
#define SK_ALL_SHADERS(M)
SkDEBUGCODE(SK_SPI) SkThreadID SkGetThreadID()
static std::unique_ptr< GrFragmentProcessor > Make(std::unique_ptr< GrFragmentProcessor > inputFP, GrRecordingContext *context, const SkBitmap &bitmap)
const GrCaps * caps() const
sk_sp< SkColorSpace > refColorSpace() const
SkColorSpace * colorSpace() const
GrColorType colorType() const
SkAlphaType alphaType() const
static std::unique_ptr< GrFragmentProcessor > MakeColor(SkPMColor4f color)
static std::unique_ptr< GrFragmentProcessor > DeviceSpace(std::unique_ptr< GrFragmentProcessor >)
static std::unique_ptr< GrFragmentProcessor > MulInputByChildAlpha(std::unique_ptr< GrFragmentProcessor > child)
static std::unique_ptr< GrFragmentProcessor > DestColor()
static std::unique_ptr< GrFragmentProcessor > ColorMatrix(std::unique_ptr< GrFragmentProcessor > child, const float matrix[20], bool unpremulInput, bool clampRGBOutput, bool premulOutput)
static std::unique_ptr< GrFragmentProcessor > Compose(std::unique_ptr< GrFragmentProcessor > f, std::unique_ptr< GrFragmentProcessor > g)
static std::unique_ptr< GrFragmentProcessor > Make(const SkMatrix &matrix, std::unique_ptr< GrFragmentProcessor > child)
static std::unique_ptr< GrFragmentProcessor > Make(SkPerlinNoiseShaderType type, int numOctaves, bool stitchTiles, std::unique_ptr< SkPerlinNoiseShader::PaintingData > paintingData, GrSurfaceProxyView permutationsView, GrSurfaceProxyView noiseView, const GrCaps &caps)
bool assignUniqueKeyToProxy(const skgpu::UniqueKey &, GrTextureProxy *)
sk_sp< GrTextureProxy > findOrCreateProxyByUniqueKey(const skgpu::UniqueKey &, UseAllocator=UseAllocator::kYes)
GrRecordingContextPriv priv()
@ kCompatibleWithCoverageAsAlpha
static std::unique_ptr< GrSkSLFP > MakeWithData(sk_sp< SkRuntimeEffect > effect, const char *name, sk_sp< SkColorSpace > dstColorSpace, std::unique_ptr< GrFragmentProcessor > inputFP, std::unique_ptr< GrFragmentProcessor > destColorFP, const sk_sp< const SkData > &uniforms, SkSpan< std::unique_ptr< GrFragmentProcessor > > childFPs)
static std::unique_ptr< GrSkSLFP > Make(const SkRuntimeEffect *effect, const char *name, std::unique_ptr< GrFragmentProcessor > inputFP, OptFlags optFlags, Args &&... args)
static GrSpecializedUniform< T > Specialize(const T &value)
GrTextureProxy * asTextureProxy() const
static std::unique_ptr< GrFragmentProcessor > Make(GrSurfaceProxyView, SkAlphaType, const SkMatrix &=SkMatrix::I(), GrSamplerState::Filter=GrSamplerState::Filter::kNearest, GrSamplerState::MipmapMode mipmapMode=GrSamplerState::MipmapMode::kNone)
sk_sp< SkShader > dst() const
sk_sp< SkShader > src() const
virtual BlenderType type() const =0
const SkMatrix & ctm() const
sk_sp< SkShader > proxyShader() const
sk_sp< SkColorSpace > colorSpace() const
sk_sp< SkColorFilterBase > filter() const
sk_sp< SkShader > shader() const
static sk_sp< SkColorSpace > MakeSRGB()
uint32_t toXYZD50Hash() const
uint32_t transferFnHash() const
sk_sp< SkColorFilterBase > inner() const
sk_sp< SkColorFilterBase > outer() const
const SkPoint & getStartCenter() const
SkScalar getDiffRadius() const
SkScalar getCenterX1() const
SkScalar getStartRadius() const
const FocalData & getFocalData() const
sk_sp< SkShader > shader() const
SkSamplingOptions sampling() const
SkTileMode tileModeX() const
sk_sp< SkImage > image() const
SkTileMode tileModeY() const
SkColorSpace * colorSpace() const
SkISize dimensions() const
SkAlphaType alphaType() const
const SkMatrix & localMatrix() const
sk_sp< SkShader > wrappedShader() const
const float * matrix() const
static SkMatrix Scale(SkScalar sx, SkScalar sy)
static SkMatrix Translate(SkScalar dx, SkScalar dy)
bool invert(SkMatrix *inverse) const
static const SkMatrix & I()
SkPerlinNoiseShaderType noiseType() const
std::unique_ptr< PaintingData > getPaintingData() const
SkTileMode tileModeY() const
SkTileMode tileModeX() const
SkFilterMode filter() const
sk_sp< SkPicture > picture() const
uint32_t uniqueID() const
sk_sp< SkRuntimeEffect > effect() const
SkSpan< const SkRuntimeEffect::ChildPtr > children() const
sk_sp< const SkData > uniforms() const
SkSpan< const SkRuntimeEffect::ChildPtr > children() const
sk_sp< SkRuntimeEffect > effect() const
sk_sp< const SkData > uniforms() const
static sk_sp< const SkData > TransformUniforms(SkSpan< const SkRuntimeEffect::Uniform > uniforms, sk_sp< const SkData > originalData, const SkColorSpaceXformSteps &)
static bool SupportsConstantOutputForConstantInput(const SkRuntimeEffect *effect)
static bool CanDraw(const SkCapabilities *, const SkSL::Program *)
SkBlender * blender() const
SkShader * shader() const
std::optional< ChildType > type() const
SkColorFilter * colorFilter() const
static Result MakeForColorFilter(SkString sksl, const Options &)
SkSpan< const Uniform > uniforms() const
static Result MakeForShader(SkString sksl, const Options &)
SkSpan< const SkRuntimeEffect::ChildPtr > children() const
sk_sp< const SkData > uniformData(const SkColorSpace *dstCS) const
sk_sp< SkRuntimeEffect > effect() const
SkRuntimeEffect * asRuntimeEffect() const override
virtual GradientType asGradient(GradientInfo *info=nullptr, SkMatrix *localMatrix=nullptr) const
void markTotalMatrixInvalid()
MatrixRec applied() const
std::tuple< SkMatrix, bool > applyForFragmentProcessor(const SkMatrix &postInv) const
MatrixRec concat(const SkMatrix &m) const
SkMatrix totalMatrix() const
const SkBitmap & bitmap() const
sk_sp< SkShader > shader() const
sk_sp< SkColorSpace > workingSpace() const
static Domain GenerateDomain()
FlutterSemanticsFlag flags
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
std::unique_ptr< GrFragmentProcessor > Make(std::unique_ptr< GrFragmentProcessor > src, std::unique_ptr< GrFragmentProcessor > dst, SkBlendMode mode, bool shareBlendLogic=true)
static std::unique_ptr< GrFragmentProcessor > make_fp_from_shader_mask_filter(const SkMaskFilterBase *maskfilter, const GrFPArgs &args, const SkMatrix &ctm)
static std::unique_ptr< GrFragmentProcessor > make_gradient_fp(const SkConicalGradient *shader, const GrFPArgs &args, const SkShaders::MatrixRec &mRec)
GrFPResult MakeChildFP(const SkRuntimeEffect::ChildPtr &child, const GrFPArgs &childArgs)
static std::unique_ptr< GrFragmentProcessor > make_blender_fp(const SkRuntimeBlender *rtb, std::unique_ptr< GrFragmentProcessor > srcFP, std::unique_ptr< GrFragmentProcessor > dstFP, const GrFPArgs &fpArgs)
static SkPMColor4f map_color(const SkColor4f &c, SkColorSpace *src, SkColorSpace *dst)
std::unique_ptr< GrFragmentProcessor > Make(const SkMaskFilter *maskfilter, const GrFPArgs &args, const SkMatrix &ctm)
static std::unique_ptr< GrFragmentProcessor > hsl_to_rgb(std::unique_ptr< GrFragmentProcessor > child)
static std::unique_ptr< GrFragmentProcessor > rgb_to_hsl(std::unique_ptr< GrFragmentProcessor > child)
static bool needs_subset(sk_sp< const SkImage > img, const SkRect &subset)
static std::unique_ptr< GrFragmentProcessor > make_shader_fp(const SkBlendShader *shader, const GrFPArgs &args, const SkShaders::MatrixRec &mRec)
bool IsSupported(const SkMaskFilter *maskfilter)
static GrFPResult make_colorfilter_fp(GrRecordingContext *, const SkBlendModeColorFilter *filter, std::unique_ptr< GrFragmentProcessor > inputFP, const GrColorInfo &dstColorInfo, const SkSurfaceProps &props)
static GrFPResult make_effect_fp(sk_sp< SkRuntimeEffect > effect, const char *name, sk_sp< const SkData > uniforms, std::unique_ptr< GrFragmentProcessor > inputFP, std::unique_ptr< GrFragmentProcessor > destColorFP, SkSpan< const SkRuntimeEffect::ChildPtr > children, const GrFPArgs &childArgs)
std::unique_ptr< GrFragmentProcessor > MakeGradientFP(const SkGradientBaseShader &shader, const GrFPArgs &args, const SkShaders::MatrixRec &mRec, std::unique_ptr< GrFragmentProcessor > layout, const SkMatrix *overrideMatrix)
std::unique_ptr< GrFragmentProcessor > MakeLinear(const SkLinearGradient &shader, const GrFPArgs &args, const SkShaders::MatrixRec &mRec)
unsigned useCenter Optional< SkMatrix > matrix
sk_sp< const SkImage > image
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
DEF_SWITCHES_START aot vmservice shared library name
const myers::Point & get< 0 >(const myers::Segment &s)
std::unique_ptr< GrFragmentProcessor > AsFragmentProcessor(GrRecordingContext *rContext, const SkImage *img, SkSamplingOptions sampling, const SkTileMode tileModes[2], const SkMatrix &m, const SkRect *subset, const SkRect *domain)
std::tuple< GrSurfaceProxyView, GrColorType > AsView(GrRecordingContext *rContext, const SkImage *img, skgpu::Mipmapped mipmapped, GrImageTexGenPolicy policy)
const SkSurfaceProps & fSurfaceProps
const GrColorInfo * fDstColorInfo
GrRecordingContext * fContext
bool isNativelyFocal() const
bool isWellBehaved() const
bool isFocalOnCircle() const
static CachedImageInfo Make(const SkRect &bounds, const SkMatrix &totalM, SkColorType dstColorType, SkColorSpace *dstColorSpace, const int maxTextureSize, const SkSurfaceProps &propsIn)
static SkRect Make(const SkISize &size)