OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrCoverageSetOpXP_DEFINED | 8 #ifndef GrCoverageSetOpXP_DEFINED |
9 #define GrCoverageSetOpXP_DEFINED | 9 #define GrCoverageSetOpXP_DEFINED |
10 | 10 |
11 #include "GrTypes.h" | 11 #include "GrTypes.h" |
12 #include "GrXferProcessor.h" | 12 #include "GrXferProcessor.h" |
13 #include "SkRegion.h" | 13 #include "SkRegion.h" |
14 | 14 |
15 class GrProcOptInfo; | 15 class GrProcOptInfo; |
16 | 16 |
17 /** | |
18 * This xfer processor directly blends the the src coverage with the dst using a
set operator. It is | |
19 * useful for rendering coverage masks using CSG. It can optionally invert the s
rc coverage before | |
20 * applying the set operator. | |
21 * */ | |
22 class GrCoverageSetOpXP : public GrXferProcessor { | |
23 public: | |
24 static GrXferProcessor* Create(SkRegion::Op regionOp, bool invertCoverage) { | |
25 return SkNEW_ARGS(GrCoverageSetOpXP, (regionOp, invertCoverage)); | |
26 } | |
27 | |
28 ~GrCoverageSetOpXP() SK_OVERRIDE; | |
29 | |
30 const char* name() const SK_OVERRIDE { return "Coverage Set Op"; } | |
31 | |
32 GrGLXferProcessor* createGLInstance() const SK_OVERRIDE; | |
33 | |
34 bool hasSecondaryOutput() const SK_OVERRIDE { return false; } | |
35 | |
36 GrXferProcessor::OptFlags getOptimizations(const GrProcOptInfo& colorPOI, | |
37 const GrProcOptInfo& coveragePOI, | |
38 bool doesStencilWrite, | |
39 GrColor* color, | |
40 const GrDrawTargetCaps& caps) SK_
OVERRIDE; | |
41 | |
42 void getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const SK_OVERRIDE; | |
43 | |
44 bool invertCoverage() const { return fInvertCoverage; } | |
45 | |
46 private: | |
47 GrCoverageSetOpXP(SkRegion::Op regionOp, bool fInvertCoverage); | |
48 | |
49 void onGetGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) con
st SK_OVERRIDE; | |
50 | |
51 bool onIsEqual(const GrXferProcessor& xpBase) const SK_OVERRIDE { | |
52 const GrCoverageSetOpXP& xp = xpBase.cast<GrCoverageSetOpXP>(); | |
53 return (fRegionOp == xp.fRegionOp && | |
54 fInvertCoverage == xp.fInvertCoverage); | |
55 } | |
56 | |
57 SkRegion::Op fRegionOp; | |
58 bool fInvertCoverage; | |
59 | |
60 typedef GrXferProcessor INHERITED; | |
61 }; | |
62 | |
63 /////////////////////////////////////////////////////////////////////////////// | |
64 | |
65 class GrCoverageSetOpXPFactory : public GrXPFactory { | 17 class GrCoverageSetOpXPFactory : public GrXPFactory { |
66 public: | 18 public: |
67 static GrXPFactory* Create(SkRegion::Op regionOp, bool invertCoverage = fals
e); | 19 static GrXPFactory* Create(SkRegion::Op regionOp, bool invertCoverage = fals
e); |
68 | 20 |
69 bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const
SK_OVERRIDE { | 21 bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const
SK_OVERRIDE { |
70 return true; | 22 return true; |
71 } | 23 } |
72 | 24 |
73 bool canApplyCoverage(const GrProcOptInfo& colorPOI, | 25 bool canApplyCoverage(const GrProcOptInfo& colorPOI, |
74 const GrProcOptInfo& coveragePOI) const SK_OVERRIDE { | 26 const GrProcOptInfo& coveragePOI) const SK_OVERRIDE { |
(...skipping 21 matching lines...) Expand all Loading... |
96 | 48 |
97 GR_DECLARE_XP_FACTORY_TEST; | 49 GR_DECLARE_XP_FACTORY_TEST; |
98 | 50 |
99 SkRegion::Op fRegionOp; | 51 SkRegion::Op fRegionOp; |
100 bool fInvertCoverage; | 52 bool fInvertCoverage; |
101 | 53 |
102 typedef GrXPFactory INHERITED; | 54 typedef GrXPFactory INHERITED; |
103 }; | 55 }; |
104 #endif | 56 #endif |
105 | 57 |
OLD | NEW |