diff options
Diffstat (limited to 'src/gpu/effects')
26 files changed, 79 insertions, 42 deletions
diff --git a/src/gpu/effects/GrAlphaThresholdFragmentProcessor.cpp b/src/gpu/effects/GrAlphaThresholdFragmentProcessor.cpp index 176e812821..6e12bd4fde 100644 --- a/src/gpu/effects/GrAlphaThresholdFragmentProcessor.cpp +++ b/src/gpu/effects/GrAlphaThresholdFragmentProcessor.cpp @@ -93,12 +93,16 @@ GrAlphaThresholdFragmentProcessor::GrAlphaThresholdFragmentProcessor( , fInnerThreshold(src.fInnerThreshold) , fOuterThreshold(src.fOuterThreshold) , fMaskCoordTransform(src.fMaskCoordTransform) { - this->addTextureSampler(&fMask); + this->setTextureSamplerCnt(1); this->addCoordTransform(&fMaskCoordTransform); } std::unique_ptr<GrFragmentProcessor> GrAlphaThresholdFragmentProcessor::clone() const { return std::unique_ptr<GrFragmentProcessor>(new GrAlphaThresholdFragmentProcessor(*this)); } +const GrFragmentProcessor::TextureSampler& GrAlphaThresholdFragmentProcessor::onTextureSampler( + int index) const { + return IthTextureSampler(index, fMask); +} GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrAlphaThresholdFragmentProcessor); #if GR_TEST_UTILS std::unique_ptr<GrFragmentProcessor> GrAlphaThresholdFragmentProcessor::TestCreate( diff --git a/src/gpu/effects/GrAlphaThresholdFragmentProcessor.h b/src/gpu/effects/GrAlphaThresholdFragmentProcessor.h index 1c0cd2eb91..74811d3e26 100644 --- a/src/gpu/effects/GrAlphaThresholdFragmentProcessor.h +++ b/src/gpu/effects/GrAlphaThresholdFragmentProcessor.h @@ -40,12 +40,13 @@ private: , fMaskCoordTransform( SkMatrix::MakeTrans(SkIntToScalar(-bounds.x()), SkIntToScalar(-bounds.y())), fMask.proxy()) { - this->addTextureSampler(&fMask); + this->setTextureSamplerCnt(1); this->addCoordTransform(&fMaskCoordTransform); } GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override; bool onIsEqual(const GrFragmentProcessor&) const override; + const TextureSampler& onTextureSampler(int) const override; GR_DECLARE_FRAGMENT_PROCESSOR_TEST TextureSampler fMask; float fInnerThreshold; diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp index 803f2907a6..6607efc7b5 100644 --- a/src/gpu/effects/GrBicubicEffect.cpp +++ b/src/gpu/effects/GrBicubicEffect.cpp @@ -125,7 +125,7 @@ GrBicubicEffect::GrBicubicEffect(sk_sp<GrTextureProxy> proxy, , fTextureSampler(std::move(proxy), GrSamplerState(wrapModes, GrSamplerState::Filter::kNearest)) { this->addCoordTransform(&fCoordTransform); - this->addTextureSampler(&fTextureSampler); + this->setTextureSamplerCnt(1); } GrBicubicEffect::GrBicubicEffect(sk_sp<GrTextureProxy> proxy, @@ -136,7 +136,7 @@ GrBicubicEffect::GrBicubicEffect(sk_sp<GrTextureProxy> proxy, , fDomain(proxy.get(), domain, GrTextureDomain::kClamp_Mode) , fTextureSampler(std::move(proxy)) { this->addCoordTransform(&fCoordTransform); - this->addTextureSampler(&fTextureSampler); + this->setTextureSamplerCnt(1); } GrBicubicEffect::GrBicubicEffect(const GrBicubicEffect& that) @@ -145,7 +145,7 @@ GrBicubicEffect::GrBicubicEffect(const GrBicubicEffect& that) , fDomain(that.fDomain) , fTextureSampler(that.fTextureSampler) { this->addCoordTransform(&fCoordTransform); - this->addTextureSampler(&fTextureSampler); + this->setTextureSamplerCnt(1); } void GrBicubicEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps, diff --git a/src/gpu/effects/GrBicubicEffect.h b/src/gpu/effects/GrBicubicEffect.h index 1d70103524..45c416f3f1 100644 --- a/src/gpu/effects/GrBicubicEffect.h +++ b/src/gpu/effects/GrBicubicEffect.h @@ -70,6 +70,8 @@ private: bool onIsEqual(const GrFragmentProcessor&) const override; + const TextureSampler& onTextureSampler(int) const override { return fTextureSampler; } + GrCoordTransform fCoordTransform; GrTextureDomain fDomain; TextureSampler fTextureSampler; diff --git a/src/gpu/effects/GrBitmapTextGeoProc.cpp b/src/gpu/effects/GrBitmapTextGeoProc.cpp index 2594f40ee5..32da45c10f 100644 --- a/src/gpu/effects/GrBitmapTextGeoProc.cpp +++ b/src/gpu/effects/GrBitmapTextGeoProc.cpp @@ -151,10 +151,9 @@ GrBitmapTextGeoProc::GrBitmapTextGeoProc(GrColor color, for (int i = 0; i < numActiveProxies; ++i) { SkASSERT(proxies[i]); - fTextureSamplers[i].reset(std::move(proxies[i]), params); - this->addTextureSampler(&fTextureSamplers[i]); } + this->setTextureSamplerCnt(numActiveProxies); } const GrPrimitiveProcessor::Attribute& GrBitmapTextGeoProc::onVertexAttribute(int i) const { @@ -171,9 +170,9 @@ void GrBitmapTextGeoProc::addNewProxies(const sk_sp<GrTextureProxy>* proxies, if (!fTextureSamplers[i].isInitialized()) { fTextureSamplers[i].reset(std::move(proxies[i]), params); - this->addTextureSampler(&fTextureSamplers[i]); } } + this->setTextureSamplerCnt(numActiveProxies); } void GrBitmapTextGeoProc::getGLSLProcessorKey(const GrShaderCaps& caps, diff --git a/src/gpu/effects/GrBitmapTextGeoProc.h b/src/gpu/effects/GrBitmapTextGeoProc.h index 5e444977c2..1bc062003e 100644 --- a/src/gpu/effects/GrBitmapTextGeoProc.h +++ b/src/gpu/effects/GrBitmapTextGeoProc.h @@ -59,6 +59,7 @@ private: const SkMatrix& localMatrix, bool usesW); const Attribute& onVertexAttribute(int i) const override; + const TextureSampler& onTextureSampler(int i) const override { return fTextureSamplers[i]; } GrColor fColor; SkMatrix fLocalMatrix; diff --git a/src/gpu/effects/GrCircleBlurFragmentProcessor.cpp b/src/gpu/effects/GrCircleBlurFragmentProcessor.cpp index efd9ee754a..921d69b803 100644 --- a/src/gpu/effects/GrCircleBlurFragmentProcessor.cpp +++ b/src/gpu/effects/GrCircleBlurFragmentProcessor.cpp @@ -330,11 +330,15 @@ GrCircleBlurFragmentProcessor::GrCircleBlurFragmentProcessor( , fTextureRadius(src.fTextureRadius) , fSolidRadius(src.fSolidRadius) , fBlurProfileSampler(src.fBlurProfileSampler) { - this->addTextureSampler(&fBlurProfileSampler); + this->setTextureSamplerCnt(1); } std::unique_ptr<GrFragmentProcessor> GrCircleBlurFragmentProcessor::clone() const { return std::unique_ptr<GrFragmentProcessor>(new GrCircleBlurFragmentProcessor(*this)); } +const GrFragmentProcessor::TextureSampler& GrCircleBlurFragmentProcessor::onTextureSampler( + int index) const { + return IthTextureSampler(index, fBlurProfileSampler); +} GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrCircleBlurFragmentProcessor); #if GR_TEST_UTILS std::unique_ptr<GrFragmentProcessor> GrCircleBlurFragmentProcessor::TestCreate( diff --git a/src/gpu/effects/GrCircleBlurFragmentProcessor.h b/src/gpu/effects/GrCircleBlurFragmentProcessor.h index 3670a98dbe..373ea42d6b 100644 --- a/src/gpu/effects/GrCircleBlurFragmentProcessor.h +++ b/src/gpu/effects/GrCircleBlurFragmentProcessor.h @@ -34,11 +34,12 @@ private: , fTextureRadius(textureRadius) , fSolidRadius(solidRadius) , fBlurProfileSampler(std::move(blurProfileSampler)) { - this->addTextureSampler(&fBlurProfileSampler); + this->setTextureSamplerCnt(1); } GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override; bool onIsEqual(const GrFragmentProcessor&) const override; + const TextureSampler& onTextureSampler(int) const override; GR_DECLARE_FRAGMENT_PROCESSOR_TEST SkRect fCircleRect; float fTextureRadius; diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.cpp b/src/gpu/effects/GrDistanceFieldGeoProc.cpp index 4d5d50b8db..351e191264 100644 --- a/src/gpu/effects/GrDistanceFieldGeoProc.cpp +++ b/src/gpu/effects/GrDistanceFieldGeoProc.cpp @@ -236,10 +236,9 @@ GrDistanceFieldA8TextGeoProc::GrDistanceFieldA8TextGeoProc(const sk_sp<GrTexture for (int i = 0; i < numProxies; ++i) { SkASSERT(proxies[i]); - fTextureSamplers[i].reset(std::move(proxies[i]), params); - this->addTextureSampler(&fTextureSamplers[i]); } + this->setTextureSamplerCnt(numProxies); } void GrDistanceFieldA8TextGeoProc::addNewProxies(const sk_sp<GrTextureProxy>* proxies, @@ -249,12 +248,11 @@ void GrDistanceFieldA8TextGeoProc::addNewProxies(const sk_sp<GrTextureProxy>* pr for (int i = 0; i < numProxies; ++i) { SkASSERT(proxies[i]); - if (!fTextureSamplers[i].isInitialized()) { fTextureSamplers[i].reset(std::move(proxies[i]), params); - this->addTextureSampler(&fTextureSamplers[i]); } } + this->setTextureSamplerCnt(numProxies); } void GrDistanceFieldA8TextGeoProc::getGLSLProcessorKey(const GrShaderCaps& caps, @@ -519,10 +517,9 @@ GrDistanceFieldPathGeoProc::GrDistanceFieldPathGeoProc(const SkMatrix& matrix, this->setVertexAttributeCnt(3); for (int i = 0; i < numProxies; ++i) { SkASSERT(proxies[i]); - fTextureSamplers[i].reset(std::move(proxies[i]), params); - this->addTextureSampler(&fTextureSamplers[i]); } + this->setTextureSamplerCnt(numProxies); } void GrDistanceFieldPathGeoProc::addNewProxies(const sk_sp<GrTextureProxy>* proxies, @@ -535,9 +532,9 @@ void GrDistanceFieldPathGeoProc::addNewProxies(const sk_sp<GrTextureProxy>* prox if (!fTextureSamplers[i].isInitialized()) { fTextureSamplers[i].reset(std::move(proxies[i]), params); - this->addTextureSampler(&fTextureSamplers[i]); } } + this->setTextureSamplerCnt(numProxies); } void GrDistanceFieldPathGeoProc::getGLSLProcessorKey(const GrShaderCaps& caps, @@ -834,10 +831,9 @@ GrDistanceFieldLCDTextGeoProc::GrDistanceFieldLCDTextGeoProc(const sk_sp<GrTextu for (int i = 0; i < numProxies; ++i) { SkASSERT(proxies[i]); - fTextureSamplers[i].reset(std::move(proxies[i]), params); - this->addTextureSampler(&fTextureSamplers[i]); } + this->setTextureSamplerCnt(numProxies); } void GrDistanceFieldLCDTextGeoProc::addNewProxies(const sk_sp<GrTextureProxy>* proxies, @@ -850,9 +846,9 @@ void GrDistanceFieldLCDTextGeoProc::addNewProxies(const sk_sp<GrTextureProxy>* p if (!fTextureSamplers[i].isInitialized()) { fTextureSamplers[i].reset(std::move(proxies[i]), params); - this->addTextureSampler(&fTextureSamplers[i]); } } + this->setTextureSamplerCnt(numProxies); } void GrDistanceFieldLCDTextGeoProc::getGLSLProcessorKey(const GrShaderCaps& caps, diff --git a/src/gpu/effects/GrDistanceFieldGeoProc.h b/src/gpu/effects/GrDistanceFieldGeoProc.h index 71626fa938..a0fb9d74e5 100644 --- a/src/gpu/effects/GrDistanceFieldGeoProc.h +++ b/src/gpu/effects/GrDistanceFieldGeoProc.h @@ -104,6 +104,8 @@ private: return IthAttribute(i, fInPosition, kInColor, kInTextureCoords); } + const TextureSampler& onTextureSampler(int i) const override { return fTextureSamplers[i]; } + static constexpr int kMaxTextures = 4; TextureSampler fTextureSamplers[kMaxTextures]; @@ -165,6 +167,7 @@ private: const GrSamplerState&, uint32_t flags); const Attribute& onVertexAttribute(int i) const override; + const TextureSampler& onTextureSampler(int i) const override { return fTextureSamplers[i]; } SkMatrix fMatrix; // view matrix if perspective, local matrix otherwise TextureSampler fTextureSamplers[kMaxTextures]; @@ -235,6 +238,7 @@ private: const SkMatrix& localMatrix); const Attribute& onVertexAttribute(int) const override; + const TextureSampler& onTextureSampler(int i) const override { return fTextureSamplers[i]; } static constexpr int kMaxTextures = 4; diff --git a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp index bfd3f86e41..f05bf42c92 100644 --- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp +++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.cpp @@ -223,7 +223,7 @@ GrGaussianConvolutionFragmentProcessor::GrGaussianConvolutionFragmentProcessor( , fDirection(direction) , fMode(mode) { this->addCoordTransform(&fCoordTransform); - this->addTextureSampler(&fTextureSampler); + this->setTextureSamplerCnt(1); SkASSERT(radius <= kMaxKernelRadius); fill_in_1D_gaussian_kernel(fKernel, this->width(), gaussianSigma, this->radius()); @@ -240,7 +240,7 @@ GrGaussianConvolutionFragmentProcessor::GrGaussianConvolutionFragmentProcessor( , fDirection(that.fDirection) , fMode(that.fMode) { this->addCoordTransform(&fCoordTransform); - this->addTextureSampler(&fTextureSampler); + this->setTextureSamplerCnt(1); memcpy(fKernel, that.fKernel, that.width() * sizeof(float)); memcpy(fBounds, that.fBounds, sizeof(fBounds)); } diff --git a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h index 6d68292616..cc34febff4 100644 --- a/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h +++ b/src/gpu/effects/GrGaussianConvolutionFragmentProcessor.h @@ -81,6 +81,8 @@ private: bool onIsEqual(const GrFragmentProcessor&) const override; + const TextureSampler& onTextureSampler(int) const override { return fTextureSampler; } + GR_DECLARE_FRAGMENT_PROCESSOR_TEST GrCoordTransform fCoordTransform; diff --git a/src/gpu/effects/GrMagnifierEffect.cpp b/src/gpu/effects/GrMagnifierEffect.cpp index 752a81bd1b..aadd541ce2 100644 --- a/src/gpu/effects/GrMagnifierEffect.cpp +++ b/src/gpu/effects/GrMagnifierEffect.cpp @@ -161,12 +161,15 @@ GrMagnifierEffect::GrMagnifierEffect(const GrMagnifierEffect& src) , fXInvInset(src.fXInvInset) , fYInvInset(src.fYInvInset) , fSrcCoordTransform(src.fSrcCoordTransform) { - this->addTextureSampler(&fSrc); + this->setTextureSamplerCnt(1); this->addCoordTransform(&fSrcCoordTransform); } std::unique_ptr<GrFragmentProcessor> GrMagnifierEffect::clone() const { return std::unique_ptr<GrFragmentProcessor>(new GrMagnifierEffect(*this)); } +const GrFragmentProcessor::TextureSampler& GrMagnifierEffect::onTextureSampler(int index) const { + return IthTextureSampler(index, fSrc); +} GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrMagnifierEffect); #if GR_TEST_UTILS std::unique_ptr<GrFragmentProcessor> GrMagnifierEffect::TestCreate(GrProcessorTestData* d) { diff --git a/src/gpu/effects/GrMagnifierEffect.h b/src/gpu/effects/GrMagnifierEffect.h index 7888f9c737..582e0efff0 100644 --- a/src/gpu/effects/GrMagnifierEffect.h +++ b/src/gpu/effects/GrMagnifierEffect.h @@ -43,12 +43,13 @@ private: , fXInvInset(xInvInset) , fYInvInset(yInvInset) , fSrcCoordTransform(SkMatrix::I(), fSrc.proxy()) { - this->addTextureSampler(&fSrc); + this->setTextureSamplerCnt(1); this->addCoordTransform(&fSrcCoordTransform); } GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override; bool onIsEqual(const GrFragmentProcessor&) const override; + const TextureSampler& onTextureSampler(int) const override; GR_DECLARE_FRAGMENT_PROCESSOR_TEST TextureSampler fSrc; SkIRect fBounds; diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp index c2c1f7c8ba..ccb32cf968 100644 --- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp +++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp @@ -165,7 +165,7 @@ GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(sk_sp<GrTextureProxy> srcPr , fBias(SkScalarToFloat(bias) / 255.0f) , fConvolveAlpha(convolveAlpha) { this->addCoordTransform(&fCoordTransform); - this->addTextureSampler(&fTextureSampler); + this->setTextureSamplerCnt(1); for (int i = 0; i < kernelSize.width() * kernelSize.height(); i++) { fKernel[i] = SkScalarToFloat(kernel[i]); } @@ -183,7 +183,7 @@ GrMatrixConvolutionEffect::GrMatrixConvolutionEffect(const GrMatrixConvolutionEf , fBias(that.fBias) , fConvolveAlpha(that.fConvolveAlpha) { this->addCoordTransform(&fCoordTransform); - this->addTextureSampler(&fTextureSampler); + this->setTextureSamplerCnt(1); memcpy(fKernel, that.fKernel, sizeof(float) * fKernelSize.width() * fKernelSize.height()); memcpy(fKernelOffset, that.fKernelOffset, sizeof(fKernelOffset)); } diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.h b/src/gpu/effects/GrMatrixConvolutionEffect.h index 844f721864..f20c805c73 100644 --- a/src/gpu/effects/GrMatrixConvolutionEffect.h +++ b/src/gpu/effects/GrMatrixConvolutionEffect.h @@ -75,6 +75,8 @@ private: bool onIsEqual(const GrFragmentProcessor&) const override; + const TextureSampler& onTextureSampler(int i) const override { return fTextureSampler; } + GrCoordTransform fCoordTransform; GrTextureDomain fDomain; TextureSampler fTextureSampler; diff --git a/src/gpu/effects/GrRRectBlurEffect.cpp b/src/gpu/effects/GrRRectBlurEffect.cpp index 9ab844a51d..6101f24cb1 100644 --- a/src/gpu/effects/GrRRectBlurEffect.cpp +++ b/src/gpu/effects/GrRRectBlurEffect.cpp @@ -146,11 +146,14 @@ GrRRectBlurEffect::GrRRectBlurEffect(const GrRRectBlurEffect& src) , fRect(src.fRect) , fCornerRadius(src.fCornerRadius) , fNinePatchSampler(src.fNinePatchSampler) { - this->addTextureSampler(&fNinePatchSampler); + this->setTextureSamplerCnt(1); } std::unique_ptr<GrFragmentProcessor> GrRRectBlurEffect::clone() const { return std::unique_ptr<GrFragmentProcessor>(new GrRRectBlurEffect(*this)); } +const GrFragmentProcessor::TextureSampler& GrRRectBlurEffect::onTextureSampler(int index) const { + return IthTextureSampler(index, fNinePatchSampler); +} GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRRectBlurEffect); #if GR_TEST_UTILS std::unique_ptr<GrFragmentProcessor> GrRRectBlurEffect::TestCreate(GrProcessorTestData* d) { diff --git a/src/gpu/effects/GrRRectBlurEffect.h b/src/gpu/effects/GrRRectBlurEffect.h index 04af1273f7..3e386a62da 100644 --- a/src/gpu/effects/GrRRectBlurEffect.h +++ b/src/gpu/effects/GrRRectBlurEffect.h @@ -115,11 +115,12 @@ private: , fRect(rect) , fCornerRadius(cornerRadius) , fNinePatchSampler(std::move(ninePatchSampler)) { - this->addTextureSampler(&fNinePatchSampler); + this->setTextureSamplerCnt(1); } GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override; bool onIsEqual(const GrFragmentProcessor&) const override; + const TextureSampler& onTextureSampler(int) const override; GR_DECLARE_FRAGMENT_PROCESSOR_TEST float fSigma; SkRect fRect; diff --git a/src/gpu/effects/GrRectBlurEffect.cpp b/src/gpu/effects/GrRectBlurEffect.cpp index 219fefa713..9ade87cbe1 100644 --- a/src/gpu/effects/GrRectBlurEffect.cpp +++ b/src/gpu/effects/GrRectBlurEffect.cpp @@ -149,11 +149,14 @@ GrRectBlurEffect::GrRectBlurEffect(const GrRectBlurEffect& src) , fRect(src.fRect) , fSigma(src.fSigma) , fBlurProfile(src.fBlurProfile) { - this->addTextureSampler(&fBlurProfile); + this->setTextureSamplerCnt(1); } std::unique_ptr<GrFragmentProcessor> GrRectBlurEffect::clone() const { return std::unique_ptr<GrFragmentProcessor>(new GrRectBlurEffect(*this)); } +const GrFragmentProcessor::TextureSampler& GrRectBlurEffect::onTextureSampler(int index) const { + return IthTextureSampler(index, fBlurProfile); +} GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrRectBlurEffect); #if GR_TEST_UTILS std::unique_ptr<GrFragmentProcessor> GrRectBlurEffect::TestCreate(GrProcessorTestData* data) { diff --git a/src/gpu/effects/GrRectBlurEffect.h b/src/gpu/effects/GrRectBlurEffect.h index 8307a49bbe..0d443c3a2b 100644 --- a/src/gpu/effects/GrRectBlurEffect.h +++ b/src/gpu/effects/GrRectBlurEffect.h @@ -104,11 +104,12 @@ private: , fRect(rect) , fSigma(sigma) , fBlurProfile(std::move(blurProfile), samplerParams) { - this->addTextureSampler(&fBlurProfile); + this->setTextureSamplerCnt(1); } GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override; bool onIsEqual(const GrFragmentProcessor&) const override; + const TextureSampler& onTextureSampler(int) const override; GR_DECLARE_FRAGMENT_PROCESSOR_TEST SkRect fRect; float fSigma; diff --git a/src/gpu/effects/GrSimpleTextureEffect.cpp b/src/gpu/effects/GrSimpleTextureEffect.cpp index 5e3e6979ca..0dda499731 100644 --- a/src/gpu/effects/GrSimpleTextureEffect.cpp +++ b/src/gpu/effects/GrSimpleTextureEffect.cpp @@ -54,12 +54,16 @@ GrSimpleTextureEffect::GrSimpleTextureEffect(const GrSimpleTextureEffect& src) , fImage(src.fImage) , fMatrix(src.fMatrix) , fImageCoordTransform(src.fImageCoordTransform) { - this->addTextureSampler(&fImage); + this->setTextureSamplerCnt(1); this->addCoordTransform(&fImageCoordTransform); } std::unique_ptr<GrFragmentProcessor> GrSimpleTextureEffect::clone() const { return std::unique_ptr<GrFragmentProcessor>(new GrSimpleTextureEffect(*this)); } +const GrFragmentProcessor::TextureSampler& GrSimpleTextureEffect::onTextureSampler( + int index) const { + return IthTextureSampler(index, fImage); +} GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSimpleTextureEffect); #if GR_TEST_UTILS std::unique_ptr<GrFragmentProcessor> GrSimpleTextureEffect::TestCreate( diff --git a/src/gpu/effects/GrSimpleTextureEffect.h b/src/gpu/effects/GrSimpleTextureEffect.h index fcd29b81ae..8a8924b494 100644 --- a/src/gpu/effects/GrSimpleTextureEffect.h +++ b/src/gpu/effects/GrSimpleTextureEffect.h @@ -55,12 +55,13 @@ private: , fImage(std::move(image), samplerParams) , fMatrix(matrix) , fImageCoordTransform(matrix, fImage.proxy()) { - this->addTextureSampler(&fImage); + this->setTextureSamplerCnt(1); this->addCoordTransform(&fImageCoordTransform); } GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override; bool onIsEqual(const GrFragmentProcessor&) const override; + const TextureSampler& onTextureSampler(int) const override; GR_DECLARE_FRAGMENT_PROCESSOR_TEST TextureSampler fImage; SkMatrix44 fMatrix; diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp index e2197023b1..ee27cc0479 100644 --- a/src/gpu/effects/GrTextureDomain.cpp +++ b/src/gpu/effects/GrTextureDomain.cpp @@ -234,7 +234,7 @@ GrTextureDomainEffect::GrTextureDomainEffect(sk_sp<GrTextureProxy> proxy, SkASSERT(mode != GrTextureDomain::kRepeat_Mode || filterMode == GrSamplerState::Filter::kNearest); this->addCoordTransform(&fCoordTransform); - this->addTextureSampler(&fTextureSampler); + this->setTextureSamplerCnt(1); } GrTextureDomainEffect::GrTextureDomainEffect(const GrTextureDomainEffect& that) @@ -243,7 +243,7 @@ GrTextureDomainEffect::GrTextureDomainEffect(const GrTextureDomainEffect& that) , fTextureDomain(that.fTextureDomain) , fTextureSampler(that.fTextureSampler) { this->addCoordTransform(&fCoordTransform); - this->addTextureSampler(&fTextureSampler); + this->setTextureSamplerCnt(1); } void GrTextureDomainEffect::onGetGLSLProcessorKey(const GrShaderCaps& caps, @@ -334,7 +334,7 @@ GrDeviceSpaceTextureDecalFragmentProcessor::GrDeviceSpaceTextureDecalFragmentPro , fTextureSampler(proxy, GrSamplerState::ClampNearest()) , fTextureDomain(proxy.get(), GrTextureDomain::MakeTexelDomain(subset), GrTextureDomain::kDecal_Mode) { - this->addTextureSampler(&fTextureSampler); + this->setTextureSamplerCnt(1); fDeviceSpaceOffset.fX = deviceSpaceOffset.fX - subset.fLeft; fDeviceSpaceOffset.fY = deviceSpaceOffset.fY - subset.fTop; } @@ -346,7 +346,7 @@ GrDeviceSpaceTextureDecalFragmentProcessor::GrDeviceSpaceTextureDecalFragmentPro , fTextureSampler(that.fTextureSampler) , fTextureDomain(that.fTextureDomain) , fDeviceSpaceOffset(that.fDeviceSpaceOffset) { - this->addTextureSampler(&fTextureSampler); + this->setTextureSamplerCnt(1); } std::unique_ptr<GrFragmentProcessor> GrDeviceSpaceTextureDecalFragmentProcessor::clone() const { diff --git a/src/gpu/effects/GrTextureDomain.h b/src/gpu/effects/GrTextureDomain.h index 048c8dc3f2..b3728cb9fe 100644 --- a/src/gpu/effects/GrTextureDomain.h +++ b/src/gpu/effects/GrTextureDomain.h @@ -192,6 +192,8 @@ private: bool onIsEqual(const GrFragmentProcessor&) const override; + const TextureSampler& onTextureSampler(int) const override { return fTextureSampler; } + GR_DECLARE_FRAGMENT_PROCESSOR_TEST typedef GrFragmentProcessor INHERITED; @@ -233,6 +235,8 @@ private: bool onIsEqual(const GrFragmentProcessor& fp) const override; + const TextureSampler& onTextureSampler(int) const override { return fTextureSampler; } + GR_DECLARE_FRAGMENT_PROCESSOR_TEST typedef GrFragmentProcessor INHERITED; diff --git a/src/gpu/effects/GrYUVtoRGBEffect.cpp b/src/gpu/effects/GrYUVtoRGBEffect.cpp index 905445e852..33dff41460 100644 --- a/src/gpu/effects/GrYUVtoRGBEffect.cpp +++ b/src/gpu/effects/GrYUVtoRGBEffect.cpp @@ -171,9 +171,7 @@ GrYUVtoRGBEffect::GrYUVtoRGBEffect(const GrYUVtoRGBEffect& src) , fYSamplerCoordTransform(src.fYSamplerCoordTransform) , fUSamplerCoordTransform(src.fUSamplerCoordTransform) , fVSamplerCoordTransform(src.fVSamplerCoordTransform) { - this->addTextureSampler(&fYSampler); - this->addTextureSampler(&fUSampler); - this->addTextureSampler(&fVSampler); + this->setTextureSamplerCnt(3); this->addCoordTransform(&fYSamplerCoordTransform); this->addCoordTransform(&fUSamplerCoordTransform); this->addCoordTransform(&fVSamplerCoordTransform); @@ -181,3 +179,6 @@ GrYUVtoRGBEffect::GrYUVtoRGBEffect(const GrYUVtoRGBEffect& src) std::unique_ptr<GrFragmentProcessor> GrYUVtoRGBEffect::clone() const { return std::unique_ptr<GrFragmentProcessor>(new GrYUVtoRGBEffect(*this)); } +const GrFragmentProcessor::TextureSampler& GrYUVtoRGBEffect::onTextureSampler(int index) const { + return IthTextureSampler(index, fYSampler, fUSampler, fVSampler); +} diff --git a/src/gpu/effects/GrYUVtoRGBEffect.h b/src/gpu/effects/GrYUVtoRGBEffect.h index 6cc468edc0..0b3393cf63 100644 --- a/src/gpu/effects/GrYUVtoRGBEffect.h +++ b/src/gpu/effects/GrYUVtoRGBEffect.h @@ -55,9 +55,7 @@ private: , fYSamplerCoordTransform(ySamplerTransform, fYSampler.proxy()) , fUSamplerCoordTransform(uSamplerTransform, fUSampler.proxy()) , fVSamplerCoordTransform(vSamplerTransform, fVSampler.proxy()) { - this->addTextureSampler(&fYSampler); - this->addTextureSampler(&fUSampler); - this->addTextureSampler(&fVSampler); + this->setTextureSamplerCnt(3); this->addCoordTransform(&fYSamplerCoordTransform); this->addCoordTransform(&fUSamplerCoordTransform); this->addCoordTransform(&fVSamplerCoordTransform); @@ -65,6 +63,7 @@ private: GrGLSLFragmentProcessor* onCreateGLSLInstance() const override; void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override; bool onIsEqual(const GrFragmentProcessor&) const override; + const TextureSampler& onTextureSampler(int) const override; GR_DECLARE_FRAGMENT_PROCESSOR_TEST TextureSampler fYSampler; SkMatrix44 fYSamplerTransform; |