Remove arithmetic mode GrXP code.

The arithmetic mode xfermode is only used as an implementation detail of SkXfermodeImageFilter which always uses the arithmetic FP.

Change-Id: I5f9607aa9731a21e6666d9c749dfa705d40d5775
Reviewed-on: https://skia-review.googlesource.com/6688
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Brian Salomon 2017-01-06 12:54:58 -05:00 committed by Skia Commit-Bot
parent 1090da6433
commit 1c4717b54b
4 changed files with 5 additions and 170 deletions

View File

@ -36,7 +36,10 @@ public:
#if SK_SUPPORT_GPU
sk_sp<GrFragmentProcessor> makeFragmentProcessorForImageFilter(
sk_sp<GrFragmentProcessor> dst) const override;
sk_sp<GrXPFactory> asXPFactory() const override;
sk_sp<GrXPFactory> asXPFactory() const override {
SkFAIL("This should only be used as a FP.");
return nullptr;
}
#endif
bool isArithmetic(SkArithmeticParams* params) const override {
@ -146,14 +149,6 @@ sk_sp<GrFragmentProcessor> SkArithmeticMode_scalar::makeFragmentProcessorForImag
std::move(dst));
}
sk_sp<GrXPFactory> SkArithmeticMode_scalar::asXPFactory() const {
return GrArithmeticXPFactory::Make(SkScalarToFloat(fK[0]),
SkScalarToFloat(fK[1]),
SkScalarToFloat(fK[2]),
SkScalarToFloat(fK[3]),
fEnforcePMColor);
}
#endif
SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkArithmeticMode)

View File

@ -177,119 +177,4 @@ private:
typedef GrXferProcessor INHERITED;
};
///////////////////////////////////////////////////////////////////////////////
class GLArithmeticXP : public GrGLSLXferProcessor {
public:
GLArithmeticXP(const ArithmeticXP& arithmeticXP)
: fEnforcePMColor(arithmeticXP.enforcePMColor()) {
}
~GLArithmeticXP() override {}
static void GenKey(const GrProcessor& processor, const GrShaderCaps& caps,
GrProcessorKeyBuilder* b) {
const ArithmeticXP& arith = processor.cast<ArithmeticXP>();
uint32_t key = arith.enforcePMColor() ? 1 : 0;
b->add32(key);
}
private:
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 {
fKUni = uniformHandler->addUniform(kFragment_GrShaderFlag,
kVec4f_GrSLType, kDefault_GrSLPrecision,
"k");
const char* kUni = uniformHandler->getUniformCStr(fKUni);
add_arithmetic_code(fragBuilder, srcColor, dstColor, outColor, kUni, fEnforcePMColor);
// Apply coverage.
INHERITED::DefaultCoverageModulation(fragBuilder, srcCoverage, dstColor, outColor,
outColorSecondary, proc);
}
void onSetData(const GrGLSLProgramDataManager& pdman,
const GrXferProcessor& processor) override {
const ArithmeticXP& arith = processor.cast<ArithmeticXP>();
pdman.set4f(fKUni, arith.k1(), arith.k2(), arith.k3(), arith.k4());
fEnforcePMColor = arith.enforcePMColor();
}
GrGLSLProgramDataManager::UniformHandle fKUni;
bool fEnforcePMColor;
typedef GrGLSLXferProcessor INHERITED;
};
///////////////////////////////////////////////////////////////////////////////
ArithmeticXP::ArithmeticXP(const DstTexture* dstTexture, bool hasMixedSamples,
float k1, float k2, float k3, float k4, bool enforcePMColor)
: INHERITED(dstTexture, true, hasMixedSamples)
, fK1(k1)
, fK2(k2)
, fK3(k3)
, fK4(k4)
, fEnforcePMColor(enforcePMColor) {
this->initClassID<ArithmeticXP>();
}
void ArithmeticXP::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const {
GLArithmeticXP::GenKey(*this, caps, b);
}
GrGLSLXferProcessor* ArithmeticXP::createGLSLInstance() const { return new GLArithmeticXP(*this); }
GrXferProcessor::OptFlags ArithmeticXP::onGetOptimizations(const GrPipelineAnalysis&,
bool doesStencilWrite,
GrColor* overrideColor,
const GrCaps& caps) const {
return GrXferProcessor::kNone_OptFlags;
}
///////////////////////////////////////////////////////////////////////////////
GrArithmeticXPFactory::GrArithmeticXPFactory(float k1, float k2, float k3, float k4,
bool enforcePMColor)
: fK1(k1), fK2(k2), fK3(k3), fK4(k4), fEnforcePMColor(enforcePMColor) {
this->initClassID<GrArithmeticXPFactory>();
}
GrXferProcessor* GrArithmeticXPFactory::onCreateXferProcessor(const GrCaps& caps,
const GrPipelineAnalysis&,
bool hasMixedSamples,
const DstTexture* dstTexture) const {
return new ArithmeticXP(dstTexture, hasMixedSamples, fK1, fK2, fK3, fK4, fEnforcePMColor);
}
void GrArithmeticXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
InvariantBlendedColor* blendedColor) const {
blendedColor->fWillBlendWithDst = true;
// TODO: We could try to optimize this more. For example if fK1 and fK3 are zero, then we won't
// be blending the color with dst at all so we can know what the output color is (up to the
// valid color components passed in).
blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags;
}
GR_DEFINE_XP_FACTORY_TEST(GrArithmeticXPFactory);
sk_sp<GrXPFactory> GrArithmeticXPFactory::TestCreate(GrProcessorTestData* d) {
float k1 = d->fRandom->nextF();
float k2 = d->fRandom->nextF();
float k3 = d->fRandom->nextF();
float k4 = d->fRandom->nextF();
bool enforcePMColor = d->fRandom->nextBool();
return GrArithmeticXPFactory::Make(k1, k2, k3, k4, enforcePMColor);
}
#endif

