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 844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 } | 855 } |
856 | 856 |
857 GrXferProcessor* GrPorterDuffXPFactory::CreateSrcOverXferProcessor( | 857 GrXferProcessor* GrPorterDuffXPFactory::CreateSrcOverXferProcessor( |
858 const GrCaps& caps, | 858 const GrCaps& caps, |
859 const GrPipelineOptimizations& optimizations, | 859 const GrPipelineOptimizations& optimizations, |
860 bool hasMixedSamples, | 860 bool hasMixedSamples, |
861 const GrXferProcessor::DstTexture* dstTexture) { | 861 const GrXferProcessor::DstTexture* dstTexture) { |
862 if (optimizations.fOverrides.fUsePLSDstRead) { | 862 if (optimizations.fOverrides.fUsePLSDstRead) { |
863 return new ShaderPDXferProcessor(dstTexture, hasMixedSamples, SkXfermode
::kSrcOver_Mode); | 863 return new ShaderPDXferProcessor(dstTexture, hasMixedSamples, SkXfermode
::kSrcOver_Mode); |
864 } | 864 } |
865 if (!optimizations.fCoveragePOI.isFourChannelOutput() && | 865 |
866 !(optimizations.fCoveragePOI.isSolidWhite() && | 866 // We want to not make an xfer processor if possible. Thus for the simple ca
se where we are not |
867 !hasMixedSamples && | 867 // doing lcd blending we will just use our global SimpleSrcOverXP. This slig
htly differs from |
868 optimizations.fColorPOI.isOpaque())) { | 868 // the general case where we convert a src-over blend that has solid coverag
e and an opaque |
| 869 // color to src-mode, which allows disabling of blending. |
| 870 if (!optimizations.fCoveragePOI.isFourChannelOutput()) { |
869 // We return nullptr here, which our caller interprets as meaning "use S
impleSrcOverXP". | 871 // We return nullptr here, which our caller interprets as meaning "use S
impleSrcOverXP". |
870 // We don't simply return the address of that XP here because our caller
would have to unref | 872 // We don't simply return the address of that XP here because our caller
would have to unref |
871 // it and since it is a global object and GrProgramElement's ref-cnting
system is not thread | 873 // it and since it is a global object and GrProgramElement's ref-cnting
system is not thread |
872 // safe. | 874 // safe. |
873 return nullptr; | 875 return nullptr; |
874 } | 876 } |
875 | 877 |
876 BlendFormula blendFormula; | 878 if (kRGBA_GrColorComponentFlags == optimizations.fColorPOI.validFlags() && |
877 if (optimizations.fCoveragePOI.isFourChannelOutput()) { | 879 !caps.shaderCaps()->dualSourceBlendingSupport() && |
878 if (kRGBA_GrColorComponentFlags == optimizations.fColorPOI.validFlags()
&& | 880 !caps.shaderCaps()->dstReadInShaderSupport()) { |
879 !caps.shaderCaps()->dualSourceBlendingSupport() && | 881 // If we don't have dual source blending or in shader dst reads, we fall |
880 !caps.shaderCaps()->dstReadInShaderSupport()) { | 882 // back to this trick for rendering SrcOver LCD text instead of doing a |
881 // If we don't have dual source blending or in shader dst reads, we
fall | 883 // dst copy. |
882 // back to this trick for rendering SrcOver LCD text instead of doin
g a | 884 SkASSERT(!dstTexture || !dstTexture->texture()); |
883 // dst copy. | 885 return PDLCDXferProcessor::Create(SkXfermode::kSrcOver_Mode, optimizatio
ns.fColorPOI); |
884 SkASSERT(!dstTexture || !dstTexture->texture()); | |
885 return PDLCDXferProcessor::Create(SkXfermode::kSrcOver_Mode, optimiz
ations.fColorPOI); | |
886 } | |
887 blendFormula = get_lcd_blend_formula(optimizations.fCoveragePOI, SkXferm
ode::kSrcOver_Mode); | |
888 } else { | |
889 blendFormula = get_blend_formula(optimizations.fColorPOI, optimizations.
fCoveragePOI, | |
890 hasMixedSamples, SkXfermode::kSrcOver_M
ode); | |
891 } | 886 } |
892 | 887 |
| 888 BlendFormula blendFormula; |
| 889 blendFormula = get_lcd_blend_formula(optimizations.fCoveragePOI, SkXfermode:
:kSrcOver_Mode); |
893 if (blendFormula.hasSecondaryOutput() && !caps.shaderCaps()->dualSourceBlend
ingSupport()) { | 890 if (blendFormula.hasSecondaryOutput() && !caps.shaderCaps()->dualSourceBlend
ingSupport()) { |
894 return new ShaderPDXferProcessor(dstTexture, hasMixedSamples, SkXfermode
::kSrcOver_Mode); | 891 return new ShaderPDXferProcessor(dstTexture, hasMixedSamples, SkXfermode
::kSrcOver_Mode); |
895 } | 892 } |
896 | 893 |
897 SkASSERT(!dstTexture || !dstTexture->texture()); | 894 SkASSERT(!dstTexture || !dstTexture->texture()); |
898 return new PorterDuffXferProcessor(blendFormula); | 895 return new PorterDuffXferProcessor(blendFormula); |
899 } | 896 } |
900 | 897 |
901 bool GrPorterDuffXPFactory::SrcOverWillNeedDstTexture(const GrCaps& caps, | 898 bool GrPorterDuffXPFactory::SrcOverWillNeedDstTexture(const GrCaps& caps, |
902 const GrPipelineOptimizatio
ns& optimizations) { | 899 const GrPipelineOptimizatio
ns& optimizations) { |
(...skipping 14 matching lines...) Expand all Loading... |
917 SkXfermode::kSrcOver_Mode).hasSecondaryOutp
ut(); | 914 SkXfermode::kSrcOver_Mode).hasSecondaryOutp
ut(); |
918 } | 915 } |
919 | 916 |
920 // We fallback on the shader XP when the blend formula would use dual source
blending but we | 917 // We fallback on the shader XP when the blend formula would use dual source
blending but we |
921 // don't have support for it. | 918 // don't have support for it. |
922 static const bool kHasMixedSamples = false; | 919 static const bool kHasMixedSamples = false; |
923 SkASSERT(!caps.usesMixedSamples()); // We never use mixed samples without du
al source blending. | 920 SkASSERT(!caps.usesMixedSamples()); // We never use mixed samples without du
al source blending. |
924 return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI
, | 921 return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI
, |
925 kHasMixedSamples, SkXfermode::kSrcOver_Mode).hasSec
ondaryOutput(); | 922 kHasMixedSamples, SkXfermode::kSrcOver_Mode).hasSec
ondaryOutput(); |
926 } | 923 } |
OLD | NEW |