bool SkBlendShader::isOpaque() const {
SkBlendModeCoeff srcCoeff, dstCoeff; if (!SkBlendMode_AsCoeff(fMode, &srcCoeff, &dstCoeff)) { returnfalse; // pessimistic
} // The result of the blend is opaque if the sum of "srcCoeff*src + dstCoeff*dst"'s alpha is 1. // This is definitely the case if either term of the addition will always be 1. constbool srcIsOpaque = fSrc->isOpaque(); constbool dstIsOpaque = fDst->isOpaque(); auto coeffIsOpaque = [&](SkBlendModeCoeff coeff) { bool srcAlpha = coeff == SkBlendModeCoeff::kSA || coeff == SkBlendModeCoeff::kSC; bool dstAlpha = coeff == SkBlendModeCoeff::kDA || coeff == SkBlendModeCoeff::kDC; return coeff == SkBlendModeCoeff::kOne ||
(srcAlpha && srcIsOpaque) ||
(dstAlpha && dstIsOpaque);
}; return (srcIsOpaque && coeffIsOpaque(srcCoeff)) || (dstIsOpaque && coeffIsOpaque(dstCoeff));
}
// Returns the output of e0, and leaves the output of e1 in r,g,b,a staticfloat* append_two_shaders(const SkStageRec& rec, const SkShaders::MatrixRec& mRec,
SkShader* s0,
SkShader* s1) { struct Storage { float fCoords[2 * SkRasterPipelineContexts::kMaxStride]; float fRes0[4 * SkRasterPipelineContexts::kMaxStride];
}; auto storage = rec.fAlloc->make<Storage>();
// Note we cannot simply apply mRec here and then unconditionally store the coordinates. When // building for Android Framework it would interrupt the backwards local matrix concatenation if // mRec had a pending local matrix and either of the children also had a local matrix. // b/256873449 if (mRec.rasterPipelineCoordsAreSeeded()) {
rec.fPipeline->append(SkRasterPipelineOp::store_src_rg, storage->fCoords);
} if (!as_SB(s0)->appendStages(rec, mRec)) { return nullptr;
}
rec.fPipeline->append(SkRasterPipelineOp::store_src, storage->fRes0);
if (mRec.rasterPipelineCoordsAreSeeded()) {
rec.fPipeline->append(SkRasterPipelineOp::load_src_rg, storage->fCoords);
} if (!as_SB(s1)->appendStages(rec, mRec)) { return nullptr;
} return storage->fRes0;
}
if (!src || !dst) { return nullptr;
} if (!blender) { return SkShaders::Blend(SkBlendMode::kSrcOver, std::move(dst), std::move(src));
} if (std::optional<SkBlendMode> mode = as_BB(blender)->asBlendMode()) { return SkShaders::Blend(*mode, std::move(dst), std::move(src));
}
// This isn't a built-in blend mode; we might as well use a runtime effect to evaluate it. const SkRuntimeEffect* blendEffect = GetKnownRuntimeEffect(StableKey::kBlend);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.