View File

@ -71,50 +71,5 @@ private:
typedef GrFragmentProcessor INHERITED;
};
///////////////////////////////////////////////////////////////////////////////
// Xfer Processor
///////////////////////////////////////////////////////////////////////////////
class GrArithmeticXPFactory : public GrXPFactory {
public:
static sk_sp<GrXPFactory> Make(float k1, float k2, float k3, float k4, bool enforcePMColor) {
return sk_sp<GrXPFactory>(new GrArithmeticXPFactory(k1, k2, k3, k4, enforcePMColor));
}
void getInvariantBlendedColor(const GrProcOptInfo& colorPOI,
GrXPFactory::InvariantBlendedColor*) const override;
private:
GrArithmeticXPFactory(float k1, float k2, float k3, float k4, bool enforcePMColor);
GrXferProcessor* onCreateXferProcessor(const GrCaps& caps,
const GrPipelineAnalysis&,
bool hasMixedSamples,
const DstTexture*) const override;
bool onWillReadDstColor(const GrCaps&, const GrPipelineAnalysis&) const override {
return true;
}
bool onIsEqual(const GrXPFactory& xpfBase) const override {
const GrArithmeticXPFactory& xpf = xpfBase.cast<GrArithmeticXPFactory>();
if (fK1 != xpf.fK1 ||
fK2 != xpf.fK2 ||
fK3 != xpf.fK3 ||
fK4 != xpf.fK4 ||
fEnforcePMColor != xpf.fEnforcePMColor) {
return false;
}
return true;
}
GR_DECLARE_XP_FACTORY_TEST;
float fK1, fK2, fK3, fK4;
bool fEnforcePMColor;
typedef GrXPFactory INHERITED;
};
#endif
#endif

View File

@ -52,7 +52,7 @@ GrProcessorTestFactory<GrGeometryProcessor>::GetFactories() {
*/
static const int kFPFactoryCount = 40;
static const int kGPFactoryCount = 14;
static const int kXPFactoryCount = 5;
static const int kXPFactoryCount = 4;
template<>
void GrProcessorTestFactory<GrFragmentProcessor>::VerifyFactoryCount() {