40 , fBlendFormula(blendFormula) {
43 const char*
name()
const override {
return "Porter Duff"; }
52 bool onHasSecondaryOutput()
const override {
return fBlendFormula.
hasSecondaryOutput(); }
55 blendInfo->fEquation = fBlendFormula.
equation();
63 return fBlendFormula == xp.fBlendFormula;
75 BlendFormula::OutputType outputType,
const char*
output,
76 const char* inColor,
const char* inCoverage) {
96 fragBuilder->
codeAppendf(
"%s = (half4(1.0) - %s) * %s;",
output, inColor, inCoverage);
99 SK_ABORT(
"Unsupported output type.");
106 static_assert(BlendFormula::kLast_OutputType < 8);
112 void emitOutputsForBlendState(
const EmitArgs&
args)
override {
121 args.fOutputSecondary,
123 args.fInputCoverage);
130 args.fInputCoverage);
134 return std::make_unique<Impl>();
143 , fXfermode(xfermode) {
146 const char*
name()
const override {
return "Porter Duff Shader"; }
155 return fXfermode == xp.fXfermode;
175 const char* srcColor,
176 const char* srcCoverage,
177 const char* dstColor,
178 const char* outColor,
179 const char* outColorSecondary,
184 &xp, uniformHandler, &fBlendUniform, srcColor, dstColor, xp.fXfermode);
185 fragBuilder->
codeAppendf(
"%s = %s;", outColor, blendExpr.c_str());
188 DefaultCoverageModulation(fragBuilder,
198 if (fBlendUniform.isValid()) {
207 return std::make_unique<Impl>();
217 const char*
name()
const override {
return "Porter Duff LCD"; }
234 if (fBlendConstant != xp.fBlendConstant || fAlpha != xp.fAlpha) {
246PDLCDXferProcessor::PDLCDXferProcessor(
const SkPMColor4f& blendConstant,
float alpha)
249 , fBlendConstant(blendConstant)
259 if (!
color.isConstant(&blendConstantPM)) {
263 float alpha = blendConstantUPM.fA;
264 blendConstantPM = { blendConstantUPM.fR, blendConstantUPM.fG, blendConstantUPM.fB, 1 };
271 void emitOutputsForBlendState(
const EmitArgs&
args)
override {
273 fAlphaUniform =
args.fUniformHandler->addUniform(
nullptr,
286 alpha,
args.fInputCoverage);
291 if (fLastAlpha != alpha) {
292 pdm.
set1f(fAlphaUniform, alpha);
301 return std::make_unique<Impl>();
306constexpr GrPorterDuffXPFactory::GrPorterDuffXPFactory(
SkBlendMode xfermode)
336 return &gSrcOverPDXPF;
338 return &gDstOverPDXPF;
344 return &gSrcOutPDXPF;
346 return &gDstOutPDXPF;
348 return &gSrcATopPDXPF;
350 return &gDstATopPDXPF;
356 return &gModulatePDXPF;
358 return &gScreenPDXPF;
416 props |= AnalysisProperties::kCompatibleWithCoverageAsAlpha;
424 props |= AnalysisProperties::kIgnoresInputColor;
434 props |= AnalysisProperties::kReadsDstInShader;
441 props |= AnalysisProperties::kReadsDstInShader;
447 props |= AnalysisProperties::kReadsDstInShader;
451 props |= AnalysisProperties::kIgnoresInputColor;
455 props |= AnalysisProperties::kUnaffectedByDstValue;
470#if defined(GR_TEST_UTILS)
471const GrXPFactory* GrPorterDuffXPFactory::TestGet(GrProcessorTestData*
d) {
477void GrPorterDuffXPFactory::TestGetXPOutputTypes(
const GrXferProcessor* xp,
480 if (!!strcmp(xp->
name(),
"Porter Duff")) {
481 *outPrimary = *outSecondary = -1;
529 if (
color.isConstant() &&
@ kISAModulate_OutputType
@ kISCModulate_OutputType
static void append_color_output(const PorterDuffXferProcessor &xp, GrGLSLXPFragmentBuilder *fragBuilder, BlendFormula::OutputType outputType, const char *output, const char *inColor, const char *inCoverage)
static GrXPFactory::AnalysisProperties analysis_properties(const GrProcessorAnalysisColor &color, const GrProcessorAnalysisCoverage &coverage, const GrCaps &caps, GrClampType clampType, SkBlendMode mode)
GrProcessorAnalysisCoverage
#define GR_DEFINE_XP_FACTORY_TEST(...)
#define SK_ABORT(message,...)
@ kLastCoeffMode
last porter duff blend mode
@ kSrcOver
r = s + (1-sa)*d
@ kXor
r = s*(1-da) + d*(1-sa)
@ kSrcATop
r = s*da + d*(1-sa)
@ kDstATop
r = d*sa + s*(1-da)
@ kDstOver
r = d + (1-da)*s
constexpr float SK_FloatNaN
static bool isLCD(const SkScalerContextRec &rec)
#define INHERITED(method,...)
const GrShaderCaps * shaderCaps() const
bool shouldCollapseSrcOverToSrcWhenAble() const
virtual void set1f(UniformHandle, float v0) const =0
void codeAppendf(const char format[],...) SK_PRINTF_LIKE(2
static sk_sp< const GrXferProcessor > MakeSrcOverXferProcessor(const GrProcessorAnalysisColor &, GrProcessorAnalysisCoverage, const GrCaps &)
static const GrXPFactory * Get(SkBlendMode blendMode)
static sk_sp< const GrXferProcessor > MakeNoCoverageXP(SkBlendMode)
static const GrXferProcessor & SimpleSrcOverXP()
static AnalysisProperties SrcOverAnalysisProperties(const GrProcessorAnalysisColor &, const GrProcessorAnalysisCoverage &, const GrCaps &, GrClampType)
virtual const char * name() const =0
@ kPorterDuffXferProcessor_ClassID
@ kShaderPDXferProcessor_ClassID
GrXferProcessor(ClassID classID)
const char * name() const override
static sk_sp< const GrXferProcessor > Make(SkBlendMode mode, const GrProcessorAnalysisColor &inputColor)
std::unique_ptr< ProgramImpl > makeProgramImpl() const override
const char * name() const override
PorterDuffXferProcessor(BlendFormula blendFormula, GrProcessorAnalysisCoverage coverage)
BlendFormula getBlendFormula() const
std::unique_ptr< ProgramImpl > makeProgramImpl() const override
std::unique_ptr< ProgramImpl > makeProgramImpl() const override
ShaderPDXferProcessor(SkBlendMode xfermode, GrProcessorAnalysisCoverage coverage)
const char * name() const override
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
std::string BlendExpression(const GrProcessor *processor, GrGLSLUniformHandler *uniformHandler, GrGLSLProgramDataManager::UniformHandle *blendUniform, const char *srcColor, const char *dstColor, SkBlendMode mode)
int BlendKey(SkBlendMode mode)
void SetBlendModeUniformData(const GrGLSLProgramDataManager &pdman, GrGLSLProgramDataManager::UniformHandle blendUniform, SkBlendMode mode)
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
BlendFormula GetBlendFormula(bool isOpaque, bool hasCoverage, SkBlendMode xfermode)
BlendFormula GetLCDBlendFormula(SkBlendMode xfermode)
bool fDstReadInShaderSupport
SkRGBA4f< kUnpremul_SkAlphaType > unpremul() const
bool fDualSourceBlendingSupport
skgpu::BlendCoeff fDstBlend
SkPMColor4f fBlendConstant
skgpu::BlendCoeff fSrcBlend