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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/core/SkRegion.h" |
| 12 | #include "include/gpu/GrTypes.h" |
| 13 | #include "src/gpu/GrXferProcessor.h" |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 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. |
Chris Dalton | 1ef8094 | 2017-12-04 12:01:30 -0700 | [diff] [blame] | 16 | #if defined(__GNUC__) |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 17 | #pragma GCC diagnostic push |
| 18 | #pragma GCC diagnostic ignored "-Wnon-virtual-dtor" |
| 19 | #endif |
Chris Dalton | 1ef8094 | 2017-12-04 12:01:30 -0700 | [diff] [blame] | 20 | #if defined(__clang__) |
| 21 | #pragma clang diagnostic push |
| 22 | #pragma clang diagnostic ignored "-Wnon-virtual-dtor" |
| 23 | #endif |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 24 | |
egdaniel | b197b8f | 2015-02-17 07:34:43 -0800 | [diff] [blame] | 25 | /** |
| 26 | * This xfer processor directly blends the the src coverage with the dst using a set operator. It is |
| 27 | * useful for rendering coverage masks using CSG. It can optionally invert the src coverage before |
| 28 | * applying the set operator. |
| 29 | */ |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 30 | class GrCoverageSetOpXPFactory : public GrXPFactory { |
| 31 | public: |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 32 | static const GrXPFactory* Get(SkRegion::Op regionOp, bool invertCoverage = false); |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 33 | |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 34 | private: |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 35 | constexpr GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage); |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 36 | |
Brian Salomon | d61c9d9 | 2017-04-10 10:54:25 -0400 | [diff] [blame] | 37 | sk_sp<const GrXferProcessor> makeXferProcessor(const GrProcessorAnalysisColor&, |
| 38 | GrProcessorAnalysisCoverage, |
| 39 | bool hasMixedSamples, |
Brian Osman | 5ced0bf | 2019-03-15 10:15:29 -0400 | [diff] [blame] | 40 | const GrCaps&, |
| 41 | GrClampType) const override; |
bsalomon | 50785a3 | 2015-02-06 07:02:37 -0800 | [diff] [blame] | 42 | |
Brian Salomon | a811b12 | 2017-03-30 08:21:32 -0400 | [diff] [blame] | 43 | AnalysisProperties analysisProperties(const GrProcessorAnalysisColor&, |
| 44 | const GrProcessorAnalysisCoverage&, |
Brian Osman | 5ced0bf | 2019-03-15 10:15:29 -0400 | [diff] [blame] | 45 | const GrCaps&, |
| 46 | GrClampType) const override { |
Brian Salomon | 3185384 | 2017-03-28 16:32:05 -0400 | [diff] [blame] | 47 | return AnalysisProperties::kIgnoresInputColor; |
Brian Salomon | 9a51498 | 2017-02-14 10:28:22 -0500 | [diff] [blame] | 48 | } |
bsalomon | 50785a3 | 2015-02-06 07:02:37 -0800 | [diff] [blame] | 49 | |
Brian Salomon | 780b41f | 2017-03-13 10:36:40 -0400 | [diff] [blame] | 50 | |
Brian Salomon | 0c26a9d | 2017-07-06 10:09:38 -0400 | [diff] [blame] | 51 | GR_DECLARE_XP_FACTORY_TEST |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 52 | |
| 53 | SkRegion::Op fRegionOp; |
| 54 | bool fInvertCoverage; |
| 55 | |
| 56 | typedef GrXPFactory INHERITED; |
| 57 | }; |
Chris Dalton | 1ef8094 | 2017-12-04 12:01:30 -0700 | [diff] [blame] | 58 | #if defined(__GNUC__) |
Brian Salomon | a163392 | 2017-01-09 11:46:10 -0500 | [diff] [blame] | 59 | #pragma GCC diagnostic pop |
| 60 | #endif |
Chris Dalton | 1ef8094 | 2017-12-04 12:01:30 -0700 | [diff] [blame] | 61 | #if defined(__clang__) |
| 62 | #pragma clang diagnostic pop |
egdaniel | 8750924 | 2014-12-17 13:37:13 -0800 | [diff] [blame] | 63 | #endif |
| 64 | |
Chris Dalton | 1ef8094 | 2017-12-04 12:01:30 -0700 | [diff] [blame] | 65 | #endif |