| 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 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 return nullptr; | 741 return nullptr; |
| 742 } | 742 } |
| 743 return SkRef(gFactories[xfermode]); | 743 return SkRef(gFactories[xfermode]); |
| 744 } | 744 } |
| 745 | 745 |
| 746 GrXferProcessor* | 746 GrXferProcessor* |
| 747 GrPorterDuffXPFactory::onCreateXferProcessor(const GrCaps& caps, | 747 GrPorterDuffXPFactory::onCreateXferProcessor(const GrCaps& caps, |
| 748 const GrPipelineOptimizations& opti
mizations, | 748 const GrPipelineOptimizations& opti
mizations, |
| 749 bool hasMixedSamples, | 749 bool hasMixedSamples, |
| 750 const DstTexture* dstTexture) const
{ | 750 const DstTexture* dstTexture) const
{ |
| 751 if (optimizations.fOverrides.fUsePLSDstRead) { | |
| 752 return new ShaderPDXferProcessor(dstTexture, hasMixedSamples, fXfermode)
; | |
| 753 } | |
| 754 BlendFormula blendFormula; | 751 BlendFormula blendFormula; |
| 755 if (optimizations.fCoveragePOI.isFourChannelOutput()) { | 752 if (optimizations.fCoveragePOI.isFourChannelOutput()) { |
| 756 if (SkXfermode::kSrcOver_Mode == fXfermode && | 753 if (SkXfermode::kSrcOver_Mode == fXfermode && |
| 757 kRGBA_GrColorComponentFlags == optimizations.fColorPOI.validFlags()
&& | 754 kRGBA_GrColorComponentFlags == optimizations.fColorPOI.validFlags()
&& |
| 758 !caps.shaderCaps()->dualSourceBlendingSupport() && | 755 !caps.shaderCaps()->dualSourceBlendingSupport() && |
| 759 !caps.shaderCaps()->dstReadInShaderSupport()) { | 756 !caps.shaderCaps()->dstReadInShaderSupport()) { |
| 760 // If we don't have dual source blending or in shader dst reads, we
fall back to this | 757 // If we don't have dual source blending or in shader dst reads, we
fall back to this |
| 761 // trick for rendering SrcOver LCD text instead of doing a dst copy. | 758 // trick for rendering SrcOver LCD text instead of doing a dst copy. |
| 762 SkASSERT(!dstTexture || !dstTexture->texture()); | 759 SkASSERT(!dstTexture || !dstTexture->texture()); |
| 763 return PDLCDXferProcessor::Create(fXfermode, optimizations.fColorPOI
); | 760 return PDLCDXferProcessor::Create(fXfermode, optimizations.fColorPOI
); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 blendedColor->fKnownColor = colorPOI.color(); | 797 blendedColor->fKnownColor = colorPOI.color(); |
| 801 blendedColor->fKnownColorFlags = colorPOI.validFlags(); | 798 blendedColor->fKnownColorFlags = colorPOI.validFlags(); |
| 802 return; | 799 return; |
| 803 | 800 |
| 804 default: | 801 default: |
| 805 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; | 802 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; |
| 806 return; | 803 return; |
| 807 } | 804 } |
| 808 } | 805 } |
| 809 | 806 |
| 810 bool GrPorterDuffXPFactory::onWillReadDstColor(const GrCaps& caps, | 807 bool GrPorterDuffXPFactory::willReadDstColor(const GrCaps& caps, |
| 811 const GrPipelineOptimizations& op
timizations, | 808 const GrPipelineOptimizations& opti
mizations, |
| 812 bool hasMixedSamples) const { | 809 bool hasMixedSamples) const { |
| 813 if (caps.shaderCaps()->dualSourceBlendingSupport()) { | 810 if (caps.shaderCaps()->dualSourceBlendingSupport()) { |
| 814 return false; | 811 return false; |
| 815 } | 812 } |
| 816 | 813 |
| 817 // When we have four channel coverage we always need to read the dst in orde
r to correctly | 814 // When we have four channel coverage we always need to read the dst in orde
r to correctly |
| 818 // blend. The one exception is when we are using srcover mode and we know th
e input color into | 815 // blend. The one exception is when we are using srcover mode and we know th
e input color into |
| 819 // the XP. | 816 // the XP. |
| 820 if (optimizations.fCoveragePOI.isFourChannelOutput()) { | 817 if (optimizations.fCoveragePOI.isFourChannelOutput()) { |
| 821 if (SkXfermode::kSrcOver_Mode == fXfermode && | 818 if (SkXfermode::kSrcOver_Mode == fXfermode && |
| 822 kRGBA_GrColorComponentFlags == optimizations.fColorPOI.validFlags()
&& | 819 kRGBA_GrColorComponentFlags == optimizations.fColorPOI.validFlags()
&& |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 kISA_GrBlendCoeff); | 856 kISA_GrBlendCoeff); |
| 860 static PorterDuffXferProcessor gSrcOverXP(gSrcOverBlendFormula); | 857 static PorterDuffXferProcessor gSrcOverXP(gSrcOverBlendFormula); |
| 861 return gSrcOverXP; | 858 return gSrcOverXP; |
| 862 } | 859 } |
| 863 | 860 |
| 864 GrXferProcessor* GrPorterDuffXPFactory::CreateSrcOverXferProcessor( | 861 GrXferProcessor* GrPorterDuffXPFactory::CreateSrcOverXferProcessor( |
| 865 const GrCaps& caps, | 862 const GrCaps& caps, |
| 866 const GrPipelineOptimizations& optimizations, | 863 const GrPipelineOptimizations& optimizations, |
| 867 bool hasMixedSamples, | 864 bool hasMixedSamples, |
| 868 const GrXferProcessor::DstTexture* dstTexture) { | 865 const GrXferProcessor::DstTexture* dstTexture) { |
| 869 if (optimizations.fOverrides.fUsePLSDstRead) { | |
| 870 return new ShaderPDXferProcessor(dstTexture, hasMixedSamples, SkXfermode
::kSrcOver_Mode); | |
| 871 } | |
| 872 if (!optimizations.fCoveragePOI.isFourChannelOutput() && | 866 if (!optimizations.fCoveragePOI.isFourChannelOutput() && |
| 873 !(optimizations.fCoveragePOI.isSolidWhite() && | 867 !(optimizations.fCoveragePOI.isSolidWhite() && |
| 874 !hasMixedSamples && | 868 !hasMixedSamples && |
| 875 optimizations.fColorPOI.isOpaque())) { | 869 optimizations.fColorPOI.isOpaque())) { |
| 876 // We return nullptr here, which our caller interprets as meaning "use S
impleSrcOverXP". | 870 // We return nullptr here, which our caller interprets as meaning "use S
impleSrcOverXP". |
| 877 // We don't simply return the address of that XP here because our caller
would have to unref | 871 // We don't simply return the address of that XP here because our caller
would have to unref |
| 878 // it and since it is a global object and GrProgramElement's ref-cnting
system is not thread | 872 // it and since it is a global object and GrProgramElement's ref-cnting
system is not thread |
| 879 // safe. | 873 // safe. |
| 880 return nullptr; | 874 return nullptr; |
| 881 } | 875 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 } | 917 } |
| 924 return get_lcd_blend_formula(optimizations.fCoveragePOI, | 918 return get_lcd_blend_formula(optimizations.fCoveragePOI, |
| 925 SkXfermode::kSrcOver_Mode).hasSecondaryOutp
ut(); | 919 SkXfermode::kSrcOver_Mode).hasSecondaryOutp
ut(); |
| 926 } | 920 } |
| 927 // We fallback on the shader XP when the blend formula would use dual source
blending but we | 921 // We fallback on the shader XP when the blend formula would use dual source
blending but we |
| 928 // don't have support for it. | 922 // don't have support for it. |
| 929 return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI
, | 923 return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI
, |
| 930 hasMixedSamples, SkXfermode::kSrcOver_Mode).hasSeco
ndaryOutput(); | 924 hasMixedSamples, SkXfermode::kSrcOver_Mode).hasSeco
ndaryOutput(); |
| 931 } | 925 } |
| 932 | 926 |
| OLD | NEW |