| 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 #include "effects/GrPorterDuffXferProcessor.h" | 8 #include "effects/GrPorterDuffXferProcessor.h" |
| 9 | 9 |
| 10 #include "GrBlend.h" | 10 #include "GrBlend.h" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 | 259 |
| 260 // If we do have coverage determine whether it matters. Dual source blendin
g is expensive so | 260 // If we do have coverage determine whether it matters. Dual source blendin
g is expensive so |
| 261 // we don't do it if we are doing coverage drawing. If we aren't then We al
ways do dual source | 261 // we don't do it if we are doing coverage drawing. If we aren't then We al
ways do dual source |
| 262 // blending if we have any effective coverage stages OR the geometry process
or doesn't emits | 262 // blending if we have any effective coverage stages OR the geometry process
or doesn't emits |
| 263 // solid coverage. | 263 // solid coverage. |
| 264 if (!(optFlags & kSetCoverageDrawing_OptFlag) && !hasSolidCoverage) { | 264 if (!(optFlags & kSetCoverageDrawing_OptFlag) && !hasSolidCoverage) { |
| 265 if (caps.dualSourceBlendingSupport()) { | 265 if (caps.dualSourceBlendingSupport()) { |
| 266 if (kZero_GrBlendCoeff == fDstBlend) { | 266 if (kZero_GrBlendCoeff == fDstBlend) { |
| 267 // write the coverage value to second color | 267 // write the coverage value to second color |
| 268 fSecondaryOutputType = kCoverage_SecondaryOutputType; | 268 fSecondaryOutputType = kCoverage_SecondaryOutputType; |
| 269 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; | 269 fDstBlend = kIS2C_GrBlendCoeff; |
| 270 } else if (kSA_GrBlendCoeff == fDstBlend) { | 270 } else if (kSA_GrBlendCoeff == fDstBlend) { |
| 271 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially
covered. | 271 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially
covered. |
| 272 fSecondaryOutputType = kCoverageISA_SecondaryOutputType; | 272 fSecondaryOutputType = kCoverageISA_SecondaryOutputType; |
| 273 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; | 273 fDstBlend = kIS2C_GrBlendCoeff; |
| 274 } else if (kSC_GrBlendCoeff == fDstBlend) { | 274 } else if (kSC_GrBlendCoeff == fDstBlend) { |
| 275 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially
covered. | 275 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially
covered. |
| 276 fSecondaryOutputType = kCoverageISC_SecondaryOutputType; | 276 fSecondaryOutputType = kCoverageISC_SecondaryOutputType; |
| 277 fDstBlend = (GrBlendCoeff)GrGpu::kIS2C_GrBlendCoeff; | 277 fDstBlend = kIS2C_GrBlendCoeff; |
| 278 } | 278 } |
| 279 } | 279 } |
| 280 } | 280 } |
| 281 } | 281 } |
| 282 | 282 |
| 283 GrXferProcessor::OptFlags | 283 GrXferProcessor::OptFlags |
| 284 PorterDuffXferProcessor::internalGetOptimizations(const GrProcOptInfo& colorPOI, | 284 PorterDuffXferProcessor::internalGetOptimizations(const GrProcOptInfo& colorPOI, |
| 285 const GrProcOptInfo& coverageP
OI, | 285 const GrProcOptInfo& coverageP
OI, |
| 286 bool doesStencilWrite) { | 286 bool doesStencilWrite) { |
| 287 bool srcAIsOne; | 287 bool srcAIsOne; |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 const GrProcOptInfo& coveragePOI) c
onst { | 610 const GrProcOptInfo& coveragePOI) c
onst { |
| 611 return false; | 611 return false; |
| 612 } | 612 } |
| 613 | 613 |
| 614 GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory); | 614 GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory); |
| 615 | 615 |
| 616 GrXPFactory* GrPorterDuffXPFactory::TestCreate(SkRandom* random, | 616 GrXPFactory* GrPorterDuffXPFactory::TestCreate(SkRandom* random, |
| 617 GrContext*, | 617 GrContext*, |
| 618 const GrDrawTargetCaps&, | 618 const GrDrawTargetCaps&, |
| 619 GrTexture*[]) { | 619 GrTexture*[]) { |
| 620 GrBlendCoeff src; | 620 SkXfermode::Mode mode = SkXfermode::Mode(random->nextULessThan(SkXfermode::k
LastCoeffMode)); |
| 621 do { | 621 return GrPorterDuffXPFactory::Create(mode); |
| 622 src = GrBlendCoeff(random->nextRangeU(kFirstPublicGrBlendCoeff, kLastPub
licGrBlendCoeff)); | |
| 623 } while (GrBlendCoeffRefsSrc(src)); | |
| 624 | |
| 625 GrBlendCoeff dst; | |
| 626 do { | |
| 627 dst = GrBlendCoeff(random->nextRangeU(kFirstPublicGrBlendCoeff, kLastPub
licGrBlendCoeff)); | |
| 628 } while (GrBlendCoeffRefsDst(dst)); | |
| 629 | |
| 630 return GrPorterDuffXPFactory::Create(src, dst); | |
| 631 } | 622 } |
| 632 | 623 |
| OLD | NEW |