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