aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2014-10-16 09:18:09 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-10-16 09:18:09 -0700
commit420d7e9a79358908850c74192b4949375563449a (patch)
treef3b37d543e37ac16ac99041a0ee28be02dcc77df /src
parent6c4b51d3ca18129889c962a342e681ebdd93c79c (diff)
Auto-compare GrProcessors' texture accesses in isEqual().
R=joshualitt@google.com Review URL: https://codereview.chromium.org/654313002
Diffstat (limited to 'src')
-rw-r--r--src/core/SkXfermode.cpp3
-rw-r--r--src/effects/SkAlphaThresholdFilter.cpp3
-rw-r--r--src/effects/SkArithmeticMode.cpp3
-rw-r--r--src/effects/SkColorCubeFilter.cpp7
-rw-r--r--src/effects/SkDisplacementMapEffect.cpp4
-rw-r--r--src/effects/SkLightingImageFilter.cpp3
-rw-r--r--src/effects/SkLumaColorFilter.cpp4
-rw-r--r--src/effects/SkMagnifierImageFilter.cpp3
-rw-r--r--src/effects/SkMorphologyImageFilter.cpp3
-rw-r--r--src/effects/SkPerlinNoiseShader.cpp2
-rw-r--r--src/effects/SkTableColorFilter.cpp6
-rw-r--r--src/effects/gradients/SkGradientShader.cpp6
-rw-r--r--src/gpu/GrProcessor.cpp14
-rw-r--r--src/gpu/effects/GrBicubicEffect.cpp3
-rw-r--r--src/gpu/effects/GrConfigConversionEffect.cpp3
-rw-r--r--src/gpu/effects/GrConvolutionEffect.cpp3
-rw-r--r--src/gpu/effects/GrCustomCoordsTextureEffect.cpp3
-rwxr-xr-xsrc/gpu/effects/GrDistanceFieldTextureEffect.cpp9
-rw-r--r--src/gpu/effects/GrMatrixConvolutionEffect.cpp3
-rw-r--r--src/gpu/effects/GrSimpleTextureEffect.h5
-rw-r--r--src/gpu/effects/GrSingleTextureEffect.h8
-rw-r--r--src/gpu/effects/GrTextureDomain.cpp3
-rw-r--r--src/gpu/effects/GrYUVtoRGBEffect.cpp5
23 files changed, 33 insertions, 73 deletions
diff --git a/src/core/SkXfermode.cpp b/src/core/SkXfermode.cpp
index 616a361b81..0cc120dfa7 100644
--- a/src/core/SkXfermode.cpp
+++ b/src/core/SkXfermode.cpp
@@ -1208,8 +1208,7 @@ private:
}
virtual bool onIsEqual(const GrFragmentProcessor& other) const SK_OVERRIDE {
const XferEffect& s = other.cast<XferEffect>();
- return fMode == s.fMode &&
- fBackgroundAccess.getTexture() == s.fBackgroundAccess.getTexture();
+ return fMode == s.fMode;
}
virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE {
diff --git a/src/effects/SkAlphaThresholdFilter.cpp b/src/effects/SkAlphaThresholdFilter.cpp
index 016780fb01..7e91af4f4b 100644
--- a/src/effects/SkAlphaThresholdFilter.cpp
+++ b/src/effects/SkAlphaThresholdFilter.cpp
@@ -223,8 +223,7 @@ const GrBackendFragmentProcessorFactory& AlphaThresholdEffect::getFactory() cons
bool AlphaThresholdEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
const AlphaThresholdEffect& s = sBase.cast<AlphaThresholdEffect>();
- return (this->texture(0) == s.texture(0) &&
- this->fInnerThreshold == s.fInnerThreshold &&
+ return (this->fInnerThreshold == s.fInnerThreshold &&
this->fOuterThreshold == s.fOuterThreshold);
}
diff --git a/src/effects/SkArithmeticMode.cpp b/src/effects/SkArithmeticMode.cpp
index 06a602ac01..3048aec823 100644
--- a/src/effects/SkArithmeticMode.cpp
+++ b/src/effects/SkArithmeticMode.cpp
@@ -336,8 +336,7 @@ bool GrArithmeticEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
fK2 == s.fK2 &&
fK3 == s.fK3 &&
fK4 == s.fK4 &&
- fEnforcePMColor == s.fEnforcePMColor &&
- backgroundTexture() == s.backgroundTexture();
+ fEnforcePMColor == s.fEnforcePMColor;
}
const GrBackendFragmentProcessorFactory& GrArithmeticEffect::getFactory() const {
diff --git a/src/effects/SkColorCubeFilter.cpp b/src/effects/SkColorCubeFilter.cpp
index 325d7de780..f79c1c7fae 100644
--- a/src/effects/SkColorCubeFilter.cpp
+++ b/src/effects/SkColorCubeFilter.cpp
@@ -232,7 +232,7 @@ public:
};
private:
- virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE { return true; }
GrColorCubeEffect(GrTexture* colorCube);
@@ -254,11 +254,6 @@ GrColorCubeEffect::GrColorCubeEffect(GrTexture* colorCube)
GrColorCubeEffect::~GrColorCubeEffect() {
}
-bool GrColorCubeEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
- const GrColorCubeEffect& s = sBase.cast<GrColorCubeEffect>();
- return fColorCubeAccess.getTexture() == s.fColorCubeAccess.getTexture();
-}
-
const GrBackendFragmentProcessorFactory& GrColorCubeEffect::getFactory() const {
return GrTBackendFragmentProcessorFactory<GrColorCubeEffect>::getInstance();
}
diff --git a/src/effects/SkDisplacementMapEffect.cpp b/src/effects/SkDisplacementMapEffect.cpp
index bc35752c0e..e2546f77db 100644
--- a/src/effects/SkDisplacementMapEffect.cpp
+++ b/src/effects/SkDisplacementMapEffect.cpp
@@ -480,9 +480,7 @@ GrDisplacementMapEffect::~GrDisplacementMapEffect() {
bool GrDisplacementMapEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
const GrDisplacementMapEffect& s = sBase.cast<GrDisplacementMapEffect>();
- return fDisplacementAccess.getTexture() == s.fDisplacementAccess.getTexture() &&
- fColorAccess.getTexture() == s.fColorAccess.getTexture() &&
- fXChannelSelector == s.fXChannelSelector &&
+ return fXChannelSelector == s.fXChannelSelector &&
fYChannelSelector == s.fYChannelSelector &&
fScale == s.fScale;
}
diff --git a/src/effects/SkLightingImageFilter.cpp b/src/effects/SkLightingImageFilter.cpp
index 0e063d95c8..24bfbbd56e 100644
--- a/src/effects/SkLightingImageFilter.cpp
+++ b/src/effects/SkLightingImageFilter.cpp
@@ -1304,8 +1304,7 @@ GrLightingEffect::~GrLightingEffect() {
bool GrLightingEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
const GrLightingEffect& s = sBase.cast<GrLightingEffect>();
- return this->texture(0) == s.texture(0) &&
- fLight->isEqual(*s.fLight) &&
+ return fLight->isEqual(*s.fLight) &&
fSurfaceScale == s.fSurfaceScale;
}
diff --git a/src/effects/SkLumaColorFilter.cpp b/src/effects/SkLumaColorFilter.cpp
index 7750f04d72..b1b2ffd477 100644
--- a/src/effects/SkLumaColorFilter.cpp
+++ b/src/effects/SkLumaColorFilter.cpp
@@ -109,9 +109,7 @@ public:
};
private:
- virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE {
- return true;
- }
+ virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE { return true; }
virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE {
// The output is always black. The alpha value for the color passed in is arbitrary.
diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp
index f4940d754c..e69ac58601 100644
--- a/src/effects/SkMagnifierImageFilter.cpp
+++ b/src/effects/SkMagnifierImageFilter.cpp
@@ -218,8 +218,7 @@ const GrBackendFragmentProcessorFactory& GrMagnifierEffect::getFactory() const {
bool GrMagnifierEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
const GrMagnifierEffect& s = sBase.cast<GrMagnifierEffect>();
- return (this->texture(0) == s.texture(0) &&
- this->fXOffset == s.fXOffset &&
+ return (this->fXOffset == s.fXOffset &&
this->fYOffset == s.fYOffset &&
this->fXInvZoom == s.fXInvZoom &&
this->fYInvZoom == s.fYInvZoom &&
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index 95cf85e800..03c50e4927 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -450,8 +450,7 @@ const GrBackendFragmentProcessorFactory& GrMorphologyEffect::getFactory() const
bool GrMorphologyEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
const GrMorphologyEffect& s = sBase.cast<GrMorphologyEffect>();
- return (this->texture(0) == s.texture(0) &&
- this->radius() == s.radius() &&
+ return (this->radius() == s.radius() &&
this->direction() == s.direction() &&
this->type() == s.type());
}
diff --git a/src/effects/SkPerlinNoiseShader.cpp b/src/effects/SkPerlinNoiseShader.cpp
index 68cdcc6b11..3ce106028a 100644
--- a/src/effects/SkPerlinNoiseShader.cpp
+++ b/src/effects/SkPerlinNoiseShader.cpp
@@ -580,8 +580,6 @@ private:
fNumOctaves == s.fNumOctaves &&
fStitchTiles == s.fStitchTiles &&
fAlpha == s.fAlpha &&
- fPermutationsAccess.getTexture() == s.fPermutationsAccess.getTexture() &&
- fNoiseAccess.getTexture() == s.fNoiseAccess.getTexture() &&
fPaintingData->fStitchDataInit == s.fPaintingData->fStitchDataInit;
}
diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp
index fb177b2b40..ca2757f299 100644
--- a/src/effects/SkTableColorFilter.cpp
+++ b/src/effects/SkTableColorFilter.cpp
@@ -297,7 +297,7 @@ public:
typedef GLColorTableEffect GLProcessor;
private:
- virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE;
+ virtual bool onIsEqual(const GrFragmentProcessor&) const SK_OVERRIDE{ return true; }
virtual void onComputeInvariantOutput(InvariantOutput* inout) const SK_OVERRIDE;
@@ -397,10 +397,6 @@ const GrBackendFragmentProcessorFactory& ColorTableEffect::getFactory() const {
return GrTBackendFragmentProcessorFactory<ColorTableEffect>::getInstance();
}
-bool ColorTableEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
- return this->texture(0) == sBase.texture(0);
-}
-
void ColorTableEffect::onComputeInvariantOutput(InvariantOutput* inout) const {
// If we kept the table in the effect then we could actually run known inputs through the
// table.
diff --git a/src/effects/gradients/SkGradientShader.cpp b/src/effects/gradients/SkGradientShader.cpp
index f131d72f23..9dce5c2e0f 100644
--- a/src/effects/gradients/SkGradientShader.cpp
+++ b/src/effects/gradients/SkGradientShader.cpp
@@ -1202,10 +1202,8 @@ bool GrGradientEffect::onIsEqual(const GrFragmentProcessor& processor) const {
}
}
- return fTextureAccess.getTexture() == s.fTextureAccess.getTexture() &&
- fTextureAccess.getParams().getTileModeX() ==
- s.fTextureAccess.getParams().getTileModeX() &&
- this->useAtlas() == s.useAtlas();
+ SkASSERT(this->useAtlas() == s.useAtlas());
+ return true;
}
return false;
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 {