| 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 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 732 return nullptr; | 732 return nullptr; |
| 733 } | 733 } |
| 734 return SkRef(gFactories[xfermode]); | 734 return SkRef(gFactories[xfermode]); |
| 735 } | 735 } |
| 736 | 736 |
| 737 GrXferProcessor* | 737 GrXferProcessor* |
| 738 GrPorterDuffXPFactory::onCreateXferProcessor(const GrCaps& caps, | 738 GrPorterDuffXPFactory::onCreateXferProcessor(const GrCaps& caps, |
| 739 const GrPipelineOptimizations& opti
mizations, | 739 const GrPipelineOptimizations& opti
mizations, |
| 740 bool hasMixedSamples, | 740 bool hasMixedSamples, |
| 741 const DstTexture* dstTexture) const
{ | 741 const DstTexture* dstTexture) const
{ |
| 742 if (optimizations.fOverrides.fUsePLSDstRead) { |
| 743 return new ShaderPDXferProcessor(dstTexture, hasMixedSamples, fXfermode)
; |
| 744 } |
| 742 BlendFormula blendFormula; | 745 BlendFormula blendFormula; |
| 743 if (optimizations.fCoveragePOI.isFourChannelOutput()) { | 746 if (optimizations.fCoveragePOI.isFourChannelOutput()) { |
| 744 if (SkXfermode::kSrcOver_Mode == fXfermode && | 747 if (SkXfermode::kSrcOver_Mode == fXfermode && |
| 745 kRGBA_GrColorComponentFlags == optimizations.fColorPOI.validFlags()
&& | 748 kRGBA_GrColorComponentFlags == optimizations.fColorPOI.validFlags()
&& |
| 746 !caps.shaderCaps()->dualSourceBlendingSupport() && | 749 !caps.shaderCaps()->dualSourceBlendingSupport() && |
| 747 !caps.shaderCaps()->dstReadInShaderSupport()) { | 750 !caps.shaderCaps()->dstReadInShaderSupport()) { |
| 748 // If we don't have dual source blending or in shader dst reads, we
fall back to this | 751 // If we don't have dual source blending or in shader dst reads, we
fall back to this |
| 749 // trick for rendering SrcOver LCD text instead of doing a dst copy. | 752 // trick for rendering SrcOver LCD text instead of doing a dst copy. |
| 750 SkASSERT(!dstTexture || !dstTexture->texture()); | 753 SkASSERT(!dstTexture || !dstTexture->texture()); |
| 751 return PDLCDXferProcessor::Create(fXfermode, optimizations.fColorPOI
); | 754 return PDLCDXferProcessor::Create(fXfermode, optimizations.fColorPOI
); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 | 794 |
| 792 default: | 795 default: |
| 793 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; | 796 blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; |
| 794 return; | 797 return; |
| 795 } | 798 } |
| 796 } | 799 } |
| 797 | 800 |
| 798 bool GrPorterDuffXPFactory::willReadDstColor(const GrCaps& caps, | 801 bool GrPorterDuffXPFactory::willReadDstColor(const GrCaps& caps, |
| 799 const GrPipelineOptimizations& opti
mizations, | 802 const GrPipelineOptimizations& opti
mizations, |
| 800 bool hasMixedSamples) const { | 803 bool hasMixedSamples) const { |
| 804 if (INHERITED::willReadDstColor(caps, optimizations, hasMixedSamples)) { |
| 805 return true; |
| 806 } |
| 801 if (caps.shaderCaps()->dualSourceBlendingSupport()) { | 807 if (caps.shaderCaps()->dualSourceBlendingSupport()) { |
| 802 return false; | 808 return false; |
| 803 } | 809 } |
| 804 | 810 |
| 805 // When we have four channel coverage we always need to read the dst in orde
r to correctly | 811 // When we have four channel coverage we always need to read the dst in orde
r to correctly |
| 806 // blend. The one exception is when we are using srcover mode and we know th
e input color into | 812 // blend. The one exception is when we are using srcover mode and we know th
e input color into |
| 807 // the XP. | 813 // the XP. |
| 808 if (optimizations.fCoveragePOI.isFourChannelOutput()) { | 814 if (optimizations.fCoveragePOI.isFourChannelOutput()) { |
| 809 if (SkXfermode::kSrcOver_Mode == fXfermode && | 815 if (SkXfermode::kSrcOver_Mode == fXfermode && |
| 810 kRGBA_GrColorComponentFlags == optimizations.fColorPOI.validFlags()
&& | 816 kRGBA_GrColorComponentFlags == optimizations.fColorPOI.validFlags()
&& |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 kISA_GrBlendCoeff); | 853 kISA_GrBlendCoeff); |
| 848 static PorterDuffXferProcessor gSrcOverXP(gSrcOverBlendFormula); | 854 static PorterDuffXferProcessor gSrcOverXP(gSrcOverBlendFormula); |
| 849 return gSrcOverXP; | 855 return gSrcOverXP; |
| 850 } | 856 } |
| 851 | 857 |
| 852 GrXferProcessor* GrPorterDuffXPFactory::CreateSrcOverXferProcessor( | 858 GrXferProcessor* GrPorterDuffXPFactory::CreateSrcOverXferProcessor( |
| 853 const GrCaps& caps, | 859 const GrCaps& caps, |
| 854 const GrPipelineOptimizations& optimizations, | 860 const GrPipelineOptimizations& optimizations, |
| 855 bool hasMixedSamples, | 861 bool hasMixedSamples, |
| 856 const GrXferProcessor::DstTexture* dstTexture) { | 862 const GrXferProcessor::DstTexture* dstTexture) { |
| 863 if (optimizations.fOverrides.fUsePLSDstRead) { |
| 864 return new ShaderPDXferProcessor(dstTexture, hasMixedSamples, SkXfermode
::kSrcOver_Mode); |
| 865 } |
| 857 if (!optimizations.fCoveragePOI.isFourChannelOutput() && | 866 if (!optimizations.fCoveragePOI.isFourChannelOutput() && |
| 858 !(optimizations.fCoveragePOI.isSolidWhite() && | 867 !(optimizations.fCoveragePOI.isSolidWhite() && |
| 859 !hasMixedSamples && | 868 !hasMixedSamples && |
| 860 optimizations.fColorPOI.isOpaque())) { | 869 optimizations.fColorPOI.isOpaque())) { |
| 861 // 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". |
| 862 // 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 |
| 863 // 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 |
| 864 // safe. | 873 // safe. |
| 865 return nullptr; | 874 return nullptr; |
| 866 } | 875 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 908 } | 917 } |
| 909 return get_lcd_blend_formula(optimizations.fCoveragePOI, | 918 return get_lcd_blend_formula(optimizations.fCoveragePOI, |
| 910 SkXfermode::kSrcOver_Mode).hasSecondaryOutp
ut(); | 919 SkXfermode::kSrcOver_Mode).hasSecondaryOutp
ut(); |
| 911 } | 920 } |
| 912 // 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 |
| 913 // don't have support for it. | 922 // don't have support for it. |
| 914 return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI
, | 923 return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI
, |
| 915 hasMixedSamples, SkXfermode::kSrcOver_Mode).hasSeco
ndaryOutput(); | 924 hasMixedSamples, SkXfermode::kSrcOver_Mode).hasSeco
ndaryOutput(); |
| 916 } | 925 } |
| 917 | 926 |
| OLD | NEW |