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: |
bungeman | 06ca8ec | 2016-06-09 08:01:03 -0700 | [diff] [blame] | 24 | static sk_sp<GrXPFactory> Make(SkRegion::Op regionOp, bool invertCoverage = false); |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 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 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame^] | 32 | GrXferProcessor* onCreateXferProcessor(const GrCaps&, |
| 33 | const GrPipelineAnalysis&, |
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 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame^] | 37 | bool onWillReadDstColor(const GrCaps&, const GrPipelineAnalysis&) const override { |
egdaniel | e36914c | 2015-02-13 09:00:33 -0800 | [diff] [blame] | 38 | return false; |
| 39 | } |
bsalomon | 50785a3 | 2015-02-06 07:02:37 -0800 | [diff] [blame] | 40 | |
mtklein | 36352bf | 2015-03-25 18:17:31 -0700 | [diff] [blame] | 41 | bool onIsEqual(const GrXPFactory& xpfBase) const override { |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 42 | const GrCoverageSetOpXPFactory& xpf = xpfBase.cast<GrCoverageSetOpXPFactory>(); |
| 43 | return fRegionOp == xpf.fRegionOp; |
| 44 | } |
| 45 | |
| 46 | GR_DECLARE_XP_FACTORY_TEST; |
| 47 | |
| 48 | SkRegion::Op fRegionOp; |
| 49 | bool fInvertCoverage; |
| 50 | |
| 51 | typedef GrXPFactory INHERITED; |
| 52 | }; |
| 53 | #endif |
| 54 | |