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 | |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 17 | // See the comment above GrXPFactory's definition about this warning suppression. |
| 18 | #if defined(__GNUC__) || defined(__clang) |
| 19 | #pragma GCC diagnostic push |
| 20 | #pragma GCC diagnostic ignored "-Wnon-virtual-dtor" |
| 21 | #endif |
| 22 | |
egdaniel | b197b8f | 2015-02-17 07:34:43 -0800 | [diff] [blame] | 23 | /** |
| 24 | * This xfer processor directly blends the the src coverage with the dst using a set operator. It is |
| 25 | * useful for rendering coverage masks using CSG. It can optionally invert the src coverage before |
| 26 | * applying the set operator. |
| 27 | */ |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 28 | class GrCoverageSetOpXPFactory : public GrXPFactory { |
| 29 | public: |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 30 | static const GrXPFactory* Get(SkRegion::Op regionOp, bool invertCoverage = false); |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 31 | |
cdalton | 1fa4572 | 2015-06-02 10:43:39 -0700 | [diff] [blame] | 32 | void getInvariantBlendedColor(const GrProcOptInfo& colorPOI, |
| 33 | GrXPFactory::InvariantBlendedColor*) const override; |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 34 | |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 35 | private: |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 36 | constexpr GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage); |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 37 | |
Brian Salomon | 92aee3d | 2016-12-21 09:20:25 -0500 | [diff] [blame] | 38 | GrXferProcessor* onCreateXferProcessor(const GrCaps&, |
| 39 | const GrPipelineAnalysis&, |
cdalton | 86ae0a9 | 2015-06-08 15:11:04 -0700 | [diff] [blame] | 40 | bool hasMixedSamples, |
bsalomon | 6a44c6a | 2015-05-26 09:49:05 -0700 | [diff] [blame] | 41 | const DstTexture*) const override; |
bsalomon | 50785a3 | 2015-02-06 07:02:37 -0800 | [diff] [blame] | 42 | |
Brian Salomon | 5be6c95 | 2017-01-20 19:06:29 +0000 | [diff] [blame^] | 43 | bool willReadDstColor(const GrCaps&, ColorType, CoverageType) const override { return false; } |
bsalomon | 50785a3 | 2015-02-06 07:02:37 -0800 | [diff] [blame] | 44 | |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 45 | GR_DECLARE_XP_FACTORY_TEST; |
| 46 | |
| 47 | SkRegion::Op fRegionOp; |
| 48 | bool fInvertCoverage; |
| 49 | |
| 50 | typedef GrXPFactory INHERITED; |
| 51 | }; |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 52 | #if defined(__GNUC__) || defined(__clang) |
| 53 | #pragma GCC diagnostic pop |
| 54 | #endif |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 55 | #endif |
| 56 | |