| Index: include/gpu/effects/GrAdvancedEquationXPFactory.h
|
| diff --git a/include/gpu/effects/GrAdvancedEquationXPFactory.h b/include/gpu/effects/GrAdvancedEquationXPFactory.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..7cb174aaec041d94f81562221f38df5e100617c3
|
| --- /dev/null
|
| +++ b/include/gpu/effects/GrAdvancedEquationXPFactory.h
|
| @@ -0,0 +1,104 @@
|
| +/*
|
| + * Copyright 2015 Google Inc.
|
| + *
|
| + * Use of this source code is governed by a BSD-style license that can be
|
| + * found in the LICENSE file.
|
| + */
|
| +
|
| +#ifndef GrAdvancedBlendXferProcessor_DEFINED
|
| +#define GrAdvancedBlendXferProcessor_DEFINED
|
| +
|
| +#include "GrTypes.h"
|
| +#include "GrXferProcessor.h"
|
| +
|
| +/**
|
| + * Provides Xfer processors that implement advanced blend modes in hardware,
|
| + * without the need for a dst texture. Can only be used if supported by the GPU.
|
| + */
|
| +class GrAdvancedEquationXPFactory : public GrXPFactory {
|
| +public:
|
| + static bool IsSupported(const GrContext*, SkXfermode::Mode);
|
| + static GrXPFactory* Create(const GrContext*, SkXfermode::Mode);
|
| +
|
| + bool canTweakAlphaForCoverage() const override;
|
| + bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const override;
|
| + bool willBlendCoherently(const GrDrawTargetCaps&) const override;
|
| +
|
| + void getInvariantOutput(const GrProcOptInfo&, const GrProcOptInfo&,
|
| + GrXPFactory::InvariantOutput* output) const override {
|
| + output->fWillBlendWithDst = true;
|
| + output->fBlendedColorFlags = 0;
|
| + }
|
| +
|
| +private:
|
| + template<GrBlendEquation> static GrXPFactory* TakeFactoryRef();
|
| +
|
| + GrAdvancedEquationXPFactory(GrBlendEquation equation)
|
| + : fEquation(equation),
|
| + fXferProcessorWithCoverage(equation),
|
| + fXferProcessor(equation) {}
|
| +
|
| + GrXferProcessor* onCreateXferProcessor(const GrDrawTargetCaps& caps,
|
| + const GrProcOptInfo& colorPOI,
|
| + const GrProcOptInfo& coveragePOI,
|
| + const GrDeviceCoordTexture* dstCopy) const override;
|
| +
|
| + bool willReadDstColor(const GrDrawTargetCaps&, const GrProcOptInfo&,
|
| + const GrProcOptInfo&) const override {
|
| + return false;
|
| + }
|
| +
|
| + bool onIsEqual(const GrXPFactory& xpfBase) const override {
|
| + const GrAdvancedEquationXPFactory& xpf = xpfBase.cast<GrAdvancedEquationXPFactory>();
|
| + return fEquation == xpf.fEquation;
|
| + }
|
| +
|
| + class XferProcessorBase : public GrXferProcessor {
|
| + public:
|
| + XferProcessorBase(GrBlendEquation equation) : fEquation(equation) {}
|
| +
|
| + const char* name() const override { return "Blend Equation Advanced"; }
|
| + bool hasSecondaryOutput() const override { return false; }
|
| +
|
| + GrXferProcessor::OptFlags getOptimizations(const GrProcOptInfo&, const GrProcOptInfo&, bool,
|
| + GrColor*, const GrDrawTargetCaps&) override {
|
| + return GrXferProcessor::kNone_Opt;
|
| + }
|
| +
|
| + protected:
|
| + void onGetGLProcessorKey(const GrGLCaps&, GrProcessorKeyBuilder*) const override;
|
| +
|
| + void onGetBlendInfo(BlendInfo*) const override;
|
| +
|
| + const GrBlendEquation fEquation;
|
| +
|
| + typedef GrXferProcessor INHERITED;
|
| + };
|
| +
|
| + template<bool HasCoverage> class XferProcessor : public XferProcessorBase {
|
| + public:
|
| + XferProcessor(GrBlendEquation equation) : INHERITED(equation) {
|
| + this->initClassID<XferProcessor>();
|
| + }
|
| +
|
| + GrGLXferProcessor* createGLInstance() const override;
|
| +
|
| + private:
|
| + bool onIsEqual(const GrXferProcessor& xpBase) const override {
|
| + const XferProcessor& xp = xpBase.cast<XferProcessor>();
|
| + return fEquation == xp.fEquation;
|
| + }
|
| +
|
| + typedef XferProcessorBase INHERITED;
|
| + };
|
| +
|
| + const GrBlendEquation fEquation;
|
| + mutable XferProcessor<true> fXferProcessorWithCoverage;
|
| + mutable XferProcessor<false> fXferProcessor;
|
| +
|
| + GR_DECLARE_XP_FACTORY_TEST;
|
| +
|
| + typedef GrXPFactory INHERITED;
|
| +};
|
| +
|
| +#endif
|
|
|