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 "GrCaps.h" | 10 #include "GrCaps.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 const char* name() const override { return "Coverage Set Op"; } | 26 const char* name() const override { return "Coverage Set Op"; } |
27 | 27 |
28 GrGLSLXferProcessor* createGLSLInstance() const override; | 28 GrGLSLXferProcessor* createGLSLInstance() const override; |
29 | 29 |
30 bool invertCoverage() const { return fInvertCoverage; } | 30 bool invertCoverage() const { return fInvertCoverage; } |
31 | 31 |
32 private: | 32 private: |
33 CoverageSetOpXP(SkRegion::Op regionOp, bool fInvertCoverage); | 33 CoverageSetOpXP(SkRegion::Op regionOp, bool fInvertCoverage); |
34 | 34 |
35 GrXferProcessor::OptFlags onGetOptimizations(const GrProcOptInfo& colorPOI, | 35 GrXferProcessor::OptFlags onGetOptimizations(const GrPipelineOptimizations&
optimizations, |
36 const GrProcOptInfo& coveragePO
I, | |
37 bool doesStencilWrite, | 36 bool doesStencilWrite, |
38 GrColor* color, | 37 GrColor* color, |
39 const GrCaps& caps) override; | 38 const GrCaps& caps) override; |
40 | 39 |
41 void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b)
const override; | 40 void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b)
const override; |
42 | 41 |
43 void onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const override; | 42 void onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) const override; |
44 | 43 |
45 bool onIsEqual(const GrXferProcessor& xpBase) const override { | 44 bool onIsEqual(const GrXferProcessor& xpBase) const override { |
46 const CoverageSetOpXP& xp = xpBase.cast<CoverageSetOpXP>(); | 45 const CoverageSetOpXP& xp = xpBase.cast<CoverageSetOpXP>(); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 void CoverageSetOpXP::onGetGLSLProcessorKey(const GrGLSLCaps& caps, | 99 void CoverageSetOpXP::onGetGLSLProcessorKey(const GrGLSLCaps& caps, |
101 GrProcessorKeyBuilder* b) const { | 100 GrProcessorKeyBuilder* b) const { |
102 GLCoverageSetOpXP::GenKey(*this, caps, b); | 101 GLCoverageSetOpXP::GenKey(*this, caps, b); |
103 } | 102 } |
104 | 103 |
105 GrGLSLXferProcessor* CoverageSetOpXP::createGLSLInstance() const { | 104 GrGLSLXferProcessor* CoverageSetOpXP::createGLSLInstance() const { |
106 return new GLCoverageSetOpXP(*this); | 105 return new GLCoverageSetOpXP(*this); |
107 } | 106 } |
108 | 107 |
109 GrXferProcessor::OptFlags | 108 GrXferProcessor::OptFlags |
110 CoverageSetOpXP::onGetOptimizations(const GrProcOptInfo& colorPOI, | 109 CoverageSetOpXP::onGetOptimizations(const GrPipelineOptimizations& optimizations
, |
111 const GrProcOptInfo& coveragePOI, | |
112 bool doesStencilWrite, | 110 bool doesStencilWrite, |
113 GrColor* color, | 111 GrColor* color, |
114 const GrCaps& caps) { | 112 const GrCaps& caps) { |
115 // We never look at the color input | 113 // We never look at the color input |
116 return GrXferProcessor::kIgnoreColor_OptFlag; | 114 return GrXferProcessor::kIgnoreColor_OptFlag; |
117 } | 115 } |
118 | 116 |
119 void CoverageSetOpXP::onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) cons
t { | 117 void CoverageSetOpXP::onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) cons
t { |
120 switch (fRegionOp) { | 118 switch (fRegionOp) { |
121 case SkRegion::kReplace_Op: | 119 case SkRegion::kReplace_Op: |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 } | 214 } |
217 break; | 215 break; |
218 } | 216 } |
219 default: | 217 default: |
220 return nullptr; | 218 return nullptr; |
221 } | 219 } |
222 } | 220 } |
223 | 221 |
224 GrXferProcessor* | 222 GrXferProcessor* |
225 GrCoverageSetOpXPFactory::onCreateXferProcessor(const GrCaps& caps, | 223 GrCoverageSetOpXPFactory::onCreateXferProcessor(const GrCaps& caps, |
226 const GrProcOptInfo& colorPOI, | 224 const GrPipelineOptimizations& o
ptimizations, |
227 const GrProcOptInfo& covPOI, | |
228 bool hasMixedSamples, | 225 bool hasMixedSamples, |
229 const DstTexture* dst) const { | 226 const DstTexture* dst) const { |
230 // We don't support inverting coverage with mixed samples. We don't expect t
o ever want this in | 227 // We don't support inverting coverage with mixed samples. We don't expect t
o ever want this in |
231 // the future, however we could at some point make this work using an invert
ed coverage | 228 // the future, however we could at some point make this work using an invert
ed coverage |
232 // modulation table. Note that an inverted table still won't work if there a
re coverage procs. | 229 // modulation table. Note that an inverted table still won't work if there a
re coverage procs. |
233 if (fInvertCoverage && hasMixedSamples) { | 230 if (fInvertCoverage && hasMixedSamples) { |
234 SkASSERT(false); | 231 SkASSERT(false); |
235 return nullptr; | 232 return nullptr; |
236 } | 233 } |
237 | 234 |
238 return CoverageSetOpXP::Create(fRegionOp, fInvertCoverage); | 235 return CoverageSetOpXP::Create(fRegionOp, fInvertCoverage); |
239 } | 236 } |
240 | 237 |
241 void GrCoverageSetOpXPFactory::getInvariantBlendedColor(const GrProcOptInfo& col
orPOI, | 238 void GrCoverageSetOpXPFactory::getInvariantBlendedColor(const GrProcOptInfo& col
orPOI, |
242 InvariantBlendedColor* b
lendedColor) const { | 239 InvariantBlendedColor* b
lendedColor) const { |
243 blendedColor->fWillBlendWithDst = SkRegion::kReplace_Op != fRegionOp; | 240 blendedColor->fWillBlendWithDst = SkRegion::kReplace_Op != fRegionOp; |
244 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; | 241 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; |
245 } | 242 } |
246 | 243 |
247 GR_DEFINE_XP_FACTORY_TEST(GrCoverageSetOpXPFactory); | 244 GR_DEFINE_XP_FACTORY_TEST(GrCoverageSetOpXPFactory); |
248 | 245 |
249 const GrXPFactory* GrCoverageSetOpXPFactory::TestCreate(GrProcessorTestData* d)
{ | 246 const GrXPFactory* GrCoverageSetOpXPFactory::TestCreate(GrProcessorTestData* d)
{ |
250 SkRegion::Op regionOp = SkRegion::Op(d->fRandom->nextULessThan(SkRegion::kLa
stOp + 1)); | 247 SkRegion::Op regionOp = SkRegion::Op(d->fRandom->nextULessThan(SkRegion::kLa
stOp + 1)); |
251 bool invertCoverage = !d->fRenderTarget->hasMixedSamples() && d->fRandom->ne
xtBool(); | 248 bool invertCoverage = !d->fRenderTarget->hasMixedSamples() && d->fRandom->ne
xtBool(); |
252 return GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage); | 249 return GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage); |
253 } | 250 } |
254 | 251 |
OLD | NEW |