Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: src/gpu/effects/GrPorterDuffXferProcessor.cpp

Issue 1471053002: Don't create a GXPFactory when blend is SrcOver (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix compile Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/effects/GrDisableColorXP.h ('k') | tests/TessellatingPathRendererTests.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 int* outPrimary, 823 int* outPrimary,
824 int* outSecondary) { 824 int* outSecondary) {
825 if (!!strcmp(xp->name(), "Porter Duff")) { 825 if (!!strcmp(xp->name(), "Porter Duff")) {
826 *outPrimary = *outSecondary = -1; 826 *outPrimary = *outSecondary = -1;
827 return; 827 return;
828 } 828 }
829 BlendFormula blendFormula = static_cast<const PorterDuffXferProcessor*>(xp)- >getBlendFormula(); 829 BlendFormula blendFormula = static_cast<const PorterDuffXferProcessor*>(xp)- >getBlendFormula();
830 *outPrimary = blendFormula.fPrimaryOutputType; 830 *outPrimary = blendFormula.fPrimaryOutputType;
831 *outSecondary = blendFormula.fSecondaryOutputType; 831 *outSecondary = blendFormula.fSecondaryOutputType;
832 } 832 }
833
834
835 //////////////////////////////////////////////////////////////////////////////// ////////////////
836 // SrcOver Global functions
837 //////////////////////////////////////////////////////////////////////////////// ////////////////
838
839 GrXferProcessor* GrPorterDuffXPFactory::CreateSrcOverXferProcessor(
840 const GrCaps& caps,
841 const GrProcOptInfo& colorPOI,
842 const GrProcOptInfo& covPOI,
843 bool hasMixedSamples,
844 const GrXferProcessor::DstTexture* dstTexture) {
845 BlendFormula blendFormula;
846 if (covPOI.isFourChannelOutput()) {
847 if (kRGBA_GrColorComponentFlags == colorPOI.validFlags() &&
848 !caps.shaderCaps()->dualSourceBlendingSupport() &&
849 !caps.shaderCaps()->dstReadInShaderSupport()) {
850 // If we don't have dual source blending or in shader dst reads, we fall
851 // back to this trick for rendering SrcOver LCD text instead of doin g a
852 // dst copy.
853 SkASSERT(!dstTexture || !dstTexture->texture());
854 return PDLCDXferProcessor::Create(SkXfermode::kSrcOver_Mode, colorPO I);
855 }
856 blendFormula = get_lcd_blend_formula(covPOI, SkXfermode::kSrcOver_Mode);
857 } else {
858 blendFormula = get_blend_formula(colorPOI, covPOI, hasMixedSamples,
859 SkXfermode::kSrcOver_Mode);
860 }
861
862 if (blendFormula.hasSecondaryOutput() && !caps.shaderCaps()->dualSourceBlend ingSupport()) {
863 return new ShaderPDXferProcessor(dstTexture, hasMixedSamples, SkXfermode ::kSrcOver_Mode);
864 }
865
866 SkASSERT(!dstTexture || !dstTexture->texture());
867 return new PorterDuffXferProcessor(blendFormula);
868 }
869
870 bool GrPorterDuffXPFactory::SrcOverWillNeedDstTexture(const GrCaps& caps,
871 const GrProcOptInfo& color POI,
872 const GrProcOptInfo& covPO I,
873 bool hasMixedSamples) {
874 if (caps.shaderCaps()->dstReadInShaderSupport() ||
875 caps.shaderCaps()->dualSourceBlendingSupport()) {
876 return false;
877 }
878
879 // When we have four channel coverage we always need to read the dst in orde r to correctly
880 // blend. The one exception is when we are using srcover mode and we know th e input color
881 // into the XP.
882 if (covPOI.isFourChannelOutput()) {
883 if (kRGBA_GrColorComponentFlags == colorPOI.validFlags() &&
884 !caps.shaderCaps()->dstReadInShaderSupport()) {
885 return false;
886 }
887 return get_lcd_blend_formula(covPOI, SkXfermode::kSrcOver_Mode).hasSecon daryOutput();
888 }
889 // We fallback on the shader XP when the blend formula would use dual source blending but we
890 // don't have support for it.
891 return get_blend_formula(colorPOI, covPOI,
892 hasMixedSamples, SkXfermode::kSrcOver_Mode).hasSeco ndaryOutput();
893 }
894
OLDNEW
« no previous file with comments | « src/gpu/effects/GrDisableColorXP.h ('k') | tests/TessellatingPathRendererTests.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698