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 
15 // See the comment above GrXPFactory's definition about this warning suppression.
16 #if defined(__GNUC__)
17 #pragma GCC diagnostic push
18 #pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
19 #endif
20 #if defined(__clang__)
21 #pragma clang diagnostic push
22 #pragma clang diagnostic ignored "-Wnon-virtual-dtor"
23 #endif
24 
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  */
30 class GrCoverageSetOpXPFactory : public GrXPFactory {
31 public:
32     static const GrXPFactory* Get(SkRegion::Op regionOp, bool invertCoverage = false);
33 
34 private:
35     constexpr GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage);
36 
37     sk_sp<const GrXferProcessor> makeXferProcessor(const GrProcessorAnalysisColor&,
38                                                    GrProcessorAnalysisCoverage,
39                                                    bool hasMixedSamples,
40                                                    const GrCaps&) const override;
41 
analysisProperties(const GrProcessorAnalysisColor &,const GrProcessorAnalysisCoverage &,const GrCaps &)42     AnalysisProperties analysisProperties(const GrProcessorAnalysisColor&,
43                                           const GrProcessorAnalysisCoverage&,
44                                           const GrCaps&) const override {
45         return AnalysisProperties::kIgnoresInputColor;
46     }
47 
48 
49     GR_DECLARE_XP_FACTORY_TEST
50 
51     SkRegion::Op fRegionOp;
52     bool         fInvertCoverage;
53 
54     typedef GrXPFactory INHERITED;
55 };
56 #if defined(__GNUC__)
57 #pragma GCC diagnostic pop
58 #endif
59 #if defined(__clang__)
60 #pragma clang diagnostic pop
61 #endif
62 
63 #endif
64