35bool precompilebase_is_valid_as_child(
const PrecompileBase *child) {
40 switch (child->type()) {
61 inline static constexpr int kNumIntrinsicCombinations = 2;
63 int numIntrinsicCombinations()
const override {
return kNumIntrinsicCombinations; }
65 void addToKey(
const KeyContext& keyContext,
67 PipelineDataGatherer* gatherer,
68 int desiredCombination)
const override {
69 SkASSERT(desiredCombination < kNumIntrinsicCombinations);
74 YUVImageShaderBlock::ImageData imgData(desiredCombination == 1 ? kDefaultCubicSampling
84 return sk_make_sp<PrecompileYUVImageShader>();
110 , fBlender(
std::move(blender)) {
114 void onCreatePipelines(
130 paintOptions.
setShaders({ std::move(blendShader) });
165 if (std::optional<SkBlendMode> bm = blender->priv().asBlendMode()) {
176 return sk_make_sp<PrecompileBlendFilterImageFilter>(std::move(blender),
inputs);
181void create_blur_imagefilter_pipelines(
214 void onCreatePipelines(
219 create_blur_imagefilter_pipelines(keyContext, gatherer, processCombination);
225 return sk_make_sp<PrecompileBlurImageFilter>(
SkSpan(&input, 1));
234 , fColorFilter(
std::move(colorFilter)) {
242 void onCreatePipelines(
243 const KeyContext& keyContext,
244 PipelineDataGatherer* gatherer,
253 paintOptions.setShaders({ std::move(imageShader) });
254 paintOptions.setColorFilters({ fColorFilter });
255 paintOptions.setBlendModes(kBlendModes);
257 paintOptions.priv().buildCombinations(keyContext,
271 if (colorFilter && input) {
274 colorFilter = colorFilter->makeComposed(std::move(inputCF));
281 filter = sk_make_sp<PrecompileColorFilterImageFilter>(std::move(colorFilter),
295 void onCreatePipelines(
321 return sk_make_sp<PrecompileDisplacementMapImageFilter>(
SkSpan(&input, 1));
332 void onCreatePipelines(
355 return sk_make_sp<PrecompileLightingImageFilter>(
SkSpan(&input, 1));
366 void onCreatePipelines(
392 return sk_make_sp<PrecompileMatrixConvolutionImageFilter>(
SkSpan(&input, 1));
403 void onCreatePipelines(
433 linear.setBlendModes(kBlendModes);
435 linear.priv().buildCombinations(keyContext,
447 return sk_make_sp<PrecompileMorphologyImageFilter>(
SkSpan(&input, 1));
458 void createPipelines(
462 create_blur_imagefilter_pipelines(keyContext, gatherer, processCombination);
467 return sk_make_sp<PrecompileBlurMaskFilter>();
476 : fChild(
std::move(cf)) {
481 : fChild(
std::move(child)) {
482 SkASSERT(precompilebase_is_valid_as_child(fChild.get()));
487 switch (fChild->type()) {
522int num_options_in_set(
const std::vector<PrecompileChildPtr>& optionSet) {
526 if (childOption.base()) {
535void add_children_to_key(
const KeyContext& keyContext,
536 PaintParamsKeyBuilder*
builder,
537 PipelineDataGatherer* gatherer,
538 int desiredCombination,
539 const std::vector<PrecompileChildPtr>& optionSet,
547 int remainingCombinations = desiredCombination;
549 for (
size_t index = 0; index < optionSet.size(); ++index) {
550 const PrecompileChildPtr& childOption = optionSet[index];
552 const int numChildCombos = childOption.base() ? childOption.base()->priv().numCombinations()
554 const int curCombo = remainingCombinations % numChildCombos;
555 remainingCombinations /= numChildCombos;
557 std::optional<ChildType>
type = childOption.type();
559 childOption.shader()->priv().addToKey(childContext,
builder, gatherer, curCombo);
561 childOption.colorFilter()->priv().addToKey(childContext,
builder, gatherer, curCombo);
563 childOption.blender()->priv().addToKey(childContext,
builder, gatherer, curCombo);
568 switch (childInfo[index].
type) {
596 : fEffect(
std::move(effect)) {
597 fChildOptions.reserve(childOptions.
size());
599 fChildOptions.push_back({ c.begin(), c.end() });
604 int numChildCombinations()
const override {
606 for (
const std::vector<PrecompileChildPtr>& optionSet : fChildOptions) {
607 numOptions += num_options_in_set(optionSet);
610 return numOptions ? numOptions : 1;
613 void addToKey(
const KeyContext& keyContext,
614 PaintParamsKeyBuilder*
builder,
615 PipelineDataGatherer* gatherer,
616 int desiredCombination)
const override {
618 SkASSERT(desiredCombination < this->numCombinations());
624 for (
const std::vector<PrecompileChildPtr>& optionSet : fChildOptions) {
625 int numOptionsInSet = num_options_in_set(optionSet);
627 if (desiredCombination < numOptionsInSet) {
628 add_children_to_key(keyContext,
builder, gatherer, desiredCombination, optionSet,
633 desiredCombination -= numOptionsInSet;
640 std::vector<std::vector<PrecompileChildPtr>> fChildOptions;
649 return sk_make_sp<PrecompileRTEffect<PrecompileShader>>(std::move(effect), childOptions);
658 return sk_make_sp<PrecompileRTEffect<PrecompileColorFilter>>(std::move(effect), childOptions);
667 return sk_make_sp<PrecompileRTEffect<PrecompileBlender>>(std::move(effect), childOptions);
@ kSrcOver
r = s + (1-sa)*d
constexpr SkPMColor4f SK_PMColor4fTRANSPARENT
sk_sp< T > sk_ref_sp(T *obj)
SkSpan(Container &&) -> SkSpan< std::remove_pointer_t< decltype(std::data(std::declval< Container >()))> >
SkSpan< const Child > children() const
constexpr size_t size() const
PaintOptions::ProcessCombination ProcessCombination
void buildCombinations(const KeyContext &keyContext, PipelineDataGatherer *gatherer, DrawTypeFlags drawTypes, bool withPrimitiveBlender, Coverage coverage, const ProcessCombination &processCombination) const
void setBlendModes(SkSpan< const SkBlendMode > blendModes)
void setShaders(SkSpan< const sk_sp< PrecompileShader > > shaders)
PrecompileBlendFilterImageFilter(sk_sp< PrecompileBlender > blender, SkSpan< sk_sp< PrecompileImageFilter > > inputs)
int numCombinations() const
PrecompileBlenderPriv priv()
PrecompileBlurImageFilter(SkSpan< sk_sp< PrecompileImageFilter > > inputs)
PrecompileBlurMaskFilter()
PrecompileShader * shader() const
PrecompileBlender * blender() const
std::optional< SkRuntimeEffect::ChildType > type() const
PrecompileColorFilter * colorFilter() const
PrecompileChildPtr()=default
PrecompileColorFilterImageFilter(sk_sp< PrecompileColorFilter > colorFilter, sk_sp< PrecompileImageFilter > input)
PrecompileDisplacementMapImageFilter(SkSpan< sk_sp< PrecompileImageFilter > > inputs)
friend class PaintOptions
virtual sk_sp< PrecompileColorFilter > isColorFilterNode() const
const PrecompileImageFilter * getInput(int index) const
PrecompileLightingImageFilter(SkSpan< sk_sp< PrecompileImageFilter > > inputs)
PrecompileMatrixConvolutionImageFilter(SkSpan< sk_sp< PrecompileImageFilter > > inputs)
PrecompileMorphologyImageFilter(SkSpan< sk_sp< PrecompileImageFilter > > inputs)
PrecompileRTEffect(sk_sp< SkRuntimeEffect > effect, SkSpan< const PrecompileChildOptions > childOptions)
PrecompileYUVImageShader()
SK_API sk_sp< PrecompileBlender > Arithmetic()
SK_API sk_sp< PrecompileBlender > Mode(SkBlendMode)
SK_API sk_sp< PrecompileImageFilter > Blur(sk_sp< PrecompileImageFilter > input)
SK_API sk_sp< PrecompileImageFilter > ColorFilter(sk_sp< PrecompileColorFilter > colorFilter, sk_sp< PrecompileImageFilter > input)
SK_API sk_sp< PrecompileImageFilter > MatrixConvolution(sk_sp< PrecompileImageFilter > input)
SK_API sk_sp< PrecompileImageFilter > DisplacementMap(sk_sp< PrecompileImageFilter > input)
SK_API sk_sp< PrecompileImageFilter > Arithmetic(sk_sp< PrecompileImageFilter > background, sk_sp< PrecompileImageFilter > foreground)
SK_API sk_sp< PrecompileImageFilter > Morphology(sk_sp< PrecompileImageFilter > input)
SK_API sk_sp< PrecompileImageFilter > Lighting(sk_sp< PrecompileImageFilter > input)
SK_API sk_sp< PrecompileImageFilter > Blend(SkBlendMode bm, sk_sp< PrecompileImageFilter > background, sk_sp< PrecompileImageFilter > foreground)
SK_API sk_sp< PrecompileMaskFilter > Blur()
sk_sp< PrecompileShader > Lighting(sk_sp< PrecompileShader > wrapped)
sk_sp< PrecompileShader > Image(SkEnumBitMask< PrecompileImageShaderFlags >)
sk_sp< PrecompileShader > Displacement(sk_sp< PrecompileShader > displacement, sk_sp< PrecompileShader > color)
sk_sp< PrecompileShader > LinearMorphology(sk_sp< PrecompileShader > wrapped)
sk_sp< PrecompileShader > MatrixConvolution(sk_sp< PrecompileShader > wrapped)
sk_sp< PrecompileShader > SparseMorphology(sk_sp< PrecompileShader > wrapped)
sk_sp< PrecompileShader > Blur(sk_sp< PrecompileShader > wrapped)
SK_API sk_sp< PrecompileShader > Blend(SkSpan< const SkBlendMode > blendModes, SkSpan< const sk_sp< PrecompileShader > > dsts, SkSpan< const sk_sp< PrecompileShader > > srcs)
SK_API sk_sp< PrecompileShader > YUVImage()
sk_sp< PrecompileBlender > MakePrecompileBlender(sk_sp< SkRuntimeEffect > effect, SkSpan< const PrecompileChildOptions > childOptions)
sk_sp< PrecompileShader > MakePrecompileShader(sk_sp< SkRuntimeEffect > effect, SkSpan< const PrecompileChildOptions > childOptions)
void AddKnownModeBlend(const KeyContext &keyContext, PaintParamsKeyBuilder *builder, PipelineDataGatherer *gatherer, SkBlendMode bm)
void Blend(const KeyContext &keyContext, PaintParamsKeyBuilder *keyBuilder, PipelineDataGatherer *gatherer, AddToKeyFn addBlendToKey, AddToKeyFn addSrcToKey, AddToKeyFn addDstToKey)
sk_sp< PrecompileColorFilter > MakePrecompileColorFilter(sk_sp< SkRuntimeEffect > effect, SkSpan< const PrecompileChildOptions > childOptions)
static constexpr SkCubicResampler Mitchell()
static constexpr SkISize MakeEmpty()
static constexpr SkRect MakeEmpty()
static void BeginBlock(const KeyContext &, PaintParamsKeyBuilder *, PipelineDataGatherer *, const ShaderData &)
static void AddBlock(const KeyContext &, PaintParamsKeyBuilder *, PipelineDataGatherer *, const SkPMColor4f &)
static void AddBlock(const KeyContext &, PaintParamsKeyBuilder *, PipelineDataGatherer *, const ImageData &)
static sk_sp< SkShader > linear(sk_sp< SkShader > shader)