diff options
author | Brian Salomon <bsalomon@google.com> | 2017-07-28 07:34:05 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-07-28 11:54:47 +0000 |
commit | 3f6f965a5a65415c65fe9e64eb41896c66da771d (patch) | |
tree | 1de139167492fd077527517356bbf1f3298a9800 /src/gpu/effects | |
parent | 71603cca8ec779bb3ad5ad18a3dc69e97910fb7c (diff) |
Implement clone for 6 additional GrFragmentProcessor subclasses.
GrMagnifierEffect
GrMorphologyEffect
GrBicubicEffect
GrGaussianConvolutionFragmentProcessor
GrMatrixConvolutionEffect
GrTextureDomainEffect
Bug: skia:
Change-Id: I69721b9b95346b365723e5ee21dff2dee8884466
Reviewed-on: https://skia-review.googlesource.com/27900
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/effects')
-rw-r--r-- | src/gpu/effects/GrBicubicEffect.cpp | 10 | ||||
-rw-r--r-- | src/gpu/effects/GrBicubicEffect.h | 6 | ||||
-rw-r--r-- | src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp | 15 | ||||
-rw-r--r-- | src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h | 8 | ||||
-rw-r--r-- | src/gpu/effects/GrMatrixConvolutionEffect.cpp | 21 | ||||
-rw-r--r-- | src/gpu/effects/GrMatrixConvolutionEffect.h | 4 | ||||
-rw-r--r-- | src/gpu/effects/GrTextureDomain.cpp | 11 | ||||
-rw-r--r-- | src/gpu/effects/GrTextureDomain.h | 6 |
8 files changed, 75 insertions, 6 deletions
diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp index dc608c5c9f..4095f93e7a 100644 --- a/src/gpu/effects/GrBicubicEffect.cpp +++ b/src/gpu/effects/GrBicubicEffect.cpp @@ -160,7 +160,15 @@ GrBicubicEffect::GrBicubicEffect(sk_sp<GrTextureProxy> proxy, this->addTextureSampler(&fTextureSampler); } -GrBicubicEffect::~GrBicubicEffect() { +GrBicubicEffect::GrBicubicEffect(const GrBicubicEffect& that) + : INHERITED(that.optimizationFlags()) + , fCoordTransform(that.fCoordTransform) + , fDomain(that.fDomain) + , fTextureSampler(that.fTextureSampler) + , fColorSpaceXform(that.fColorSpaceXform) { + this->initClassID<GrBicubicEffect>(); + this->addCoordTransform(&fCoordTransform); + this->addTextureSampler(&fTextureSampler); } void GrBicubicEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps, diff --git a/src/gpu/effects/GrBicubicEffect.h b/src/gpu/effects/GrBicubicEffect.h index 0d4c7c5dd9..65e2c3dbba 100644 --- a/src/gpu/effects/GrBicubicEffect.h +++ b/src/gpu/effects/GrBicubicEffect.h @@ -19,10 +19,13 @@ public: kFilterTexelPad = 2, // Given a src rect in texels to be filtered, this number of // surrounding texels are needed by the kernel in x and y. }; - ~GrBicubicEffect() override; const char* name() const override { return "Bicubic"; } + sk_sp<GrFragmentProcessor> clone() const override { + return sk_sp<GrFragmentProcessor>(new GrBicubicEffect(*this)); + } + const GrTextureDomain& domain() const { return fDomain; } const GrColorSpaceXform* colorSpaceXform() const { return fColorSpaceXform.get(); } @@ -66,6 +69,7 @@ private: const SkMatrix &matrix, const SkShader::TileMode tileModes[2]); GrBicubicEffect(sk_sp<GrTextureProxy>, sk_sp<GrColorSpaceXform>, const SkMatrix &matrix, const SkRect& domain); + explicit GrBicubicEffect(const GrBicubicEffect&); GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; diff --git a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp index 6d51cf9ed1..ebe86dd8f7 100644 --- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp +++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp @@ -217,7 +217,20 @@ GrGaussianConvolutionFragmentProcessor::GrGaussianConvolutionFragmentProcessor( memcpy(fBounds, bounds, sizeof(fBounds)); } -GrGaussianConvolutionFragmentProcessor::~GrGaussianConvolutionFragmentProcessor() {} +GrGaussianConvolutionFragmentProcessor::GrGaussianConvolutionFragmentProcessor( + const GrGaussianConvolutionFragmentProcessor& that) + : INHERITED(that.optimizationFlags()) + , fCoordTransform(that.fCoordTransform) + , fTextureSampler(that.fTextureSampler) + , fRadius(that.fRadius) + , fDirection(that.fDirection) + , fMode(that.fMode) { + this->initClassID<GrGaussianConvolutionFragmentProcessor>(); + this->addCoordTransform(&fCoordTransform); + this->addTextureSampler(&fTextureSampler); + memcpy(fKernel, that.fKernel, that.width() * sizeof(float)); + memcpy(fBounds, that.fBounds, sizeof(fBounds)); +} void GrGaussianConvolutionFragmentProcessor::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const { diff --git a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h index bdc4384a2c..74e9a94c2d 100644 --- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h +++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h @@ -32,8 +32,6 @@ public: std::move(proxy), dir, halfWidth, gaussianSigma, mode, bounds)); } - ~GrGaussianConvolutionFragmentProcessor() override; - const float* kernel() const { return fKernel; } const int* bounds() const { return fBounds; } @@ -46,6 +44,10 @@ public: const char* name() const override { return "GaussianConvolution"; } + sk_sp<GrFragmentProcessor> clone() const override { + return sk_sp<GrFragmentProcessor>(new GrGaussianConvolutionFragmentProcessor(*this)); + } + // This was decided based on the min allowed value for the max texture // samples per fragment program run in DX9SM2 (32). A sigma param of 4.0 // on a blur filter gives a kernel width of 25 while a sigma of 5.0 @@ -61,6 +63,8 @@ private: int halfWidth, float gaussianSigma, GrTextureDomain::Mode mode, int bounds[2]); + explicit GrGaussianConvolutionFragmentProcessor(const GrGaussianConvolutionFragmentProcessor&); + GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override; diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp index cb453fc941..46dc2d8cb9 100644 --- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp +++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp @@ -178,6 +178,26 @@ GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(sk_sp<GrTextureProxy> proxy fKernelOffset[1] = static_cast<float>(kernelOffset.y()); } +GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(const GrMatrixConvolutionEffect& that) + : INHERITED(kNone_OptimizationFlags) + , fCoordTransform(that.fCoordTransform) + , fDomain(that.fDomain) + , fTextureSampler(that.fTextureSampler) + , fKernelSize(that.fKernelSize) + , fGain(that.fGain) + , fBias(that.fBias) + , fConvolveAlpha(that.fConvolveAlpha) { + this->initClassID<GrMatrixConvolutionEffect>(); + this->addCoordTransform(&fCoordTransform); + this->addTextureSampler(&fTextureSampler); + memcpy(fKernel, that.fKernel, sizeof(float) * fKernelSize.width() * fKernelSize.height()); + memcpy(fKernelOffset, that.fKernelOffset, sizeof(fKernelOffset)); +} + +sk_sp<GrFragmentProcessor> GrMatrixConvolutionEffect::clone() const { + return sk_sp<GrFragmentProcessor>(new GrMatrixConvolutionEffect(*this)); +} + void GrMatrixConvolutionEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const { GrGLMatrixConvolutionEffect::GenKey(*this, caps, b); @@ -227,7 +247,6 @@ static void fill_in_2D_gaussian_kernel(float* kernel, int width, int height, } } - // Static function to create a 2D convolution sk_sp<GrFragmentProcessor> GrMatrixConvolutionEffect::MakeGaussian( sk_sp<GrTextureProxy> proxy, diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.h b/src/gpu/effects/GrMatrixConvolutionEffect.h index a89d640b52..9ece00ee5d 100644 --- a/src/gpu/effects/GrMatrixConvolutionEffect.h +++ b/src/gpu/effects/GrMatrixConvolutionEffect.h @@ -52,6 +52,8 @@ public: const char* name() const override { return "MatrixConvolution"; } + sk_sp<GrFragmentProcessor> clone() const override; + private: GrMatrixConvolutionEffect(sk_sp<GrTextureProxy> proxy, const SkIRect& bounds, @@ -63,6 +65,8 @@ private: GrTextureDomain::Mode tileMode, bool convolveAlpha); + GrMatrixConvolutionEffect(const GrMatrixConvolutionEffect&); + GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override; diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp index e26ea67462..fa560580e4 100644 --- a/src/gpu/effects/GrTextureDomain.cpp +++ b/src/gpu/effects/GrTextureDomain.cpp @@ -242,6 +242,17 @@ GrTextureDomainEffect::GrTextureDomainEffect(sk_sp<GrTextureProxy> proxy, this->addTextureSampler(&fTextureSampler); } +GrTextureDomainEffect::GrTextureDomainEffect(const GrTextureDomainEffect& that) + : INHERITED(that.optimizationFlags()) + , fCoordTransform(that.fCoordTransform) + , fTextureDomain(that.fTextureDomain) + , fTextureSampler(that.fTextureSampler) + , fColorSpaceXform(that.fColorSpaceXform) { + this->initClassID<GrTextureDomainEffect>(); + this->addCoordTransform(&fCoordTransform); + this->addTextureSampler(&fTextureSampler); +} + void GrTextureDomainEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps, GrProcessorKeyBuilder* b) const { b->add32(GrTextureDomain::GLDomain::DomainKey(fTextureDomain)); diff --git a/src/gpu/effects/GrTextureDomain.h b/src/gpu/effects/GrTextureDomain.h index f134d8deb5..96bbc235c3 100644 --- a/src/gpu/effects/GrTextureDomain.h +++ b/src/gpu/effects/GrTextureDomain.h @@ -162,6 +162,10 @@ public: const char* name() const override { return "TextureDomain"; } + sk_sp<GrFragmentProcessor> clone() const override { + return sk_sp<GrFragmentProcessor>(new GrTextureDomainEffect(*this)); + } + SkString dumpInfo() const override { SkString str; str.appendf("Domain: [L: %.2f, T: %.2f, R: %.2f, B: %.2f]", @@ -184,6 +188,8 @@ private: GrTextureDomain::Mode, GrSamplerParams::FilterMode); + explicit GrTextureDomainEffect(const GrTextureDomainEffect&); + static OptimizationFlags OptFlags(GrPixelConfig config, GrTextureDomain::Mode mode); GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; |