From: Brian Salomon Date: Sun, 12 Feb 2017 14:28:54 +0000 (-0500) Subject: Remove GrFragmentProcessor::computeInvariantOutput X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~55^2~351 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cb30bb2cb727e276792812c6390547dba474c831;p=platform%2Fupstream%2FlibSkiaSharp.git Remove GrFragmentProcessor::computeInvariantOutput Change-Id: If475730103052c6097eb91be06808fb723b70bf8 Reviewed-on: https://skia-review.googlesource.com/8330 Reviewed-by: Greg Daniel Commit-Queue: Brian Salomon --- diff --git a/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp b/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp index 06589f2..9422261 100644 --- a/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp +++ b/experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp @@ -19,7 +19,6 @@ #if SK_SUPPORT_GPU #include "GrContext.h" #include "GrCoordTransform.h" -#include "GrInvariantOutput.h" #include "SkGr.h" #include "effects/GrConstColorProcessor.h" #include "glsl/GrGLSLFragmentProcessor.h" @@ -669,10 +668,6 @@ private: fPaintingData->fStitchDataInit == s.fPaintingData->fStitchDataInit; } - void onComputeInvariantOutput(GrInvariantOutput* inout) const override { - inout->setToUnknown(); - } - GrPerlinNoise2Effect(SkPerlinNoiseShader2::Type type, int numOctaves, bool stitchTiles, SkPerlinNoiseShader2::PaintingData* paintingData, GrTexture* permutationsTexture, GrTexture* noiseTexture, @@ -1082,10 +1077,6 @@ private: fPaintingData->fBaseFrequency == s.fPaintingData->fBaseFrequency; } - void onComputeInvariantOutput(GrInvariantOutput* inout) const override { - inout->setToUnknown(); - } - GrImprovedPerlinNoiseEffect(int octaves, SkScalar z, SkPerlinNoiseShader2::PaintingData* paintingData, GrTexture* permutationsTexture, GrTexture* gradientTexture, diff --git a/gn/gpu.gni b/gn/gpu.gni index 001e6c1..db3ebc6 100644 --- a/gn/gpu.gni +++ b/gn/gpu.gni @@ -20,7 +20,6 @@ skia_gpu_sources = [ "$_include/gpu/GrCoordTransform.h", "$_include/gpu/GrFragmentProcessor.h", "$_include/gpu/GrGpuResource.h", - "$_include/gpu/GrInvariantOutput.h", "$_include/gpu/GrPaint.h", "$_include/gpu/GrProcessor.h", "$_include/gpu/GrProcessorUnitTest.h", @@ -143,6 +142,7 @@ skia_gpu_sources = [ "$_src/gpu/GrPipeline.h", "$_src/gpu/GrPipelineBuilder.cpp", "$_src/gpu/GrPipelineBuilder.h", + "$_src/gpu/GrPipelineInput.h", "$_src/gpu/GrPrimitiveProcessor.cpp", "$_src/gpu/GrPrimitiveProcessor.h", "$_src/gpu/GrProcessorSet.cpp", diff --git a/gn/tests.gni b/gn/tests.gni index f0c3f0e..b5ad9cc 100644 --- a/gn/tests.gni +++ b/gn/tests.gni @@ -78,7 +78,6 @@ tests_sources = [ "$_tests/GeometryTest.cpp", "$_tests/GifTest.cpp", "$_tests/GLProgramsTest.cpp", - "$_tests/GpuColorFilterTest.cpp", "$_tests/GpuDrawPathTest.cpp", "$_tests/GpuLayerCacheTest.cpp", "$_tests/GpuRectanizerTest.cpp", diff --git a/include/gpu/GrFragmentProcessor.h b/include/gpu/GrFragmentProcessor.h index 202e7fa..96ca1c8 100644 --- a/include/gpu/GrFragmentProcessor.h +++ b/include/gpu/GrFragmentProcessor.h @@ -138,18 +138,6 @@ public: bool isEqual(const GrFragmentProcessor& that) const; /** - * This function is used to perform optimizations. When called the invarientOuput param - * indicate whether the input components to this processor in the FS will have known values. - * In inout the validFlags member is a bitfield of GrColorComponentFlags. The isSingleComponent - * member indicates whether the input will be 1 or 4 bytes. The function updates the members of - * inout to indicate known values of its output. A component of the color member only has - * meaning if the corresponding bit in validFlags is set. - */ - void computeInvariantOutput(GrInvariantOutput* inout) const { - this->onComputeInvariantOutput(inout); - } - - /** * Pre-order traversal of a FP hierarchy, or of the forest of FPs in a GrPipeline. In the latter * case the tree rooted at each FP in the GrPipeline is visited successively. */ @@ -278,14 +266,6 @@ protected: int registerChildProcessor(sk_sp child); /** - * Subclass implements this to support getConstantColorComponents(...). - * - * Note: it's up to the subclass implementation to do any recursive call to compute the child - * procs' output invariants; computeInvariantOutput will not be recursive. - */ - virtual void onComputeInvariantOutput(GrInvariantOutput* inout) const = 0; - - /** * Sub-classes should call this in their constructors if they need access to a distance * vector field to the nearest edge */ diff --git a/include/gpu/GrInvariantOutput.h b/include/gpu/GrInvariantOutput.h deleted file mode 100644 index ee43359..0000000 --- a/include/gpu/GrInvariantOutput.h +++ /dev/null @@ -1,247 +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 GrInvariantOutput_DEFINED -#define GrInvariantOutput_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 { - GrPipelineInput() - : fValidFlags(kNone_GrColorComponentFlags) - , fColor(0) - , fIsLCDCoverage(false) {} - - void setKnownFourComponents(GrColor color) { - fColor = color; - fValidFlags = kRGBA_GrColorComponentFlags; - } - - void setUnknownFourComponents() { - fValidFlags = kNone_GrColorComponentFlags; - } - - void setUnknownOpaqueFourComponents() { - fColor = 0xffU << GrColor_SHIFT_A; - fValidFlags = kA_GrColorComponentFlag; - } - - void setKnownSingleComponent(uint8_t alpha) { - fColor = GrColorPackRGBA(alpha, alpha, alpha, alpha); - fValidFlags = kRGBA_GrColorComponentFlags; - } - - void setUnknownSingleComponent() { - fValidFlags = kNone_GrColorComponentFlags; - } - - void setUsingLCDCoverage() { fIsLCDCoverage = true; } - - GrColorComponentFlags fValidFlags; - GrColor fColor; - bool fIsLCDCoverage; // Temorary data member until texture pixel configs are - // updated -}; - -/** This describes the output of a GrFragmentProcessor in a GrPipeline. */ -class GrInvariantOutput { -public: - GrInvariantOutput(GrColor color, GrColorComponentFlags flags) - : fColor(color), fValidFlags(flags), fNonMulStageFound(false) {} - - GrInvariantOutput(const GrPipelineInput& input) - : fColor(input.fColor), fValidFlags(input.fValidFlags), fNonMulStageFound(false) {} - - virtual ~GrInvariantOutput() {} - - void mulByUnknownOpaqueFourComponents() { - if (this->isOpaque()) { - fValidFlags = kA_GrColorComponentFlag; - } else { - // Since the current state is not opaque we no longer care if the color being - // multiplied is opaque. - this->mulByUnknownFourComponents(); - } - } - - void mulByUnknownFourComponents() { - if (this->hasZeroAlpha()) { - this->internalSetToTransparentBlack(); - } else { - this->internalSetToUnknown(); - } - } - - void mulByUnknownSingleComponent() { - if (this->hasZeroAlpha()) { - this->internalSetToTransparentBlack(); - } else { - // We don't need to change fIsSingleComponent in this case - fValidFlags = kNone_GrColorComponentFlags; - } - } - - void mulByKnownSingleComponent(uint8_t alpha) { - if (this->hasZeroAlpha() || 0 == alpha) { - this->internalSetToTransparentBlack(); - } else { - if (alpha != 255) { - // Multiply color by alpha - fColor = GrColorPackRGBA(SkMulDiv255Round(GrColorUnpackR(fColor), alpha), - SkMulDiv255Round(GrColorUnpackG(fColor), alpha), - SkMulDiv255Round(GrColorUnpackB(fColor), alpha), - SkMulDiv255Round(GrColorUnpackA(fColor), alpha)); - // We don't need to change fIsSingleComponent in this case - } - } - } - - void mulByKnownFourComponents(GrColor color) { - uint32_t a; - if (GetAlphaAndCheckSingleChannel(color, &a)) { - this->mulByKnownSingleComponent(a); - } else { - if (color != 0xffffffff) { - fColor = GrColorPackRGBA( - SkMulDiv255Round(GrColorUnpackR(fColor), GrColorUnpackR(color)), - SkMulDiv255Round(GrColorUnpackG(fColor), GrColorUnpackG(color)), - SkMulDiv255Round(GrColorUnpackB(fColor), GrColorUnpackB(color)), - SkMulDiv255Round(GrColorUnpackA(fColor), a)); - } - } - } - - // Ignores the incoming color's RGB and muls its alpha by color. - void mulAlphaByKnownFourComponents(GrColor color) { - uint32_t a; - if (GetAlphaAndCheckSingleChannel(color, &a)) { - this->mulAlphaByKnownSingleComponent(a); - } else if (fValidFlags & kA_GrColorComponentFlag) { - GrColor preAlpha = GrColorUnpackA(fColor); - if (0 == preAlpha) { - this->internalSetToTransparentBlack(); - } else { - // We know that color has different component values - fColor = GrColorPackRGBA( - SkMulDiv255Round(preAlpha, GrColorUnpackR(color)), - SkMulDiv255Round(preAlpha, GrColorUnpackG(color)), - SkMulDiv255Round(preAlpha, GrColorUnpackB(color)), - SkMulDiv255Round(preAlpha, a)); - fValidFlags = kRGBA_GrColorComponentFlags; - } - } else { - fValidFlags = kNone_GrColorComponentFlags; - } - } - - // Ignores the incoming color's RGB and muls its alpha by the alpha param and sets all channels - // equal to that value. - void mulAlphaByKnownSingleComponent(uint8_t alpha) { - if (0 == alpha || this->hasZeroAlpha()) { - this->internalSetToTransparentBlack(); - } else { - if (fValidFlags & kA_GrColorComponentFlag) { - GrColor a = GrColorUnpackA(fColor); - a = SkMulDiv255Round(alpha, a); - fColor = GrColorPackRGBA(a, a, a, a); - fValidFlags = kRGBA_GrColorComponentFlags; - } else { - fValidFlags = kNone_GrColorComponentFlags; - } - } - } - - void premulFourChannelColor() { - fNonMulStageFound = true; - if (!(fValidFlags & kA_GrColorComponentFlag)) { - fValidFlags = kNone_GrColorComponentFlags; - } else { - fColor = GrPremulColor(fColor); - } - } - - void invalidateComponents(GrColorComponentFlags invalidateFlags) { - fValidFlags = (fValidFlags & ~invalidateFlags); - fNonMulStageFound = true; - } - - void setToOther(GrColorComponentFlags validFlags, GrColor color) { - fValidFlags = validFlags; - fColor = color; - fNonMulStageFound = true; - } - - void setToUnknown() { - this->internalSetToUnknown(); - fNonMulStageFound = true; - } - - GrColor color() const { return fColor; } - GrColorComponentFlags validFlags() const { return fValidFlags; } - -private: - friend class GrProcOptInfo; - - /** Extracts the alpha channel and returns true if r,g,b == a. */ - static bool GetAlphaAndCheckSingleChannel(GrColor color, uint32_t* alpha) { - *alpha = GrColorUnpackA(color); - return *alpha == GrColorUnpackR(color) && *alpha == GrColorUnpackG(color) && - *alpha == GrColorUnpackB(color); - } - - void reset(GrColor color, GrColorComponentFlags flags) { - fColor = color; - fValidFlags = flags; - fNonMulStageFound = false; - } - - void reset(const GrPipelineInput& input) { - fColor = input.fColor; - fValidFlags = input.fValidFlags; - fNonMulStageFound = false; - } - - void internalSetToTransparentBlack() { - fValidFlags = kRGBA_GrColorComponentFlags; - fColor = 0; - } - - void internalSetToUnknown() { - fValidFlags = kNone_GrColorComponentFlags; - } - - bool hasZeroAlpha() const { - return ((fValidFlags & kA_GrColorComponentFlag) && 0 == GrColorUnpackA(fColor)); - } - - bool isOpaque() const { - return ((fValidFlags & kA_GrColorComponentFlag) && 0xFF == GrColorUnpackA(fColor)); - } - - bool isSolidWhite() const { - return (fValidFlags == kRGBA_GrColorComponentFlags && 0xFFFFFFFF == fColor); - } - - bool allStagesMulInput() const { return !fNonMulStageFound; } - void resetNonMulStageFound() { fNonMulStageFound = false; } - - /** - * If alpha is valid, check that any valid R,G,B values are <= A - */ - SkDEBUGCODE(bool validPreMulColor() const;) - - GrColor fColor; - GrColorComponentFlags fValidFlags; - bool fNonMulStageFound; -}; - -#endif - diff --git a/include/gpu/effects/GrBlurredEdgeFragmentProcessor.h b/include/gpu/effects/GrBlurredEdgeFragmentProcessor.h index c9dd276..d0864ed 100644 --- a/include/gpu/effects/GrBlurredEdgeFragmentProcessor.h +++ b/include/gpu/effects/GrBlurredEdgeFragmentProcessor.h @@ -58,8 +58,6 @@ private: bool onIsEqual(const GrFragmentProcessor&) const override; - void onComputeInvariantOutput(GrInvariantOutput* inout) const override; - GR_DECLARE_FRAGMENT_PROCESSOR_TEST; Mode fMode; diff --git a/include/gpu/effects/GrConstColorProcessor.h b/include/gpu/effects/GrConstColorProcessor.h index b32421b..44e8cb1 100644 --- a/include/gpu/effects/GrConstColorProcessor.h +++ b/include/gpu/effects/GrConstColorProcessor.h @@ -65,7 +65,6 @@ private: bool onIsEqual(const GrFragmentProcessor&) const override; - void onComputeInvariantOutput(GrInvariantOutput* inout) const override; GrColor4f constantOutputForConstantInput(GrColor4f input) const override; GR_DECLARE_FRAGMENT_PROCESSOR_TEST; diff --git a/src/core/SkColorMatrixFilterRowMajor255.cpp b/src/core/SkColorMatrixFilterRowMajor255.cpp index 0c6318b..6809890 100644 --- a/src/core/SkColorMatrixFilterRowMajor255.cpp +++ b/src/core/SkColorMatrixFilterRowMajor255.cpp @@ -270,7 +270,6 @@ SkColorMatrixFilterRowMajor255::makeComposed(sk_sp innerFilter) c #if SK_SUPPORT_GPU #include "GrFragmentProcessor.h" -#include "GrInvariantOutput.h" #include "glsl/GrGLSLFragmentProcessor.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" #include "glsl/GrGLSLProgramDataManager.h" @@ -367,50 +366,6 @@ private: return 0 == memcmp(fMatrix, cme.fMatrix, sizeof(fMatrix)); } - void onComputeInvariantOutput(GrInvariantOutput* inout) const override { - // We only bother to check whether the alpha channel will be constant. If SkColorMatrix had - // type flags it might be worth checking the other components. - - // The matrix is defined such the 4th row determines the output alpha. The first four - // columns of that row multiply the input r, g, b, and a, respectively, and the last column - // is the "translation". - static const uint32_t kRGBAFlags[] = { - kR_GrColorComponentFlag, - kG_GrColorComponentFlag, - kB_GrColorComponentFlag, - kA_GrColorComponentFlag - }; - static const int kShifts[] = { - GrColor_SHIFT_R, GrColor_SHIFT_G, GrColor_SHIFT_B, GrColor_SHIFT_A, - }; - enum { - kAlphaRowStartIdx = 15, - kAlphaRowTranslateIdx = 19, - }; - - SkScalar outputA = 0; - for (int i = 0; i < 4; ++i) { - // If any relevant component of the color to be passed through the matrix is non-const - // then we can't know the final result. - if (0 != fMatrix[kAlphaRowStartIdx + i]) { - if (!(inout->validFlags() & kRGBAFlags[i])) { - inout->setToUnknown(); - return; - } else { - uint32_t component = (inout->color() >> kShifts[i]) & 0xFF; - outputA += fMatrix[kAlphaRowStartIdx + i] * component; - } - } - } - outputA += fMatrix[kAlphaRowTranslateIdx]; - // We pin the color to [0,1]. This would happen to the *final* color output from the frag - // shader but currently the effect does not pin its own output. So in the case of over/ - // underflow this may deviate from the actual result. Maybe the effect should pin its - // result if the matrix could over/underflow for any component? - inout->setToOther(kA_GrColorComponentFlag, - static_cast(SkScalarPin(outputA, 0, 255)) << GrColor_SHIFT_A); - } - SkScalar fMatrix[20]; typedef GrFragmentProcessor INHERITED; diff --git a/src/core/SkLightingShader.cpp b/src/core/SkLightingShader.cpp index 5bdaee5..2deacc2 100644 --- a/src/core/SkLightingShader.cpp +++ b/src/core/SkLightingShader.cpp @@ -100,7 +100,6 @@ private: #include "GrCoordTransform.h" #include "GrFragmentProcessor.h" -#include "GrInvariantOutput.h" #include "glsl/GrGLSLFragmentProcessor.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" #include "glsl/GrGLSLProgramDataManager.h" @@ -241,10 +240,6 @@ public: const char* name() const override { return "LightingFP"; } - void onComputeInvariantOutput(GrInvariantOutput* inout) const override { - inout->mulByUnknownFourComponents(); - } - const SkTArray& directionalLights() const { return fDirectionalLights; } const SkColor3f& ambientColor() const { return fAmbientColor; } diff --git a/src/core/SkModeColorFilter.cpp b/src/core/SkModeColorFilter.cpp index 05dfbff..d074482 100644 --- a/src/core/SkModeColorFilter.cpp +++ b/src/core/SkModeColorFilter.cpp @@ -106,7 +106,6 @@ bool SkModeColorFilter::onAppendStages(SkRasterPipeline* p, /////////////////////////////////////////////////////////////////////////////// #if SK_SUPPORT_GPU #include "GrBlend.h" -#include "GrInvariantOutput.h" #include "effects/GrXfermodeFragmentProcessor.h" #include "effects/GrConstColorProcessor.h" #include "SkGr.h" @@ -129,10 +128,7 @@ sk_sp SkModeColorFilter::asFragmentProcessor( // With a solid color input this should always be able to compute the blended color // (at least for coeff modes) if ((unsigned)fMode <= (unsigned)SkBlendMode::kLastCoeffMode) { - static SkRandom gRand; - GrInvariantOutput io(GrPremulColor(gRand.nextU()), kRGBA_GrColorComponentFlags); - fp->computeInvariantOutput(&io); - SkASSERT(io.validFlags() == kRGBA_GrColorComponentFlags); + SkASSERT(fp->hasConstantOutputForConstantInput()); } #endif return fp; diff --git a/src/core/SkNormalBevelSource.cpp b/src/core/SkNormalBevelSource.cpp index 5ff7d82..39e25e0 100644 --- a/src/core/SkNormalBevelSource.cpp +++ b/src/core/SkNormalBevelSource.cpp @@ -15,7 +15,6 @@ #include "SkWriteBuffer.h" #if SK_SUPPORT_GPU -#include "GrInvariantOutput.h" #include "glsl/GrGLSLFragmentProcessor.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" #include "SkGr.h" @@ -224,10 +223,6 @@ public: const char* name() const override { return "NormalBevelFP"; } - void onComputeInvariantOutput(GrInvariantOutput* inout) const override { - inout->setToUnknown(); - } - private: GrGLSLFragmentProcessor* onCreateGLSLInstance() const override { return new GLSLNormalBevelFP; } diff --git a/src/core/SkNormalFlatSource.cpp b/src/core/SkNormalFlatSource.cpp index 73ef549..c08813d 100644 --- a/src/core/SkNormalFlatSource.cpp +++ b/src/core/SkNormalFlatSource.cpp @@ -15,7 +15,6 @@ #include "SkWriteBuffer.h" #if SK_SUPPORT_GPU -#include "GrInvariantOutput.h" #include "glsl/GrGLSLFragmentProcessor.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" @@ -50,9 +49,7 @@ private: void onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const override { GLSLNormalFlatFP::GenKey(*this, caps, b); } - void onComputeInvariantOutput(GrInvariantOutput* inout) const override { - inout->setToUnknown(); - } + GrColor4f constantOutputForConstantInput(GrColor4f) const override { return GrColor4f(0, 0, 1, 0); } diff --git a/src/core/SkNormalMapSource.cpp b/src/core/SkNormalMapSource.cpp index 2d3d241..afa4698 100644 --- a/src/core/SkNormalMapSource.cpp +++ b/src/core/SkNormalMapSource.cpp @@ -18,7 +18,6 @@ #if SK_SUPPORT_GPU #include "GrCoordTransform.h" -#include "GrInvariantOutput.h" #include "GrSamplerParams.h" #include "glsl/GrGLSLFragmentProcessor.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" @@ -103,10 +102,6 @@ public: const char* name() const override { return "NormalMapFP"; } - void onComputeInvariantOutput(GrInvariantOutput* inout) const override { - inout->setToUnknown(); - } - const SkMatrix& invCTM() const { return fInvCTM; } private: diff --git a/src/core/SkRadialShadowMapShader.cpp b/src/core/SkRadialShadowMapShader.cpp index b56d61e..0cc60f1 100644 --- a/src/core/SkRadialShadowMapShader.cpp +++ b/src/core/SkRadialShadowMapShader.cpp @@ -219,9 +219,6 @@ public: const char* name() const override { return "RadialShadowMapFP"; } - void onComputeInvariantOutput(GrInvariantOutput* inout) const override { - inout->mulByUnknownFourComponents(); - } const SkVector3& lightPos() const { return fLightPos; } diff --git a/src/core/SkShadowShader.cpp b/src/core/SkShadowShader.cpp index 80794da..afefa95 100644 --- a/src/core/SkShadowShader.cpp +++ b/src/core/SkShadowShader.cpp @@ -558,9 +558,6 @@ public: const char* name() const override { return "shadowFP"; } - void onComputeInvariantOutput(GrInvariantOutput* inout) const override { - inout->mulByUnknownFourComponents(); - } int32_t numLights() const { return fNumNonAmbLights; } const SkColor3f& ambientColor() const { return fAmbientColor; } bool isPointLight(int i) const { diff --git a/src/effects/GrAlphaThresholdFragmentProcessor.cpp b/src/effects/GrAlphaThresholdFragmentProcessor.cpp index 45a7b65..f0338a6 100644 --- a/src/effects/GrAlphaThresholdFragmentProcessor.cpp +++ b/src/effects/GrAlphaThresholdFragmentProcessor.cpp @@ -9,9 +9,7 @@ #if SK_SUPPORT_GPU -#include "GrInvariantOutput.h" #include "SkRefCnt.h" - #include "glsl/GrGLSLColorSpaceXformHelper.h" #include "glsl/GrGLSLFragmentProcessor.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" @@ -71,17 +69,6 @@ bool GrAlphaThresholdFragmentProcessor::onIsEqual(const GrFragmentProcessor& sBa this->fOuterThreshold == s.fOuterThreshold); } -void GrAlphaThresholdFragmentProcessor::onComputeInvariantOutput(GrInvariantOutput* inout) const { - GrPixelConfig config = this->textureSampler(0).texture()->config(); - if (GrPixelConfigIsAlphaOnly(config)) { - inout->mulByUnknownSingleComponent(); - } else if (GrPixelConfigIsOpaque(config) && fOuterThreshold >= 1.f) { - inout->mulByUnknownOpaqueFourComponents(); - } else { - inout->mulByUnknownFourComponents(); - } -} - /////////////////////////////////////////////////////////////////////////////// class GrGLAlphaThresholdFragmentProcessor : public GrGLSLFragmentProcessor { diff --git a/src/effects/GrAlphaThresholdFragmentProcessor.h b/src/effects/GrAlphaThresholdFragmentProcessor.h index f2c14c6..fe97c7d 100644 --- a/src/effects/GrAlphaThresholdFragmentProcessor.h +++ b/src/effects/GrAlphaThresholdFragmentProcessor.h @@ -50,8 +50,6 @@ private: bool onIsEqual(const GrFragmentProcessor&) const override; - void onComputeInvariantOutput(GrInvariantOutput* inout) const override; - GR_DECLARE_FRAGMENT_PROCESSOR_TEST; float fInnerThreshold; diff --git a/src/effects/GrCircleBlurFragmentProcessor.cpp b/src/effects/GrCircleBlurFragmentProcessor.cpp index c54a71c..70c4247 100644 --- a/src/effects/GrCircleBlurFragmentProcessor.cpp +++ b/src/effects/GrCircleBlurFragmentProcessor.cpp @@ -10,9 +10,7 @@ #if SK_SUPPORT_GPU #include "GrContext.h" -#include "GrInvariantOutput.h" #include "GrTextureProvider.h" - #include "glsl/GrGLSLFragmentProcessor.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" #include "glsl/GrGLSLProgramDataManager.h" @@ -107,10 +105,6 @@ void GrCircleBlurFragmentProcessor::onGetGLSLProcessorKey(const GrShaderCaps& ca return; } -void GrCircleBlurFragmentProcessor::onComputeInvariantOutput(GrInvariantOutput* inout) const { - inout->mulByUnknownSingleComponent(); -} - // Computes an unnormalized half kernel (right side). Returns the summation of all the half kernel // values. static float make_unnormalized_half_kernel(float* halfKernel, int halfKernelSize, float sigma) { diff --git a/src/effects/GrCircleBlurFragmentProcessor.h b/src/effects/GrCircleBlurFragmentProcessor.h index 4e7ed13..f577cc7 100644 --- a/src/effects/GrCircleBlurFragmentProcessor.h +++ b/src/effects/GrCircleBlurFragmentProcessor.h @@ -59,8 +59,6 @@ private: fTextureRadius == cbfp.fTextureRadius; } - void onComputeInvariantOutput(GrInvariantOutput* inout) const override; - SkRect fCircle; SkScalar fSolidRadius; float fTextureRadius; diff --git a/src/effects/SkArithmeticImageFilter.cpp b/src/effects/SkArithmeticImageFilter.cpp index 4056069..af834aa 100644 --- a/src/effects/SkArithmeticImageFilter.cpp +++ b/src/effects/SkArithmeticImageFilter.cpp @@ -285,11 +285,6 @@ private: fEnforcePMColor == fp.fEnforcePMColor; } - void onComputeInvariantOutput(GrInvariantOutput* inout) const override { - // TODO: optimize this - inout->setToUnknown(); - } - // This could implement the const input -> const output optimization but it's unlikely to help. ArithmeticFP(float k1, float k2, float k3, float k4, bool enforcePMColor, sk_sp dst) diff --git a/src/effects/SkBlurMaskFilter.cpp b/src/effects/SkBlurMaskFilter.cpp index f41648d..c070ccf 100644 --- a/src/effects/SkBlurMaskFilter.cpp +++ b/src/effects/SkBlurMaskFilter.cpp @@ -21,7 +21,6 @@ #include "GrRenderTargetContext.h" #include "GrTexture.h" #include "GrFragmentProcessor.h" -#include "GrInvariantOutput.h" #include "GrShaderCaps.h" #include "GrStyle.h" #include "GrTextureProxy.h" @@ -823,8 +822,6 @@ private: bool onIsEqual(const GrFragmentProcessor&) const override; - void onComputeInvariantOutput(GrInvariantOutput* inout) const override; - static GrTexture* CreateBlurProfileTexture(GrTextureProvider*, float sigma); SkRect fRect; @@ -999,10 +996,6 @@ bool GrRectBlurEffect::onIsEqual(const GrFragmentProcessor& sBase) const { return this->getSigma() == s.getSigma() && this->getRect() == s.getRect(); } -void GrRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { - inout->mulByUnknownSingleComponent(); -} - GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRectBlurEffect); #if GR_TEST_UTILS @@ -1093,8 +1086,6 @@ private: bool onIsEqual(const GrFragmentProcessor& other) const override; - void onComputeInvariantOutput(GrInvariantOutput* inout) const override; - SkRRect fRRect; float fSigma; TextureSampler fNinePatchSampler; @@ -1205,10 +1196,6 @@ sk_sp GrRRectBlurEffect::Make(GrContext* context, mask.get())); } -void GrRRectBlurEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { - inout->mulByUnknownSingleComponent(); -} - GrRRectBlurEffect::GrRRectBlurEffect(float sigma, const SkRRect& rrect, GrTexture* ninePatchTexture) : INHERITED(kModulatesInput_OptimizationFlag) , fRRect(rrect) diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp index 67fb761..6b9cb2b 100644 --- a/src/effects/SkDisplacementMapEffect.cpp +++ b/src/effects/SkDisplacementMapEffect.cpp @@ -16,7 +16,6 @@ #if SK_SUPPORT_GPU #include "GrContext.h" #include "GrCoordTransform.h" -#include "GrInvariantOutput.h" #include "GrRenderTargetContext.h" #include "GrTextureProxy.h" @@ -250,8 +249,6 @@ private: bool onIsEqual(const GrFragmentProcessor&) const override; - void onComputeInvariantOutput(GrInvariantOutput* inout) const override; - GrDisplacementMapEffect(SkDisplacementMapEffect::ChannelSelectorType xChannelSelector, SkDisplacementMapEffect::ChannelSelectorType yChannelSelector, const SkVector& scale, @@ -524,15 +521,6 @@ bool GrDisplacementMapEffect::onIsEqual(const GrFragmentProcessor& sBase) const fScale == s.fScale; } -void GrDisplacementMapEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { - // Any displacement offset bringing a pixel out of bounds will output a color of (0,0,0,0), - // so the only way we'd get a constant alpha is if the input color image has a constant alpha - // and no displacement offset push any texture coordinates out of bounds OR if the constant - // alpha is 0. Since this isn't trivial to compute at this point, let's assume the output is - // not of constant color when a displacement effect is applied. - inout->setToUnknown(); -} - /////////////////////////////////////////////////////////////////////////////// GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDisplacementMapEffect); diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp index fc7b29b..5108724 100644 --- a/src/effects/SkLightingImageFilter.cpp +++ b/src/effects/SkLightingImageFilter.cpp @@ -18,7 +18,6 @@ #include "GrContext.h" #include "GrFixedClip.h" #include "GrFragmentProcessor.h" -#include "GrInvariantOutput.h" #include "GrPaint.h" #include "GrRenderTargetContext.h" #include "GrTextureProxy.h" @@ -558,10 +557,6 @@ public: protected: bool onIsEqual(const GrFragmentProcessor&) const override; - void onComputeInvariantOutput(GrInvariantOutput* inout) const override { - // lighting shaders are complicated. We just throw up our hands. - inout->mulByUnknownFourComponents(); - } private: const SkImageFilterLight* fLight; diff --git a/src/effects/SkLumaColorFilter.cpp b/src/effects/SkLumaColorFilter.cpp index 1792437..2809c8b 100644 --- a/src/effects/SkLumaColorFilter.cpp +++ b/src/effects/SkLumaColorFilter.cpp @@ -13,7 +13,6 @@ #if SK_SUPPORT_GPU #include "GrContext.h" -#include "GrInvariantOutput.h" #include "glsl/GrGLSLFragmentProcessor.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" #endif @@ -113,10 +112,6 @@ private: bool onIsEqual(const GrFragmentProcessor&) const override { return true; } - void onComputeInvariantOutput(GrInvariantOutput* inout) const override { - // The output is always black. The alpha value for the color passed in is arbitrary. - inout->setToOther(kRGB_GrColorComponentFlags, GrColorPackRGBA(0, 0, 0, 0)); - } GrColor4f constantOutputForConstantInput(GrColor4f input) const override { float luma = SK_ITU_BT709_LUM_COEFF_R * input.fRGBA[0] + SK_ITU_BT709_LUM_COEFF_G * input.fRGBA[1] + diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp index 93a6710..d62ce9c 100644 --- a/src/effects/SkMagnifierImageFilter.cpp +++ b/src/effects/SkMagnifierImageFilter.cpp @@ -17,7 +17,6 @@ //////////////////////////////////////////////////////////////////////////////// #if SK_SUPPORT_GPU #include "GrContext.h" -#include "GrInvariantOutput.h" #include "effects/GrSingleTextureEffect.h" #include "glsl/GrGLSLColorSpaceXformHelper.h" #include "glsl/GrGLSLFragmentProcessor.h" @@ -88,8 +87,6 @@ private: bool onIsEqual(const GrFragmentProcessor&) const override; - void onComputeInvariantOutput(GrInvariantOutput* inout) const override; - GR_DECLARE_FRAGMENT_PROCESSOR_TEST; SkRect fBounds; @@ -251,10 +248,6 @@ bool GrMagnifierEffect::onIsEqual(const GrFragmentProcessor& sBase) const { this->fYInvInset == s.fYInvInset); } -void GrMagnifierEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { - this->updateInvariantOutputForModulation(inout); -} - #endif //////////////////////////////////////////////////////////////////////////////// diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp index 2c813e2..bf92b4f 100644 --- a/src/effects/SkMorphologyImageFilter.cpp +++ b/src/effects/SkMorphologyImageFilter.cpp @@ -18,7 +18,6 @@ #if SK_SUPPORT_GPU #include "GrContext.h" #include "GrFixedClip.h" -#include "GrInvariantOutput.h" #include "GrRenderTargetContext.h" #include "GrTexture.h" #include "GrTextureProxy.h" @@ -177,8 +176,6 @@ private: bool onIsEqual(const GrFragmentProcessor&) const override; - void onComputeInvariantOutput(GrInvariantOutput* inout) const override; - GrMorphologyEffect(GrTexture*, Direction, int radius, MorphologyType); GrMorphologyEffect(GrTexture*, Direction, int radius, MorphologyType, const float bounds[2]); @@ -363,12 +360,6 @@ bool GrMorphologyEffect::onIsEqual(const GrFragmentProcessor& sBase) const { this->type() == s.type()); } -void GrMorphologyEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { - // This is valid because the color components of the result of the kernel all come - // exactly from existing values in the source texture. - this->updateInvariantOutputForModulation(inout); -} - /////////////////////////////////////////////////////////////////////////////// GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMorphologyEffect); diff --git a/src/effects/SkOverdrawColorFilter.cpp b/src/effects/SkOverdrawColorFilter.cpp index 243ef77..7c5212d 100644 --- a/src/effects/SkOverdrawColorFilter.cpp +++ b/src/effects/SkOverdrawColorFilter.cpp @@ -50,7 +50,6 @@ SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END #if SK_SUPPORT_GPU #include "GrFragmentProcessor.h" -#include "GrInvariantOutput.h" #include "glsl/GrGLSLFragmentProcessor.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" @@ -63,7 +62,6 @@ private: GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {} bool onIsEqual(const GrFragmentProcessor&) const override; - void onComputeInvariantOutput(GrInvariantOutput* inout) const override; OverdrawFragmentProcessor(const GrColor4f* colors); @@ -122,10 +120,6 @@ bool OverdrawFragmentProcessor::onIsEqual(const GrFragmentProcessor& other) cons sizeof(GrColor4f) * SkOverdrawColorFilter::kNumColors); } -void OverdrawFragmentProcessor::onComputeInvariantOutput(GrInvariantOutput* inout) const { - inout->invalidateComponents(kRGBA_GrColorComponentFlags); -} - GLOverdrawFragmentProcessor::GLOverdrawFragmentProcessor(const GrColor4f* colors) { memcpy(fColors, colors, SkOverdrawColorFilter::kNumColors * sizeof(GrColor4f)); } diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp index 7582196..668ca6c 100644 --- a/src/effects/SkPerlinNoiseShader.cpp +++ b/src/effects/SkPerlinNoiseShader.cpp @@ -18,7 +18,6 @@ #if SK_SUPPORT_GPU #include "GrContext.h" #include "GrCoordTransform.h" -#include "GrInvariantOutput.h" #include "SkGr.h" #include "effects/GrConstColorProcessor.h" #include "glsl/GrGLSLFragmentProcessor.h" @@ -532,10 +531,6 @@ private: fPaintingData->fStitchDataInit == s.fPaintingData->fStitchDataInit; } - void onComputeInvariantOutput(GrInvariantOutput* inout) const override { - inout->setToUnknown(); - } - GrPerlinNoiseEffect(SkPerlinNoiseShader::Type type, int numOctaves, bool stitchTiles, SkPerlinNoiseShader::PaintingData* paintingData, GrTexture* permutationsTexture, GrTexture* noiseTexture, diff --git a/src/effects/SkRRectsGaussianEdgeMaskFilter.cpp b/src/effects/SkRRectsGaussianEdgeMaskFilter.cpp index 223887b..7635759 100644 --- a/src/effects/SkRRectsGaussianEdgeMaskFilter.cpp +++ b/src/effects/SkRRectsGaussianEdgeMaskFilter.cpp @@ -190,7 +190,6 @@ bool SkRRectsGaussianEdgeMaskFilterImpl::filterMask(SkMask* dst, const SkMask& s #include "GrCoordTransform.h" #include "GrFragmentProcessor.h" -#include "GrInvariantOutput.h" #include "glsl/GrGLSLFragmentProcessor.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" #include "glsl/GrGLSLProgramDataManager.h" @@ -453,10 +452,6 @@ public: const char* name() const override { return "RRectsGaussianEdgeFP"; } - void onComputeInvariantOutput(GrInvariantOutput* inout) const override { - inout->setToUnknown(); - } - const SkRRect& first() const { return fFirst; } Mode firstMode() const { return fFirstMode; } const SkRRect& second() const { return fSecond; } diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp index 7de1008..8960449 100644 --- a/src/effects/SkTableColorFilter.cpp +++ b/src/effects/SkTableColorFilter.cpp @@ -361,7 +361,6 @@ sk_sp SkTable_ColorFilter::makeComposed(sk_sp inne #include "GrContext.h" #include "GrFragmentProcessor.h" -#include "GrInvariantOutput.h" #include "GrTextureStripAtlas.h" #include "SkGr.h" #include "glsl/GrGLSLFragmentProcessor.h" @@ -387,19 +386,13 @@ private: bool onIsEqual(const GrFragmentProcessor&) const override; - void onComputeInvariantOutput(GrInvariantOutput* inout) const override; - ColorTableEffect(GrTexture* texture, GrTextureStripAtlas* atlas, int row, unsigned flags); GR_DECLARE_FRAGMENT_PROCESSOR_TEST; - TextureSampler fTextureSampler; - - // currently not used in shader code, just to assist onComputeInvariantOutput(). - unsigned fFlags; - - GrTextureStripAtlas* fAtlas; - int fRow; + TextureSampler fTextureSampler; + GrTextureStripAtlas* fAtlas; + int fRow; typedef GrFragmentProcessor INHERITED; }; @@ -514,7 +507,6 @@ ColorTableEffect::ColorTableEffect(GrTexture* texture, GrTextureStripAtlas* atla unsigned flags) : INHERITED(kNone_OptimizationFlags) // Not bothering with table-specific optimizations. , fTextureSampler(texture) - , fFlags(flags) , fAtlas(atlas) , fRow(row) { this->initClassID(); @@ -546,25 +538,6 @@ bool ColorTableEffect::onIsEqual(const GrFragmentProcessor& other) const { return fRow == that.fRow; } -void ColorTableEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { - // If we kept the table in the effect then we could actually run known inputs through the - // table. - GrColorComponentFlags invalidateFlags = kNone_GrColorComponentFlags; - if (fFlags & SkTable_ColorFilter::kR_Flag) { - invalidateFlags |= kR_GrColorComponentFlag; - } - if (fFlags & SkTable_ColorFilter::kG_Flag) { - invalidateFlags |= kG_GrColorComponentFlag; - } - if (fFlags & SkTable_ColorFilter::kB_Flag) { - invalidateFlags |= kB_GrColorComponentFlag; - } - if (fFlags & SkTable_ColorFilter::kA_Flag) { - invalidateFlags |= kA_GrColorComponentFlag; - } - inout->invalidateComponents(invalidateFlags); -} - /////////////////////////////////////////////////////////////////////////////// GR_DEFINE_FRAGMENT_PROCESSOR_TEST(ColorTableEffect); diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp index 9b38cb5..03f0cbc 100644 --- a/src/effects/gradients/SkGradientShader.cpp +++ b/src/effects/gradients/SkGradientShader.cpp @@ -1121,7 +1121,6 @@ SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END #if SK_SUPPORT_GPU #include "GrContext.h" -#include "GrInvariantOutput.h" #include "GrShaderCaps.h" #include "GrTextureStripAtlas.h" #include "gl/GrGLContext.h" @@ -1744,14 +1743,6 @@ bool GrGradientEffect::onIsEqual(const GrFragmentProcessor& processor) const { return GrColorSpaceXform::Equals(this->fColorSpaceXform.get(), ge.fColorSpaceXform.get()); } -void GrGradientEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { - if (fIsOpaque) { - inout->mulByUnknownOpaqueFourComponents(); - } else { - inout->mulByUnknownFourComponents(); - } -} - #if GR_TEST_UTILS GrGradientEffect::RandomGradientParams::RandomGradientParams(SkRandom* random) { // Set color count to min of 2 so that we don't trigger the const color optimization and make diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h index fe238ff..1e34153 100644 --- a/src/effects/gradients/SkGradientShaderPriv.h +++ b/src/effects/gradients/SkGradientShaderPriv.h @@ -427,8 +427,6 @@ protected: bool onIsEqual(const GrFragmentProcessor&) const override; - void onComputeInvariantOutput(GrInvariantOutput* inout) const override; - const GrCoordTransform& getCoordTransform() const { return fCoordTransform; } private: diff --git a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp index a301d64..bf92299 100644 --- a/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp +++ b/src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp @@ -10,7 +10,6 @@ #if SK_SUPPORT_GPU #include "GrCoordTransform.h" -#include "GrInvariantOutput.h" #include "GrPaint.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" #include "glsl/GrGLSLProgramDataManager.h" diff --git a/src/gpu/GrDefaultGeoProcFactory.cpp b/src/gpu/GrDefaultGeoProcFactory.cpp index f371e24..90d3239 100644 --- a/src/gpu/GrDefaultGeoProcFactory.cpp +++ b/src/gpu/GrDefaultGeoProcFactory.cpp @@ -7,7 +7,6 @@ #include "GrDefaultGeoProcFactory.h" -#include "GrInvariantOutput.h" #include "SkRefCnt.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" #include "glsl/GrGLSLGeometryProcessor.h" diff --git a/src/gpu/GrFragmentProcessor.cpp b/src/gpu/GrFragmentProcessor.cpp index 07bbe7b..9ff426f 100644 --- a/src/gpu/GrFragmentProcessor.cpp +++ b/src/gpu/GrFragmentProcessor.cpp @@ -7,7 +7,6 @@ #include "GrFragmentProcessor.h" #include "GrCoordTransform.h" -#include "GrInvariantOutput.h" #include "GrPipeline.h" #include "GrProcOptInfo.h" #include "glsl/GrGLSLFragmentProcessor.h" @@ -137,9 +136,6 @@ sk_sp GrFragmentProcessor::PremulInput(sk_sppremulFourChannelColor(); - } GrColor4f constantOutputForConstantInput(GrColor4f input) const override { return input.premul(); } @@ -195,38 +191,7 @@ sk_sp GrFragmentProcessor::MakeInputPremulAndMulByOutput( } return flags; } - void onComputeInvariantOutput(GrInvariantOutput* inout) const override { - // TODO: Add a helper to GrInvariantOutput that handles multiplying by color with flags? - if (!(inout->validFlags() & kA_GrColorComponentFlag)) { - inout->setToUnknown(); - return; - } - - GrInvariantOutput childOutput(GrColor_WHITE, kRGBA_GrColorComponentFlags); - this->childProcessor(0).computeInvariantOutput(&childOutput); - if (0 == GrColorUnpackA(inout->color()) || 0 == GrColorUnpackA(childOutput.color())) { - inout->mulByKnownFourComponents(0x0); - return; - } - GrColorComponentFlags commonFlags = childOutput.validFlags() & inout->validFlags(); - GrColor c0 = GrPremulColor(inout->color()); - GrColor c1 = childOutput.color(); - GrColor color = 0x0; - if (commonFlags & kR_GrColorComponentFlag) { - color |= SkMulDiv255Round(GrColorUnpackR(c0), GrColorUnpackR(c1)) << - GrColor_SHIFT_R; - } - if (commonFlags & kG_GrColorComponentFlag) { - color |= SkMulDiv255Round(GrColorUnpackG(c0), GrColorUnpackG(c1)) << - GrColor_SHIFT_G; - } - if (commonFlags & kB_GrColorComponentFlag) { - color |= SkMulDiv255Round(GrColorUnpackB(c0), GrColorUnpackB(c1)) << - GrColor_SHIFT_B; - } - inout->setToOther(commonFlags, color); - } GrColor4f constantOutputForConstantInput(GrColor4f input) const override { GrColor4f childColor = ConstantOutputForConstantInput(this->childProcessor(0), GrColor4f::OpaqueWhite()); @@ -310,11 +275,6 @@ sk_sp GrFragmentProcessor::OverrideInput(sk_sp().fColor; } - void onComputeInvariantOutput(GrInvariantOutput* inout) const override { - inout->setToOther(kRGBA_GrColorComponentFlags, fColor.toGrColor()); - this->childProcessor(0).computeInvariantOutput(inout); - } - GrColor4f constantOutputForConstantInput(GrColor4f) const override { return ConstantOutputForConstantInput(this->childProcessor(0), fColor); } @@ -324,8 +284,6 @@ sk_sp GrFragmentProcessor::OverrideInput(sk_spcomputeInvariantOutput(&childOut); return sk_sp(new ReplaceInputFragmentProcessor(std::move(fp), color)); } @@ -375,11 +333,6 @@ sk_sp GrFragmentProcessor::RunInSeries(sk_spnumChildProcessors(); ++i) { - this->childProcessor(i).computeInvariantOutput(inout); - } - } GrColor4f constantOutputForConstantInput(GrColor4f color) const override { int childCnt = this->numChildProcessors(); for (int i = 0; i < childCnt; ++i) { diff --git a/src/gpu/GrPipelineInput.h b/src/gpu/GrPipelineInput.h new file mode 100644 index 0000000..43d88d0 --- /dev/null +++ b/src/gpu/GrPipelineInput.h @@ -0,0 +1,47 @@ +/* + * 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 { + GrPipelineInput() + : fValidFlags(kNone_GrColorComponentFlags), fColor(0), fIsLCDCoverage(false) {} + + void setKnownFourComponents(GrColor color) { + fColor = color; + fValidFlags = kRGBA_GrColorComponentFlags; + } + + void setUnknownFourComponents() { fValidFlags = kNone_GrColorComponentFlags; } + + void setUnknownOpaqueFourComponents() { + fColor = 0xffU << GrColor_SHIFT_A; + fValidFlags = kA_GrColorComponentFlag; + } + + void setKnownSingleComponent(uint8_t alpha) { + fColor = GrColorPackRGBA(alpha, alpha, alpha, alpha); + fValidFlags = kRGBA_GrColorComponentFlags; + } + + void setUnknownSingleComponent() { fValidFlags = kNone_GrColorComponentFlags; } + + void setUsingLCDCoverage() { fIsLCDCoverage = true; } + + GrColorComponentFlags fValidFlags; + GrColor fColor; + bool fIsLCDCoverage; +}; + +#endif diff --git a/src/gpu/GrPrimitiveProcessor.h b/src/gpu/GrPrimitiveProcessor.h index f1af14d..9f726d2 100644 --- a/src/gpu/GrPrimitiveProcessor.h +++ b/src/gpu/GrPrimitiveProcessor.h @@ -21,10 +21,10 @@ * functionality. * * There are two feedback loops between the GrFragmentProcessors, the GrXferProcessor, and the - * GrPrimitiveProcessor. These loops run on the CPU and compute any invariant components which - * might be useful for correctness / optimization decisions. The GrPrimitiveProcessor seeds these - * loops, one with initial color and one with initial coverage, in its - * onComputeInvariantColor / Coverage calls. These seed values are processed by the subsequent + * GrPrimitiveProcessor. These loops run on the CPU and to determine known properties of the final + * color and coverage inputs to the GrXferProcessor in order to perform optimizations that preserve + * correctness. The GrDrawOp seeds these loops with initial color and coverage, in its + * getPipelineAnalysisInput implementation. These seed values are processed by the subsequent * stages of the rendering pipeline and the output is then fed back into the GrDrawOp in * the applyPipelineOptimizations call, where the op can use the information to inform decisions * about GrPrimitiveProcessor creation. diff --git a/src/gpu/GrProcOptInfo.h b/src/gpu/GrProcOptInfo.h index be46712..89b4d2c 100644 --- a/src/gpu/GrProcOptInfo.h +++ b/src/gpu/GrProcOptInfo.h @@ -9,7 +9,7 @@ #define GrProcOptInfo_DEFINED #include "GrColor.h" -#include "GrInvariantOutput.h" +#include "GrPipelineInput.h" class GrDrawOp; class GrFragmentProcessor; diff --git a/src/gpu/GrProcessor.cpp b/src/gpu/GrProcessor.cpp index 897a755..663527e 100644 --- a/src/gpu/GrProcessor.cpp +++ b/src/gpu/GrProcessor.cpp @@ -8,7 +8,6 @@ #include "GrProcessor.h" #include "GrContext.h" #include "GrGeometryProcessor.h" -#include "GrInvariantOutput.h" #include "GrMemoryPool.h" #include "GrSamplerParams.h" #include "GrTexturePriv.h" diff --git a/src/gpu/effects/GrBezierEffect.h b/src/gpu/effects/GrBezierEffect.h index 824883c..f908551 100644 --- a/src/gpu/effects/GrBezierEffect.h +++ b/src/gpu/effects/GrBezierEffect.h @@ -11,7 +11,6 @@ #include "GrCaps.h" #include "GrProcessor.h" #include "GrGeometryProcessor.h" -#include "GrInvariantOutput.h" #include "GrTypesPriv.h" /** diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp index 2499c20..5f06fc1 100644 --- a/src/gpu/effects/GrBicubicEffect.cpp +++ b/src/gpu/effects/GrBicubicEffect.cpp @@ -6,7 +6,6 @@ */ #include "GrBicubicEffect.h" -#include "GrInvariantOutput.h" #include "GrProxyMove.h" #include "GrTextureProxy.h" #include "glsl/GrGLSLColorSpaceXformHelper.h" @@ -196,11 +195,6 @@ bool GrBicubicEffect::onIsEqual(const GrFragmentProcessor& sBase) const { return fDomain == s.fDomain; } -void GrBicubicEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { - // FIXME: Perhaps we can do better. - inout->mulByUnknownSingleComponent(); -} - GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrBicubicEffect); #if GR_TEST_UTILS diff --git a/src/gpu/effects/GrBicubicEffect.h b/src/gpu/effects/GrBicubicEffect.h index a51aad8..ba80ec2 100644 --- a/src/gpu/effects/GrBicubicEffect.h +++ b/src/gpu/effects/GrBicubicEffect.h @@ -99,8 +99,6 @@ private: bool onIsEqual(const GrFragmentProcessor&) const override; - void onComputeInvariantOutput(GrInvariantOutput* inout) const override; - GrTextureDomain fDomain; GR_DECLARE_FRAGMENT_PROCESSOR_TEST; diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp index 60df6b9..cb9cfdc 100644 --- a/src/gpu/effects/GrBitmapTextGeoProc.cpp +++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp @@ -6,7 +6,6 @@ */ #include "GrBitmapTextGeoProc.h" -#include "GrInvariantOutput.h" #include "GrTexture.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" #include "glsl/GrGLSLGeometryProcessor.h" diff --git a/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp index a4db68d..2d49883 100644 --- a/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp +++ b/src/gpu/effects/GrBlurredEdgeFragmentProcessor.cpp @@ -6,7 +6,6 @@ */ #include "effects/GrBlurredEdgeFragmentProcessor.h" -#include "GrInvariantOutput.h" #include "glsl/GrGLSLFragmentProcessor.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" @@ -68,8 +67,4 @@ bool GrBlurredEdgeFP::onIsEqual(const GrFragmentProcessor& other) const { return that.fMode == fMode; } -void GrBlurredEdgeFP::onComputeInvariantOutput(GrInvariantOutput* inout) const { - inout->mulByUnknownFourComponents(); -} - diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp index 771eba8..ba089fa 100644 --- a/src/gpu/effects/GrConfigConversionEffect.cpp +++ b/src/gpu/effects/GrConfigConversionEffect.cpp @@ -8,7 +8,6 @@ #include "GrConfigConversionEffect.h" #include "GrContext.h" #include "GrRenderTargetContext.h" -#include "GrInvariantOutput.h" #include "GrSimpleTextureEffect.h" #include "SkMatrix.h" #include "glsl/GrGLSLFragmentProcessor.h" @@ -136,10 +135,6 @@ bool GrConfigConversionEffect::onIsEqual(const GrFragmentProcessor& s) const { other.fPMConversion == fPMConversion; } -void GrConfigConversionEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { - this->updateInvariantOutputForModulation(inout); -} - /////////////////////////////////////////////////////////////////////////////// GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConfigConversionEffect); diff --git a/src/gpu/effects/GrConfigConversionEffect.h b/src/gpu/effects/GrConfigConversionEffect.h index 151365b..afa24c0 100644 --- a/src/gpu/effects/GrConfigConversionEffect.h +++ b/src/gpu/effects/GrConfigConversionEffect.h @@ -64,8 +64,6 @@ private: bool onIsEqual(const GrFragmentProcessor&) const override; - void onComputeInvariantOutput(GrInvariantOutput* inout) const override; - GrSwizzle fSwizzle; PMConversion fPMConversion; diff --git a/src/gpu/effects/GrConstColorProcessor.cpp b/src/gpu/effects/GrConstColorProcessor.cpp index 1d20512..1013ff3 100644 --- a/src/gpu/effects/GrConstColorProcessor.cpp +++ b/src/gpu/effects/GrConstColorProcessor.cpp @@ -6,7 +6,6 @@ */ #include "effects/GrConstColorProcessor.h" -#include "GrInvariantOutput.h" #include "glsl/GrGLSLFragmentProcessor.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" #include "glsl/GrGLSLProgramDataManager.h" @@ -62,29 +61,6 @@ private: /////////////////////////////////////////////////////////////////////////////// -void GrConstColorProcessor::onComputeInvariantOutput(GrInvariantOutput* inout) const { - if (kIgnore_InputMode == fMode) { - inout->setToOther(kRGBA_GrColorComponentFlags, fColor.toGrColor()); - } else { - float r = fColor.fRGBA[0]; - bool colorIsSingleChannel = r == fColor.fRGBA[1] && r == fColor.fRGBA[2] && - r == fColor.fRGBA[3]; - if (kModulateRGBA_InputMode == fMode) { - if (colorIsSingleChannel) { - inout->mulByKnownSingleComponent(SkToU8(sk_float_round2int(255.0f * r))); - } else { - inout->mulByKnownFourComponents(fColor.toGrColor()); - } - } else { - if (colorIsSingleChannel) { - inout->mulAlphaByKnownSingleComponent(SkToU8(sk_float_round2int(255.0f * r))); - } else { - inout->mulAlphaByKnownFourComponents(fColor.toGrColor()); - } - } - } -} - GrColor4f GrConstColorProcessor::constantOutputForConstantInput(GrColor4f input) const { switch (fMode) { case kIgnore_InputMode: diff --git a/src/gpu/effects/GrConvexPolyEffect.cpp b/src/gpu/effects/GrConvexPolyEffect.cpp index db8c2d9..907a9e5 100644 --- a/src/gpu/effects/GrConvexPolyEffect.cpp +++ b/src/gpu/effects/GrConvexPolyEffect.cpp @@ -6,7 +6,6 @@ */ #include "GrConvexPolyEffect.h" -#include "GrInvariantOutput.h" #include "SkPathPriv.h" #include "effects/GrConstColorProcessor.h" #include "glsl/GrGLSLFragmentProcessor.h" @@ -43,15 +42,6 @@ private: return fRect == aare.fRect; } - void onComputeInvariantOutput(GrInvariantOutput* inout) const override { - if (fRect.isEmpty()) { - // An empty rect will have no coverage anywhere. - inout->mulByKnownSingleComponent(0); - } else { - inout->mulByUnknownSingleComponent(); - } - } - SkRect fRect; GrPrimitiveEdgeType fEdgeType; @@ -327,10 +317,6 @@ sk_sp GrConvexPolyEffect::Make(GrPrimitiveEdgeType edgeType GrConvexPolyEffect::~GrConvexPolyEffect() {} -void GrConvexPolyEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { - inout->mulByUnknownSingleComponent(); -} - void GrConvexPolyEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const { GrGLConvexPolyEffect::GenKey(*this, caps, b); diff --git a/src/gpu/effects/GrConvexPolyEffect.h b/src/gpu/effects/GrConvexPolyEffect.h index 2d9d20f..b5ae724 100644 --- a/src/gpu/effects/GrConvexPolyEffect.h +++ b/src/gpu/effects/GrConvexPolyEffect.h @@ -78,8 +78,6 @@ private: bool onIsEqual(const GrFragmentProcessor& other) const override; - void onComputeInvariantOutput(GrInvariantOutput* inout) const override; - GrPrimitiveEdgeType fEdgeType; int fEdgeCount; SkScalar fEdges[3 * kMaxEdges]; diff --git a/src/gpu/effects/GrCustomXfermode.cpp b/src/gpu/effects/GrCustomXfermode.cpp index e40d184..4a4cb60 100644 --- a/src/gpu/effects/GrCustomXfermode.cpp +++ b/src/gpu/effects/GrCustomXfermode.cpp @@ -10,7 +10,6 @@ #include "GrCoordTransform.h" #include "GrContext.h" #include "GrFragmentProcessor.h" -#include "GrInvariantOutput.h" #include "GrPipeline.h" #include "GrProcessor.h" #include "GrShaderCaps.h" diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp index 0f9625e..9a7e787 100644 --- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp +++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp @@ -6,11 +6,8 @@ */ #include "GrDistanceFieldGeoProc.h" -#include "GrInvariantOutput.h" #include "GrTexture.h" - #include "SkDistanceFieldGen.h" - #include "glsl/GrGLSLFragmentShaderBuilder.h" #include "glsl/GrGLSLGeometryProcessor.h" #include "glsl/GrGLSLProgramDataManager.h" diff --git a/src/gpu/effects/GrDitherEffect.cpp b/src/gpu/effects/GrDitherEffect.cpp index 34a1565..036d42c 100644 --- a/src/gpu/effects/GrDitherEffect.cpp +++ b/src/gpu/effects/GrDitherEffect.cpp @@ -7,7 +7,6 @@ #include "GrDitherEffect.h" #include "GrFragmentProcessor.h" -#include "GrInvariantOutput.h" #include "SkRect.h" #include "glsl/GrGLSLFragmentProcessor.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" @@ -35,17 +34,11 @@ private: // All dither effects are equal bool onIsEqual(const GrFragmentProcessor&) const override { return true; } - void onComputeInvariantOutput(GrInvariantOutput* inout) const override; - GR_DECLARE_FRAGMENT_PROCESSOR_TEST; typedef GrFragmentProcessor INHERITED; }; -void DitherEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { - inout->setToUnknown(); -} - ////////////////////////////////////////////////////////////////////////////// GR_DEFINE_FRAGMENT_PROCESSOR_TEST(DitherEffect); diff --git a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h index 0bb9c5e..6d6e5b0 100644 --- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h +++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h @@ -9,7 +9,6 @@ #define GrGaussianConvolutionFragmentProcessor_DEFINED #include "Gr1DKernelEffect.h" -#include "GrInvariantOutput.h" /** * A 1D Gaussian convolution effect. The kernel is computed as an array of 2 * half-width weights. @@ -73,12 +72,6 @@ private: bool onIsEqual(const GrFragmentProcessor&) const override; - void onComputeInvariantOutput(GrInvariantOutput* inout) const override { - // If the texture was opaque we could know that the output color if we knew the sum of the - // kernel values. - inout->mulByUnknownFourComponents(); - } - GR_DECLARE_FRAGMENT_PROCESSOR_TEST; // TODO: Inline the kernel constants into the generated shader code. This may involve pulling diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.h b/src/gpu/effects/GrMatrixConvolutionEffect.h index 0bb7c50..581323b 100644 --- a/src/gpu/effects/GrMatrixConvolutionEffect.h +++ b/src/gpu/effects/GrMatrixConvolutionEffect.h @@ -9,7 +9,6 @@ #define GrMatrixConvolutionEffect_DEFINED #include "GrSingleTextureEffect.h" -#include "GrInvariantOutput.h" #include "GrTextureDomain.h" // A little bit less than the minimum # uniforms required by DX9SM2 (32). @@ -109,11 +108,6 @@ private: bool onIsEqual(const GrFragmentProcessor&) const override; - void onComputeInvariantOutput(GrInvariantOutput* inout) const override { - // TODO: Try to do better? - inout->mulByUnknownFourComponents(); - } - SkIRect fBounds; SkISize fKernelSize; float fKernel[MAX_KERNEL_SIZE]; diff --git a/src/gpu/effects/GrOvalEffect.cpp b/src/gpu/effects/GrOvalEffect.cpp index b64ac56..36db836 100644 --- a/src/gpu/effects/GrOvalEffect.cpp +++ b/src/gpu/effects/GrOvalEffect.cpp @@ -8,7 +8,6 @@ #include "GrOvalEffect.h" #include "GrFragmentProcessor.h" -#include "GrInvariantOutput.h" #include "SkRect.h" #include "GrShaderCaps.h" #include "glsl/GrGLSLFragmentProcessor.h" @@ -42,8 +41,6 @@ private: bool onIsEqual(const GrFragmentProcessor&) const override; - void onComputeInvariantOutput(GrInvariantOutput* inout) const override; - SkPoint fCenter; SkScalar fRadius; GrPrimitiveEdgeType fEdgeType; @@ -59,10 +56,6 @@ sk_sp CircleEffect::Make(GrPrimitiveEdgeType edgeType, cons return sk_sp(new CircleEffect(edgeType, center, radius)); } -void CircleEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { - inout->mulByUnknownSingleComponent(); -} - CircleEffect::CircleEffect(GrPrimitiveEdgeType edgeType, const SkPoint& c, SkScalar r) : INHERITED(kModulatesInput_OptimizationFlag), fCenter(c), fRadius(r), fEdgeType(edgeType) { this->initClassID(); @@ -207,8 +200,6 @@ private: bool onIsEqual(const GrFragmentProcessor&) const override; - void onComputeInvariantOutput(GrInvariantOutput* inout) const override; - SkPoint fCenter; SkVector fRadii; GrPrimitiveEdgeType fEdgeType; @@ -226,10 +217,6 @@ sk_sp EllipseEffect::Make(GrPrimitiveEdgeType edgeType, return sk_sp(new EllipseEffect(edgeType, center, rx, ry)); } -void EllipseEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { - inout->mulByUnknownSingleComponent(); -} - EllipseEffect::EllipseEffect(GrPrimitiveEdgeType edgeType, const SkPoint& c, SkScalar rx, SkScalar ry) : INHERITED(kModulatesInput_OptimizationFlag) diff --git a/src/gpu/effects/GrRRectEffect.cpp b/src/gpu/effects/GrRRectEffect.cpp index dabf11a..29d3d3d 100644 --- a/src/gpu/effects/GrRRectEffect.cpp +++ b/src/gpu/effects/GrRRectEffect.cpp @@ -9,7 +9,6 @@ #include "GrConvexPolyEffect.h" #include "GrFragmentProcessor.h" -#include "GrInvariantOutput.h" #include "GrOvalEffect.h" #include "GrShaderCaps.h" #include "SkRRect.h" @@ -68,8 +67,6 @@ private: bool onIsEqual(const GrFragmentProcessor& other) const override; - void onComputeInvariantOutput(GrInvariantOutput* inout) const override; - SkRRect fRRect; GrPrimitiveEdgeType fEdgeType; uint32_t fCircularCornerFlags; @@ -89,10 +86,6 @@ sk_sp CircularRRectEffect::Make(GrPrimitiveEdgeType edgeTyp new CircularRRectEffect(edgeType, circularCornerFlags, rrect)); } -void CircularRRectEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { - inout->mulByUnknownSingleComponent(); -} - CircularRRectEffect::CircularRRectEffect(GrPrimitiveEdgeType edgeType, uint32_t circularCornerFlags, const SkRRect& rrect) : INHERITED(kModulatesInput_OptimizationFlag) @@ -411,8 +404,6 @@ private: bool onIsEqual(const GrFragmentProcessor& other) const override; - void onComputeInvariantOutput(GrInvariantOutput* inout) const override; - SkRRect fRRect; GrPrimitiveEdgeType fEdgeType; @@ -429,10 +420,6 @@ EllipticalRRectEffect::Make(GrPrimitiveEdgeType edgeType, const SkRRect& rrect) return sk_sp(new EllipticalRRectEffect(edgeType, rrect)); } -void EllipticalRRectEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { - inout->mulByUnknownSingleComponent(); -} - EllipticalRRectEffect::EllipticalRRectEffect(GrPrimitiveEdgeType edgeType, const SkRRect& rrect) : INHERITED(kModulatesInput_OptimizationFlag), fRRect(rrect), fEdgeType(edgeType) { this->initClassID(); diff --git a/src/gpu/effects/GrSRGBEffect.cpp b/src/gpu/effects/GrSRGBEffect.cpp index ad90e70..39d6403 100644 --- a/src/gpu/effects/GrSRGBEffect.cpp +++ b/src/gpu/effects/GrSRGBEffect.cpp @@ -9,7 +9,6 @@ #include "GrContext.h" #include "GrFragmentProcessor.h" -#include "GrInvariantOutput.h" #include "GrProcessor.h" #include "glsl/GrGLSLFragmentProcessor.h" #include "glsl/GrGLSLFragmentShaderBuilder.h" @@ -82,10 +81,6 @@ bool GrSRGBEffect::onIsEqual(const GrFragmentProcessor& s) const { return other.fMode == fMode; } -void GrSRGBEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { - inout->setToUnknown(); -} - static inline float srgb_to_linear(float srgb) { return (srgb <= 0.04045f) ? srgb / 12.92f : powf((srgb + 0.055f) / 1.055f, 2.4f); } diff --git a/src/gpu/effects/GrSRGBEffect.h b/src/gpu/effects/GrSRGBEffect.h index 3d05dd6..17afa5e 100644 --- a/src/gpu/effects/GrSRGBEffect.h +++ b/src/gpu/effects/GrSRGBEffect.h @@ -32,7 +32,7 @@ private: GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override; bool onIsEqual(const GrFragmentProcessor&) const override; - void onComputeInvariantOutput(GrInvariantOutput* inout) const override; + GrColor4f constantOutputForConstantInput(GrColor4f input) const override; Mode fMode; diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrSimpleTextureEffect.cpp index 8b63fec..bd4e720 100644 --- a/src/gpu/effects/GrSimpleTextureEffect.cpp +++ b/src/gpu/effects/GrSimpleTextureEffect.cpp @@ -6,7 +6,6 @@ */ #include "GrSimpleTextureEffect.h" -#include "GrInvariantOutput.h" #include "GrProxyMove.h" #include "GrTexture.h" #include "glsl/GrGLSLColorSpaceXformHelper.h" @@ -79,10 +78,6 @@ private: /////////////////////////////////////////////////////////////////////////////// -void GrSimpleTextureEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { - this->updateInvariantOutputForModulation(inout); -} - void GrSimpleTextureEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const { GrGLSimpleTextureEffect::GenKey(*this, caps, b); diff --git a/src/gpu/effects/GrSimpleTextureEffect.h b/src/gpu/effects/GrSimpleTextureEffect.h index 64ca3cb..e7fe8bd 100644 --- a/src/gpu/effects/GrSimpleTextureEffect.h +++ b/src/gpu/effects/GrSimpleTextureEffect.h @@ -111,8 +111,6 @@ private: bool onIsEqual(const GrFragmentProcessor& other) const override { return true; } - void onComputeInvariantOutput(GrInvariantOutput* inout) const override; - GR_DECLARE_FRAGMENT_PROCESSOR_TEST; typedef GrSingleTextureEffect INHERITED; diff --git a/src/gpu/effects/GrSingleTextureEffect.h b/src/gpu/effects/GrSingleTextureEffect.h index 29105b5..894334b 100644 --- a/src/gpu/effects/GrSingleTextureEffect.h +++ b/src/gpu/effects/GrSingleTextureEffect.h @@ -11,7 +11,6 @@ #include "GrFragmentProcessor.h" #include "GrColorSpaceXform.h" #include "GrCoordTransform.h" -#include "GrInvariantOutput.h" #include "SkMatrix.h" class GrTexture; @@ -55,22 +54,6 @@ protected: sk_sp, const SkMatrix&, const GrSamplerParams&); /** - * Can be used as a helper to implement subclass onComputeInvariantOutput(). It assumes that - * the subclass output color will be a modulation of the input color with a value read from the - * texture. - */ - void updateInvariantOutputForModulation(GrInvariantOutput* inout) const { - GrPixelConfig config = this->textureSampler(0).texture()->config(); - if (GrPixelConfigIsAlphaOnly(config)) { - inout->mulByUnknownSingleComponent(); - } else if (GrPixelConfigIsOpaque(config)) { - inout->mulByUnknownOpaqueFourComponents(); - } else { - inout->mulByUnknownFourComponents(); - } - } - - /** * Can be used as a helper to implement subclass onOptimizationFlags(). It assumes that * the subclass output color will be a modulation of the input color with a value read from the * texture. diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp index 58707f5..142cd1d 100644 --- a/src/gpu/effects/GrTextureDomain.cpp +++ b/src/gpu/effects/GrTextureDomain.cpp @@ -8,7 +8,6 @@ #include "GrTextureDomain.h" #include "GrContext.h" -#include "GrInvariantOutput.h" #include "GrShaderCaps.h" #include "GrSimpleTextureEffect.h" #include "GrSurfaceProxyPriv.h" @@ -359,18 +358,6 @@ bool GrTextureDomainEffect::onIsEqual(const GrFragmentProcessor& sBase) const { return this->fTextureDomain == s.fTextureDomain; } -void GrTextureDomainEffect::onComputeInvariantOutput(GrInvariantOutput* inout) const { - if (GrTextureDomain::kDecal_Mode == fTextureDomain.mode()) { - if (GrPixelConfigIsAlphaOnly(this->textureSampler(0).texture()->config())) { - inout->mulByUnknownSingleComponent(); - } else { - inout->mulByUnknownFourComponents(); - } - } else { - this->updateInvariantOutputForModulation(inout); - } -} - /////////////////////////////////////////////////////////////////////////////// GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrTextureDomainEffect); @@ -504,15 +491,6 @@ bool GrDeviceSpaceTextureDecalFragmentProcessor::onIsEqual(const GrFragmentProce dstdfp.fTextureDomain == fTextureDomain; } -void GrDeviceSpaceTextureDecalFragmentProcessor::onComputeInvariantOutput( - GrInvariantOutput* inout) const { - if (GrPixelConfigIsAlphaOnly(this->textureSampler(0).texture()->config())) { - inout->mulByUnknownSingleComponent(); - } else { - inout->mulByUnknownFourComponents(); - } -} - /////////////////////////////////////////////////////////////////////////////// GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrDeviceSpaceTextureDecalFragmentProcessor); diff --git a/src/gpu/effects/GrTextureDomain.h b/src/gpu/effects/GrTextureDomain.h index fbc20f1..f00d460 100644 --- a/src/gpu/effects/GrTextureDomain.h +++ b/src/gpu/effects/GrTextureDomain.h @@ -205,8 +205,6 @@ private: bool onIsEqual(const GrFragmentProcessor&) const override; - void onComputeInvariantOutput(GrInvariantOutput* inout) const override; - GR_DECLARE_FRAGMENT_PROCESSOR_TEST; typedef GrSingleTextureEffect INHERITED; @@ -248,7 +246,6 @@ private: void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {} bool onIsEqual(const GrFragmentProcessor& fp) const override; - void onComputeInvariantOutput(GrInvariantOutput* inout) const override; GR_DECLARE_FRAGMENT_PROCESSOR_TEST; diff --git a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp index 78918ce..612ebea 100644 --- a/src/gpu/effects/GrXfermodeFragmentProcessor.cpp +++ b/src/gpu/effects/GrXfermodeFragmentProcessor.cpp @@ -8,7 +8,6 @@ #include "effects/GrXfermodeFragmentProcessor.h" #include "GrFragmentProcessor.h" -#include "GrInvariantOutput.h" #include "effects/GrConstColorProcessor.h" #include "glsl/GrGLSLFragmentProcessor.h" #include "glsl/GrGLSLBlend.h" @@ -62,10 +61,6 @@ private: return fMode == cs.fMode; } - void onComputeInvariantOutput(GrInvariantOutput* inout) const override { - inout->setToUnknown(); - } - GrColor4f constantOutputForConstantInput(GrColor4f input) const override { float alpha = input.fRGBA[3]; input = input.opaque(); @@ -216,32 +211,6 @@ private: return fMode == that.cast().fMode; } - void onComputeInvariantOutput(GrInvariantOutput* inout) const override { - SkXfermode::Coeff skSrcCoeff, skDstCoeff; - if (SkXfermode::ModeAsCoeff(fMode, &skSrcCoeff, &skDstCoeff)) { - GrBlendCoeff srcCoeff = SkXfermodeCoeffToGrBlendCoeff(skSrcCoeff); - GrBlendCoeff dstCoeff = SkXfermodeCoeffToGrBlendCoeff(skDstCoeff); - GrInvariantOutput childOutput(0xFFFFFFFF, kRGBA_GrColorComponentFlags); - this->childProcessor(0).computeInvariantOutput(&childOutput); - GrColor blendColor; - GrColorComponentFlags blendFlags; - if (kDst_Child == fChild) { - GrGetCoeffBlendKnownComponents(srcCoeff, dstCoeff, - inout->color(), inout->validFlags(), - childOutput.color(), childOutput.validFlags(), - &blendColor, &blendFlags); - } else { - GrGetCoeffBlendKnownComponents(srcCoeff, dstCoeff, - childOutput.color(), childOutput.validFlags(), - inout->color(), inout->validFlags(), - &blendColor, &blendFlags); - } - inout->setToOther(blendFlags, blendColor); - } else { - inout->setToUnknown(); - } - } - GrColor4f constantOutputForConstantInput(GrColor4f inputColor) const override { GrColor4f childColor = ConstantOutputForConstantInput(this->childProcessor(0), GrColor4f::OpaqueWhite()); diff --git a/src/gpu/effects/GrYUVEffect.cpp b/src/gpu/effects/GrYUVEffect.cpp index 6d917f3..e09e185 100644 --- a/src/gpu/effects/GrYUVEffect.cpp +++ b/src/gpu/effects/GrYUVEffect.cpp @@ -10,7 +10,6 @@ #include "GrContext.h" #include "GrCoordTransform.h" #include "GrFragmentProcessor.h" -#include "GrInvariantOutput.h" #include "GrProcessor.h" #include "GrTextureProxy.h" #include "glsl/GrGLSLFragmentProcessor.h" @@ -191,11 +190,6 @@ private: return (fColorSpace == s.getColorSpace()) && (fNV12 == s.isNV12()); } - void onComputeInvariantOutput(GrInvariantOutput* inout) const override { - // YUV is opaque - inout->setToOther(kA_GrColorComponentFlag, 0xFF << GrColor_SHIFT_A); - } - GrCoordTransform fYTransform; TextureSampler fYSampler; GrCoordTransform fUTransform; @@ -354,10 +348,6 @@ private: return fColorSpace == s.getColorSpace() && fOutputChannels == s.outputChannels(); } - void onComputeInvariantOutput(GrInvariantOutput* inout) const override { - inout->setToUnknown(); - } - GrCoordTransform fTransform; TextureSampler fTextureSampler; SkYUVColorSpace fColorSpace; diff --git a/src/gpu/ops/GrAAConvexPathRenderer.cpp b/src/gpu/ops/GrAAConvexPathRenderer.cpp index 767b7a0..d239732 100644 --- a/src/gpu/ops/GrAAConvexPathRenderer.cpp +++ b/src/gpu/ops/GrAAConvexPathRenderer.cpp @@ -13,7 +13,6 @@ #include "GrDefaultGeoProcFactory.h" #include "GrDrawOpTest.h" #include "GrGeometryProcessor.h" -#include "GrInvariantOutput.h" #include "GrOpFlushState.h" #include "GrPathUtils.h" #include "GrPipelineBuilder.h" diff --git a/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp b/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp index fdb5d7f..0cf08d7 100644 --- a/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp +++ b/src/gpu/ops/GrAALinearizingConvexPathRenderer.cpp @@ -12,7 +12,6 @@ #include "GrDefaultGeoProcFactory.h" #include "GrDrawOpTest.h" #include "GrGeometryProcessor.h" -#include "GrInvariantOutput.h" #include "GrOpFlushState.h" #include "GrPathUtils.h" #include "GrPipelineBuilder.h" diff --git a/src/gpu/ops/GrAnalyticRectOp.cpp b/src/gpu/ops/GrAnalyticRectOp.cpp index df62e05..23a024b 100644 --- a/src/gpu/ops/GrAnalyticRectOp.cpp +++ b/src/gpu/ops/GrAnalyticRectOp.cpp @@ -9,7 +9,6 @@ #include "GrDrawOpTest.h" #include "GrGeometryProcessor.h" -#include "GrInvariantOutput.h" #include "GrOpFlushState.h" #include "GrProcessor.h" #include "GrResourceProvider.h" diff --git a/src/gpu/ops/GrDashOp.cpp b/src/gpu/ops/GrDashOp.cpp index 7d7dbf1..dbd319a 100644 --- a/src/gpu/ops/GrDashOp.cpp +++ b/src/gpu/ops/GrDashOp.cpp @@ -13,7 +13,6 @@ #include "GrDefaultGeoProcFactory.h" #include "GrDrawOpTest.h" #include "GrGeometryProcessor.h" -#include "GrInvariantOutput.h" #include "GrOpFlushState.h" #include "GrProcessor.h" #include "GrStyle.h" diff --git a/src/gpu/ops/GrOvalOpFactory.cpp b/src/gpu/ops/GrOvalOpFactory.cpp index 4c00189..a8f0c92 100644 --- a/src/gpu/ops/GrOvalOpFactory.cpp +++ b/src/gpu/ops/GrOvalOpFactory.cpp @@ -9,7 +9,6 @@ #include "GrDrawOpTest.h" #include "GrGeometryProcessor.h" -#include "GrInvariantOutput.h" #include "GrOpFlushState.h" #include "GrProcessor.h" #include "GrResourceProvider.h" diff --git a/src/gpu/ops/GrPLSPathRenderer.cpp b/src/gpu/ops/GrPLSPathRenderer.cpp index 80a4cda..3df31fb 100644 --- a/src/gpu/ops/GrPLSPathRenderer.cpp +++ b/src/gpu/ops/GrPLSPathRenderer.cpp @@ -11,7 +11,6 @@ #include "GrContext.h" #include "GrDefaultGeoProcFactory.h" #include "GrDrawOpTest.h" -#include "GrInvariantOutput.h" #include "GrOpFlushState.h" #include "GrPLSGeometryProcessor.h" #include "GrPathUtils.h" diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp index 19f190e..dc189d6 100644 --- a/tests/GLProgramsTest.cpp +++ b/tests/GLProgramsTest.cpp @@ -16,7 +16,6 @@ #include "GrContextPriv.h" #include "GrDrawOpTest.h" #include "GrDrawingManager.h" -#include "GrInvariantOutput.h" #include "GrPipeline.h" #include "GrRenderTargetContextPriv.h" #include "GrResourceProvider.h" @@ -84,7 +83,6 @@ private: GLBigKeyProcessor::GenKey(*this, caps, b); } bool onIsEqual(const GrFragmentProcessor&) const override { return true; } - void onComputeInvariantOutput(GrInvariantOutput* inout) const override { } GR_DECLARE_FRAGMENT_PROCESSOR_TEST; @@ -132,11 +130,6 @@ private: bool onIsEqual(const GrFragmentProcessor&) const override { return true; } - void onComputeInvariantOutput(GrInvariantOutput* inout) const override { - inout->setToOther(kRGBA_GrColorComponentFlags, GrColor_WHITE); - this->childProcessor(0).computeInvariantOutput(inout); - } - typedef GrFragmentProcessor INHERITED; }; diff --git a/tests/GpuColorFilterTest.cpp b/tests/GpuColorFilterTest.cpp deleted file mode 100644 index 5d45141..0000000 --- a/tests/GpuColorFilterTest.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2013 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "SkColorFilter.h" -#include "Test.h" - -#if SK_SUPPORT_GPU - -#include "GrContext.h" -#include "GrFragmentProcessor.h" -#include "GrInvariantOutput.h" -#include "SkGr.h" - -static GrColor filterColor(const GrColor& color, uint32_t flags) { - uint32_t mask = 0; - if (flags & kR_GrColorComponentFlag) { - mask = 0xFF << GrColor_SHIFT_R; - } - if (flags & kG_GrColorComponentFlag) { - mask |= 0xFF << GrColor_SHIFT_G; - } - if (flags & kB_GrColorComponentFlag) { - mask |= 0xFF << GrColor_SHIFT_B; - } - if (flags & kA_GrColorComponentFlag) { - mask |= 0xFF << GrColor_SHIFT_A; - } - return color & mask; -} - -DEF_GPUTEST_FOR_ALL_CONTEXTS(GpuColorFilter, reporter, ctxInfo) { - struct GetConstantComponentTestCase { - // "Shape drawn with" - uint32_t inputComponents; // "rgb of", "red of", "alpha of", ... - GrColor inputColor; // "[color]" - - SkColor filterColor; // "with filter color [color]" - SkBlendMode filterMode; // "in mode [mode]" - - // "produces" - uint32_t outputComponents; // "rgb of", "red of", "alpha of", ... - GrColor outputColor; // "[color]" - }; - - // Shorthands. - enum { - kR = kR_GrColorComponentFlag, - kG = kG_GrColorComponentFlag, - kB = kB_GrColorComponentFlag, - kA = kA_GrColorComponentFlag, - kRGB = kRGB_GrColorComponentFlags, - kRGBA = kRGBA_GrColorComponentFlags - }; - - // Note: below, SkColors are non-premultiplied, where as GrColors are premultiplied. - - const SkColor c1 = SkColorSetARGB(200, 200, 200, 200); - const SkColor c2 = SkColorSetARGB(60, 60, 60, 60); - const GrColor gr_c1 = SkColorToPremulGrColor(c1); - const GrColor gr_c2 = SkColorToPremulGrColor(c2); - - const GrColor gr_black = GrColorPackA4(0); - const GrColor gr_white = GrColorPackA4(255); - const GrColor gr_whiteTrans = GrColorPackA4(128); - - GetConstantComponentTestCase filterTests[] = { - // A color filtered with Clear produces black. - { kRGBA, gr_white, SK_ColorBLACK, SkBlendMode::kClear, kRGBA, gr_black }, - { kRGBA, gr_c1, SK_ColorWHITE, SkBlendMode::kClear, kRGBA, gr_black }, - { kR, gr_white, c1, SkBlendMode::kClear, kRGBA, gr_black }, - - // A color filtered with a color in mode Src, produces the filter color. - { kRGBA, gr_c2, c1, SkBlendMode::kSrc, kRGBA, gr_c1 }, - { kA, gr_c1, c1, SkBlendMode::kSrc, kRGBA, gr_c1 }, - - // A color filtered with SrcOver produces a color. - { kRGBA, gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkBlendMode::kSrcOver, kRGBA, GrColorPackRGBA(164, 164, 164, 192)}, - // An unknown color with known alpha filtered with SrcOver produces an unknown color with known alpha. - { kA , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkBlendMode::kSrcOver, kA , GrColorPackRGBA(0, 0, 0, 192)}, - // A color with unknown alpha filtered with SrcOver produces a color with unknown alpha. - { kRGB , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkBlendMode::kSrcOver, kRGB, GrColorPackRGBA(164, 164, 164, 0)}, - - // A color filtered with DstOver produces a color. - { kRGBA, gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkBlendMode::kDstOver, kRGBA, GrColorPackRGBA(178, 178, 178, 192)}, - // An unknown color with known alpha filtered with DstOver produces an unknown color with known alpha. - { kA , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkBlendMode::kDstOver, kA , GrColorPackRGBA(0, 0, 0, 192)}, - // A color with unknown alpha filtered with DstOver produces an unknown color. - { kRGB , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkBlendMode::kDstOver, 0 , gr_black}, - - // An unknown color with known alpha and red component filtered with Multiply produces an unknown color with known red and alpha. - { kR|kA , gr_whiteTrans, SkColorSetARGB(128, 200, 200, 200), SkBlendMode::kModulate, kR|kA, GrColorPackRGBA(50, 0, 0, 64) } - }; - - GrPaint paint; - for (size_t i = 0; i < SK_ARRAY_COUNT(filterTests); ++i) { - const GetConstantComponentTestCase& test = filterTests[i]; - auto cf(SkColorFilter::MakeModeFilter(test.filterColor, test.filterMode)); - // TODO: Test other color spaces - sk_sp fp(cf->asFragmentProcessor(ctxInfo.grContext(), nullptr)); - REPORTER_ASSERT(reporter, fp); - GrInvariantOutput inout(test.inputColor, - static_cast(test.inputComponents)); - fp->computeInvariantOutput(&inout); - REPORTER_ASSERT(reporter, filterColor(inout.color(), inout.validFlags()) == - test.outputColor); - REPORTER_ASSERT(reporter, test.outputComponents == inout.validFlags()); - } -} - -#endif diff --git a/tests/ImageStorageTest.cpp b/tests/ImageStorageTest.cpp index aa34831..dc7db51 100644 --- a/tests/ImageStorageTest.cpp +++ b/tests/ImageStorageTest.cpp @@ -10,7 +10,6 @@ #if SK_SUPPORT_GPU #include "GrFragmentProcessor.h" -#include "GrInvariantOutput.h" #include "GrRenderTargetContext.h" #include "GrTexture.h" #include "glsl/GrGLSLFragmentProcessor.h" @@ -36,10 +35,6 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ImageStorageLoad, reporter, ctxInfo) { void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override {} - void onComputeInvariantOutput(GrInvariantOutput* inout) const override { - inout->setToUnknown(); - } - bool onIsEqual(const GrFragmentProcessor& that) const override { return true; } GrGLSLFragmentProcessor* onCreateGLSLInstance() const override { diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp index 678fbaa..a69371d 100644 --- a/tests/ProcessorTest.cpp +++ b/tests/ProcessorTest.cpp @@ -64,11 +64,6 @@ public: b->add32(sk_atomic_inc(&gKey)); } - void onComputeInvariantOutput(GrInvariantOutput* inout) const override { - // We don't care about optimizing these processors. - inout->setToUnknown(); - } - private: TestFP(const SkTArray>& textures, const SkTArray>& buffers, const SkTArray& images)