From 532b3f944a4991064963aee8f535c695f4068368 Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Wed, 11 Jul 2018 10:02:07 -0400 Subject: Remove clamping of kPlus with F16 configs The most common use-case for F16 is to draw things that are explicitly outside of [0,1]. We can't prevent out-of-range values in general, users could just draw out-of-range content in src mode. We've decided that it's best to avoid surprising behavior, and trust the user in these situations. This effectively reverts https://skia-review.googlesource.com/c/skia/+/48183 Bug: skia: Change-Id: I71c2dd925c567e2862d96ab70c752f19245a69c4 Reviewed-on: https://skia-review.googlesource.com/140500 Reviewed-by: Mike Klein Reviewed-by: Brian Salomon Commit-Queue: Brian Osman --- src/gpu/effects/GrCoverageSetOpXP.cpp | 3 +-- src/gpu/effects/GrCoverageSetOpXP.h | 6 ++---- src/gpu/effects/GrCustomXfermode.cpp | 11 ++++------- src/gpu/effects/GrDisableColorXP.cpp | 3 +-- src/gpu/effects/GrDisableColorXP.h | 6 ++---- src/gpu/effects/GrPorterDuffXferProcessor.cpp | 23 +++++++---------------- src/gpu/effects/GrPorterDuffXferProcessor.h | 9 +++------ 7 files changed, 20 insertions(+), 41 deletions(-) (limited to 'src/gpu/effects') diff --git a/src/gpu/effects/GrCoverageSetOpXP.cpp b/src/gpu/effects/GrCoverageSetOpXP.cpp index 2524c9c298..e7ac874c2b 100644 --- a/src/gpu/effects/GrCoverageSetOpXP.cpp +++ b/src/gpu/effects/GrCoverageSetOpXP.cpp @@ -211,8 +211,7 @@ sk_sp GrCoverageSetOpXPFactory::makeXferProcessor( const GrProcessorAnalysisColor&, GrProcessorAnalysisCoverage, bool hasMixedSamples, - const GrCaps& caps, - GrPixelConfigIsClamped dstIsClamped) const { + const GrCaps& caps) const { // We don't support inverting coverage with mixed samples. We don't expect to ever want this in // the future, however we could at some point make this work using an inverted coverage // modulation table. Note that an inverted table still won't work if there are coverage procs. diff --git a/src/gpu/effects/GrCoverageSetOpXP.h b/src/gpu/effects/GrCoverageSetOpXP.h index cf91848944..e8bc5a223f 100644 --- a/src/gpu/effects/GrCoverageSetOpXP.h +++ b/src/gpu/effects/GrCoverageSetOpXP.h @@ -37,13 +37,11 @@ private: sk_sp makeXferProcessor(const GrProcessorAnalysisColor&, GrProcessorAnalysisCoverage, bool hasMixedSamples, - const GrCaps&, - GrPixelConfigIsClamped) const override; + const GrCaps&) const override; AnalysisProperties analysisProperties(const GrProcessorAnalysisColor&, const GrProcessorAnalysisCoverage&, - const GrCaps&, - GrPixelConfigIsClamped) const override { + const GrCaps&) const override { return AnalysisProperties::kIgnoresInputColor; } diff --git a/src/gpu/effects/GrCustomXfermode.cpp b/src/gpu/effects/GrCustomXfermode.cpp index bdeda9467c..5c352604c6 100644 --- a/src/gpu/effects/GrCustomXfermode.cpp +++ b/src/gpu/effects/GrCustomXfermode.cpp @@ -217,13 +217,11 @@ private: sk_sp makeXferProcessor(const GrProcessorAnalysisColor&, GrProcessorAnalysisCoverage, bool hasMixedSamples, - const GrCaps&, - GrPixelConfigIsClamped) const override; + const GrCaps&) const override; AnalysisProperties analysisProperties(const GrProcessorAnalysisColor&, const GrProcessorAnalysisCoverage&, - const GrCaps&, - GrPixelConfigIsClamped) const override; + const GrCaps&) const override; GR_DECLARE_XP_FACTORY_TEST @@ -243,8 +241,7 @@ sk_sp CustomXPFactory::makeXferProcessor( const GrProcessorAnalysisColor&, GrProcessorAnalysisCoverage coverage, bool hasMixedSamples, - const GrCaps& caps, - GrPixelConfigIsClamped dstIsClamped) const { + const GrCaps& caps) const { SkASSERT(GrCustomXfermode::IsSupportedMode(fMode)); if (can_use_hw_blend_equation(fHWBlendEquation, coverage, caps)) { return sk_sp(new CustomXP(fMode, fHWBlendEquation)); @@ -254,7 +251,7 @@ sk_sp CustomXPFactory::makeXferProcessor( GrXPFactory::AnalysisProperties CustomXPFactory::analysisProperties( const GrProcessorAnalysisColor&, const GrProcessorAnalysisCoverage& coverage, - const GrCaps& caps, GrPixelConfigIsClamped dstIsClamped) const { + const GrCaps& caps) const { /* The general SVG blend equation is defined in the spec as follows: diff --git a/src/gpu/effects/GrDisableColorXP.cpp b/src/gpu/effects/GrDisableColorXP.cpp index 314be6ee13..3f9f71e314 100644 --- a/src/gpu/effects/GrDisableColorXP.cpp +++ b/src/gpu/effects/GrDisableColorXP.cpp @@ -79,8 +79,7 @@ sk_sp GrDisableColorXPFactory::makeXferProcessor( const GrProcessorAnalysisColor&, GrProcessorAnalysisCoverage, bool hasMixedSamples, - const GrCaps& caps, - GrPixelConfigIsClamped dstIsClamped) const { + const GrCaps& caps) const { return sk_sp(new DisableColorXP); } diff --git a/src/gpu/effects/GrDisableColorXP.h b/src/gpu/effects/GrDisableColorXP.h index 0c4f5cf2bb..d15f9525c8 100644 --- a/src/gpu/effects/GrDisableColorXP.h +++ b/src/gpu/effects/GrDisableColorXP.h @@ -30,8 +30,7 @@ private: AnalysisProperties analysisProperties(const GrProcessorAnalysisColor&, const GrProcessorAnalysisCoverage&, - const GrCaps&, - GrPixelConfigIsClamped) const override { + const GrCaps&) const override { return AnalysisProperties::kCompatibleWithAlphaAsCoverage | AnalysisProperties::kIgnoresInputColor; } @@ -39,8 +38,7 @@ private: sk_sp makeXferProcessor(const GrProcessorAnalysisColor&, GrProcessorAnalysisCoverage, bool hasMixedSamples, - const GrCaps&, - GrPixelConfigIsClamped) const override; + const GrCaps&) const override; GR_DECLARE_XP_FACTORY_TEST diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.cpp b/src/gpu/effects/GrPorterDuffXferProcessor.cpp index ca082603de..89f61ecd1f 100644 --- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp +++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp @@ -759,7 +759,7 @@ const GrXPFactory* GrPorterDuffXPFactory::Get(SkBlendMode blendMode) { sk_sp GrPorterDuffXPFactory::makeXferProcessor( const GrProcessorAnalysisColor& color, GrProcessorAnalysisCoverage coverage, - bool hasMixedSamples, const GrCaps& caps, GrPixelConfigIsClamped dstIsClamped) const { + bool hasMixedSamples, const GrCaps& caps) const { BlendFormula blendFormula; bool isLCD = coverage == GrProcessorAnalysisCoverage::kLCD; if (isLCD) { @@ -778,10 +778,8 @@ sk_sp GrPorterDuffXPFactory::makeXferProcessor( hasMixedSamples, fBlendMode); } - bool needsClamp = SkBlendMode::kPlus == fBlendMode; if ((blendFormula.hasSecondaryOutput() && !caps.shaderCaps()->dualSourceBlendingSupport()) || - (isLCD && (SkBlendMode::kSrcOver != fBlendMode /*|| !color.isOpaque()*/)) || - (needsClamp && (GrPixelConfigIsClamped::kNo == dstIsClamped))) { + (isLCD && (SkBlendMode::kSrcOver != fBlendMode /*|| !color.isOpaque()*/))) { return sk_sp(new ShaderPDXferProcessor(hasMixedSamples, fBlendMode, coverage)); } @@ -790,7 +788,7 @@ sk_sp GrPorterDuffXPFactory::makeXferProcessor( static inline GrXPFactory::AnalysisProperties analysis_properties( const GrProcessorAnalysisColor& color, const GrProcessorAnalysisCoverage& coverage, - const GrCaps& caps, GrPixelConfigIsClamped dstIsClamped, SkBlendMode mode) { + const GrCaps& caps, SkBlendMode mode) { using AnalysisProperties = GrXPFactory::AnalysisProperties; AnalysisProperties props = AnalysisProperties::kNone; bool hasCoverage = GrProcessorAnalysisCoverage::kNone != coverage; @@ -837,11 +835,6 @@ static inline GrXPFactory::AnalysisProperties analysis_properties( } } - bool needsClamp = SkBlendMode::kPlus == mode; - if (needsClamp && (GrPixelConfigIsClamped::kNo == dstIsClamped)) { - props |= AnalysisProperties::kReadsDstInShader; - } - if (!formula.modifiesDst() || !formula.usesInputColor()) { props |= AnalysisProperties::kIgnoresInputColor; } @@ -857,9 +850,8 @@ static inline GrXPFactory::AnalysisProperties analysis_properties( GrXPFactory::AnalysisProperties GrPorterDuffXPFactory::analysisProperties( const GrProcessorAnalysisColor& color, const GrProcessorAnalysisCoverage& coverage, - const GrCaps& caps, - GrPixelConfigIsClamped dstIsClamped) const { - return analysis_properties(color, coverage, caps, dstIsClamped, fBlendMode); + const GrCaps& caps) const { + return analysis_properties(color, coverage, caps, fBlendMode); } GR_DEFINE_XP_FACTORY_TEST(GrPorterDuffXPFactory); @@ -946,7 +938,6 @@ sk_sp GrPorterDuffXPFactory::MakeNoCoverageXP(SkBlendMode GrXPFactory::AnalysisProperties GrPorterDuffXPFactory::SrcOverAnalysisProperties( const GrProcessorAnalysisColor& color, const GrProcessorAnalysisCoverage& coverage, - const GrCaps& caps, - GrPixelConfigIsClamped dstIsClamped) { - return analysis_properties(color, coverage, caps, dstIsClamped, SkBlendMode::kSrcOver); + const GrCaps& caps) { + return analysis_properties(color, coverage, caps, SkBlendMode::kSrcOver); } diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.h b/src/gpu/effects/GrPorterDuffXferProcessor.h index 74ae1533bf..ebe02126d2 100644 --- a/src/gpu/effects/GrPorterDuffXferProcessor.h +++ b/src/gpu/effects/GrPorterDuffXferProcessor.h @@ -41,8 +41,7 @@ public: static AnalysisProperties SrcOverAnalysisProperties(const GrProcessorAnalysisColor&, const GrProcessorAnalysisCoverage&, - const GrCaps&, - GrPixelConfigIsClamped); + const GrCaps&); private: constexpr GrPorterDuffXPFactory(SkBlendMode); @@ -50,13 +49,11 @@ private: sk_sp makeXferProcessor(const GrProcessorAnalysisColor&, GrProcessorAnalysisCoverage, bool hasMixedSamples, - const GrCaps&, - GrPixelConfigIsClamped) const override; + const GrCaps&) const override; AnalysisProperties analysisProperties(const GrProcessorAnalysisColor&, const GrProcessorAnalysisCoverage&, - const GrCaps&, - GrPixelConfigIsClamped) const override; + const GrCaps&) const override; GR_DECLARE_XP_FACTORY_TEST static void TestGetXPOutputTypes(const GrXferProcessor*, int* outPrimary, int* outSecondary); -- cgit v1.2.3