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

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

Issue 1540363002: Don't ref/unref the static src-over xp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tiny Created 4 years, 12 months 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/batches/GrDrawBatch.h ('k') | src/gpu/gl/GrGLGpu.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 832 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 } 843 }
844 BlendFormula blendFormula = static_cast<const PorterDuffXferProcessor*>(xp)- >getBlendFormula(); 844 BlendFormula blendFormula = static_cast<const PorterDuffXferProcessor*>(xp)- >getBlendFormula();
845 *outPrimary = blendFormula.fPrimaryOutputType; 845 *outPrimary = blendFormula.fPrimaryOutputType;
846 *outSecondary = blendFormula.fSecondaryOutputType; 846 *outSecondary = blendFormula.fSecondaryOutputType;
847 } 847 }
848 848
849 849
850 //////////////////////////////////////////////////////////////////////////////// //////////////// 850 //////////////////////////////////////////////////////////////////////////////// ////////////////
851 // SrcOver Global functions 851 // SrcOver Global functions
852 //////////////////////////////////////////////////////////////////////////////// //////////////// 852 //////////////////////////////////////////////////////////////////////////////// ////////////////
853 const GrXferProcessor& GrPorterDuffXPFactory::SimpleSrcOverXP() {
854 static BlendFormula gSrcOverBlendFormula = COEFF_FORMULA(kOne_GrBlendCoeff,
855 kISA_GrBlendCoeff);
856 static PorterDuffXferProcessor gSrcOverXP(gSrcOverBlendFormula);
857 return gSrcOverXP;
858 }
853 859
854 GrXferProcessor* GrPorterDuffXPFactory::CreateSrcOverXferProcessor( 860 GrXferProcessor* GrPorterDuffXPFactory::CreateSrcOverXferProcessor(
855 const GrCaps& caps, 861 const GrCaps& caps,
856 const GrPipelineOptimizations& optimizations, 862 const GrPipelineOptimizations& optimizations,
857 bool hasMixedSamples, 863 bool hasMixedSamples,
858 const GrXferProcessor::DstTexture* dstTexture) { 864 const GrXferProcessor::DstTexture* dstTexture) {
859 if (!optimizations.fCoveragePOI.isFourChannelOutput() && 865 if (!optimizations.fCoveragePOI.isFourChannelOutput() &&
860 !(optimizations.fCoveragePOI.isSolidWhite() && 866 !(optimizations.fCoveragePOI.isSolidWhite() &&
861 !hasMixedSamples && 867 !hasMixedSamples &&
862 optimizations.fColorPOI.isOpaque())) { 868 optimizations.fColorPOI.isOpaque())) {
863 static BlendFormula gSrcOverBlendFormula = COEFF_FORMULA(kOne_GrBlendCoe ff, 869 // We return nullptr here, which our caller interprets as meaning "use S impleSrcOverXP".
864 kISA_GrBlendCoe ff); 870 // We don't simply return the address of that XP here because our caller would have to unref
865 static PorterDuffXferProcessor gSrcOverXP(gSrcOverBlendFormula); 871 // it and since it is a global object and GrProgramElement's ref-cnting system is not thread
866 SkASSERT(!dstTexture || !dstTexture->texture()); 872 // safe.
867 gSrcOverXP.ref(); 873 return nullptr;
868 return &gSrcOverXP;
869 } 874 }
870 875
871 BlendFormula blendFormula; 876 BlendFormula blendFormula;
872 if (optimizations.fCoveragePOI.isFourChannelOutput()) { 877 if (optimizations.fCoveragePOI.isFourChannelOutput()) {
873 if (kRGBA_GrColorComponentFlags == optimizations.fColorPOI.validFlags() && 878 if (kRGBA_GrColorComponentFlags == optimizations.fColorPOI.validFlags() &&
874 !caps.shaderCaps()->dualSourceBlendingSupport() && 879 !caps.shaderCaps()->dualSourceBlendingSupport() &&
875 !caps.shaderCaps()->dstReadInShaderSupport()) { 880 !caps.shaderCaps()->dstReadInShaderSupport()) {
876 // If we don't have dual source blending or in shader dst reads, we fall 881 // If we don't have dual source blending or in shader dst reads, we fall
877 // back to this trick for rendering SrcOver LCD text instead of doin g a 882 // back to this trick for rendering SrcOver LCD text instead of doin g a
878 // dst copy. 883 // dst copy.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 } 916 }
912 return get_lcd_blend_formula(optimizations.fCoveragePOI, 917 return get_lcd_blend_formula(optimizations.fCoveragePOI,
913 SkXfermode::kSrcOver_Mode).hasSecondaryOutp ut(); 918 SkXfermode::kSrcOver_Mode).hasSecondaryOutp ut();
914 } 919 }
915 // We fallback on the shader XP when the blend formula would use dual source blending but we 920 // We fallback on the shader XP when the blend formula would use dual source blending but we
916 // don't have support for it. 921 // don't have support for it.
917 return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI , 922 return get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI ,
918 hasMixedSamples, SkXfermode::kSrcOver_Mode).hasSeco ndaryOutput(); 923 hasMixedSamples, SkXfermode::kSrcOver_Mode).hasSeco ndaryOutput();
919 } 924 }
920 925
OLDNEW
« no previous file with comments | « src/gpu/batches/GrDrawBatch.h ('k') | src/gpu/gl/GrGLGpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698