| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef GrCoverageSetOpXP_DEFINED | 8 #ifndef GrCoverageSetOpXP_DEFINED |
| 9 #define GrCoverageSetOpXP_DEFINED | 9 #define GrCoverageSetOpXP_DEFINED |
| 10 | 10 |
| 11 #include "GrTypes.h" | 11 #include "GrTypes.h" |
| 12 #include "GrXferProcessor.h" | 12 #include "GrXferProcessor.h" |
| 13 #include "SkRegion.h" | 13 #include "SkRegion.h" |
| 14 | 14 |
| 15 class GrProcOptInfo; | 15 class GrProcOptInfo; |
| 16 | 16 |
| 17 /** |
| 18 * This xfer processor directly blends the the src coverage with the dst using a
set operator. It is |
| 19 * useful for rendering coverage masks using CSG. It can optionally invert the s
rc coverage before |
| 20 * applying the set operator. |
| 21 */ |
| 17 class GrCoverageSetOpXPFactory : public GrXPFactory { | 22 class GrCoverageSetOpXPFactory : public GrXPFactory { |
| 18 public: | 23 public: |
| 19 static GrXPFactory* Create(SkRegion::Op regionOp, bool invertCoverage = fals
e); | 24 static GrXPFactory* Create(SkRegion::Op regionOp, bool invertCoverage = fals
e); |
| 20 | 25 |
| 21 bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const
SK_OVERRIDE { | 26 bool supportsRGBCoverage(GrColor /*knownColor*/, |
| 27 uint32_t /*knownColorFlags*/) const SK_OVERRIDE { |
| 22 return true; | 28 return true; |
| 23 } | 29 } |
| 24 | 30 |
| 25 bool canApplyCoverage(const GrProcOptInfo& colorPOI, | 31 bool canApplyCoverage(const GrProcOptInfo& /*colorPOI*/, |
| 26 const GrProcOptInfo& coveragePOI) const SK_OVERRIDE { | 32 const GrProcOptInfo& /*coveragePOI*/) const SK_OVERRID
E { |
| 27 return true; | 33 return true; |
| 28 } | 34 } |
| 29 | 35 |
| 30 bool canTweakAlphaForCoverage() const SK_OVERRIDE { return false; } | 36 bool canTweakAlphaForCoverage() const SK_OVERRIDE { return false; } |
| 31 | 37 |
| 32 void getInvariantOutput(const GrProcOptInfo& colorPOI, const GrProcOptInfo&
coveragePOI, | 38 void getInvariantOutput(const GrProcOptInfo& colorPOI, const GrProcOptInfo&
coveragePOI, |
| 33 GrXPFactory::InvariantOutput*) const SK_OVERRIDE; | 39 GrXPFactory::InvariantOutput*) const SK_OVERRIDE; |
| 34 | 40 |
| 35 private: | 41 private: |
| 36 GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage); | 42 GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage); |
| 37 | 43 |
| 38 GrXferProcessor* onCreateXferProcessor(const GrProcOptInfo& colorPOI, | 44 GrXferProcessor* onCreateXferProcessor(const GrProcOptInfo& colorPOI, |
| 39 const GrProcOptInfo& coveragePOI, | 45 const GrProcOptInfo& coveragePOI, |
| 40 const GrDeviceCoordTexture* dstCopy)
const SK_OVERRIDE; | 46 const GrDeviceCoordTexture* dstCopy)
const SK_OVERRIDE; |
| 41 | 47 |
| 42 bool willReadDstColor(const GrProcOptInfo& colorPOI, | 48 bool willReadDstColor(const GrProcOptInfo& /*colorPOI*/, |
| 43 const GrProcOptInfo& coveragePOI) const SK_OVERRIDE { | 49 const GrProcOptInfo& /*coveragePOI*/) const SK_OVERRID
E { |
| 44 return false; | 50 return false; |
| 45 } | 51 } |
| 46 | 52 |
| 47 bool onIsEqual(const GrXPFactory& xpfBase) const SK_OVERRIDE { | 53 bool onIsEqual(const GrXPFactory& xpfBase) const SK_OVERRIDE { |
| 48 const GrCoverageSetOpXPFactory& xpf = xpfBase.cast<GrCoverageSetOpXPFact
ory>(); | 54 const GrCoverageSetOpXPFactory& xpf = xpfBase.cast<GrCoverageSetOpXPFact
ory>(); |
| 49 return fRegionOp == xpf.fRegionOp; | 55 return fRegionOp == xpf.fRegionOp; |
| 50 } | 56 } |
| 51 | 57 |
| 52 GR_DECLARE_XP_FACTORY_TEST; | 58 GR_DECLARE_XP_FACTORY_TEST; |
| 53 | 59 |
| 54 SkRegion::Op fRegionOp; | 60 SkRegion::Op fRegionOp; |
| 55 bool fInvertCoverage; | 61 bool fInvertCoverage; |
| 56 | 62 |
| 57 typedef GrXPFactory INHERITED; | 63 typedef GrXPFactory INHERITED; |
| 58 }; | 64 }; |
| 59 #endif | 65 #endif |
| 60 | 66 |
| OLD | NEW |