diff options
Diffstat (limited to 'src/gpu/effects')
-rw-r--r-- | src/gpu/effects/Gr1DKernelEffect.h | 28 | ||||
-rw-r--r-- | src/gpu/effects/GrBicubicEffect.cpp | 29 | ||||
-rw-r--r-- | src/gpu/effects/GrBicubicEffect.h | 10 | ||||
-rw-r--r-- | src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp | 6 | ||||
-rw-r--r-- | src/gpu/effects/GrMatrixConvolutionEffect.cpp | 20 | ||||
-rw-r--r-- | src/gpu/effects/GrMatrixConvolutionEffect.h | 23 | ||||
-rw-r--r-- | src/gpu/effects/GrSingleTextureEffect.cpp | 47 | ||||
-rw-r--r-- | src/gpu/effects/GrSingleTextureEffect.h | 66 | ||||
-rw-r--r-- | src/gpu/effects/GrTextureDomain.cpp | 10 | ||||
-rw-r--r-- | src/gpu/effects/GrTextureDomain.h | 14 |
10 files changed, 84 insertions, 169 deletions
diff --git a/src/gpu/effects/Gr1DKernelEffect.h b/src/gpu/effects/Gr1DKernelEffect.h index fbdfed6d4f..8eac5cd7ad 100644 --- a/src/gpu/effects/Gr1DKernelEffect.h +++ b/src/gpu/effects/Gr1DKernelEffect.h @@ -8,7 +8,8 @@ #ifndef Gr1DKernelEffect_DEFINED #define Gr1DKernelEffect_DEFINED -#include "GrSingleTextureEffect.h" +#include "GrCoordTransform.h" +#include "GrFragmentProcessor.h" #include "SkMatrix.h" /** @@ -20,8 +21,7 @@ * two times the radius. */ -class Gr1DKernelEffect : public GrSingleTextureEffect { - +class Gr1DKernelEffect : public GrFragmentProcessor { public: enum Direction { kX_Direction, @@ -44,18 +44,24 @@ public: } protected: - Gr1DKernelEffect(OptimizationFlags optFlags, - sk_sp<GrTextureProxy> proxy, Direction direction, int radius) - : INHERITED(optFlags, std::move(proxy), nullptr, SkMatrix::I()) - , fDirection(direction) - , fRadius(radius) { + Gr1DKernelEffect(OptimizationFlags optFlags, sk_sp<GrTextureProxy> proxy, Direction direction, + int radius) + : INHERITED(optFlags) + , fCoordTransform(proxy.get()) + , fTextureSampler(std::move(proxy)) + , fDirection(direction) + , fRadius(radius) { + this->addCoordTransform(&fCoordTransform); + this->addTextureSampler(&fTextureSampler); } private: - Direction fDirection; - int fRadius; + GrCoordTransform fCoordTransform; + TextureSampler fTextureSampler; + Direction fDirection; + int fRadius; - typedef GrSingleTextureEffect INHERITED; + typedef GrFragmentProcessor INHERITED; }; #endif diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp index f7441bc043..9472f5192e 100644 --- a/src/gpu/effects/GrBicubicEffect.cpp +++ b/src/gpu/effects/GrBicubicEffect.cpp @@ -135,26 +135,31 @@ void GrGLBicubicEffect::onSetData(const GrGLSLProgramDataManager& pdman, GrBicubicEffect::GrBicubicEffect(sk_sp<GrTextureProxy> proxy, sk_sp<GrColorSpaceXform> colorSpaceXform, - const SkMatrix &matrix, + const SkMatrix& matrix, const SkShader::TileMode tileModes[2]) - : INHERITED{ModulationFlags(proxy->config()), - GR_PROXY_MOVE(proxy), - std::move(colorSpaceXform), - matrix, - GrSamplerParams(tileModes, GrSamplerParams::kNone_FilterMode)} - , fDomain(GrTextureDomain::IgnoredDomain()) { + : INHERITED{ModulateByConfigOptimizationFlags(proxy->config())} + , fCoordTransform(matrix, proxy.get()) + , fDomain(GrTextureDomain::IgnoredDomain()) + , fTextureSampler(std::move(proxy), + GrSamplerParams(tileModes, GrSamplerParams::kNone_FilterMode)) + , fColorSpaceXform(std::move(colorSpaceXform)) { this->initClassID<GrBicubicEffect>(); + this->addCoordTransform(&fCoordTransform); + this->addTextureSampler(&fTextureSampler); } GrBicubicEffect::GrBicubicEffect(sk_sp<GrTextureProxy> proxy, sk_sp<GrColorSpaceXform> colorSpaceXform, - const SkMatrix &matrix, + const SkMatrix& matrix, const SkRect& domain) - : INHERITED(ModulationFlags(proxy->config()), proxy, - std::move(colorSpaceXform), matrix, - GrSamplerParams(SkShader::kClamp_TileMode, GrSamplerParams::kNone_FilterMode)) - , fDomain(proxy.get(), domain, GrTextureDomain::kClamp_Mode) { + : INHERITED(ModulateByConfigOptimizationFlags(proxy->config())) + , fCoordTransform(matrix, proxy.get()) + , fDomain(proxy.get(), domain, GrTextureDomain::kClamp_Mode) + , fTextureSampler(std::move(proxy)) + , fColorSpaceXform(std::move(colorSpaceXform)) { this->initClassID<GrBicubicEffect>(); + this->addCoordTransform(&fCoordTransform); + this->addTextureSampler(&fTextureSampler); } GrBicubicEffect::~GrBicubicEffect() { diff --git a/src/gpu/effects/GrBicubicEffect.h b/src/gpu/effects/GrBicubicEffect.h index e96d290629..0d4c7c5dd9 100644 --- a/src/gpu/effects/GrBicubicEffect.h +++ b/src/gpu/effects/GrBicubicEffect.h @@ -8,13 +8,12 @@ #ifndef GrBicubicTextureEffect_DEFINED #define GrBicubicTextureEffect_DEFINED -#include "GrSingleTextureEffect.h" #include "GrTextureDomain.h" #include "glsl/GrGLSLFragmentProcessor.h" class GrInvariantOutput; -class GrBicubicEffect : public GrSingleTextureEffect { +class GrBicubicEffect : public GrFragmentProcessor { public: enum { kFilterTexelPad = 2, // Given a src rect in texels to be filtered, this number of @@ -26,6 +25,8 @@ public: const GrTextureDomain& domain() const { return fDomain; } + const GrColorSpaceXform* colorSpaceXform() const { return fColorSpaceXform.get(); } + /** * Create a Mitchell filter effect with specified texture matrix and x/y tile modes. */ @@ -72,11 +73,14 @@ private: bool onIsEqual(const GrFragmentProcessor&) const override; + GrCoordTransform fCoordTransform; GrTextureDomain fDomain; + TextureSampler fTextureSampler; + sk_sp<GrColorSpaceXform> fColorSpaceXform; GR_DECLARE_FRAGMENT_PROCESSOR_TEST - typedef GrSingleTextureEffect INHERITED; + typedef GrFragmentProcessor INHERITED; }; #endif diff --git a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp index 1ab9b78cfc..8e8c3001b0 100644 --- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp +++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp @@ -201,10 +201,8 @@ GrGaussianConvolutionFragmentProcessor::GrGaussianConvolutionFragmentProcessor( float gaussianSigma, GrTextureDomain::Mode mode, int bounds[2]) - : INHERITED{ModulationFlags(proxy->config()), - GR_PROXY_MOVE(proxy), - direction, - radius} + : INHERITED{ModulateByConfigOptimizationFlags(proxy->config()), GR_PROXY_MOVE(proxy), + direction, radius} , fMode(mode) { this->initClassID<GrGaussianConvolutionFragmentProcessor>(); SkASSERT(radius <= kMaxKernelRadius); diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp index abfe5b3774..cb453fc941 100644 --- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp +++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp @@ -158,15 +158,19 @@ GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(sk_sp<GrTextureProxy> proxy const SkIPoint& kernelOffset, GrTextureDomain::Mode tileMode, bool convolveAlpha) - // To advertise either the modulation or opaqueness optimizations we'd have to examine the - // parameters. - : INHERITED(kNone_OptimizationFlags, proxy, nullptr, SkMatrix::I()) - , fKernelSize(kernelSize) - , fGain(SkScalarToFloat(gain)) - , fBias(SkScalarToFloat(bias) / 255.0f) - , fConvolveAlpha(convolveAlpha) - , fDomain(proxy.get(), GrTextureDomain::MakeTexelDomainForMode(bounds, tileMode), tileMode) { + // To advertise either the modulation or opaqueness optimizations we'd have to examine the + // parameters. + : INHERITED(kNone_OptimizationFlags) + , fCoordTransform(proxy.get()) + , fDomain(proxy.get(), GrTextureDomain::MakeTexelDomainForMode(bounds, tileMode), tileMode) + , fTextureSampler(std::move(proxy)) + , fKernelSize(kernelSize) + , fGain(SkScalarToFloat(gain)) + , fBias(SkScalarToFloat(bias) / 255.0f) + , fConvolveAlpha(convolveAlpha) { this->initClassID<GrMatrixConvolutionEffect>(); + this->addCoordTransform(&fCoordTransform); + this->addTextureSampler(&fTextureSampler); for (int i = 0; i < kernelSize.width() * kernelSize.height(); i++) { fKernel[i] = SkScalarToFloat(kernel[i]); } diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.h b/src/gpu/effects/GrMatrixConvolutionEffect.h index 57e0fd9a72..a89d640b52 100644 --- a/src/gpu/effects/GrMatrixConvolutionEffect.h +++ b/src/gpu/effects/GrMatrixConvolutionEffect.h @@ -8,14 +8,13 @@ #ifndef GrMatrixConvolutionEffect_DEFINED #define GrMatrixConvolutionEffect_DEFINED -#include "GrSingleTextureEffect.h" #include "GrTextureDomain.h" // A little bit less than the minimum # uniforms required by DX9SM2 (32). // Allows for a 5x5 kernel (or 25x1, for that matter). #define MAX_KERNEL_SIZE 25 -class GrMatrixConvolutionEffect : public GrSingleTextureEffect { +class GrMatrixConvolutionEffect : public GrFragmentProcessor { public: static sk_sp<GrFragmentProcessor> Make(sk_sp<GrTextureProxy> proxy, const SkIRect& bounds, @@ -70,18 +69,20 @@ private: bool onIsEqual(const GrFragmentProcessor&) const override; - SkIRect fBounds; - SkISize fKernelSize; - float fKernel[MAX_KERNEL_SIZE]; - float fGain; - float fBias; - float fKernelOffset[2]; - bool fConvolveAlpha; - GrTextureDomain fDomain; + GrCoordTransform fCoordTransform; + GrTextureDomain fDomain; + TextureSampler fTextureSampler; + SkIRect fBounds; + SkISize fKernelSize; + float fKernel[MAX_KERNEL_SIZE]; + float fGain; + float fBias; + float fKernelOffset[2]; + bool fConvolveAlpha; GR_DECLARE_FRAGMENT_PROCESSOR_TEST - typedef GrSingleTextureEffect INHERITED; + typedef GrFragmentProcessor INHERITED; }; #endif diff --git a/src/gpu/effects/GrSingleTextureEffect.cpp b/src/gpu/effects/GrSingleTextureEffect.cpp deleted file mode 100644 index 9dbf32d9c9..0000000000 --- a/src/gpu/effects/GrSingleTextureEffect.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2012 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "effects/GrSingleTextureEffect.h" - -#include "GrTextureProxy.h" - -GrSingleTextureEffect::GrSingleTextureEffect(OptimizationFlags optFlags, - sk_sp<GrTextureProxy> proxy, - sk_sp<GrColorSpaceXform> colorSpaceXform, - const SkMatrix& m) - : INHERITED(optFlags) - , fCoordTransform(m, proxy.get()) - , fTextureSampler(std::move(proxy)) - , fColorSpaceXform(std::move(colorSpaceXform)) { - this->addCoordTransform(&fCoordTransform); - this->addTextureSampler(&fTextureSampler); -} - -GrSingleTextureEffect::GrSingleTextureEffect(OptimizationFlags optFlags, - sk_sp<GrTextureProxy> proxy, - sk_sp<GrColorSpaceXform> colorSpaceXform, - const SkMatrix& m, - GrSamplerParams::FilterMode filterMode) - : INHERITED(optFlags) - , fCoordTransform(m, proxy.get()) - , fTextureSampler(std::move(proxy), filterMode) - , fColorSpaceXform(std::move(colorSpaceXform)) { - this->addCoordTransform(&fCoordTransform); - this->addTextureSampler(&fTextureSampler); -} - -GrSingleTextureEffect::GrSingleTextureEffect(OptimizationFlags optFlags, - sk_sp<GrTextureProxy> proxy, - sk_sp<GrColorSpaceXform> colorSpaceXform, - const SkMatrix& m, const GrSamplerParams& params) - : INHERITED(optFlags) - , fCoordTransform(m, proxy.get()) - , fTextureSampler(std::move(proxy), params) - , fColorSpaceXform(std::move(colorSpaceXform)) { - this->addCoordTransform(&fCoordTransform); - this->addTextureSampler(&fTextureSampler); -} diff --git a/src/gpu/effects/GrSingleTextureEffect.h b/src/gpu/effects/GrSingleTextureEffect.h deleted file mode 100644 index eab29c61e8..0000000000 --- a/src/gpu/effects/GrSingleTextureEffect.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2012 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef GrSingleTextureEffect_DEFINED -#define GrSingleTextureEffect_DEFINED - -#include "GrFragmentProcessor.h" -#include "GrColorSpaceXform.h" -#include "GrCoordTransform.h" - -class GrTextureProxy; -class SkMatrix; - -/** - * A base class for effects that draw a single texture with a texture matrix. This effect has no - * backend implementations. One must be provided by the subclass. - */ -class GrSingleTextureEffect : public GrFragmentProcessor { -public: - SkString dumpInfo() const override { - SkString str; - str.appendf("Texture: %d", fTextureSampler.proxy()->uniqueID().asUInt()); - return str; - } - - GrColorSpaceXform* colorSpaceXform() const { return fColorSpaceXform.get(); } - -protected: - /** unfiltered, clamp mode */ - GrSingleTextureEffect(OptimizationFlags, sk_sp<GrTextureProxy>, - sk_sp<GrColorSpaceXform>, const SkMatrix&); - /** clamp mode */ - GrSingleTextureEffect(OptimizationFlags, sk_sp<GrTextureProxy>, - sk_sp<GrColorSpaceXform>, const SkMatrix&, - GrSamplerParams::FilterMode filterMode); - GrSingleTextureEffect(OptimizationFlags, sk_sp<GrTextureProxy>, - sk_sp<GrColorSpaceXform>, const SkMatrix&, const GrSamplerParams&); - - /** - * Can be used as a helper to decide which fragment processor OptimizationFlags should be set. - * This assumes that the subclass output color will be a modulation of the input color with a - * value read from the texture and that the texture contains premultiplied color or alpha values - * that are in range. - */ - static OptimizationFlags ModulationFlags(GrPixelConfig config) { - if (GrPixelConfigIsOpaque(config)) { - return kCompatibleWithCoverageAsAlpha_OptimizationFlag | - kPreservesOpaqueInput_OptimizationFlag; - } else { - return kCompatibleWithCoverageAsAlpha_OptimizationFlag; - } - } - -private: - GrCoordTransform fCoordTransform; - TextureSampler fTextureSampler; - sk_sp<GrColorSpaceXform> fColorSpaceXform; - - typedef GrFragmentProcessor INHERITED; -}; - -#endif diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp index 17ad223c2c..e26ea67462 100644 --- a/src/gpu/effects/GrTextureDomain.cpp +++ b/src/gpu/effects/GrTextureDomain.cpp @@ -230,12 +230,16 @@ GrTextureDomainEffect::GrTextureDomainEffect(sk_sp<GrTextureProxy> proxy, const SkRect& domain, GrTextureDomain::Mode mode, GrSamplerParams::FilterMode filterMode) - : GrSingleTextureEffect(OptFlags(proxy->config(), mode), proxy, - std::move(colorSpaceXform), matrix, filterMode) - , fTextureDomain(proxy.get(), domain, mode) { + : INHERITED(OptFlags(proxy->config(), mode)) + , fCoordTransform(matrix, proxy.get()) + , fTextureDomain(proxy.get(), domain, mode) + , fTextureSampler(std::move(proxy), filterMode) + , fColorSpaceXform(std::move(colorSpaceXform)) { SkASSERT(mode != GrTextureDomain::kRepeat_Mode || filterMode == GrSamplerParams::kNone_FilterMode); this->initClassID<GrTextureDomainEffect>(); + this->addCoordTransform(&fCoordTransform); + this->addTextureSampler(&fTextureSampler); } void GrTextureDomainEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps, diff --git a/src/gpu/effects/GrTextureDomain.h b/src/gpu/effects/GrTextureDomain.h index c74a9919c4..f134d8deb5 100644 --- a/src/gpu/effects/GrTextureDomain.h +++ b/src/gpu/effects/GrTextureDomain.h @@ -8,7 +8,9 @@ #ifndef GrTextureDomainEffect_DEFINED #define GrTextureDomainEffect_DEFINED -#include "GrSingleTextureEffect.h" +#include "GrCoordTransform.h" +#include "GrFragmentProcessor.h" +#include "GrColorSpaceXform.h" #include "glsl/GrGLSLFragmentProcessor.h" #include "glsl/GrGLSLProgramDataManager.h" @@ -149,8 +151,7 @@ protected: /** * A basic texture effect that uses GrTextureDomain. */ -class GrTextureDomainEffect : public GrSingleTextureEffect { - +class GrTextureDomainEffect : public GrFragmentProcessor { public: static sk_sp<GrFragmentProcessor> Make(sk_sp<GrTextureProxy>, sk_sp<GrColorSpaceXform>, @@ -171,7 +172,10 @@ public: } private: + GrCoordTransform fCoordTransform; GrTextureDomain fTextureDomain; + TextureSampler fTextureSampler; + sk_sp<GrColorSpaceXform> fColorSpaceXform; GrTextureDomainEffect(sk_sp<GrTextureProxy>, sk_sp<GrColorSpaceXform>, @@ -188,9 +192,11 @@ private: bool onIsEqual(const GrFragmentProcessor&) const override; + const GrColorSpaceXform* colorSpaceXform() const { return fColorSpaceXform.get(); } + GR_DECLARE_FRAGMENT_PROCESSOR_TEST - typedef GrSingleTextureEffect INHERITED; + typedef GrFragmentProcessor INHERITED; }; class GrDeviceSpaceTextureDecalFragmentProcessor : public GrFragmentProcessor { |