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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 } else if (optFlags & kIgnoreCoverage_OptFlag) { | 344 } else if (optFlags & kIgnoreCoverage_OptFlag) { |
345 fPrimaryOutputType = kColor_PrimaryOutputType; | 345 fPrimaryOutputType = kColor_PrimaryOutputType; |
346 return; | 346 return; |
347 } | 347 } |
348 | 348 |
349 // If we do have coverage determine whether it matters. Dual source blendin
g is expensive so | 349 // If we do have coverage determine whether it matters. Dual source blendin
g is expensive so |
350 // we don't do it if we are doing coverage drawing. If we aren't then We al
ways do dual source | 350 // we don't do it if we are doing coverage drawing. If we aren't then We al
ways do dual source |
351 // blending if we have any effective coverage stages OR the geometry process
or doesn't emits | 351 // blending if we have any effective coverage stages OR the geometry process
or doesn't emits |
352 // solid coverage. | 352 // solid coverage. |
353 if (!(optFlags & kSetCoverageDrawing_OptFlag) && !hasSolidCoverage) { | 353 if (!(optFlags & kSetCoverageDrawing_OptFlag) && !hasSolidCoverage) { |
354 if (caps.dualSourceBlendingSupport()) { | 354 if (caps.shaderCaps()->dualSourceBlendingSupport()) { |
355 if (kZero_GrBlendCoeff == fDstBlend) { | 355 if (kZero_GrBlendCoeff == fDstBlend) { |
356 // write the coverage value to second color | 356 // write the coverage value to second color |
357 fSecondaryOutputType = kCoverage_SecondaryOutputType; | 357 fSecondaryOutputType = kCoverage_SecondaryOutputType; |
358 fDstBlend = kIS2C_GrBlendCoeff; | 358 fDstBlend = kIS2C_GrBlendCoeff; |
359 } else if (kSA_GrBlendCoeff == fDstBlend) { | 359 } else if (kSA_GrBlendCoeff == fDstBlend) { |
360 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially
covered. | 360 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially
covered. |
361 fSecondaryOutputType = kCoverageISA_SecondaryOutputType; | 361 fSecondaryOutputType = kCoverageISA_SecondaryOutputType; |
362 fDstBlend = kIS2C_GrBlendCoeff; | 362 fDstBlend = kIS2C_GrBlendCoeff; |
363 } else if (kSC_GrBlendCoeff == fDstBlend) { | 363 } else if (kSC_GrBlendCoeff == fDstBlend) { |
364 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially
covered. | 364 // SA dst coeff becomes 1-(1-SA)*coverage when dst is partially
covered. |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 break; | 661 break; |
662 } | 662 } |
663 | 663 |
664 output->fWillBlendWithDst = false; | 664 output->fWillBlendWithDst = false; |
665 } | 665 } |
666 | 666 |
667 bool GrPorterDuffXPFactory::willReadDstColor(const GrDrawTargetCaps& caps, | 667 bool GrPorterDuffXPFactory::willReadDstColor(const GrDrawTargetCaps& caps, |
668 const GrProcOptInfo& colorPOI, | 668 const GrProcOptInfo& colorPOI, |
669 const GrProcOptInfo& coveragePOI) c
onst { | 669 const GrProcOptInfo& coveragePOI) c
onst { |
670 // We can always blend correctly if we have dual source blending. | 670 // We can always blend correctly if we have dual source blending. |
671 if (caps.dualSourceBlendingSupport()) { | 671 if (caps.shaderCaps()->dualSourceBlendingSupport()) { |
672 return false; | 672 return false; |
673 } | 673 } |
674 | 674 |
675 if (this->canTweakAlphaForCoverage()) { | 675 if (this->canTweakAlphaForCoverage()) { |
676 return false; | 676 return false; |
677 } | 677 } |
678 | 678 |
679 bool srcAIsOne = colorPOI.isOpaque(); | 679 bool srcAIsOne = colorPOI.isOpaque(); |
680 | 680 |
681 if (kZero_GrBlendCoeff == fDstCoeff) { | 681 if (kZero_GrBlendCoeff == fDstCoeff) { |
(...skipping 18 matching lines...) Expand all Loading... |
700 GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory); | 700 GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory); |
701 | 701 |
702 GrXPFactory* GrPorterDuffXPFactory::TestCreate(SkRandom* random, | 702 GrXPFactory* GrPorterDuffXPFactory::TestCreate(SkRandom* random, |
703 GrContext*, | 703 GrContext*, |
704 const GrDrawTargetCaps&, | 704 const GrDrawTargetCaps&, |
705 GrTexture*[]) { | 705 GrTexture*[]) { |
706 SkXfermode::Mode mode = SkXfermode::Mode(random->nextULessThan(SkXfermode::k
LastCoeffMode)); | 706 SkXfermode::Mode mode = SkXfermode::Mode(random->nextULessThan(SkXfermode::k
LastCoeffMode)); |
707 return GrPorterDuffXPFactory::Create(mode); | 707 return GrPorterDuffXPFactory::Create(mode); |
708 } | 708 } |
709 | 709 |
OLD | NEW |