#include "glsl/GrGLSLCaps.h"
#include "glsl/GrGLSLFragmentProcessor.h"
#include "glsl/GrGLSLFragmentShaderBuilder.h"
-#include "glsl/GrGLSLProgramBuilder.h"
#include "glsl/GrGLSLProgramDataManager.h"
+#include "glsl/GrGLSLUniformHandler.h"
#include "glsl/GrGLSLXferProcessor.h"
bool GrCustomXfermode::IsSupportedMode(SkXfermode::Mode mode) {
}
static bool can_use_hw_blend_equation(GrBlendEquation equation,
- const GrProcOptInfo& coveragePOI,
+ const GrPipelineOptimizations& opt,
const GrCaps& caps) {
if (!caps.advancedBlendEquationSupport()) {
return false;
}
- if (coveragePOI.isFourChannelOutput()) {
+ if (opt.fOverrides.fUsePLSDstRead) {
+ return false;
+ }
+ if (opt.fCoveragePOI.isFourChannelOutput()) {
return false; // LCD coverage must be applied after the blend equation.
}
if (caps.canUseAdvancedBlendEquation(equation)) {
}
}
- void emitBlendCodeForDstRead(GrGLSLXPBuilder* pb,
- GrGLSLXPFragmentBuilder* fragBuilder,
+ void emitBlendCodeForDstRead(GrGLSLXPFragmentBuilder* fragBuilder,
+ GrGLSLUniformHandler* uniformHandler,
const char* srcColor,
+ const char* srcCoverage,
const char* dstColor,
const char* outColor,
+ const char* outColorSecondary,
const GrXferProcessor& proc) override {
const CustomXP& xp = proc.cast<CustomXP>();
SkASSERT(!xp.hasHWBlendEquation());
GrGLSLBlend::AppendMode(fragBuilder, srcColor, dstColor, outColor, xp.mode());
+
+ // Apply coverage.
+ INHERITED::DefaultCoverageModulation(fragBuilder, srcCoverage, dstColor, outColor,
+ outColorSecondary, xp);
}
void onSetData(const GrGLSLProgramDataManager&, const GrXferProcessor&) override {}
bool hasMixedSamples,
const DstTexture*) const override;
- bool willReadDstColor(const GrCaps& caps,
- const GrPipelineOptimizations& optimizations,
- bool hasMixedSamples) const override;
+ bool onWillReadDstColor(const GrCaps&, const GrPipelineOptimizations&) const override;
bool onIsEqual(const GrXPFactory& xpfBase) const override {
const CustomXPFactory& xpf = xpfBase.cast<CustomXPFactory>();
const GrPipelineOptimizations& opt,
bool hasMixedSamples,
const DstTexture* dstTexture) const {
- if (can_use_hw_blend_equation(fHWBlendEquation, opt.fCoveragePOI, caps)) {
+ if (can_use_hw_blend_equation(fHWBlendEquation, opt, caps)) {
SkASSERT(!dstTexture || !dstTexture->texture());
return new CustomXP(fMode, fHWBlendEquation);
}
return new CustomXP(dstTexture, hasMixedSamples, fMode);
}
-bool CustomXPFactory::willReadDstColor(const GrCaps& caps,
- const GrPipelineOptimizations& optimizations,
- bool hasMixedSamples) const {
- return !can_use_hw_blend_equation(fHWBlendEquation, optimizations.fCoveragePOI, caps);
+bool CustomXPFactory::onWillReadDstColor(const GrCaps& caps,
+ const GrPipelineOptimizations& optimizations) const {
+ return !can_use_hw_blend_equation(fHWBlendEquation, optimizations, caps);
}
void CustomXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
}
GR_DEFINE_XP_FACTORY_TEST(CustomXPFactory);
-const GrXPFactory* CustomXPFactory::TestCreate(GrProcessorTestData* d) {
+sk_sp<GrXPFactory> CustomXPFactory::TestCreate(GrProcessorTestData* d) {
int mode = d->fRandom->nextRangeU(SkXfermode::kLastCoeffMode + 1,
SkXfermode::kLastSeparableMode);
- return new CustomXPFactory(static_cast<SkXfermode::Mode>(mode));
+ return sk_sp<GrXPFactory>(new CustomXPFactory(static_cast<SkXfermode::Mode>(mode)));
}
///////////////////////////////////////////////////////////////////////////////
-GrXPFactory* GrCustomXfermode::CreateXPFactory(SkXfermode::Mode mode) {
+sk_sp<GrXPFactory> GrCustomXfermode::MakeXPFactory(SkXfermode::Mode mode) {
if (!GrCustomXfermode::IsSupportedMode(mode)) {
return nullptr;
} else {
- return new CustomXPFactory(mode);
+ return sk_sp<GrXPFactory>(new CustomXPFactory(mode));
}
}