OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
4 * | 3 * |
5 * 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 |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
9 #include "effects/GrCoverageSetOpXP.h" | 8 #include "effects/GrCoverageSetOpXP.h" |
10 #include "GrCaps.h" | 9 #include "GrCaps.h" |
11 #include "GrColor.h" | 10 #include "GrColor.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 GrGLSLXferProcessor* CoverageSetOpXP::createGLSLInstance() const { | 105 GrGLSLXferProcessor* CoverageSetOpXP::createGLSLInstance() const { |
107 return new GLCoverageSetOpXP(*this); | 106 return new GLCoverageSetOpXP(*this); |
108 } | 107 } |
109 | 108 |
110 GrXferProcessor::OptFlags | 109 GrXferProcessor::OptFlags |
111 CoverageSetOpXP::onGetOptimizations(const GrPipelineOptimizations& optimizations
, | 110 CoverageSetOpXP::onGetOptimizations(const GrPipelineOptimizations& optimizations
, |
112 bool doesStencilWrite, | 111 bool doesStencilWrite, |
113 GrColor* color, | 112 GrColor* color, |
114 const GrCaps& caps) const { | 113 const GrCaps& caps) const { |
115 // We never look at the color input | 114 // We never look at the color input |
116 return GrXferProcessor::kIgnoreColor_OptFlag; | 115 return GrXferProcessor::kIgnoreColor_OptFlag; |
117 } | 116 } |
118 | 117 |
119 void CoverageSetOpXP::onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) cons
t { | 118 void CoverageSetOpXP::onGetBlendInfo(GrXferProcessor::BlendInfo* blendInfo) cons
t { |
120 switch (fRegionOp) { | 119 switch (fRegionOp) { |
121 case SkRegion::kReplace_Op: | 120 case SkRegion::kReplace_Op: |
122 blendInfo->fSrcBlend = kOne_GrBlendCoeff; | 121 blendInfo->fSrcBlend = kOne_GrBlendCoeff; |
123 blendInfo->fDstBlend = kZero_GrBlendCoeff; | 122 blendInfo->fDstBlend = kZero_GrBlendCoeff; |
124 break; | 123 break; |
125 case SkRegion::kIntersect_Op: | 124 case SkRegion::kIntersect_Op: |
126 blendInfo->fSrcBlend = kDC_GrBlendCoeff; | 125 blendInfo->fSrcBlend = kDC_GrBlendCoeff; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 } | 160 } |
162 | 161 |
163 const char* name() const override { return "Coverage Set Op Shader"; } | 162 const char* name() const override { return "Coverage Set Op Shader"; } |
164 | 163 |
165 GrGLSLXferProcessor* createGLSLInstance() const override; | 164 GrGLSLXferProcessor* createGLSLInstance() const override; |
166 | 165 |
167 SkRegion::Op regionOp() const { return fRegionOp; } | 166 SkRegion::Op regionOp() const { return fRegionOp; } |
168 bool invertCoverage() const { return fInvertCoverage; } | 167 bool invertCoverage() const { return fInvertCoverage; } |
169 | 168 |
170 private: | 169 private: |
171 GrXferProcessor::OptFlags onGetOptimizations(const GrPipelineOptimizations&,
bool, GrColor*, | 170 GrXferProcessor::OptFlags onGetOptimizations(const GrPipelineOptimizations&,
bool, GrColor*, |
172 const GrCaps&) const override { | 171 const GrCaps&) const override { |
173 // We never look at the color input | 172 // We never look at the color input |
174 return GrXferProcessor::kIgnoreColor_OptFlag; | 173 return GrXferProcessor::kIgnoreColor_OptFlag; |
175 } | 174 } |
176 | 175 |
177 void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b)
const override; | 176 void onGetGLSLProcessorKey(const GrGLSLCaps& caps, GrProcessorKeyBuilder* b)
const override; |
178 | 177 |
179 bool onIsEqual(const GrXferProcessor& xpBase) const override { | 178 bool onIsEqual(const GrXferProcessor& xpBase) const override { |
180 const ShaderCSOXferProcessor& xp = xpBase.cast<ShaderCSOXferProcessor>()
; | 179 const ShaderCSOXferProcessor& xp = xpBase.cast<ShaderCSOXferProcessor>()
; |
181 return (fRegionOp == xp.fRegionOp && | 180 return (fRegionOp == xp.fRegionOp && |
182 fInvertCoverage == xp.fInvertCoverage); | 181 fInvertCoverage == xp.fInvertCoverage); |
183 } | 182 } |
184 | 183 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; | 334 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; |
336 } | 335 } |
337 | 336 |
338 GR_DEFINE_XP_FACTORY_TEST(GrCoverageSetOpXPFactory); | 337 GR_DEFINE_XP_FACTORY_TEST(GrCoverageSetOpXPFactory); |
339 | 338 |
340 const GrXPFactory* GrCoverageSetOpXPFactory::TestCreate(GrProcessorTestData* d)
{ | 339 const GrXPFactory* GrCoverageSetOpXPFactory::TestCreate(GrProcessorTestData* d)
{ |
341 SkRegion::Op regionOp = SkRegion::Op(d->fRandom->nextULessThan(SkRegion::kLa
stOp + 1)); | 340 SkRegion::Op regionOp = SkRegion::Op(d->fRandom->nextULessThan(SkRegion::kLa
stOp + 1)); |
342 bool invertCoverage = !d->fRenderTarget->hasMixedSamples() && d->fRandom->ne
xtBool(); | 341 bool invertCoverage = !d->fRenderTarget->hasMixedSamples() && d->fRandom->ne
xtBool(); |
343 return GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage); | 342 return GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage); |
344 } | 343 } |
345 | |
OLD | NEW |