egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 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 | |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 15 | class GrProcOptInfo; |
| 16 | |
egdaniel | b197b8f | 2015-02-17 07:34:43 -0800 | [diff] [blame] | 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 src coverage before |
| 20 | * applying the set operator. |
| 21 | */ |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 22 | class GrCoverageSetOpXPFactory : public GrXPFactory { |
| 23 | public: |
| 24 | static GrXPFactory* Create(SkRegion::Op regionOp, bool invertCoverage = false); |
| 25 | |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 26 | void getInvariantBlendedColor(const GrProcOptInfo& colorPOI, |
| 27 | GrXPFactory::InvariantBlendedColor*) const override; |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 28 | |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 29 | private: |
| 30 | GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage); |
| 31 | |
bsalomon | 4b91f76 | 2015-05-19 09:29:46 -0700 | [diff] [blame] | 32 | GrXferProcessor* onCreateXferProcessor(const GrCaps& caps, |
ethannicholas | de4166a | 2015-11-30 08:57:38 -0800 | [diff] [blame] | 33 | const GrPipelineOptimizations& optimizations, |
cdalton | 86ae0a9 | 2015-06-08 15:11:04 -0700 | [diff] [blame] | 34 | bool hasMixedSamples, |
bsalomon | 6a44c6a | 2015-05-26 09:49:05 -0700 | [diff] [blame] | 35 | const DstTexture*) const override; |
bsalomon | 50785a3 | 2015-02-06 07:02:37 -0800 | [diff] [blame] | 36 | |
ethannicholas | 2279325 | 2016-01-30 09:59:10 -0800 | [diff] [blame] | 37 | bool onWillReadDstColor(const GrCaps& /*caps*/, |
| 38 | const GrPipelineOptimizations& /*optimizations*/, |
| 39 | bool /*hasMixedSamples*/) const override { |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 40 | return false; |
| 41 | } |
bsalomon | 50785a3 | 2015-02-06 07:02:37 -0800 | [diff] [blame] | 42 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 43 | bool onIsEqual(const GrXPFactory& xpfBase) const override { |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 44 | const GrCoverageSetOpXPFactory& xpf = xpfBase.cast<GrCoverageSetOpXPFactory>(); |
| 45 | return fRegionOp == xpf.fRegionOp; |
| 46 | } |
| 47 | |
| 48 | GR_DECLARE_XP_FACTORY_TEST; |
| 49 | |
| 50 | SkRegion::Op fRegionOp; |
| 51 | bool fInvertCoverage; |
| 52 | |
| 53 | typedef GrXPFactory INHERITED; |
| 54 | }; |
| 55 | #endif |
| 56 | |