OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2014 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #ifndef GrCoverageSetOpXP_DEFINED |
| 9 #define GrCoverageSetOpXP_DEFINED |
| 10 |
| 11 #include "GrTypes.h" |
| 12 #include "GrXferProcessor.h" |
| 13 #include "SkRegion.h" |
| 14 |
| 15 class GrInvariantOutput; |
| 16 class GrProcOptInfo; |
| 17 |
| 18 /** |
| 19 * This xfer processor directly blends the the src coverage with the dst using a
set operator. It is |
| 20 * useful for rendering coverage masks using CSG. It can optionally invert the s
rc coverage before |
| 21 * applying the set operator. |
| 22 * */ |
| 23 class GrCoverageSetOpXP : public GrXferProcessor { |
| 24 public: |
| 25 static GrXferProcessor* Create(SkRegion::Op regionOp, bool invertCoverage) { |
| 26 return SkNEW_ARGS(GrCoverageSetOpXP, (regionOp, invertCoverage)); |
| 27 } |
| 28 |
| 29 ~GrCoverageSetOpXP() SK_OVERRIDE; |
| 30 |
| 31 virtual const char* name() const { return "Coverage Set Op"; } |
| 32 |
| 33 void getGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) const
SK_OVERRIDE; |
| 34 |
| 35 GrGLXferProcessor* createGLInstance() const SK_OVERRIDE; |
| 36 |
| 37 bool hasSecondaryOutput() const SK_OVERRIDE { return false; } |
| 38 |
| 39 GrXferProcessor::OptFlags getOptimizations(const GrProcOptInfo& colorPOI, |
| 40 const GrProcOptInfo& coveragePOI, |
| 41 bool colorWriteDisabled, |
| 42 bool doesStencilWrite, |
| 43 GrColor* color, |
| 44 const GrDrawTargetCaps& caps) SK_
OVERRIDE; |
| 45 |
| 46 void getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const SK_OVERRIDE; |
| 47 |
| 48 bool invertCoverage() const { return fInvertCoverage; } |
| 49 |
| 50 private: |
| 51 GrCoverageSetOpXP(SkRegion::Op regionOp, bool fInvertCoverage); |
| 52 |
| 53 bool onIsEqual(const GrXferProcessor& xpBase) const SK_OVERRIDE { |
| 54 const GrCoverageSetOpXP& xp = xpBase.cast<GrCoverageSetOpXP>(); |
| 55 return (fRegionOp == xp.fRegionOp && |
| 56 fInvertCoverage == xp.fInvertCoverage); |
| 57 } |
| 58 |
| 59 SkRegion::Op fRegionOp; |
| 60 bool fInvertCoverage; |
| 61 |
| 62 typedef GrXferProcessor INHERITED; |
| 63 }; |
| 64 |
| 65 /////////////////////////////////////////////////////////////////////////////// |
| 66 |
| 67 class GrCoverageSetOpXPFactory : public GrXPFactory { |
| 68 public: |
| 69 static GrXPFactory* Create(SkRegion::Op regionOp, bool invertCoverage = fals
e); |
| 70 |
| 71 GrXferProcessor* createXferProcessor(const GrProcOptInfo& colorPOI, |
| 72 const GrProcOptInfo& coveragePOI) const
SK_OVERRIDE; |
| 73 |
| 74 bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const
SK_OVERRIDE { |
| 75 return true; |
| 76 } |
| 77 |
| 78 bool canApplyCoverage(const GrProcOptInfo& colorPOI, const GrProcOptInfo& co
veragePOI, |
| 79 bool colorWriteDisabled) const SK_OVERRIDE { |
| 80 return true; |
| 81 } |
| 82 |
| 83 bool willBlendWithDst(const GrProcOptInfo& colorPOI, const GrProcOptInfo& co
veragePOI, |
| 84 bool colorWriteDisabled) const SK_OVERRIDE; |
| 85 |
| 86 bool canTweakAlphaForCoverage() const SK_OVERRIDE { return false; } |
| 87 |
| 88 bool getOpaqueAndKnownColor(const GrProcOptInfo& colorPOI, |
| 89 const GrProcOptInfo& coveragePOI, |
| 90 GrColor* solidColor, |
| 91 uint32_t* solidColorKnownComponents) const SK_OV
ERRIDE; |
| 92 |
| 93 private: |
| 94 GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage); |
| 95 |
| 96 bool onIsEqual(const GrXPFactory& xpfBase) const SK_OVERRIDE { |
| 97 const GrCoverageSetOpXPFactory& xpf = xpfBase.cast<GrCoverageSetOpXPFact
ory>(); |
| 98 return fRegionOp == xpf.fRegionOp; |
| 99 } |
| 100 |
| 101 GR_DECLARE_XP_FACTORY_TEST; |
| 102 |
| 103 SkRegion::Op fRegionOp; |
| 104 bool fInvertCoverage; |
| 105 |
| 106 typedef GrXPFactory INHERITED; |
| 107 }; |
| 108 #endif |
| 109 |
OLD | NEW |