| 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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  451             return NULL; |  451             return NULL; | 
|  452     } |  452     } | 
|  453 } |  453 } | 
|  454  |  454  | 
|  455 GrXferProcessor* |  455 GrXferProcessor* | 
|  456 GrPorterDuffXPFactory::onCreateXferProcessor(const GrProcOptInfo& colorPOI, |  456 GrPorterDuffXPFactory::onCreateXferProcessor(const GrProcOptInfo& colorPOI, | 
|  457                                              const GrProcOptInfo& covPOI, |  457                                              const GrProcOptInfo& covPOI, | 
|  458                                              const GrDeviceCoordTexture* dstCopy
     ) const { |  458                                              const GrDeviceCoordTexture* dstCopy
     ) const { | 
|  459     if (!covPOI.isFourChannelOutput()) { |  459     if (!covPOI.isFourChannelOutput()) { | 
|  460         return PorterDuffXferProcessor::Create(fSrcCoeff, fDstCoeff, 0, dstCopy, |  460         return PorterDuffXferProcessor::Create(fSrcCoeff, fDstCoeff, 0, dstCopy, | 
|  461                                                this->willReadDstColor()); |  461                                                this->willReadDstColor(colorPOI, 
     covPOI)); | 
|  462     } else { |  462     } else { | 
|  463         if (this->supportsRGBCoverage(colorPOI.color(), colorPOI.validFlags())) 
     { |  463         if (this->supportsRGBCoverage(colorPOI.color(), colorPOI.validFlags())) 
     { | 
|  464             SkASSERT(kRGBA_GrColorComponentFlags == colorPOI.validFlags()); |  464             SkASSERT(kRGBA_GrColorComponentFlags == colorPOI.validFlags()); | 
|  465             GrColor blendConstant = GrUnPreMulColor(colorPOI.color()); |  465             GrColor blendConstant = GrUnPreMulColor(colorPOI.color()); | 
|  466             return PorterDuffXferProcessor::Create(kConstC_GrBlendCoeff, kISC_Gr
     BlendCoeff, |  466             return PorterDuffXferProcessor::Create(kConstC_GrBlendCoeff, kISC_Gr
     BlendCoeff, | 
|  467                                                    blendConstant, dstCopy, |  467                                                    blendConstant, dstCopy, | 
|  468                                                    this->willReadDstColor()); |  468                                                    this->willReadDstColor(colorP
     OI, covPOI)); | 
|  469         } else { |  469         } else { | 
|  470             return NULL; |  470             return NULL; | 
|  471         } |  471         } | 
|  472     } |  472     } | 
|  473 } |  473 } | 
|  474  |  474  | 
|  475 bool GrPorterDuffXPFactory::supportsRGBCoverage(GrColor /*knownColor*/, |  475 bool GrPorterDuffXPFactory::supportsRGBCoverage(GrColor /*knownColor*/, | 
|  476                                                 uint32_t knownColorFlags) const 
     { |  476                                                 uint32_t knownColorFlags) const 
     { | 
|  477     if (kOne_GrBlendCoeff == fSrcCoeff && kISA_GrBlendCoeff == fDstCoeff && |  477     if (kOne_GrBlendCoeff == fSrcCoeff && kISA_GrBlendCoeff == fDstCoeff && | 
|  478         kRGBA_GrColorComponentFlags == knownColorFlags) { |  478         kRGBA_GrColorComponentFlags == knownColorFlags) { | 
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  580         case kIConstC_GrBlendCoeff: |  580         case kIConstC_GrBlendCoeff: | 
|  581         case kConstA_GrBlendCoeff: |  581         case kConstA_GrBlendCoeff: | 
|  582         case kIConstA_GrBlendCoeff: |  582         case kIConstA_GrBlendCoeff: | 
|  583             output->fBlendedColorFlags = 0; |  583             output->fBlendedColorFlags = 0; | 
|  584             break; |  584             break; | 
|  585     } |  585     } | 
|  586  |  586  | 
|  587     output->fWillBlendWithDst = false; |  587     output->fWillBlendWithDst = false; | 
|  588 } |  588 } | 
|  589  |  589  | 
|  590 bool GrPorterDuffXPFactory::willReadDstColor() const { |  590 bool GrPorterDuffXPFactory::willReadDstColor(const GrProcOptInfo& colorPOI, | 
 |  591                                              const GrProcOptInfo& coveragePOI) c
     onst { | 
|  591     return false; |  592     return false; | 
|  592 } |  593 } | 
|  593  |  594  | 
|  594 GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory); |  595 GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory); | 
|  595  |  596  | 
|  596 GrXPFactory* GrPorterDuffXPFactory::TestCreate(SkRandom* random, |  597 GrXPFactory* GrPorterDuffXPFactory::TestCreate(SkRandom* random, | 
|  597                                                GrContext*, |  598                                                GrContext*, | 
|  598                                                const GrDrawTargetCaps&, |  599                                                const GrDrawTargetCaps&, | 
|  599                                                GrTexture*[]) { |  600                                                GrTexture*[]) { | 
|  600     GrBlendCoeff src; |  601     GrBlendCoeff src; | 
|  601     do { |  602     do { | 
|  602         src = GrBlendCoeff(random->nextRangeU(kFirstPublicGrBlendCoeff, kLastPub
     licGrBlendCoeff)); |  603         src = GrBlendCoeff(random->nextRangeU(kFirstPublicGrBlendCoeff, kLastPub
     licGrBlendCoeff)); | 
|  603     } while (GrBlendCoeffRefsSrc(src)); |  604     } while (GrBlendCoeffRefsSrc(src)); | 
|  604  |  605  | 
|  605     GrBlendCoeff dst; |  606     GrBlendCoeff dst; | 
|  606     do { |  607     do { | 
|  607         dst = GrBlendCoeff(random->nextRangeU(kFirstPublicGrBlendCoeff, kLastPub
     licGrBlendCoeff)); |  608         dst = GrBlendCoeff(random->nextRangeU(kFirstPublicGrBlendCoeff, kLastPub
     licGrBlendCoeff)); | 
|  608     } while (GrBlendCoeffRefsDst(dst)); |  609     } while (GrBlendCoeffRefsDst(dst)); | 
|  609  |  610  | 
|  610     return GrPorterDuffXPFactory::Create(src, dst); |  611     return GrPorterDuffXPFactory::Create(src, dst); | 
|  611 } |  612 } | 
|  612  |  613  | 
| OLD | NEW |