OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "effects/GrCoverageSetOpXP.h" | 9 #include "effects/GrCoverageSetOpXP.h" |
10 #include "GrColor.h" | 10 #include "GrColor.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 bool invertCoverage() const { return fInvertCoverage; } | 32 bool invertCoverage() const { return fInvertCoverage; } |
33 | 33 |
34 private: | 34 private: |
35 CoverageSetOpXP(SkRegion::Op regionOp, bool fInvertCoverage); | 35 CoverageSetOpXP(SkRegion::Op regionOp, bool fInvertCoverage); |
36 | 36 |
37 GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI, | 37 GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI, |
38 const GrProcOptInfo& coveragePO
I, | 38 const GrProcOptInfo& coveragePO
I, |
39 bool doesStencilWrite, | 39 bool doesStencilWrite, |
40 GrColor* color, | 40 GrColor* color, |
41 const GrDrawTargetCaps& caps) o
verride; | 41 const GrCaps& caps) override; |
42 | 42 |
43 void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override; | 43 void onGetGLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b) c
onst override; |
44 | 44 |
45 void onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const override; | 45 void onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const override; |
46 | 46 |
47 bool onIsEqual(const GrXferProcessor& xpBase) const override { | 47 bool onIsEqual(const GrXferProcessor& xpBase) const override { |
48 const CoverageSetOpXP& xp = xpBase.cast<CoverageSetOpXP>(); | 48 const CoverageSetOpXP& xp = xpBase.cast<CoverageSetOpXP>(); |
49 return (fRegionOp == xp.fRegionOp && | 49 return (fRegionOp == xp.fRegionOp && |
50 fInvertCoverage == xp.fInvertCoverage); | 50 fInvertCoverage == xp.fInvertCoverage); |
51 } | 51 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 GrGLXferProcessor* CoverageSetOpXP::createGLInstance() const { | 106 GrGLXferProcessor* CoverageSetOpXP::createGLInstance() const { |
107 return SkNEW_ARGS(GLCoverageSetOpXP, (*this)); | 107 return SkNEW_ARGS(GLCoverageSetOpXP, (*this)); |
108 } | 108 } |
109 | 109 |
110 GrXferProcessor::OptFlags | 110 GrXferProcessor::OptFlags |
111 CoverageSetOpXP::onGetOptimizations(const GrProcOptInfo& colorPOI, | 111 CoverageSetOpXP::onGetOptimizations(const GrProcOptInfo& colorPOI, |
112 const GrProcOptInfo& coveragePOI, | 112 const GrProcOptInfo& coveragePOI, |
113 bool doesStencilWrite, | 113 bool doesStencilWrite, |
114 GrColor* color, | 114 GrColor* color, |
115 const GrDrawTargetCaps& caps) { | 115 const GrCaps& caps) { |
116 // We never look at the color input | 116 // We never look at the color input |
117 return GrXferProcessor::kIgnoreColor_OptFlag; | 117 return GrXferProcessor::kIgnoreColor_OptFlag; |
118 } | 118 } |
119 | 119 |
120 void CoverageSetOpXP::onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) cons
t { | 120 void CoverageSetOpXP::onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) cons
t { |
121 switch (fRegionOp) { | 121 switch (fRegionOp) { |
122 case SkRegion::kReplace_Op: | 122 case SkRegion::kReplace_Op: |
123 blendInfo->fSrcBlend = kOne_GrBlendCoeff; | 123 blendInfo->fSrcBlend = kOne_GrBlendCoeff; |
124 blendInfo->fDstBlend = kZero_GrBlendCoeff; | 124 blendInfo->fDstBlend = kZero_GrBlendCoeff; |
125 break; | 125 break; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 return SkRef(&gRevDiffCDXPF); | 216 return SkRef(&gRevDiffCDXPF); |
217 } | 217 } |
218 break; | 218 break; |
219 } | 219 } |
220 default: | 220 default: |
221 return NULL; | 221 return NULL; |
222 } | 222 } |
223 } | 223 } |
224 | 224 |
225 GrXferProcessor* | 225 GrXferProcessor* |
226 GrCoverageSetOpXPFactory::onCreateXferProcessor(const GrDrawTargetCaps& caps, | 226 GrCoverageSetOpXPFactory::onCreateXferProcessor(const GrCaps& caps, |
227 const GrProcOptInfo& colorPOI, | 227 const GrProcOptInfo& colorPOI, |
228 const GrProcOptInfo& covPOI, | 228 const GrProcOptInfo& covPOI, |
229 const GrDeviceCoordTexture* dstC
opy) const { | 229 const GrDeviceCoordTexture* dstC
opy) const { |
230 return CoverageSetOpXP::Create(fRegionOp, fInvertCoverage); | 230 return CoverageSetOpXP::Create(fRegionOp, fInvertCoverage); |
231 } | 231 } |
232 | 232 |
233 void GrCoverageSetOpXPFactory::getInvariantOutput(const GrProcOptInfo& colorPOI, | 233 void GrCoverageSetOpXPFactory::getInvariantOutput(const GrProcOptInfo& colorPOI, |
234 const GrProcOptInfo& coverageP
OI, | 234 const GrProcOptInfo& coverageP
OI, |
235 GrXPFactory::InvariantOutput*
output) const { | 235 GrXPFactory::InvariantOutput*
output) const { |
236 if (SkRegion::kReplace_Op == fRegionOp) { | 236 if (SkRegion::kReplace_Op == fRegionOp) { |
237 if (coveragePOI.isSolidWhite()) { | 237 if (coveragePOI.isSolidWhite()) { |
238 output->fBlendedColor = GrColor_WHITE; | 238 output->fBlendedColor = GrColor_WHITE; |
239 output->fBlendedColorFlags = kRGBA_GrColorComponentFlags; | 239 output->fBlendedColorFlags = kRGBA_GrColorComponentFlags; |
240 } else { | 240 } else { |
241 output->fBlendedColorFlags = 0; | 241 output->fBlendedColorFlags = 0; |
242 } | 242 } |
243 | 243 |
244 output->fWillBlendWithDst = false; | 244 output->fWillBlendWithDst = false; |
245 } else { | 245 } else { |
246 output->fBlendedColorFlags = 0; | 246 output->fBlendedColorFlags = 0; |
247 output->fWillBlendWithDst = true; | 247 output->fWillBlendWithDst = true; |
248 } | 248 } |
249 } | 249 } |
250 | 250 |
251 GR_DEFINE_XP_FACTORY_TEST(GrCoverageSetOpXPFactory); | 251 GR_DEFINE_XP_FACTORY_TEST(GrCoverageSetOpXPFactory); |
252 | 252 |
253 GrXPFactory* GrCoverageSetOpXPFactory::TestCreate(SkRandom* random, | 253 GrXPFactory* GrCoverageSetOpXPFactory::TestCreate(SkRandom* random, |
254 GrContext*, | 254 GrContext*, |
255 const GrDrawTargetCaps&, | 255 const GrCaps&, |
256 GrTexture*[]) { | 256 GrTexture*[]) { |
257 SkRegion::Op regionOp = SkRegion::Op(random->nextULessThan(SkRegion::kLastOp
+ 1)); | 257 SkRegion::Op regionOp = SkRegion::Op(random->nextULessThan(SkRegion::kLastOp
+ 1)); |
258 bool invertCoverage = random->nextBool(); | 258 bool invertCoverage = random->nextBool(); |
259 return GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage); | 259 return GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage); |
260 } | 260 } |
261 | 261 |
OLD | NEW |