From abe795e4db533c2e230be0c2be868754e5a02a7e Mon Sep 17 00:00:00 2001 From: egdaniel Date: Thu, 18 Aug 2016 15:21:55 -0700 Subject: [PATCH] Relax check for gpu use of static src-over XP BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2259113002 Review-Url: https://codereview.chromium.org/2259113002 --- src/gpu/effects/GrPorterDuffXferProcessor.cpp | 35 ++++++++++++--------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.cpp b/src/gpu/effects/GrPorterDuffXferProcessor.cpp index 9aae026..7f804bb 100644 --- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp +++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp @@ -862,10 +862,12 @@ GrXferProcessor* GrPorterDuffXPFactory::CreateSrcOverXferProcessor( if (optimizations.fOverrides.fUsePLSDstRead) { return new ShaderPDXferProcessor(dstTexture, hasMixedSamples, SkXfermode::kSrcOver_Mode); } - if (!optimizations.fCoveragePOI.isFourChannelOutput() && - !(optimizations.fCoveragePOI.isSolidWhite() && - !hasMixedSamples && - optimizations.fColorPOI.isOpaque())) { + + // We want to not make an xfer processor if possible. Thus for the simple case where we are not + // doing lcd blending we will just use our global SimpleSrcOverXP. This slightly differs from + // the general case where we convert a src-over blend that has solid coverage and an opaque + // color to src-mode, which allows disabling of blending. + if (!optimizations.fCoveragePOI.isFourChannelOutput()) { // We return nullptr here, which our caller interprets as meaning "use SimpleSrcOverXP". // We don't simply return the address of that XP here because our caller would have to unref // it and since it is a global object and GrProgramElement's ref-cnting system is not thread @@ -873,23 +875,18 @@ GrXferProcessor* GrPorterDuffXPFactory::CreateSrcOverXferProcessor( return nullptr; } - BlendFormula blendFormula; - if (optimizations.fCoveragePOI.isFourChannelOutput()) { - if (kRGBA_GrColorComponentFlags == optimizations.fColorPOI.validFlags() && - !caps.shaderCaps()->dualSourceBlendingSupport() && - !caps.shaderCaps()->dstReadInShaderSupport()) { - // If we don't have dual source blending or in shader dst reads, we fall - // back to this trick for rendering SrcOver LCD text instead of doing a - // dst copy. - SkASSERT(!dstTexture || !dstTexture->texture()); - return PDLCDXferProcessor::Create(SkXfermode::kSrcOver_Mode, optimizations.fColorPOI); - } - blendFormula = get_lcd_blend_formula(optimizations.fCoveragePOI, SkXfermode::kSrcOver_Mode); - } else { - blendFormula = get_blend_formula(optimizations.fColorPOI, optimizations.fCoveragePOI, - hasMixedSamples, SkXfermode::kSrcOver_Mode); + if (kRGBA_GrColorComponentFlags == optimizations.fColorPOI.validFlags() && + !caps.shaderCaps()->dualSourceBlendingSupport() && + !caps.shaderCaps()->dstReadInShaderSupport()) { + // If we don't have dual source blending or in shader dst reads, we fall + // back to this trick for rendering SrcOver LCD text instead of doing a + // dst copy. + SkASSERT(!dstTexture || !dstTexture->texture()); + return PDLCDXferProcessor::Create(SkXfermode::kSrcOver_Mode, optimizations.fColorPOI); } + BlendFormula blendFormula; + blendFormula = get_lcd_blend_formula(optimizations.fCoveragePOI, SkXfermode::kSrcOver_Mode); if (blendFormula.hasSecondaryOutput() && !caps.shaderCaps()->dualSourceBlendingSupport()) { return new ShaderPDXferProcessor(dstTexture, hasMixedSamples, SkXfermode::kSrcOver_Mode); } -- 2.7.4