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 GrInvariantOutput; | |
16 class GrProcOptInfo; | 15 class GrProcOptInfo; |
17 | 16 |
18 /** | 17 /** |
19 * This xfer processor directly blends the the src coverage with the dst using a
set operator. It is | 18 * This xfer processor directly blends the the src coverage with the dst using a
set operator. It is |
20 * useful for rendering coverage masks using CSG. It can optionally invert the s
rc coverage before | 19 * useful for rendering coverage masks using CSG. It can optionally invert the s
rc coverage before |
21 * applying the set operator. | 20 * applying the set operator. |
22 * */ | 21 * */ |
23 class GrCoverageSetOpXP : public GrXferProcessor { | 22 class GrCoverageSetOpXP : public GrXferProcessor { |
24 public: | 23 public: |
25 static GrXferProcessor* Create(SkRegion::Op regionOp, bool invertCoverage) { | 24 static GrXferProcessor* Create(SkRegion::Op regionOp, bool invertCoverage) { |
26 return SkNEW_ARGS(GrCoverageSetOpXP, (regionOp, invertCoverage)); | 25 return SkNEW_ARGS(GrCoverageSetOpXP, (regionOp, invertCoverage)); |
27 } | 26 } |
28 | 27 |
29 ~GrCoverageSetOpXP() SK_OVERRIDE; | 28 ~GrCoverageSetOpXP() SK_OVERRIDE; |
30 | 29 |
31 virtual const char* name() const SK_OVERRIDE { return "Coverage Set Op"; } | 30 const char* name() const SK_OVERRIDE { return "Coverage Set Op"; } |
32 | 31 |
33 void getGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) const
SK_OVERRIDE; | 32 void getGLProcessorKey(const GrGLCaps& caps, GrProcessorKeyBuilder* b) const
SK_OVERRIDE; |
34 | 33 |
35 GrGLXferProcessor* createGLInstance() const SK_OVERRIDE; | 34 GrGLXferProcessor* createGLInstance() const SK_OVERRIDE; |
36 | 35 |
37 bool hasSecondaryOutput() const SK_OVERRIDE { return false; } | 36 bool hasSecondaryOutput() const SK_OVERRIDE { return false; } |
38 | 37 |
39 GrXferProcessor::OptFlags getOptimizations(const GrProcOptInfo& colorPOI, | 38 GrXferProcessor::OptFlags getOptimizations(const GrProcOptInfo& colorPOI, |
40 const GrProcOptInfo& coveragePOI, | 39 const GrProcOptInfo& coveragePOI, |
41 bool colorWriteDisabled, | |
42 bool doesStencilWrite, | 40 bool doesStencilWrite, |
43 GrColor* color, | 41 GrColor* color, |
44 const GrDrawTargetCaps& caps) SK_
OVERRIDE; | 42 const GrDrawTargetCaps& caps) SK_
OVERRIDE; |
45 | 43 |
46 void getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const SK_OVERRIDE; | 44 void getBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const SK_OVERRIDE; |
47 | 45 |
48 bool invertCoverage() const { return fInvertCoverage; } | 46 bool invertCoverage() const { return fInvertCoverage; } |
49 | 47 |
50 private: | 48 private: |
51 GrCoverageSetOpXP(SkRegion::Op regionOp, bool fInvertCoverage); | 49 GrCoverageSetOpXP(SkRegion::Op regionOp, bool fInvertCoverage); |
(...skipping 16 matching lines...) Expand all Loading... |
68 public: | 66 public: |
69 static GrXPFactory* Create(SkRegion::Op regionOp, bool invertCoverage = fals
e); | 67 static GrXPFactory* Create(SkRegion::Op regionOp, bool invertCoverage = fals
e); |
70 | 68 |
71 GrXferProcessor* createXferProcessor(const GrProcOptInfo& colorPOI, | 69 GrXferProcessor* createXferProcessor(const GrProcOptInfo& colorPOI, |
72 const GrProcOptInfo& coveragePOI) const
SK_OVERRIDE; | 70 const GrProcOptInfo& coveragePOI) const
SK_OVERRIDE; |
73 | 71 |
74 bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const
SK_OVERRIDE { | 72 bool supportsRGBCoverage(GrColor knownColor, uint32_t knownColorFlags) const
SK_OVERRIDE { |
75 return true; | 73 return true; |
76 } | 74 } |
77 | 75 |
78 bool canApplyCoverage(const GrProcOptInfo& colorPOI, const GrProcOptInfo& co
veragePOI, | 76 bool canApplyCoverage(const GrProcOptInfo& colorPOI, |
79 bool colorWriteDisabled) const SK_OVERRIDE { | 77 const GrProcOptInfo& coveragePOI) const SK_OVERRIDE { |
80 return true; | 78 return true; |
81 } | 79 } |
82 | 80 |
83 bool canTweakAlphaForCoverage() const SK_OVERRIDE { return false; } | 81 bool canTweakAlphaForCoverage() const SK_OVERRIDE { return false; } |
84 | 82 |
85 void getInvariantOutput(const GrProcOptInfo& colorPOI, const GrProcOptInfo&
coveragePOI, | 83 void getInvariantOutput(const GrProcOptInfo& colorPOI, const GrProcOptInfo&
coveragePOI, |
86 bool colorWriteDisabled, | |
87 GrXPFactory::InvariantOutput*) const SK_OVERRIDE; | 84 GrXPFactory::InvariantOutput*) const SK_OVERRIDE; |
88 | 85 |
| 86 bool willReadDst(const GrProcOptInfo& colorPOI, |
| 87 const GrProcOptInfo& coveragePOI) const SK_OVERRIDE; |
| 88 |
89 private: | 89 private: |
90 GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage); | 90 GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage); |
91 | 91 |
92 bool onIsEqual(const GrXPFactory& xpfBase) const SK_OVERRIDE { | 92 bool onIsEqual(const GrXPFactory& xpfBase) const SK_OVERRIDE { |
93 const GrCoverageSetOpXPFactory& xpf = xpfBase.cast<GrCoverageSetOpXPFact
ory>(); | 93 const GrCoverageSetOpXPFactory& xpf = xpfBase.cast<GrCoverageSetOpXPFact
ory>(); |
94 return fRegionOp == xpf.fRegionOp; | 94 return fRegionOp == xpf.fRegionOp; |
95 } | 95 } |
96 | 96 |
97 GR_DECLARE_XP_FACTORY_TEST; | 97 GR_DECLARE_XP_FACTORY_TEST; |
98 | 98 |
99 SkRegion::Op fRegionOp; | 99 SkRegion::Op fRegionOp; |
100 bool fInvertCoverage; | 100 bool fInvertCoverage; |
101 | 101 |
102 typedef GrXPFactory INHERITED; | 102 typedef GrXPFactory INHERITED; |
103 }; | 103 }; |
104 #endif | 104 #endif |
105 | 105 |
OLD | NEW |