diff options
author | bsalomon <bsalomon@google.com> | 2014-10-16 09:18:09 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-16 09:18:09 -0700 |
commit | 420d7e9a79358908850c74192b4949375563449a (patch) | |
tree | f3b37d543e37ac16ac99041a0ee28be02dcc77df /src/gpu | |
parent | 6c4b51d3ca18129889c962a342e681ebdd93c79c (diff) |
Auto-compare GrProcessors' texture accesses in isEqual().
R=joshualitt@google.com
Review URL: https://codereview.chromium.org/654313002
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/GrProcessor.cpp | 14 | ||||
-rw-r--r-- | src/gpu/effects/GrBicubicEffect.cpp | 3 | ||||
-rw-r--r-- | src/gpu/effects/GrConfigConversionEffect.cpp | 3 | ||||
-rw-r--r-- | src/gpu/effects/GrConvolutionEffect.cpp | 3 | ||||
-rw-r--r-- | src/gpu/effects/GrCustomCoordsTextureEffect.cpp | 3 | ||||
-rwxr-xr-x | src/gpu/effects/GrDistanceFieldTextureEffect.cpp | 9 | ||||
-rw-r--r-- | src/gpu/effects/GrMatrixConvolutionEffect.cpp | 3 | ||||
-rw-r--r-- | src/gpu/effects/GrSimpleTextureEffect.h | 5 | ||||
-rw-r--r-- | src/gpu/effects/GrSingleTextureEffect.h | 8 | ||||
-rw-r--r-- | src/gpu/effects/GrTextureDomain.cpp | 3 | ||||
-rw-r--r-- | src/gpu/effects/GrYUVtoRGBEffect.cpp | 5 |
11 files changed, 21 insertions, 38 deletions
diff --git a/src/gpu/GrProcessor.cpp b/src/gpu/GrProcessor.cpp index a0ad99efe5..79798b6b82 100644 --- a/src/gpu/GrProcessor.cpp +++ b/src/gpu/GrProcessor.cpp @@ -116,14 +116,20 @@ void GrProcessor::operator delete(void* target) { GrProcessor_Globals::GetTLS()->release(target); } -#ifdef SK_DEBUG -void GrProcessor::assertTexturesEqual(const GrProcessor& other) const { - SkASSERT(this->numTextures() == other.numTextures()); +bool GrProcessor::hasSameTextureAccesses(const GrProcessor& that) const { + if (this->numTextures() != that.numTextures()) { + return false; + } for (int i = 0; i < this->numTextures(); ++i) { - SkASSERT(this->textureAccess(i) == other.textureAccess(i)); + if (this->textureAccess(i) != that.textureAccess(i)) { + return false; + } } + return true; } +#ifdef SK_DEBUG + void GrProcessor::InvariantOutput::validate() const { if (fIsSingleComponent) { SkASSERT(0 == fValidFlags || kRGBA_GrColorComponentFlags == fValidFlags); diff --git a/src/gpu/effects/GrBicubicEffect.cpp b/src/gpu/effects/GrBicubicEffect.cpp index 7a47a4f082..5ed8ece0b5 100644 --- a/src/gpu/effects/GrBicubicEffect.cpp +++ b/src/gpu/effects/GrBicubicEffect.cpp @@ -164,8 +164,7 @@ const GrBackendFragmentProcessorFactory& GrBicubicEffect::getFactory() const { bool GrBicubicEffect::onIsEqual(const GrFragmentProcessor& sBase) const { const GrBicubicEffect& s = sBase.cast<GrBicubicEffect>(); - return this->textureAccess(0) == s.textureAccess(0) && - !memcmp(fCoefficients, s.coefficients(), 16) && + return !memcmp(fCoefficients, s.coefficients(), 16) && fDomain == s.fDomain; } diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp index dec3f9d01a..290322d833 100644 --- a/src/gpu/effects/GrConfigConversionEffect.cpp +++ b/src/gpu/effects/GrConfigConversionEffect.cpp @@ -121,8 +121,7 @@ const GrBackendFragmentProcessorFactory& GrConfigConversionEffect::getFactory() bool GrConfigConversionEffect::onIsEqual(const GrFragmentProcessor& s) const { const GrConfigConversionEffect& other = s.cast<GrConfigConversionEffect>(); - return this->texture(0) == s.texture(0) && - other.fSwapRedAndBlue == fSwapRedAndBlue && + return other.fSwapRedAndBlue == fSwapRedAndBlue && other.fPMConversion == fPMConversion; } diff --git a/src/gpu/effects/GrConvolutionEffect.cpp b/src/gpu/effects/GrConvolutionEffect.cpp index 9776a2af5f..310e531aff 100644 --- a/src/gpu/effects/GrConvolutionEffect.cpp +++ b/src/gpu/effects/GrConvolutionEffect.cpp @@ -202,8 +202,7 @@ const GrBackendFragmentProcessorFactory& GrConvolutionEffect::getFactory() const bool GrConvolutionEffect::onIsEqual(const GrFragmentProcessor& sBase) const { const GrConvolutionEffect& s = sBase.cast<GrConvolutionEffect>(); - return (this->texture(0) == s.texture(0) && - this->radius() == s.radius() && + return (this->radius() == s.radius() && this->direction() == s.direction() && this->useBounds() == s.useBounds() && 0 == memcmp(fBounds, s.fBounds, sizeof(fBounds)) && diff --git a/src/gpu/effects/GrCustomCoordsTextureEffect.cpp b/src/gpu/effects/GrCustomCoordsTextureEffect.cpp index 896bfa5932..8c7555e8ff 100644 --- a/src/gpu/effects/GrCustomCoordsTextureEffect.cpp +++ b/src/gpu/effects/GrCustomCoordsTextureEffect.cpp @@ -68,8 +68,7 @@ GrCustomCoordsTextureEffect::GrCustomCoordsTextureEffect(GrTexture* texture, } bool GrCustomCoordsTextureEffect::onIsEqual(const GrGeometryProcessor& other) const { - const GrCustomCoordsTextureEffect& cte = other.cast<GrCustomCoordsTextureEffect>(); - return fTextureAccess == cte.fTextureAccess; + return true; } void GrCustomCoordsTextureEffect::onComputeInvariantOutput(InvariantOutput* inout) const { diff --git a/src/gpu/effects/GrDistanceFieldTextureEffect.cpp b/src/gpu/effects/GrDistanceFieldTextureEffect.cpp index 406f1b022d..da2e3da175 100755 --- a/src/gpu/effects/GrDistanceFieldTextureEffect.cpp +++ b/src/gpu/effects/GrDistanceFieldTextureEffect.cpp @@ -198,9 +198,8 @@ GrDistanceFieldTextureEffect::GrDistanceFieldTextureEffect(GrTexture* texture, bool GrDistanceFieldTextureEffect::onIsEqual(const GrGeometryProcessor& other) const { const GrDistanceFieldTextureEffect& cte = other.cast<GrDistanceFieldTextureEffect>(); - return fTextureAccess == cte.fTextureAccess && + return #ifdef SK_GAMMA_APPLY_TO_A8 - fGammaTextureAccess == cte.fGammaTextureAccess && fLuminance == cte.fLuminance && #endif fFlags == cte.fFlags; @@ -382,7 +381,7 @@ GrDistanceFieldNoGammaTextureEffect::GrDistanceFieldNoGammaTextureEffect(GrTextu bool GrDistanceFieldNoGammaTextureEffect::onIsEqual(const GrGeometryProcessor& other) const { const GrDistanceFieldNoGammaTextureEffect& cte = other.cast<GrDistanceFieldNoGammaTextureEffect>(); - return fTextureAccess == cte.fTextureAccess && fFlags == cte.fFlags; + return fFlags == cte.fFlags; } void GrDistanceFieldNoGammaTextureEffect::onComputeInvariantOutput(InvariantOutput* inout) const { @@ -630,9 +629,7 @@ GrDistanceFieldLCDTextureEffect::GrDistanceFieldLCDTextureEffect( bool GrDistanceFieldLCDTextureEffect::onIsEqual(const GrGeometryProcessor& other) const { const GrDistanceFieldLCDTextureEffect& cte = other.cast<GrDistanceFieldLCDTextureEffect>(); - return (fTextureAccess == cte.fTextureAccess && - fGammaTextureAccess == cte.fGammaTextureAccess && - fTextColor == cte.fTextColor && + return (fTextColor == cte.fTextColor && fFlags == cte.fFlags); } diff --git a/src/gpu/effects/GrMatrixConvolutionEffect.cpp b/src/gpu/effects/GrMatrixConvolutionEffect.cpp index 1f982672c4..07a24a3477 100644 --- a/src/gpu/effects/GrMatrixConvolutionEffect.cpp +++ b/src/gpu/effects/GrMatrixConvolutionEffect.cpp @@ -178,8 +178,7 @@ const GrBackendFragmentProcessorFactory& GrMatrixConvolutionEffect::getFactory() bool GrMatrixConvolutionEffect::onIsEqual(const GrFragmentProcessor& sBase) const { const GrMatrixConvolutionEffect& s = sBase.cast<GrMatrixConvolutionEffect>(); - return this->texture(0) == s.texture(0) && - fKernelSize == s.kernelSize() && + return fKernelSize == s.kernelSize() && !memcmp(fKernel, s.kernel(), fKernelSize.width() * fKernelSize.height() * sizeof(float)) && fGain == s.gain() && diff --git a/src/gpu/effects/GrSimpleTextureEffect.h b/src/gpu/effects/GrSimpleTextureEffect.h index 565b1eadac..4c79aab346 100644 --- a/src/gpu/effects/GrSimpleTextureEffect.h +++ b/src/gpu/effects/GrSimpleTextureEffect.h @@ -68,10 +68,7 @@ private: : GrSingleTextureEffect(texture, matrix, params, coordSet) { } - virtual bool onIsEqual(const GrFragmentProcessor& other) const SK_OVERRIDE { - const GrSimpleTextureEffect& ste = other.cast<GrSimpleTextureEffect>(); - return this->hasSameTextureParamsMatrixAndSourceCoords(ste); - } + virtual bool onIsEqual(const GrFragmentProcessor& other) const SK_OVERRIDE { return true; } virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE; diff --git a/src/gpu/effects/GrSingleTextureEffect.h b/src/gpu/effects/GrSingleTextureEffect.h index c16c088a18..836c54c234 100644 --- a/src/gpu/effects/GrSingleTextureEffect.h +++ b/src/gpu/effects/GrSingleTextureEffect.h @@ -34,14 +34,6 @@ protected: GrCoordSet = kLocal_GrCoordSet); /** - * Helper for subclass onIsEqual() functions. - */ - bool hasSameTextureParamsMatrixAndSourceCoords(const GrSingleTextureEffect& other) const { - // We don't have to check the accesses' swizzles because they are inferred from the texture. - return fTextureAccess == other.fTextureAccess; - } - - /** * 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. diff --git a/src/gpu/effects/GrTextureDomain.cpp b/src/gpu/effects/GrTextureDomain.cpp index 647aed48f9..2a0cd2065c 100644 --- a/src/gpu/effects/GrTextureDomain.cpp +++ b/src/gpu/effects/GrTextureDomain.cpp @@ -265,8 +265,7 @@ const GrBackendFragmentProcessorFactory& GrTextureDomainEffect::getFactory() con bool GrTextureDomainEffect::onIsEqual(const GrFragmentProcessor& sBase) const { const GrTextureDomainEffect& s = sBase.cast<GrTextureDomainEffect>(); - return this->hasSameTextureParamsMatrixAndSourceCoords(s) && - this->fTextureDomain == s.fTextureDomain; + return this->fTextureDomain == s.fTextureDomain; } void GrTextureDomainEffect::onComputeInvariantOutput(InvariantOutput* inout) const { diff --git a/src/gpu/effects/GrYUVtoRGBEffect.cpp b/src/gpu/effects/GrYUVtoRGBEffect.cpp index b18bd7fa01..f02c1b2295 100644 --- a/src/gpu/effects/GrYUVtoRGBEffect.cpp +++ b/src/gpu/effects/GrYUVtoRGBEffect.cpp @@ -103,10 +103,7 @@ private: virtual bool onIsEqual(const GrFragmentProcessor& sBase) const { const YUVtoRGBEffect& s = sBase.cast<YUVtoRGBEffect>(); - return fYAccess.getTexture() == s.fYAccess.getTexture() && - fUAccess.getTexture() == s.fUAccess.getTexture() && - fVAccess.getTexture() == s.fVAccess.getTexture() && - fColorSpace == s.getColorSpace(); + return fColorSpace == s.getColorSpace(); } virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE { |