From: Brian Salomon Date: Mon, 27 Mar 2017 17:09:36 +0000 (-0400) Subject: Split GrPipelineInput into separate color and coverage types, the latter of which... X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~46^2~312 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c0b642ca48d58416409e555549434066f09692b7;p=platform%2Fupstream%2FlibSkiaSharp.git Split GrPipelineInput into separate color and coverage types, the latter of which is just an enum. Assign names that indicate that they aren't just for the input phase since I plan to use them at the boundary between FPs and XPs as well. Renamed GrProcOptInfo to GrColorFragmentProcessorAnalysis. This is now only used on the color side and the new name seems clearer to me. Change GrMeshDrawOp::getFragmentProcessorAnalysisInputs to use the new color/coverage types directly rather than a class that has been reduced to simply bundling them together. Change-Id: If93bae74c9d590486eecdf63f302418c96deab65 Reviewed-on: https://skia-review.googlesource.com/10161 Commit-Queue: Brian Salomon Reviewed-by: Greg Daniel --- diff --git a/gn/gpu.gni b/gn/gpu.gni index e4bdacf..a481cfd 100644 --- a/gn/gpu.gni +++ b/gn/gpu.gni @@ -134,8 +134,9 @@ skia_gpu_sources = [ "$_src/gpu/GrPreFlushResourceProvider.h", "$_src/gpu/GrPipeline.cpp", "$_src/gpu/GrPipeline.h", + "$_src/gpu/GrPipelineAnalysis.cpp", + "$_src/gpu/GrPipelineAnalysis.h", "$_src/gpu/GrPipelineBuilder.h", - "$_src/gpu/GrPipelineInput.h", "$_src/gpu/GrPrimitiveProcessor.cpp", "$_src/gpu/GrPrimitiveProcessor.h", "$_src/gpu/GrProcessorSet.cpp", @@ -144,8 +145,6 @@ skia_gpu_sources = [ "$_src/gpu/GrProgramDesc.h", "$_src/gpu/GrProcessor.cpp", "$_src/gpu/GrProcessorUnitTest.cpp", - "$_src/gpu/GrProcOptInfo.cpp", - "$_src/gpu/GrProcOptInfo.h", "$_src/gpu/GrGpuResourceRef.cpp", "$_src/gpu/GrQuad.h", "$_src/gpu/GrRect.h", diff --git a/src/gpu/GrFragmentProcessor.cpp b/src/gpu/GrFragmentProcessor.cpp index 0d1bfad..fdec93b 100644 --- a/src/gpu/GrFragmentProcessor.cpp +++ b/src/gpu/GrFragmentProcessor.cpp @@ -8,13 +8,13 @@ #include "GrFragmentProcessor.h" #include "GrCoordTransform.h" #include "GrPipeline.h" -#include "GrProcOptInfo.h" +#include "GrPipelineAnalysis.h" +#include "effects/GrConstColorProcessor.h" +#include "effects/GrXfermodeFragmentProcessor.h" #include "glsl/GrGLSLFragmentProcessor.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" #include "glsl/GrGLSLProgramDataManager.h" #include "glsl/GrGLSLUniformHandler.h" -#include "effects/GrConstColorProcessor.h" -#include "effects/GrXfermodeFragmentProcessor.h" GrFragmentProcessor::~GrFragmentProcessor() { // If we got here then our ref count must have reached zero, so we will have converted refs @@ -466,7 +466,7 @@ sk_sp GrFragmentProcessor::RunInSeries(sk_sp> replacementSeries; GrColor4f knownColor; diff --git a/src/gpu/GrPaint.cpp b/src/gpu/GrPaint.cpp index 5dc998e..6c5a041 100644 --- a/src/gpu/GrPaint.cpp +++ b/src/gpu/GrPaint.cpp @@ -6,7 +6,6 @@ */ #include "GrPaint.h" -#include "GrProcOptInfo.h" #include "GrXferProcessor.h" #include "effects/GrCoverageSetOpXP.h" #include "effects/GrPorterDuffXferProcessor.h" diff --git a/src/gpu/GrPipeline.cpp b/src/gpu/GrPipeline.cpp index 00dc984..adcdd0f 100644 --- a/src/gpu/GrPipeline.cpp +++ b/src/gpu/GrPipeline.cpp @@ -11,7 +11,6 @@ #include "GrCaps.h" #include "GrGpu.h" #include "GrPipelineBuilder.h" -#include "GrProcOptInfo.h" #include "GrRenderTargetContext.h" #include "GrRenderTargetOpList.h" #include "GrRenderTargetPriv.h" diff --git a/src/gpu/GrPipeline.h b/src/gpu/GrPipeline.h index 7f2ac79..2169342 100644 --- a/src/gpu/GrPipeline.h +++ b/src/gpu/GrPipeline.h @@ -13,7 +13,6 @@ #include "GrNonAtomicRef.h" #include "GrPendingProgramElement.h" #include "GrPrimitiveProcessor.h" -#include "GrProcOptInfo.h" #include "GrProcessorSet.h" #include "GrProgramDesc.h" #include "GrScissorState.h" diff --git a/src/gpu/GrProcOptInfo.cpp b/src/gpu/GrPipelineAnalysis.cpp similarity index 80% rename from src/gpu/GrProcOptInfo.cpp rename to src/gpu/GrPipelineAnalysis.cpp index 902a7c7..3512c94 100644 --- a/src/gpu/GrProcOptInfo.cpp +++ b/src/gpu/GrPipelineAnalysis.cpp @@ -5,11 +5,12 @@ * found in the LICENSE file. */ -#include "GrProcOptInfo.h" +#include "GrPipelineAnalysis.h" #include "GrGeometryProcessor.h" #include "ops/GrDrawOp.h" -void GrProcOptInfo::analyzeProcessors(const GrFragmentProcessor* const* processors, int cnt) { +void GrColorFragmentProcessorAnalysis::analyzeProcessors( + const GrFragmentProcessor* const* processors, int cnt) { for (int i = 0; i < cnt; ++i) { bool knowCurrentOutput = fProcessorsVisitedWithKnownOutput == fTotalProcessorsVisited; if (fUsesLocalCoords && !knowCurrentOutput && @@ -18,8 +19,8 @@ void GrProcOptInfo::analyzeProcessors(const GrFragmentProcessor* const* processo return; } const GrFragmentProcessor* fp = processors[i]; - if (knowCurrentOutput && fp->hasConstantOutputForConstantInput(fLastKnownOutputColor, - &fLastKnownOutputColor)) { + if (knowCurrentOutput && + fp->hasConstantOutputForConstantInput(fLastKnownOutputColor, &fLastKnownOutputColor)) { ++fProcessorsVisitedWithKnownOutput; fIsOpaque = fLastKnownOutputColor.isOpaque(); // We reset these since the caller is expected to not use the earlier fragment diff --git a/src/gpu/GrProcOptInfo.h b/src/gpu/GrPipelineAnalysis.h similarity index 58% rename from src/gpu/GrProcOptInfo.h rename to src/gpu/GrPipelineAnalysis.h index 549fb7a..4f553b0 100644 --- a/src/gpu/GrProcOptInfo.h +++ b/src/gpu/GrPipelineAnalysis.h @@ -5,27 +5,73 @@ * found in the LICENSE file. */ -#ifndef GrProcOptInfo_DEFINED -#define GrProcOptInfo_DEFINED +#ifndef GrPipelineAnalysis_DEFINED +#define GrPipelineAnalysis_DEFINED #include "GrColor.h" -#include "GrPipelineInput.h" class GrDrawOp; class GrFragmentProcessor; class GrPrimitiveProcessor; +class GrPipelineAnalysisColor { +public: + enum class Opaque { + kNo, + kYes, + }; + + GrPipelineAnalysisColor(Opaque opaque = Opaque::kNo) + : fFlags(opaque == Opaque::kYes ? kIsOpaque_Flag : 0) {} + + GrPipelineAnalysisColor(GrColor color) { this->setToConstant(color); } + + void setToConstant(GrColor color) { + fColor = color; + if (GrColorIsOpaque(color)) { + fFlags = kColorIsKnown_Flag | kIsOpaque_Flag; + } else { + fFlags = kColorIsKnown_Flag; + } + } + + void setToUnknown() { fFlags = 0; } + + void setToUnknownOpaque() { fFlags = kIsOpaque_Flag; } + + bool isOpaque() const { return SkToBool(kIsOpaque_Flag & fFlags); } + + bool isConstant(GrColor* color) const { + if (kColorIsKnown_Flag & fFlags) { + *color = fColor; + return true; + } + return false; + } + +private: + enum Flags { + kColorIsKnown_Flag = 0x1, + kIsOpaque_Flag = 0x2, + }; + uint32_t fFlags; + GrColor fColor; +}; + +enum class GrPipelineAnalysisCoverage { kNone, kSingleChannel, kLCD }; + /** - * GrProcOptInfo gathers invariant data from a set of processor stages.It is used to recognize - * optimizations related to eliminating stages and vertex attributes that aren't necessary for a - * draw. + * GrColorFragmentProcessorAnalysis gathers invariant data from a set of color fragment processor. + * It is used to recognize optimizations that can simplify the generated shader or make blending + * more effecient. */ -class GrProcOptInfo { +class GrColorFragmentProcessorAnalysis { public: - GrProcOptInfo() = default; + GrColorFragmentProcessorAnalysis() = default; - GrProcOptInfo(const GrPipelineInput& input) : GrProcOptInfo() { - fAllProcessorsCompatibleWithCoverageAsAlpha = !input.isLCDCoverage(); + GrColorFragmentProcessorAnalysis(const GrPipelineAnalysisColor& input) + : GrColorFragmentProcessorAnalysis() { + fAllProcessorsCompatibleWithCoverageAsAlpha = true; fIsOpaque = input.isOpaque(); GrColor color; if (input.isConstant(&color)) { @@ -34,7 +80,9 @@ public: } } - void reset(const GrPipelineInput& input) { *this = GrProcOptInfo(input); } + void reset(const GrPipelineAnalysisColor& input) { + *this = GrColorFragmentProcessorAnalysis(input); + } /** * Runs through a series of processors and updates calculated values. This can be called @@ -80,14 +128,12 @@ public: return SkTMax(0, fProcessorsVisitedWithKnownOutput); } - bool hasKnownOutputColor(GrColor* knownOutputColor = nullptr) const { + GrPipelineAnalysisColor outputColor() const { if (fProcessorsVisitedWithKnownOutput != fTotalProcessorsVisited) { - return false; - } - if (knownOutputColor) { - *knownOutputColor = fLastKnownOutputColor.toGrColor(); + return GrPipelineAnalysisColor(fIsOpaque ? GrPipelineAnalysisColor::Opaque::kYes + : GrPipelineAnalysisColor::Opaque::kNo); } - return true; + return GrPipelineAnalysisColor(fLastKnownOutputColor.toGrColor()); } private: diff --git a/src/gpu/GrPipelineInput.h b/src/gpu/GrPipelineInput.h deleted file mode 100644 index 7079f36..0000000 --- a/src/gpu/GrPipelineInput.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2014 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef GrPipelineInput_DEFINED -#define GrPipelineInput_DEFINED - -#include "GrColor.h" - -/** - * This describes the color or coverage input that will be seen by the first color or coverage stage - * of a GrPipeline. This is also the GrPrimitiveProcessor color or coverage *output*. - */ -struct GrPipelineInput { - enum class Opaque { - kNo, - kYes, - }; - - GrPipelineInput(Opaque opaque = Opaque::kNo) - : fFlags(opaque == Opaque::kYes ? kIsOpaque_Flag : 0) {} - - GrPipelineInput(GrColor color) : fFlags(kColorIsKnown_Flag), fColor(color) {} - - void setToConstant(GrColor color) { - fColor = color; - if (GrColorIsOpaque(color)) { - fFlags = kColorIsKnown_Flag | kIsOpaque_Flag; - } else { - fFlags = kColorIsKnown_Flag; - } - } - - void setToUnknown() { fFlags = 0; } - - void setToUnknownOpaque() { fFlags = kIsOpaque_Flag; } - - void setToSolidCoverage() { - fColor = GrColor_WHITE; - fFlags = kColorIsKnown_Flag | kIsOpaque_Flag; - } - - void setToScalar(uint8_t alpha) { - this->setToConstant(GrColorPackRGBA(alpha, alpha, alpha, alpha)); - } - - void setToLCDCoverage() { fFlags = kIsLCDCoverage_Flag; } - - bool isLCDCoverage() const { return SkToBool(kIsLCDCoverage_Flag & fFlags); } - - bool isOpaque() const { return SkToBool(kIsOpaque_Flag & fFlags); } - - bool isSolidWhite() const { return (kColorIsKnown_Flag & fFlags) && GrColor_WHITE == fColor; } - - bool isConstant(GrColor* color) const { - if (kColorIsKnown_Flag & fFlags) { - *color = fColor; - return true; - } - return false; - } - -private: - enum Flags { - kColorIsKnown_Flag = 0x1, - kIsOpaque_Flag = 0x2, - kIsLCDCoverage_Flag = 0x4, - }; - uint32_t fFlags; - GrColor fColor; -}; - -#endif diff --git a/src/gpu/GrProcessorSet.cpp b/src/gpu/GrProcessorSet.cpp index a8423b6..4a50892 100644 --- a/src/gpu/GrProcessorSet.cpp +++ b/src/gpu/GrProcessorSet.cpp @@ -8,7 +8,7 @@ #include "GrProcessorSet.h" #include "GrAppliedClip.h" #include "GrCaps.h" -#include "GrProcOptInfo.h" +#include "GrPipelineAnalysis.h" GrProcessorSet::GrProcessorSet(GrPaint&& paint) { fXPFactory = paint.fXPFactory; @@ -80,13 +80,14 @@ bool GrProcessorSet::operator==(const GrProcessorSet& that) const { ////////////////////////////////////////////////////////////////////////////// -void GrProcessorSet::FragmentProcessorAnalysis::internalInit(const GrPipelineInput& colorInput, - const GrPipelineInput coverageInput, - const GrProcessorSet& processors, - const GrFragmentProcessor* clipFP, - const GrCaps& caps) { - GrProcOptInfo colorInfo(colorInput); - fCompatibleWithCoverageAsAlpha = !coverageInput.isLCDCoverage(); +void GrProcessorSet::FragmentProcessorAnalysis::internalInit( + const GrPipelineAnalysisColor& colorInput, + const GrPipelineAnalysisCoverage coverageInput, + const GrProcessorSet& processors, + const GrFragmentProcessor* clipFP, + const GrCaps& caps) { + GrColorFragmentProcessorAnalysis colorInfo(colorInput); + fCompatibleWithCoverageAsAlpha = GrPipelineAnalysisCoverage::kLCD != coverageInput; fValidInputColor = colorInput.isConstant(&fInputColor); const GrFragmentProcessor* const* fps = @@ -115,27 +116,27 @@ void GrProcessorSet::FragmentProcessorAnalysis::internalInit(const GrPipelineInp fInitialColorProcessorsToEliminate = colorInfo.initialProcessorsToEliminate(&fInputColor); fValidInputColor |= SkToBool(fInitialColorProcessorsToEliminate); - bool opaque = colorInfo.isOpaque(); - if (colorInfo.hasKnownOutputColor(&fKnownOutputColor)) { - fOutputColorType = static_cast(opaque ? ColorType::kOpaqueConstant - : ColorType::kConstant); - } else if (opaque) { + GrPipelineAnalysisColor outputColor = colorInfo.outputColor(); + if (outputColor.isConstant(&fKnownOutputColor)) { + fOutputColorType = static_cast(outputColor.isOpaque() ? ColorType::kOpaqueConstant + : ColorType::kConstant); + } else if (outputColor.isOpaque()) { fOutputColorType = static_cast(ColorType::kOpaque); } else { fOutputColorType = static_cast(ColorType::kUnknown); } - if (coverageInput.isLCDCoverage()) { - fOutputCoverageType = static_cast(CoverageType::kLCD); + if (GrPipelineAnalysisCoverage::kLCD == coverageInput) { + fOutputCoverageType = static_cast(GrPipelineAnalysisCoverage::kLCD); + } else if (hasCoverageFP || GrPipelineAnalysisCoverage::kSingleChannel == coverageInput) { + fOutputCoverageType = static_cast(GrPipelineAnalysisCoverage::kSingleChannel); } else { - fOutputCoverageType = hasCoverageFP || !coverageInput.isSolidWhite() - ? static_cast(CoverageType::kSingleChannel) - : static_cast(CoverageType::kNone); + fOutputCoverageType = static_cast(GrPipelineAnalysisCoverage::kNone); } } -void GrProcessorSet::FragmentProcessorAnalysis::init(const GrPipelineInput& colorInput, - const GrPipelineInput coverageInput, +void GrProcessorSet::FragmentProcessorAnalysis::init(const GrPipelineAnalysisColor& colorInput, + const GrPipelineAnalysisCoverage coverageInput, const GrProcessorSet& processors, const GrAppliedClip* appliedClip, const GrCaps& caps) { @@ -146,16 +147,19 @@ void GrProcessorSet::FragmentProcessorAnalysis::init(const GrPipelineInput& colo } GrProcessorSet::FragmentProcessorAnalysis::FragmentProcessorAnalysis( - const GrPipelineInput& colorInput, const GrPipelineInput coverageInput, const GrCaps& caps) + const GrPipelineAnalysisColor& colorInput, + const GrPipelineAnalysisCoverage coverageInput, + const GrCaps& caps) : FragmentProcessorAnalysis() { this->internalInit(colorInput, coverageInput, GrProcessorSet(GrPaint()), nullptr, caps); } -void GrProcessorSet::analyzeAndEliminateFragmentProcessors(FragmentProcessorAnalysis* analysis, - const GrPipelineInput& colorInput, - const GrPipelineInput coverageInput, - const GrAppliedClip* clip, - const GrCaps& caps) { +void GrProcessorSet::analyzeAndEliminateFragmentProcessors( + FragmentProcessorAnalysis* analysis, + const GrPipelineAnalysisColor& colorInput, + const GrPipelineAnalysisCoverage coverageInput, + const GrAppliedClip* clip, + const GrCaps& caps) { analysis->init(colorInput, coverageInput, *this, clip, caps); if (analysis->fInitialColorProcessorsToEliminate > 0) { for (unsigned i = 0; i < analysis->fInitialColorProcessorsToEliminate; ++i) { diff --git a/src/gpu/GrProcessorSet.h b/src/gpu/GrProcessorSet.h index 71ab2d0..bfad769 100644 --- a/src/gpu/GrProcessorSet.h +++ b/src/gpu/GrProcessorSet.h @@ -10,7 +10,7 @@ #include "GrFragmentProcessor.h" #include "GrPaint.h" -#include "GrPipelineInput.h" +#include "GrPipelineAnalysis.h" #include "SkTemplates.h" class GrAppliedClip; @@ -79,16 +79,16 @@ public: : fIsInitializedWithProcessorSet(false) , fCompatibleWithCoverageAsAlpha(true) , fValidInputColor(false) - , fOutputCoverageType(static_cast(CoverageType::kNone)) + , fOutputCoverageType(static_cast(GrPipelineAnalysisCoverage::kNone)) , fOutputColorType(static_cast(ColorType::kUnknown)) , fInitialColorProcessorsToEliminate(0) {} // This version is used by a unit test that assumes no clip, no processors, and no PLS. - FragmentProcessorAnalysis(const GrPipelineInput& colorInput, - const GrPipelineInput coverageInput, const GrCaps&); + FragmentProcessorAnalysis(const GrPipelineAnalysisColor&, GrPipelineAnalysisCoverage, + const GrCaps&); - void init(const GrPipelineInput& colorInput, const GrPipelineInput coverageInput, - const GrProcessorSet&, const GrAppliedClip*, const GrCaps&); + void init(const GrPipelineAnalysisColor&, GrPipelineAnalysisCoverage, const GrProcessorSet&, + const GrAppliedClip*, const GrCaps&); bool isInitializedWithProcessorSet() const { return fIsInitializedWithProcessorSet; } @@ -132,19 +132,19 @@ public: } return constant; } - bool hasCoverage() const { return CoverageType::kNone != this->outputCoverageType(); } - bool hasLCDCoverage() const { return CoverageType::kLCD == this->outputCoverageType(); } + GrPipelineAnalysisCoverage outputCoverageType() const { + return static_cast(fOutputCoverageType); + } + bool hasCoverage() const { + return this->outputCoverageType() != GrPipelineAnalysisCoverage::kNone; + } private: enum class ColorType : unsigned { kUnknown, kOpaqueConstant, kConstant, kOpaque }; - enum class CoverageType : unsigned { kNone, kSingleChannel, kLCD }; - CoverageType outputCoverageType() const { - return static_cast(fOutputCoverageType); - } ColorType outputColorType() const { return static_cast(fOutputColorType); } - void internalInit(const GrPipelineInput& colorInput, const GrPipelineInput coverageInput, + void internalInit(const GrPipelineAnalysisColor&, const GrPipelineAnalysisCoverage, const GrProcessorSet&, const GrFragmentProcessor* clipFP, const GrCaps&); // MSVS 2015 won't pack a bool with an unsigned. @@ -166,8 +166,8 @@ public: GR_STATIC_ASSERT(sizeof(FragmentProcessorAnalysis) == 2 * sizeof(GrColor) + sizeof(uint32_t)); void analyzeAndEliminateFragmentProcessors(FragmentProcessorAnalysis*, - const GrPipelineInput& colorInput, - const GrPipelineInput coverageInput, + const GrPipelineAnalysisColor& colorInput, + const GrPipelineAnalysisCoverage coverageInput, const GrAppliedClip*, const GrCaps&); private: diff --git a/src/gpu/GrXferProcessor.cpp b/src/gpu/GrXferProcessor.cpp index 32ab45c..bd63a0a 100644 --- a/src/gpu/GrXferProcessor.cpp +++ b/src/gpu/GrXferProcessor.cpp @@ -7,7 +7,6 @@ #include "GrXferProcessor.h" #include "GrPipeline.h" -#include "GrProcOptInfo.h" #include "gl/GrGLCaps.h" GrXferProcessor::GrXferProcessor() diff --git a/src/gpu/GrXferProcessor.h b/src/gpu/GrXferProcessor.h index 35ce5fa..bdf6f7d 100644 --- a/src/gpu/GrXferProcessor.h +++ b/src/gpu/GrXferProcessor.h @@ -17,7 +17,6 @@ class GrShaderCaps; class GrGLSLXferProcessor; -class GrProcOptInfo; /** * Barriers for blending. When a shader reads the dst directly, an Xfer barrier is sometimes diff --git a/src/gpu/effects/GrCoverageSetOpXP.cpp b/src/gpu/effects/GrCoverageSetOpXP.cpp index 52ebaad..1013706 100644 --- a/src/gpu/effects/GrCoverageSetOpXP.cpp +++ b/src/gpu/effects/GrCoverageSetOpXP.cpp @@ -8,10 +8,9 @@ #include "effects/GrCoverageSetOpXP.h" #include "GrCaps.h" #include "GrColor.h" -#include "GrRenderTargetContext.h" #include "GrPipeline.h" #include "GrProcessor.h" -#include "GrProcOptInfo.h" +#include "GrRenderTargetContext.h" #include "glsl/GrGLSLBlend.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" #include "glsl/GrGLSLUniformHandler.h" diff --git a/src/gpu/effects/GrCoverageSetOpXP.h b/src/gpu/effects/GrCoverageSetOpXP.h index 184ef4e..a0cb0c5 100644 --- a/src/gpu/effects/GrCoverageSetOpXP.h +++ b/src/gpu/effects/GrCoverageSetOpXP.h @@ -12,8 +12,6 @@ #include "GrXferProcessor.h" #include "SkRegion.h" -class GrProcOptInfo; - // See the comment above GrXPFactory's definition about this warning suppression. #if defined(__GNUC__) || defined(__clang) #pragma GCC diagnostic push diff --git a/src/gpu/effects/GrCustomXfermode.cpp b/src/gpu/effects/GrCustomXfermode.cpp index 37e4c16..1f2771c 100644 --- a/src/gpu/effects/GrCustomXfermode.cpp +++ b/src/gpu/effects/GrCustomXfermode.cpp @@ -52,12 +52,12 @@ static constexpr GrBlendEquation hw_blend_equation(SkBlendMode mode) { #undef EQ_OFFSET } -static bool can_use_hw_blend_equation(GrBlendEquation equation, bool isLCDCoverage, +static bool can_use_hw_blend_equation(GrBlendEquation equation, GrPipelineAnalysisCoverage coverage, const GrCaps& caps) { if (!caps.advancedBlendEquationSupport()) { return false; } - if (isLCDCoverage) { + if (GrPipelineAnalysisCoverage::kLCD == coverage) { return false; // LCD coverage must be applied after the blend equation. } if (caps.canUseAdvancedBlendEquation(equation)) { @@ -347,7 +347,7 @@ GrXferProcessor* CustomXPFactory::onCreateXferProcessor(const GrCaps& caps, bool hasMixedSamples, const DstTexture* dstTexture) const { SkASSERT(GrCustomXfermode::IsSupportedMode(fMode)); - if (can_use_hw_blend_equation(fHWBlendEquation, analysis.hasLCDCoverage(), caps)) { + if (can_use_hw_blend_equation(fHWBlendEquation, analysis.outputCoverageType(), caps)) { SkASSERT(!dstTexture || !dstTexture->texture()); return new CustomXP(fMode, fHWBlendEquation); } @@ -356,7 +356,7 @@ GrXferProcessor* CustomXPFactory::onCreateXferProcessor(const GrCaps& caps, bool CustomXPFactory::willReadDstInShader(const GrCaps& caps, const FragmentProcessorAnalysis& analysis) const { - return !can_use_hw_blend_equation(fHWBlendEquation, analysis.hasLCDCoverage(), caps); + return !can_use_hw_blend_equation(fHWBlendEquation, analysis.outputCoverageType(), caps); } GR_DEFINE_XP_FACTORY_TEST(CustomXPFactory); diff --git a/src/gpu/effects/GrDisableColorXP.h b/src/gpu/effects/GrDisableColorXP.h index 78442f4..821ad27 100644 --- a/src/gpu/effects/GrDisableColorXP.h +++ b/src/gpu/effects/GrDisableColorXP.h @@ -12,8 +12,6 @@ #include "GrXferProcessor.h" #include "SkRefCnt.h" -class GrProcOptInfo; - // See the comment above GrXPFactory's definition about this warning suppression. #if defined(__GNUC__) || defined(__clang) #pragma GCC diagnostic push diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.cpp b/src/gpu/effects/GrPorterDuffXferProcessor.cpp index 3dc5325..aa416e0 100644 --- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp +++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp @@ -10,8 +10,8 @@ #include "GrBlend.h" #include "GrCaps.h" #include "GrPipeline.h" +#include "GrPipelineAnalysis.h" #include "GrProcessor.h" -#include "GrProcOptInfo.h" #include "GrTypes.h" #include "GrXferProcessor.h" #include "glsl/GrGLSLBlend.h" @@ -19,7 +19,6 @@ #include "glsl/GrGLSLProgramDataManager.h" #include "glsl/GrGLSLUniformHandler.h" #include "glsl/GrGLSLXferProcessor.h" -#include /** * Wraps the shader outputs and HW blend state that comprise a Porter Duff blend mode with coverage. @@ -736,7 +735,7 @@ GrXferProcessor* GrPorterDuffXPFactory::onCreateXferProcessor( bool hasMixedSamples, const DstTexture* dstTexture) const { BlendFormula blendFormula; - if (analysis.hasLCDCoverage()) { + if (analysis.outputCoverageType() == GrPipelineAnalysisCoverage::kLCD) { if (SkBlendMode::kSrcOver == fBlendMode && analysis.hasKnownOutputColor() && !caps.shaderCaps()->dualSourceBlendingSupport() && !caps.shaderCaps()->dstReadInShaderSupport()) { @@ -775,7 +774,7 @@ bool GrPorterDuffXPFactory::willReadDstInShader(const GrCaps& caps, // When we have four channel coverage we always need to read the dst in order to correctly // blend. The one exception is when we are using srcover mode and we know the input color into // the XP. - if (analysis.hasLCDCoverage()) { + if (analysis.outputCoverageType() == GrPipelineAnalysisCoverage::kLCD) { if (SkBlendMode::kSrcOver == fBlendMode && analysis.hasKnownOutputColor() && !caps.shaderCaps()->dstReadInShaderSupport()) { return false; @@ -838,7 +837,7 @@ GrXferProcessor* GrPorterDuffXPFactory::CreateSrcOverXferProcessor( // 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 (!analysis.hasLCDCoverage()) { + if (analysis.outputCoverageType() != GrPipelineAnalysisCoverage::kLCD) { // 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 @@ -880,7 +879,7 @@ bool GrPorterDuffXPFactory::WillSrcOverNeedDstTexture(const GrCaps& caps, // When we have four channel coverage we always need to read the dst in order to correctly // blend. The one exception is when we are using srcover mode and we know the input color // into the XP. - if (analysis.hasLCDCoverage()) { + if (analysis.outputCoverageType() == GrPipelineAnalysisCoverage::kLCD) { if (analysis.hasKnownOutputColor() && !caps.shaderCaps()->dstReadInShaderSupport()) { return false; } diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.h b/src/gpu/effects/GrPorterDuffXferProcessor.h index 719bd18..23f1e9c 100644 --- a/src/gpu/effects/GrPorterDuffXferProcessor.h +++ b/src/gpu/effects/GrPorterDuffXferProcessor.h @@ -12,8 +12,6 @@ #include "GrXferProcessor.h" #include "SkBlendMode.h" -class GrProcOptInfo; - // See the comment above GrXPFactory's definition about this warning suppression. #if defined(__GNUC__) || defined(__clang) #pragma GCC diagnostic push diff --git a/src/gpu/instanced/InstancedRendering.cpp b/src/gpu/instanced/InstancedRendering.cpp index f97c342..e67a8be 100644 --- a/src/gpu/instanced/InstancedRendering.cpp +++ b/src/gpu/instanced/InstancedRendering.cpp @@ -334,12 +334,12 @@ void InstancedRendering::Op::appendParamsTexel(SkScalar x, SkScalar y, SkScalar bool InstancedRendering::Op::xpRequiresDstTexture(const GrCaps& caps, const GrAppliedClip* clip) { GrProcessorSet::FragmentProcessorAnalysis analysis; - GrPipelineInput coverageInput; + GrPipelineAnalysisCoverage coverageInput; if (GrAAType::kCoverage == fInfo.aaType() || (GrAAType::kNone == fInfo.aaType() && !fInfo.isSimpleRects() && fInfo.fCannotDiscard)) { - coverageInput = GrPipelineInput(); + coverageInput = GrPipelineAnalysisCoverage::kSingleChannel; } else { - coverageInput = GrColor_WHITE; + coverageInput = GrPipelineAnalysisCoverage::kNone; } fProcessors.analyzeAndEliminateFragmentProcessors(&analysis, this->getSingleInstance().fColor, coverageInput, clip, caps); @@ -470,18 +470,18 @@ void InstancedRendering::Op::onExecute(GrOpFlushState* state) { state->gpu()->handleDirtyContext(); GrProcessorSet::FragmentProcessorAnalysis analysis; - GrPipelineInput coverageInput; + GrPipelineAnalysisCoverage coverageInput; if (GrAAType::kCoverage == fInfo.aaType() || (GrAAType::kNone == fInfo.aaType() && !fInfo.isSimpleRects() && fInfo.fCannotDiscard)) { - coverageInput = GrPipelineInput(); + coverageInput = GrPipelineAnalysisCoverage::kSingleChannel; } else { - coverageInput = GrColor_WHITE; + coverageInput = GrPipelineAnalysisCoverage::kNone; } - GrPipelineInput colorInput; + GrPipelineAnalysisColor colorInput; if (fDrawColorsAreSame) { colorInput = fHeadDraw->fInstance.fColor; } else if (fDrawColorsAreOpaque) { - colorInput = GrPipelineInput::Opaque::kYes; + colorInput = GrPipelineAnalysisColor::Opaque::kYes; } const GrAppliedClip* clip = state->drawOpArgs().fAppliedClip; analysis.init(colorInput, coverageInput, fProcessors, clip, state->caps()); diff --git a/src/gpu/ops/GrAAConvexPathRenderer.cpp b/src/gpu/ops/GrAAConvexPathRenderer.cpp index e316fec..79259b4 100644 --- a/src/gpu/ops/GrAAConvexPathRenderer.cpp +++ b/src/gpu/ops/GrAAConvexPathRenderer.cpp @@ -747,9 +747,10 @@ private: this->setTransformedBounds(path.getBounds(), viewMatrix, HasAABloat::kYes, IsZeroArea::kNo); } - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override { - input->colorInput()->setToConstant(fColor); - input->coverageInput()->setToUnknown(); + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override { + color->setToConstant(fColor); + *coverage = GrPipelineAnalysisCoverage::kSingleChannel; } void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override { diff --git a/src/gpu/ops/GrAAFillRectOp.cpp b/src/gpu/ops/GrAAFillRectOp.cpp index 850a3c9..c6aadb9 100644 --- a/src/gpu/ops/GrAAFillRectOp.cpp +++ b/src/gpu/ops/GrAAFillRectOp.cpp @@ -203,9 +203,10 @@ public: } private: - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override { - input->colorInput()->setToConstant(this->first()->color()); - input->coverageInput()->setToUnknown(); + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override { + color->setToConstant(this->first()->color()); + *coverage = GrPipelineAnalysisCoverage::kSingleChannel; } void onPrepareDraws(Target* target) const override { diff --git a/src/gpu/ops/GrAAHairLinePathRenderer.cpp b/src/gpu/ops/GrAAHairLinePathRenderer.cpp index ec26104..494138d 100644 --- a/src/gpu/ops/GrAAHairLinePathRenderer.cpp +++ b/src/gpu/ops/GrAAHairLinePathRenderer.cpp @@ -710,9 +710,10 @@ private: IsZeroArea::kYes); } - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override { - input->colorInput()->setToConstant(fColor); - input->coverageInput()->setToUnknown(); + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override { + color->setToConstant(fColor); + *coverage = GrPipelineAnalysisCoverage::kSingleChannel; } void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override { diff --git a/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp b/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp index bdec758..c9add9d 100644 --- a/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp +++ b/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp @@ -172,9 +172,10 @@ private: this->setTransformedBounds(bounds, viewMatrix, HasAABloat::kYes, IsZeroArea::kNo); } - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override { - input->colorInput()->setToConstant(fPaths[0].fColor); - input->coverageInput()->setToUnknown(); + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override { + color->setToConstant(fPaths[0].fColor); + *coverage = GrPipelineAnalysisCoverage::kSingleChannel; } void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override { diff --git a/src/gpu/ops/GrAAStrokeRectOp.cpp b/src/gpu/ops/GrAAStrokeRectOp.cpp index b684782..89739e6 100644 --- a/src/gpu/ops/GrAAStrokeRectOp.cpp +++ b/src/gpu/ops/GrAAStrokeRectOp.cpp @@ -174,9 +174,10 @@ public: private: AAStrokeRectOp() : INHERITED(ClassID()) {} - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override { - input->colorInput()->setToConstant(fRects[0].fColor); - input->coverageInput()->setToUnknown(); + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override { + color->setToConstant(fRects[0].fColor); + *coverage = GrPipelineAnalysisCoverage::kSingleChannel; } void applyPipelineOptimizations(const GrPipelineOptimizations&) override; void onPrepareDraws(Target*) const override; diff --git a/src/gpu/ops/GrAnalyticRectOp.cpp b/src/gpu/ops/GrAnalyticRectOp.cpp index 45e20f0..87922cc 100644 --- a/src/gpu/ops/GrAnalyticRectOp.cpp +++ b/src/gpu/ops/GrAnalyticRectOp.cpp @@ -269,9 +269,10 @@ public: } private: - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override { - input->colorInput()->setToConstant(fGeoData[0].fColor); - input->coverageInput()->setToUnknown(); + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override { + color->setToConstant(fGeoData[0].fColor); + *coverage = GrPipelineAnalysisCoverage::kSingleChannel; } void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override { diff --git a/src/gpu/ops/GrAtlasTextOp.cpp b/src/gpu/ops/GrAtlasTextOp.cpp index e723bd0..f8c5443 100644 --- a/src/gpu/ops/GrAtlasTextOp.cpp +++ b/src/gpu/ops/GrAtlasTextOp.cpp @@ -46,24 +46,25 @@ SkString GrAtlasTextOp::dumpInfo() const { return str; } -void GrAtlasTextOp::getFragmentProcessorAnalysisInputs( - FragmentProcessorAnalysisInputs* input) const { +void GrAtlasTextOp::getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const { if (kColorBitmapMask_MaskType == fMaskType) { - input->colorInput()->setToUnknown(); + color->setToUnknown(); } else { - input->colorInput()->setToConstant(fColor); + color->setToConstant(fColor); } switch (fMaskType) { case kGrayscaleDistanceField_MaskType: case kGrayscaleCoverageMask_MaskType: - input->coverageInput()->setToUnknown(); + *coverage = GrPipelineAnalysisCoverage::kSingleChannel; break; case kLCDCoverageMask_MaskType: case kLCDDistanceField_MaskType: - input->coverageInput()->setToLCDCoverage(); + *coverage = GrPipelineAnalysisCoverage::kLCD; break; case kColorBitmapMask_MaskType: - input->coverageInput()->setToSolidCoverage(); + *coverage = GrPipelineAnalysisCoverage::kNone; + break; } } diff --git a/src/gpu/ops/GrAtlasTextOp.h b/src/gpu/ops/GrAtlasTextOp.h index 699503a..8c08544 100644 --- a/src/gpu/ops/GrAtlasTextOp.h +++ b/src/gpu/ops/GrAtlasTextOp.h @@ -99,7 +99,8 @@ public: SkString dumpInfo() const override; private: - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs*) const override; + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor*, + GrPipelineAnalysisCoverage*) const override; void applyPipelineOptimizations(const GrPipelineOptimizations&) override; struct FlushInfo { diff --git a/src/gpu/ops/GrDashOp.cpp b/src/gpu/ops/GrDashOp.cpp index 1372a8b..9dfacde 100644 --- a/src/gpu/ops/GrDashOp.cpp +++ b/src/gpu/ops/GrDashOp.cpp @@ -296,9 +296,10 @@ private: this->setTransformedBounds(bounds, combinedMatrix, aaBloat, zeroArea); } - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override { - input->colorInput()->setToConstant(fColor); - input->coverageInput()->setToUnknown(); + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override { + color->setToConstant(fColor); + *coverage = GrPipelineAnalysisCoverage::kSingleChannel; } void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override { diff --git a/src/gpu/ops/GrDefaultPathRenderer.cpp b/src/gpu/ops/GrDefaultPathRenderer.cpp index 300090d..62c9d45 100644 --- a/src/gpu/ops/GrDefaultPathRenderer.cpp +++ b/src/gpu/ops/GrDefaultPathRenderer.cpp @@ -132,9 +132,11 @@ private: isHairline ? IsZeroArea::kYes : IsZeroArea::kNo); } - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override { - input->colorInput()->setToConstant(fColor); - input->coverageInput()->setToScalar(this->coverage()); + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override { + color->setToConstant(fColor); + *coverage = this->coverage() == 0xff ? GrPipelineAnalysisCoverage::kNone + : GrPipelineAnalysisCoverage::kSingleChannel; } void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override { diff --git a/src/gpu/ops/GrDrawAtlasOp.h b/src/gpu/ops/GrDrawAtlasOp.h index cde345e..a39a7a9 100644 --- a/src/gpu/ops/GrDrawAtlasOp.h +++ b/src/gpu/ops/GrDrawAtlasOp.h @@ -39,13 +39,14 @@ private: GrDrawAtlasOp(GrColor color, const SkMatrix& viewMatrix, int spriteCount, const SkRSXform* xforms, const SkRect* rects, const SkColor* colors); - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override { + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override { if (this->hasColors()) { - input->colorInput()->setToUnknown(); + color->setToUnknown(); } else { - input->colorInput()->setToConstant(fGeoData[0].fColor); + color->setToConstant(fGeoData[0].fColor); } - input->coverageInput()->setToSolidCoverage(); + *coverage = GrPipelineAnalysisCoverage::kNone; } void onPrepareDraws(Target*) const override; diff --git a/src/gpu/ops/GrDrawPathOp.h b/src/gpu/ops/GrDrawPathOp.h index 70a543f..b1ce2df 100644 --- a/src/gpu/ops/GrDrawPathOp.h +++ b/src/gpu/ops/GrDrawPathOp.h @@ -43,8 +43,8 @@ protected: GrPipelineOptimizations initPipeline(const GrOpFlushState&, GrPipeline*); const GrProcessorSet::FragmentProcessorAnalysis& doFragmentProcessorAnalysis( const GrCaps& caps, const GrAppliedClip* clip) { - fProcessorSet.analyzeAndEliminateFragmentProcessors(&fAnalysis, fAnalysis.inputColor(), - GrColor_WHITE, clip, caps); + fProcessorSet.analyzeAndEliminateFragmentProcessors( + &fAnalysis, fAnalysis.inputColor(), GrPipelineAnalysisCoverage::kNone, clip, caps); return fAnalysis; } const GrProcessorSet::FragmentProcessorAnalysis& fragmentProcessorAnalysis() const { diff --git a/src/gpu/ops/GrDrawVerticesOp.cpp b/src/gpu/ops/GrDrawVerticesOp.cpp index 7c59d61..d8f91fe 100644 --- a/src/gpu/ops/GrDrawVerticesOp.cpp +++ b/src/gpu/ops/GrDrawVerticesOp.cpp @@ -75,13 +75,13 @@ GrDrawVerticesOp::GrDrawVerticesOp(sk_sp vertices, GrPrimitiveType p } void GrDrawVerticesOp::getFragmentProcessorAnalysisInputs( - FragmentProcessorAnalysisInputs* input) const { + GrPipelineAnalysisColor* color, GrPipelineAnalysisCoverage* coverage) const { if (this->requiresPerVertexColors()) { - input->colorInput()->setToUnknown(); + color->setToUnknown(); } else { - input->colorInput()->setToConstant(fMeshes[0].fColor); + color->setToConstant(fMeshes[0].fColor); } - input->coverageInput()->setToSolidCoverage(); + *coverage = GrPipelineAnalysisCoverage::kNone; } void GrDrawVerticesOp::applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) { diff --git a/src/gpu/ops/GrDrawVerticesOp.h b/src/gpu/ops/GrDrawVerticesOp.h index f881d61..176b552 100644 --- a/src/gpu/ops/GrDrawVerticesOp.h +++ b/src/gpu/ops/GrDrawVerticesOp.h @@ -70,7 +70,8 @@ private: GrRenderTargetContext::ColorArrayType, const SkMatrix& viewMatrix, uint32_t flags = 0); - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override; + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override; void applyPipelineOptimizations(const GrPipelineOptimizations&) override; void onPrepareDraws(Target*) const override; diff --git a/src/gpu/ops/GrLatticeOp.cpp b/src/gpu/ops/GrLatticeOp.cpp index a1b7584..598a839 100644 --- a/src/gpu/ops/GrLatticeOp.cpp +++ b/src/gpu/ops/GrLatticeOp.cpp @@ -61,9 +61,10 @@ public: } private: - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override { - input->colorInput()->setToUnknown(); - input->coverageInput()->setToSolidCoverage(); + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override { + color->setToUnknown(); + *coverage = GrPipelineAnalysisCoverage::kNone; } void applyPipelineOptimizations(const GrPipelineOptimizations& analysioptimizations) override { diff --git a/src/gpu/ops/GrMSAAPathRenderer.cpp b/src/gpu/ops/GrMSAAPathRenderer.cpp index ccbd0e2..4e7f036 100644 --- a/src/gpu/ops/GrMSAAPathRenderer.cpp +++ b/src/gpu/ops/GrMSAAPathRenderer.cpp @@ -259,9 +259,10 @@ private: this->setBounds(devBounds, HasAABloat::kNo, IsZeroArea::kNo); } - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override { - input->colorInput()->setToConstant(fPaths[0].fColor); - input->coverageInput()->setToSolidCoverage(); + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override { + color->setToConstant(fPaths[0].fColor); + *coverage = GrPipelineAnalysisCoverage::kNone; } void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override { diff --git a/src/gpu/ops/GrMeshDrawOp.h b/src/gpu/ops/GrMeshDrawOp.h index 4cf7c52..cbf1f62 100644 --- a/src/gpu/ops/GrMeshDrawOp.h +++ b/src/gpu/ops/GrMeshDrawOp.h @@ -33,9 +33,10 @@ public: const GrProcessorSet& processors, const GrAppliedClip* appliedClip, const GrCaps& caps) const { - FragmentProcessorAnalysisInputs input; - this->getFragmentProcessorAnalysisInputs(&input); - analysis->init(*input.colorInput(), *input.coverageInput(), processors, appliedClip, caps); + GrPipelineAnalysisColor inputColor; + GrPipelineAnalysisCoverage inputCoverage; + this->getFragmentProcessorAnalysisInputs(&inputColor, &inputCoverage); + analysis->init(inputColor, inputCoverage, processors, appliedClip, caps); } void initPipeline(const GrPipeline::InitArgs& args) { @@ -98,27 +99,13 @@ protected: return &fPipeline; } - /** - * This describes aspects of the GrPrimitiveProcessor produced by a GrDrawOp that are used in - * pipeline analysis. - */ - class FragmentProcessorAnalysisInputs { - public: - FragmentProcessorAnalysisInputs() = default; - GrPipelineInput* colorInput() { return &fColorInput; } - GrPipelineInput* coverageInput() { return &fCoverageInput; } - - private: - GrPipelineInput fColorInput; - GrPipelineInput fCoverageInput; - }; - private: /** * Provides information about the GrPrimitiveProccesor color and coverage outputs which become * inputs to the first color and coverage fragment processors. */ - virtual void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs*) const = 0; + virtual void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor*, + GrPipelineAnalysisCoverage*) const = 0; /** * After GrPipeline analysis is complete this is called so that the op can use the analysis diff --git a/src/gpu/ops/GrNonAAFillRectOp.cpp b/src/gpu/ops/GrNonAAFillRectOp.cpp index a83da15..ce4b21f 100644 --- a/src/gpu/ops/GrNonAAFillRectOp.cpp +++ b/src/gpu/ops/GrNonAAFillRectOp.cpp @@ -110,9 +110,10 @@ public: private: NonAAFillRectOp() : INHERITED(ClassID()) {} - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override { - input->colorInput()->setToConstant(fRects[0].fColor); - input->coverageInput()->setToSolidCoverage(); + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override { + color->setToConstant(fRects[0].fColor); + *coverage = GrPipelineAnalysisCoverage::kNone; } void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override { diff --git a/src/gpu/ops/GrNonAAFillRectPerspectiveOp.cpp b/src/gpu/ops/GrNonAAFillRectPerspectiveOp.cpp index 26a6469..324ea43 100644 --- a/src/gpu/ops/GrNonAAFillRectPerspectiveOp.cpp +++ b/src/gpu/ops/GrNonAAFillRectPerspectiveOp.cpp @@ -130,9 +130,10 @@ public: private: NonAAFillRectPerspectiveOp() : INHERITED(ClassID()) {} - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override { - input->colorInput()->setToConstant(fRects[0].fColor); - input->coverageInput()->setToSolidCoverage(); + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override { + color->setToConstant(fRects[0].fColor); + *coverage = GrPipelineAnalysisCoverage::kNone; } void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override { diff --git a/src/gpu/ops/GrNonAAStrokeRectOp.cpp b/src/gpu/ops/GrNonAAStrokeRectOp.cpp index a4de594..2f63d96 100644 --- a/src/gpu/ops/GrNonAAStrokeRectOp.cpp +++ b/src/gpu/ops/GrNonAAStrokeRectOp.cpp @@ -102,9 +102,10 @@ public: private: NonAAStrokeRectOp() : INHERITED(ClassID()) {} - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override { - input->colorInput()->setToConstant(fColor); - input->coverageInput()->setToSolidCoverage(); + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override { + color->setToConstant(fColor); + *coverage = GrPipelineAnalysisCoverage::kNone; } void onPrepareDraws(Target* target) const override { diff --git a/src/gpu/ops/GrOvalOpFactory.cpp b/src/gpu/ops/GrOvalOpFactory.cpp index dbab985..83e783f 100644 --- a/src/gpu/ops/GrOvalOpFactory.cpp +++ b/src/gpu/ops/GrOvalOpFactory.cpp @@ -805,9 +805,10 @@ public: private: CircleOp() : INHERITED(ClassID()) {} - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override { - input->colorInput()->setToConstant(fGeoData[0].fColor); - input->coverageInput()->setToUnknown(); + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override { + color->setToConstant(fGeoData[0].fColor); + *coverage = GrPipelineAnalysisCoverage::kSingleChannel; } void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override { @@ -1256,9 +1257,10 @@ public: private: EllipseOp() : INHERITED(ClassID()) {} - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override { - input->colorInput()->setToConstant(fGeoData[0].fColor); - input->coverageInput()->setToUnknown(); + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override { + color->setToConstant(fGeoData[0].fColor); + *coverage = GrPipelineAnalysisCoverage::kSingleChannel; } void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override { @@ -1470,9 +1472,10 @@ public: private: DIEllipseOp() : INHERITED(ClassID()) {} - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override { - input->colorInput()->setToConstant(fGeoData[0].fColor); - input->coverageInput()->setToUnknown(); + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override { + color->setToConstant(fGeoData[0].fColor); + *coverage = GrPipelineAnalysisCoverage::kSingleChannel; } void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override { @@ -1785,9 +1788,10 @@ public: } private: - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override { - input->colorInput()->setToConstant(fGeoData[0].fColor); - input->coverageInput()->setToUnknown(); + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override { + color->setToConstant(fGeoData[0].fColor); + *coverage = GrPipelineAnalysisCoverage::kSingleChannel; } void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override { @@ -2148,9 +2152,10 @@ public: private: EllipticalRRectOp() : INHERITED(ClassID()) {} - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override { - input->colorInput()->setToConstant(fGeoData[0].fColor); - input->coverageInput()->setToUnknown(); + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override { + color->setToConstant(fGeoData[0].fColor); + *coverage = GrPipelineAnalysisCoverage::kSingleChannel; } void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override { diff --git a/src/gpu/ops/GrRegionOp.cpp b/src/gpu/ops/GrRegionOp.cpp index 32cb8e4..0ebec98 100644 --- a/src/gpu/ops/GrRegionOp.cpp +++ b/src/gpu/ops/GrRegionOp.cpp @@ -77,9 +77,10 @@ public: } private: - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override { - input->colorInput()->setToConstant(fRegions[0].fColor); - input->coverageInput()->setToSolidCoverage(); + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override { + color->setToConstant(fRegions[0].fColor); + *coverage = GrPipelineAnalysisCoverage::kNone; } void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override { diff --git a/src/gpu/ops/GrShadowRRectOp.cpp b/src/gpu/ops/GrShadowRRectOp.cpp index 1381bc9..bc1a4cc 100644 --- a/src/gpu/ops/GrShadowRRectOp.cpp +++ b/src/gpu/ops/GrShadowRRectOp.cpp @@ -142,9 +142,10 @@ public: private: ShadowCircleOp() : INHERITED(ClassID()) {} - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override { - input->colorInput()->setToConstant(fCircles[0].fColor); - input->coverageInput()->setToUnknown(); + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override { + color->setToConstant(fCircles[0].fColor); + *coverage = GrPipelineAnalysisCoverage::kSingleChannel; } void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override { @@ -562,9 +563,10 @@ public: } private: - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override { - input->colorInput()->setToConstant(fGeoData[0].fColor); - input->coverageInput()->setToUnknown(); + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override { + color->setToConstant(fGeoData[0].fColor); + *coverage = GrPipelineAnalysisCoverage::kSingleChannel; } void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override { diff --git a/src/gpu/ops/GrSmallPathRenderer.cpp b/src/gpu/ops/GrSmallPathRenderer.cpp index 94364a6..8d3f7b7 100644 --- a/src/gpu/ops/GrSmallPathRenderer.cpp +++ b/src/gpu/ops/GrSmallPathRenderer.cpp @@ -199,9 +199,10 @@ private: } - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override { - input->colorInput()->setToConstant(fShapes[0].fColor); - input->coverageInput()->setToUnknown(); + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override { + color->setToConstant(fShapes[0].fColor); + *coverage = GrPipelineAnalysisCoverage::kSingleChannel; } void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override { diff --git a/src/gpu/ops/GrTessellatingPathRenderer.cpp b/src/gpu/ops/GrTessellatingPathRenderer.cpp index d1fd28a..9149988 100644 --- a/src/gpu/ops/GrTessellatingPathRenderer.cpp +++ b/src/gpu/ops/GrTessellatingPathRenderer.cpp @@ -180,9 +180,10 @@ public: } private: - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override { - input->colorInput()->setToConstant(fColor); - input->coverageInput()->setToUnknown(); + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override { + color->setToConstant(fColor); + *coverage = GrPipelineAnalysisCoverage::kSingleChannel; } void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override { diff --git a/src/gpu/ops/GrTestMeshDrawOp.h b/src/gpu/ops/GrTestMeshDrawOp.h index 039f88d..a4bf066 100644 --- a/src/gpu/ops/GrTestMeshDrawOp.h +++ b/src/gpu/ops/GrTestMeshDrawOp.h @@ -33,9 +33,10 @@ protected: bool usesLocalCoords() const { return fUsesLocalCoords; } private: - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override { - input->colorInput()->setToConstant(fColor); - input->coverageInput()->setToUnknown(); + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override { + color->setToConstant(fColor); + *coverage = GrPipelineAnalysisCoverage::kSingleChannel; } void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override { diff --git a/tests/GrPorterDuffTest.cpp b/tests/GrPorterDuffTest.cpp index de18438..ef21701 100644 --- a/tests/GrPorterDuffTest.cpp +++ b/tests/GrPorterDuffTest.cpp @@ -93,13 +93,11 @@ public: }; static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps) { - GrPipelineInput lcdInput; - lcdInput.setToLCDCoverage(); - GrProcessorSet::FragmentProcessorAnalysis analysis(GrPipelineInput(), lcdInput, caps); - + GrProcessorSet::FragmentProcessorAnalysis analysis(GrPipelineAnalysisColor(), + GrPipelineAnalysisCoverage::kLCD, caps); SkASSERT(!analysis.isOutputColorOpaque()); SkASSERT(!analysis.hasKnownOutputColor()); - SkASSERT(analysis.hasLCDCoverage()); + SkASSERT(analysis.outputCoverageType() == GrPipelineAnalysisCoverage::kLCD); for (int m = 0; m <= (int)SkBlendMode::kLastCoeffMode; m++) { SkBlendMode xfermode = static_cast(m); @@ -263,12 +261,12 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps) } } static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps) { - GrProcessorSet::FragmentProcessorAnalysis analysis(GrPipelineInput(), GrPipelineInput(), caps); + GrProcessorSet::FragmentProcessorAnalysis analysis( + GrPipelineAnalysisColor(), GrPipelineAnalysisCoverage::kSingleChannel, caps); SkASSERT(!analysis.isOutputColorOpaque()); SkASSERT(!analysis.hasKnownOutputColor()); - SkASSERT(!analysis.hasLCDCoverage()); - SkASSERT(analysis.hasCoverage()); + SkASSERT(analysis.outputCoverageType() == GrPipelineAnalysisCoverage::kSingleChannel); for (int m = 0; m <= (int)SkBlendMode::kLastCoeffMode; m++) { SkBlendMode xfermode = static_cast(m); @@ -434,7 +432,7 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const GrCaps& caps) { GrProcessorSet::FragmentProcessorAnalysis analysis(GrColorPackRGBA(229, 0, 154, 240), - GrColorPackA4(255), caps); + GrPipelineAnalysisCoverage::kNone, caps); SkASSERT(!analysis.isOutputColorOpaque()); SkASSERT(analysis.hasKnownOutputColor()); @@ -603,13 +601,13 @@ static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G } static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps) { - GrProcessorSet::FragmentProcessorAnalysis analysis(GrPipelineInput::Opaque::kYes, - GrPipelineInput(), caps); + GrProcessorSet::FragmentProcessorAnalysis analysis(GrPipelineAnalysisColor::Opaque::kYes, + GrPipelineAnalysisCoverage::kSingleChannel, + caps); SkASSERT(analysis.isOutputColorOpaque()); SkASSERT(!analysis.hasKnownOutputColor()); - SkASSERT(analysis.hasCoverage()); - SkASSERT(!analysis.hasLCDCoverage()); + SkASSERT(analysis.outputCoverageType() == GrPipelineAnalysisCoverage::kSingleChannel); for (int m = 0; m <= (int)SkBlendMode::kLastCoeffMode; m++) { SkBlendMode xfermode = static_cast(m); @@ -775,8 +773,8 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const } static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const GrCaps& caps) { - GrProcessorSet::FragmentProcessorAnalysis analysis(GrPipelineInput::Opaque::kYes, - GrColorPackA4(255), caps); + GrProcessorSet::FragmentProcessorAnalysis analysis(GrPipelineAnalysisColor::Opaque::kYes, + GrPipelineAnalysisCoverage::kNone, caps); SkASSERT(analysis.isOutputColorOpaque()); SkASSERT(!analysis.hasKnownOutputColor()); @@ -957,9 +955,10 @@ static void test_lcd_coverage_fallback_case(skiatest::Reporter* reporter, const private: void getFragmentProcessorAnalysisInputs( - FragmentProcessorAnalysisInputs* input) const override { - input->colorInput()->setToConstant(GrColorPackRGBA(123, 45, 67, 221)); - input->coverageInput()->setToLCDCoverage(); + GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override { + color->setToConstant(GrColorPackRGBA(123, 45, 67, 221)); + *coverage = GrPipelineAnalysisCoverage::kLCD; } void applyPipelineOptimizations(const GrPipelineOptimizations&) override {} @@ -973,7 +972,7 @@ static void test_lcd_coverage_fallback_case(skiatest::Reporter* reporter, const testLCDCoverageOp.analyzeProcessors(&analysis, GrProcessorSet(GrPaint()), nullptr, caps); SkASSERT(analysis.hasKnownOutputColor()); - SkASSERT(analysis.hasLCDCoverage()); + SkASSERT(analysis.outputCoverageType() == GrPipelineAnalysisCoverage::kLCD); const GrXPFactory* xpf = GrPorterDuffXPFactory::Get(SkBlendMode::kSrcOver); TEST_ASSERT(!GrXPFactory::WillNeedDstTexture(xpf, caps, analysis)); @@ -1017,21 +1016,16 @@ DEF_GPUTEST(PorterDuffNoDualSourceBlending, reporter, /*factory*/) { fakeDstTexture.setTexture( ctx->resourceProvider()->wrapBackendTexture(fakeDesc, kBorrow_GrWrapOwnership)); - static const GrPipelineInput colorInputs[] = {GrPipelineInput(), - GrPipelineInput(GrPipelineInput::Opaque::kYes), - GrPipelineInput(GrColorPackRGBA(0, 82, 17, 100)), - GrPipelineInput(GrColorPackRGBA(0, 82, 17, 255))}; + static const GrPipelineAnalysisColor colorInputs[] = { + GrPipelineAnalysisColor::Opaque::kNo, GrPipelineAnalysisColor::Opaque::kYes, + GrPipelineAnalysisColor(GrColorPackRGBA(0, 82, 17, 100)), + GrPipelineAnalysisColor(GrColorPackRGBA(0, 82, 17, 255))}; for (const auto& colorInput : colorInputs) { GrProcessorSet::FragmentProcessorAnalysis analysis; - for (bool fractionalCoverage : {true, false}) { - if (fractionalCoverage) { - analysis = GrProcessorSet::FragmentProcessorAnalysis(colorInput, GrPipelineInput(), - caps); - } else { - analysis = GrProcessorSet::FragmentProcessorAnalysis(colorInput, GrColorPackA4(255), - caps); - } + for (GrPipelineAnalysisCoverage coverageType : + {GrPipelineAnalysisCoverage::kSingleChannel, GrPipelineAnalysisCoverage::kNone}) { + analysis = GrProcessorSet::FragmentProcessorAnalysis(colorInput, coverageType, caps); for (int m = 0; m <= (int)SkBlendMode::kLastCoeffMode; m++) { SkBlendMode xfermode = static_cast(m); const GrXPFactory* xpf = GrPorterDuffXPFactory::Get(xfermode); diff --git a/tests/PreFlushCallbackTest.cpp b/tests/PreFlushCallbackTest.cpp index 773cfde..e008009 100644 --- a/tests/PreFlushCallbackTest.cpp +++ b/tests/PreFlushCallbackTest.cpp @@ -64,9 +64,10 @@ protected: SkRect fRect; private: - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override { - input->colorInput()->setToUnknown(); - input->coverageInput()->setToUnknown(); + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override { + color->setToUnknown(); + *coverage = GrPipelineAnalysisCoverage::kSingleChannel; } void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override { diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp index 30bfed9..0a9d002 100644 --- a/tests/PrimitiveProcessorTest.cpp +++ b/tests/PrimitiveProcessorTest.cpp @@ -40,9 +40,10 @@ private: this->setBounds(SkRect::MakeWH(1.f, 1.f), HasAABloat::kNo, IsZeroArea::kNo); } - void getFragmentProcessorAnalysisInputs(FragmentProcessorAnalysisInputs* input) const override { - input->colorInput()->setToUnknown(); - input->coverageInput()->setToUnknown(); + void getFragmentProcessorAnalysisInputs(GrPipelineAnalysisColor* color, + GrPipelineAnalysisCoverage* coverage) const override { + color->setToUnknown(); + *coverage = GrPipelineAnalysisCoverage::kSingleChannel; } void applyPipelineOptimizations(const GrPipelineOptimizations&) override {}