Chromium Code Reviews| Index: src/gpu/effects/GrCoverageSetOpXP.h |
| diff --git a/src/gpu/effects/GrCoverageSetOpXP.h b/src/gpu/effects/GrCoverageSetOpXP.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..eb1f81d0f90d55995882f23831f10bd70fae5176 |
| --- /dev/null |
| +++ b/src/gpu/effects/GrCoverageSetOpXP.h |
| @@ -0,0 +1,109 @@ |
| +/* |
| + * Copyright 2014 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +#ifndef GrCoverageSetOpXP_DEFINED |
| +#define GrCoverageSetOpXP_DEFINED |
| + |
| +#include "GrTypes.h" |
| +#include "GrXferProcessor.h" |
| +#include "SkRegion.h" |
| + |
| +class GrInvariantOutput; |
| +class GrProcOptInfo; |
| + |
| +/** |
| + * This Xfer Processor is used to blend the coverage together with the Dst given a specific set |
|
bsalomon
2014/12/16 17:35:56
"This xfer processor directly blends the src cover
egdaniel
2014/12/17 21:12:37
Done.
|
| + * operation. This XP will never use the output of the color stages. It is also legal to have the XP |
| + * use the inverse coverage (1 - cov) as the Src to the blend instead of simply using coverage. |
| + */ |
| +class GrCoverageSetOpXP : public GrXferProcessor { |
| +public: |
| + static GrXferProcessor* Create(SkRegion::Op regionOp, bool invertCoverage) { |
| + return SkNEW_ARGS(GrCoverageSetOpXP, (regionOp, invertCoverage)); |
| + } |
| + |
| + virtual ~GrCoverageSetOpXP(); |
| + |
| + virtual const char* name() const { return "Coverage Set Op"; } |
| + |
| + void getGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) const SK_OVERRIDE; |
| + |
| + GrGLXferProcessor* createGLInstance() const SK_OVERRIDE; |
| + |
| + bool hasSecondaryOutput() const SK_OVERRIDE { return false; } |
| + |
| + GrXferProcessor::OptFlags getOptimizations(const GrProcOptInfo& colorPOI, |
| + const GrProcOptInfo& coveragePOI, |
| + bool colorWriteDisabled, |
| + bool doesStencilWrite, |
| + GrColor* color, |
| + const GrDrawTargetCaps& caps) SK_OVERRIDE; |
| + |
| + void getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const SK_OVERRIDE; |
| + |
| + bool invertCoverage() const { return fInvertCoverage; } |
| + |
| +private: |
| + GrCoverageSetOpXP(SkRegion::Op regionOp, bool fInvertCoverage); |
| + |
| + bool onIsEqual(const GrXferProcessor& xpBase) const SK_OVERRIDE { |
| + const GrCoverageSetOpXP& xp = xpBase.cast<GrCoverageSetOpXP>(); |
| + return (fRegionOp == xp.fRegionOp && |
| + fInvertCoverage == xp.fInvertCoverage); |
| + } |
| + |
| + SkRegion::Op fRegionOp; |
| + bool fInvertCoverage; |
| + |
| + typedef GrXferProcessor INHERITED; |
| +}; |
| + |
| +/////////////////////////////////////////////////////////////////////////////// |
| + |
| +class GrCoverageSetOpXPFactory : public GrXPFactory { |
| +public: |
| + static GrXPFactory* Create(SkRegion::Op regionOp, bool invertCoverage = false); |
| + |
| + GrXferProcessor* createXferProcessor(const GrProcOptInfo& colorPOI, |
| + const GrProcOptInfo& coveragePOI) const SK_OVERRIDE; |
| + |
| + bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const SK_OVERRIDE { |
| + return false; |
|
bsalomon
2014/12/16 17:35:56
seems like it does, right? It uses the color varia
egdaniel
2014/12/17 21:12:37
Done.
|
| + } |
| + |
| + bool canApplyCoverage(const GrProcOptInfo& colorPOI, const GrProcOptInfo& coveragePOI, |
| + bool colorWriteDisabled) const SK_OVERRIDE { |
| + return true; |
| + } |
| + |
| + bool willBlendWithDst(const GrProcOptInfo& colorPOI, const GrProcOptInfo& coveragePOI, |
| + bool colorWriteDisabled) const SK_OVERRIDE; |
| + |
| + bool canTweakAlphaForCoverage() const SK_OVERRIDE { return false; } |
|
bsalomon
2014/12/16 17:35:56
can't wait to kill this guy
egdaniel
2014/12/17 21:12:37
you are not alone...
|
| + |
| + bool getOpaqueAndKnownColor(const GrProcOptInfo& colorPOI, |
| + const GrProcOptInfo& coveragePOI, |
| + GrColor* solidColor, |
| + uint32_t* solidColorKnownComponents) const SK_OVERRIDE; |
| + |
| +private: |
| + GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage); |
| + |
| + bool onIsEqual(const GrXPFactory& xpfBase) const SK_OVERRIDE { |
| + const GrCoverageSetOpXPFactory& xpf = xpfBase.cast<GrCoverageSetOpXPFactory>(); |
| + return fRegionOp == xpf.fRegionOp; |
| + } |
| + |
| + GR_DECLARE_XP_FACTORY_TEST; |
| + |
| + SkRegion::Op fRegionOp; |
| + bool fInvertCoverage; |
| + |
| + typedef GrXPFactory INHERITED; |
| +}; |
| +#endif |
| + |