Debian Codegraph @

src/gpu/ganesh/effects/GrCoverageSetOpXP.h

raw
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 "include/core/SkRefCnt.h"
12 #include "include/core/SkRegion.h"
13 #include "src/gpu/ganesh/GrCaps.h"
14 #include "src/gpu/ganesh/GrProcessorAnalysis.h"
15 #include "src/gpu/ganesh/GrProcessorUnitTest.h"
16 #include "src/gpu/ganesh/GrXferProcessor.h"
17
18 enum class GrClampType;
19
20 // See the comment above GrXPFactory's definition about this warning suppression.
21 #if defined(__GNUC__)
22 #pragma GCC diagnostic push
23 #pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
24 #endif
25 #if defined(__clang__)
26 #pragma clang diagnostic push
27 #pragma clang diagnostic ignored "-Wnon-virtual-dtor"
28 #endif
29
30 /**
31 * This xfer processor directly blends the the src coverage with the dst using a set operator. It is
32 * useful for rendering coverage masks using CSG. It can optionally invert the src coverage before
33 * applying the set operator.
34 */
35 class GrCoverageSetOpXPFactory : public GrXPFactory {
36 public:
37 static const GrXPFactory* Get(SkRegion::Op regionOp, bool invertCoverage = false);
38
39 private:
40 constexpr GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage);
41
42 sk_sp<const GrXferProcessor> makeXferProcessor(const GrProcessorAnalysisColor&,
43 GrProcessorAnalysisCoverage,
44 const GrCaps&,
45 GrClampType) const override;
46
47 AnalysisProperties analysisProperties(const GrProcessorAnalysisColor& color,
48 const GrProcessorAnalysisCoverage& coverage,
49 const GrCaps&,
50 GrClampType) const override {
51 auto props = AnalysisProperties::kIgnoresInputColor;
52 switch (fRegionOp) {
53 case SkRegion::kReplace_Op:
54 props |= AnalysisProperties::kUnaffectedByDstValue;
55 break;
56 case SkRegion::kUnion_Op:
57 case SkRegion::kDifference_Op:
58 // FIXME: If we can formalize the fact that this op only operates on alpha, we can
59 // set AnalysisProperties::kUnaffectedByDstValue if color/coverage are all opaque.
60 break;
61 case SkRegion::kIntersect_Op:
62 case SkRegion::kXOR_Op:
63 case SkRegion::kReverseDifference_Op:
64 break;
65 }
66 return props;
67 }
68
69
70 GR_DECLARE_XP_FACTORY_TEST
71
72 SkRegion::Op fRegionOp;
73 bool fInvertCoverage;
74
75 using INHERITED = GrXPFactory;
76 };
77 #if defined(__GNUC__)
78 #pragma GCC diagnostic pop
79 #endif
80 #if defined(__clang__)
81 #pragma clang diagnostic pop
82 #endif
83
84 #endif