| 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" |
| 11 #include "GrColor.h" | 11 #include "GrColor.h" |
| 12 #include "GrPipeline.h" | |
| 13 #include "GrProcessor.h" | 12 #include "GrProcessor.h" |
| 14 #include "GrProcOptInfo.h" | 13 #include "GrProcOptInfo.h" |
| 15 #include "glsl/GrGLSLBlend.h" | 14 #include "glsl/GrGLSLBlend.h" |
| 16 #include "glsl/GrGLSLFragmentShaderBuilder.h" | 15 #include "glsl/GrGLSLFragmentShaderBuilder.h" |
| 17 #include "glsl/GrGLSLUniformHandler.h" | 16 #include "glsl/GrGLSLUniformHandler.h" |
| 18 #include "glsl/GrGLSLXferProcessor.h" | 17 #include "glsl/GrGLSLXferProcessor.h" |
| 19 | 18 |
| 20 class CoverageSetOpXP : public GrXferProcessor { | 19 class CoverageSetOpXP : public GrXferProcessor { |
| 21 public: | 20 public: |
| 22 static GrXferProcessor* Create(SkRegion::Op regionOp, bool invertCoverage) { | 21 static GrXferProcessor* Create(SkRegion::Op regionOp, bool invertCoverage) { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 } | 144 } |
| 146 blendInfo->fBlendConstant = 0; | 145 blendInfo->fBlendConstant = 0; |
| 147 } | 146 } |
| 148 | 147 |
| 149 /////////////////////////////////////////////////////////////////////////////// | 148 /////////////////////////////////////////////////////////////////////////////// |
| 150 | 149 |
| 151 class ShaderCSOXferProcessor : public GrXferProcessor { | 150 class ShaderCSOXferProcessor : public GrXferProcessor { |
| 152 public: | 151 public: |
| 153 ShaderCSOXferProcessor(const DstTexture* dstTexture, | 152 ShaderCSOXferProcessor(const DstTexture* dstTexture, |
| 154 bool hasMixedSamples, | 153 bool hasMixedSamples, |
| 154 SkXfermode::Mode xfermode, |
| 155 SkRegion::Op regionOp, | 155 SkRegion::Op regionOp, |
| 156 bool invertCoverage) | 156 bool invertCoverage) |
| 157 : INHERITED(dstTexture, true, hasMixedSamples) | 157 : INHERITED(dstTexture, true, hasMixedSamples) |
| 158 , fRegionOp(regionOp) | 158 , fRegionOp(regionOp) |
| 159 , fInvertCoverage(invertCoverage) { | 159 , fInvertCoverage(invertCoverage) { |
| 160 this->initClassID<ShaderCSOXferProcessor>(); | 160 this->initClassID<ShaderCSOXferProcessor>(); |
| 161 } | 161 } |
| 162 | 162 |
| 163 const char* name() const override { return "Coverage Set Op Shader"; } | 163 const char* name() const override { return "Coverage Set Op Shader"; } |
| 164 | 164 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 bool hasMixedSamples, | 316 bool hasMixedSamples, |
| 317 const DstTexture* dst) const { | 317 const DstTexture* dst) const { |
| 318 // We don't support inverting coverage with mixed samples. We don't expect t
o ever want this in | 318 // We don't support inverting coverage with mixed samples. We don't expect t
o ever want this in |
| 319 // the future, however we could at some point make this work using an invert
ed coverage | 319 // the future, however we could at some point make this work using an invert
ed coverage |
| 320 // modulation table. Note that an inverted table still won't work if there a
re coverage procs. | 320 // modulation table. Note that an inverted table still won't work if there a
re coverage procs. |
| 321 if (fInvertCoverage && hasMixedSamples) { | 321 if (fInvertCoverage && hasMixedSamples) { |
| 322 SkASSERT(false); | 322 SkASSERT(false); |
| 323 return nullptr; | 323 return nullptr; |
| 324 } | 324 } |
| 325 | 325 |
| 326 if (optimizations.fOverrides.fUsePLSDstRead) { | |
| 327 return new ShaderCSOXferProcessor(dst, hasMixedSamples, fRegionOp, fInve
rtCoverage); | |
| 328 } | |
| 329 return CoverageSetOpXP::Create(fRegionOp, fInvertCoverage); | 326 return CoverageSetOpXP::Create(fRegionOp, fInvertCoverage); |
| 330 } | 327 } |
| 331 | 328 |
| 332 void GrCoverageSetOpXPFactory::getInvariantBlendedColor(const GrProcOptInfo& col
orPOI, | 329 void GrCoverageSetOpXPFactory::getInvariantBlendedColor(const GrProcOptInfo& col
orPOI, |
| 333 InvariantBlendedColor* b
lendedColor) const { | 330 InvariantBlendedColor* b
lendedColor) const { |
| 334 blendedColor->fWillBlendWithDst = SkRegion::kReplace_Op != fRegionOp; | 331 blendedColor->fWillBlendWithDst = SkRegion::kReplace_Op != fRegionOp; |
| 335 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; | 332 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; |
| 336 } | 333 } |
| 337 | 334 |
| 338 GR_DEFINE_XP_FACTORY_TEST(GrCoverageSetOpXPFactory); | 335 GR_DEFINE_XP_FACTORY_TEST(GrCoverageSetOpXPFactory); |
| 339 | 336 |
| 340 const GrXPFactory* GrCoverageSetOpXPFactory::TestCreate(GrProcessorTestData* d)
{ | 337 const GrXPFactory* GrCoverageSetOpXPFactory::TestCreate(GrProcessorTestData* d)
{ |
| 341 SkRegion::Op regionOp = SkRegion::Op(d->fRandom->nextULessThan(SkRegion::kLa
stOp + 1)); | 338 SkRegion::Op regionOp = SkRegion::Op(d->fRandom->nextULessThan(SkRegion::kLa
stOp + 1)); |
| 342 bool invertCoverage = !d->fRenderTarget->hasMixedSamples() && d->fRandom->ne
xtBool(); | 339 bool invertCoverage = !d->fRenderTarget->hasMixedSamples() && d->fRandom->ne
xtBool(); |
| 343 return GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage); | 340 return GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage); |
| 344 } | 341 } |
| 345 | 342 |
| OLD | NEW |