| 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 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 blendedColor->fKnownColorFlags = colorPOI.validFlags(); | 792 blendedColor->fKnownColorFlags = colorPOI.validFlags(); |
| 793 return; | 793 return; |
| 794 | 794 |
| 795 default: | 795 default: |
| 796 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; | 796 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; |
| 797 return; | 797 return; |
| 798 } | 798 } |
| 799 } | 799 } |
| 800 | 800 |
| 801 bool GrPorterDuffXPFactory::onWillReadDstColor(const GrCaps& caps, | 801 bool GrPorterDuffXPFactory::onWillReadDstColor(const GrCaps& caps, |
| 802 const GrPipelineOptimizations& op
timizations, | 802 const GrPipelineOptimizations& op
timizations) const { |
| 803 bool hasMixedSamples) const { | |
| 804 if (caps.shaderCaps()->dualSourceBlendingSupport()) { | 803 if (caps.shaderCaps()->dualSourceBlendingSupport()) { |
| 805 return false; | 804 return false; |
| 806 } | 805 } |
| 807 | 806 |
| 808 // When we have four channel coverage we always need to read the dst in orde
r to correctly | 807 // When we have four channel coverage we always need to read the dst in orde
r to correctly |
| 809 // blend. The one exception is when we are using srcover mode and we know th
e input color into | 808 // blend. The one exception is when we are using srcover mode and we know th
e input color into |
| 810 // the XP. | 809 // the XP. |
| 811 if (optimizations.fCoveragePOI.isFourChannelOutput()) { | 810 if (optimizations.fCoveragePOI.isFourChannelOutput()) { |
| 812 if (SkXfermode::kSrcOver_Mode == fXfermode && | 811 if (SkXfermode::kSrcOver_Mode == fXfermode && |
| 813 kRGBA_GrColorComponentFlags == optimizations.fColorPOI.validFlags()
&& | 812 kRGBA_GrColorComponentFlags == optimizations.fColorPOI.validFlags()
&& |
| 814 !caps.shaderCaps()->dstReadInShaderSupport()) { | 813 !caps.shaderCaps()->dstReadInShaderSupport()) { |
| 815 return false; | 814 return false; |
| 816 } | 815 } |
| 817 return get_lcd_blend_formula(optimizations.fCoveragePOI, fXfermode).hasS
econdaryOutput(); | 816 return get_lcd_blend_formula(optimizations.fCoveragePOI, fXfermode).hasS
econdaryOutput(); |
| 818 } | 817 } |
| 818 |
| 819 // We fallback on the shader XP when the blend formula would use dual source
blending but we | 819 // We fallback on the shader XP when the blend formula would use dual source
blending but we |
| 820 // don't have support for it. | 820 // don't have support for it. |
| 821 return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI
, hasMixedSamples, | 821 static const bool kHasMixedSamples = false; |
| 822 SkASSERT(!caps.usesMixedSamples()); // We never use mixed samples without du
al source blending. |
| 823 return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI
, kHasMixedSamples, |
| 822 fXfermode).hasSecondaryOutput(); | 824 fXfermode).hasSecondaryOutput(); |
| 823 } | 825 } |
| 824 | 826 |
| 825 GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory); | 827 GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory); |
| 826 | 828 |
| 827 const GrXPFactory* GrPorterDuffXPFactory::TestCreate(GrProcessorTestData* d) { | 829 const GrXPFactory* GrPorterDuffXPFactory::TestCreate(GrProcessorTestData* d) { |
| 828 SkXfermode::Mode mode = SkXfermode::Mode(d->fRandom->nextULessThan(SkXfermod
e::kLastCoeffMode)); | 830 SkXfermode::Mode mode = SkXfermode::Mode(d->fRandom->nextULessThan(SkXfermod
e::kLastCoeffMode)); |
| 829 return GrPorterDuffXPFactory::Create(mode); | 831 return GrPorterDuffXPFactory::Create(mode); |
| 830 } | 832 } |
| 831 | 833 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 | 892 |
| 891 if (blendFormula.hasSecondaryOutput() && !caps.shaderCaps()->dualSourceBlend
ingSupport()) { | 893 if (blendFormula.hasSecondaryOutput() && !caps.shaderCaps()->dualSourceBlend
ingSupport()) { |
| 892 return new ShaderPDXferProcessor(dstTexture, hasMixedSamples, SkXfermode
::kSrcOver_Mode); | 894 return new ShaderPDXferProcessor(dstTexture, hasMixedSamples, SkXfermode
::kSrcOver_Mode); |
| 893 } | 895 } |
| 894 | 896 |
| 895 SkASSERT(!dstTexture || !dstTexture->texture()); | 897 SkASSERT(!dstTexture || !dstTexture->texture()); |
| 896 return new PorterDuffXferProcessor(blendFormula); | 898 return new PorterDuffXferProcessor(blendFormula); |
| 897 } | 899 } |
| 898 | 900 |
| 899 bool GrPorterDuffXPFactory::SrcOverWillNeedDstTexture(const GrCaps& caps, | 901 bool GrPorterDuffXPFactory::SrcOverWillNeedDstTexture(const GrCaps& caps, |
| 900 const GrPipelineOptimizati
ons& optimizations, | 902 const GrPipelineOptimizatio
ns& optimizations) { |
| 901 bool hasMixedSamples) { | |
| 902 if (caps.shaderCaps()->dstReadInShaderSupport() || | 903 if (caps.shaderCaps()->dstReadInShaderSupport() || |
| 903 caps.shaderCaps()->dualSourceBlendingSupport()) { | 904 caps.shaderCaps()->dualSourceBlendingSupport()) { |
| 904 return false; | 905 return false; |
| 905 } | 906 } |
| 906 | 907 |
| 907 // When we have four channel coverage we always need to read the dst in orde
r to correctly | 908 // When we have four channel coverage we always need to read the dst in orde
r to correctly |
| 908 // blend. The one exception is when we are using srcover mode and we know th
e input color | 909 // blend. The one exception is when we are using srcover mode and we know th
e input color |
| 909 // into the XP. | 910 // into the XP. |
| 910 if (optimizations.fCoveragePOI.isFourChannelOutput()) { | 911 if (optimizations.fCoveragePOI.isFourChannelOutput()) { |
| 911 if (kRGBA_GrColorComponentFlags == optimizations.fColorPOI.validFlags()
&& | 912 if (kRGBA_GrColorComponentFlags == optimizations.fColorPOI.validFlags()
&& |
| 912 !caps.shaderCaps()->dstReadInShaderSupport()) { | 913 !caps.shaderCaps()->dstReadInShaderSupport()) { |
| 913 return false; | 914 return false; |
| 914 } | 915 } |
| 915 return get_lcd_blend_formula(optimizations.fCoveragePOI, | 916 return get_lcd_blend_formula(optimizations.fCoveragePOI, |
| 916 SkXfermode::kSrcOver_Mode).hasSecondaryOutp
ut(); | 917 SkXfermode::kSrcOver_Mode).hasSecondaryOutp
ut(); |
| 917 } | 918 } |
| 919 |
| 918 // We fallback on the shader XP when the blend formula would use dual source
blending but we | 920 // We fallback on the shader XP when the blend formula would use dual source
blending but we |
| 919 // don't have support for it. | 921 // don't have support for it. |
| 922 static const bool kHasMixedSamples = false; |
| 923 SkASSERT(!caps.usesMixedSamples()); // We never use mixed samples without du
al source blending. |
| 920 return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI
, | 924 return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI
, |
| 921 hasMixedSamples, SkXfermode::kSrcOver_Mode).hasSeco
ndaryOutput(); | 925 kHasMixedSamples, SkXfermode::kSrcOver_Mode).hasSec
ondaryOutput(); |
| 922 } | 926 } |
| OLD | NEW |