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 | |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 15 | // See the comment above GrXPFactory's definition about this warning suppression. |
| 16 | #if defined(__GNUC__) || defined(__clang) |
| 17 | #pragma GCC diagnostic push |
| 18 | #pragma GCC diagnostic ignored "-Wnon-virtual-dtor" |
| 19 | #endif |
| 20 | |
egdaniel | b197b8f | 2015-02-17 07:34:43 -0800 | [diff] [blame] | 21 | /** |
| 22 | * This xfer processor directly blends the the src coverage with the dst using a set operator. It is |
| 23 | * useful for rendering coverage masks using CSG. It can optionally invert the src coverage before |
| 24 | * applying the set operator. |
| 25 | */ |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 26 | class GrCoverageSetOpXPFactory : public GrXPFactory { |
| 27 | public: |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 28 | static const GrXPFactory* Get(SkRegion::Op regionOp, bool invertCoverage = false); |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 29 | |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 30 | private: |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 31 | constexpr GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage); |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 32 | |
Brian Salomon | d61c9d9 | 2017-04-10 10:54:25 -0400 | [diff] [blame] | 33 | sk_sp<const GrXferProcessor> makeXferProcessor(const GrProcessorAnalysisColor&, |
| 34 | GrProcessorAnalysisCoverage, |
| 35 | bool hasMixedSamples, |
| 36 | const GrCaps&) const override; |
bsalomon | 50785a3 | 2015-02-06 07:02:37 -0800 | [diff] [blame] | 37 | |
Brian Salomon | a811b12 | 2017-03-30 08:21:32 -0400 | [diff] [blame] | 38 | AnalysisProperties analysisProperties(const GrProcessorAnalysisColor&, |
| 39 | const GrProcessorAnalysisCoverage&, |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 40 | const GrCaps&) const override { |
| 41 | return AnalysisProperties::kIgnoresInputColor; |
Brian Salomon | 9a51498 | 2017-02-14 10:28:22 -0500 | [diff] [blame] | 42 | } |
bsalomon | 50785a3 | 2015-02-06 07:02:37 -0800 | [diff] [blame] | 43 | |
Brian Salomon | 780b41f | 2017-03-13 10:36:40 -0400 | [diff] [blame] | 44 | |
Brian Salomon | 0c26a9d | 2017-07-06 10:09:38 -0400 | [diff] [blame] | 45 | GR_DECLARE_XP_FACTORY_TEST |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 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 | |