aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
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 /include
parent6c4b51d3ca18129889c962a342e681ebdd93c79c (diff)
Auto-compare GrProcessors' texture accesses in isEqual().
R=joshualitt@google.com Review URL: https://codereview.chromium.org/654313002
Diffstat (limited to 'include')
-rw-r--r--include/gpu/GrFragmentProcessor.h14
-rw-r--r--include/gpu/GrGeometryProcessor.h10
-rw-r--r--include/gpu/GrProcessor.h7
3 files changed, 10 insertions, 21 deletions
diff --git a/include/gpu/GrFragmentProcessor.h b/include/gpu/GrFragmentProcessor.h
index 4642307176..044e807aae 100644
--- a/include/gpu/GrFragmentProcessor.h
+++ b/include/gpu/GrFragmentProcessor.h
@@ -45,17 +45,13 @@ public:
A return value of true from isEqual() should not be used to test whether the prceossor would
generate the same shader code. To test for identical code generation use the prceossor' keys
computed by the GrBackendProcessorFactory. */
- bool isEqual(const GrFragmentProcessor& other) const {
- if (&this->getFactory() != &other.getFactory() || !this->hasSameTransforms(other)) {
+ bool isEqual(const GrFragmentProcessor& that) const {
+ if (&this->getFactory() != &that.getFactory() ||
+ !this->hasSameTransforms(that) ||
+ !this->hasSameTextureAccesses(that)) {
return false;
}
- bool result = this->onIsEqual(other);
-#ifdef SK_DEBUG
- if (result) {
- this->assertTexturesEqual(other);
- }
-#endif
- return result;
+ return this->onIsEqual(that);
}
protected:
diff --git a/include/gpu/GrGeometryProcessor.h b/include/gpu/GrGeometryProcessor.h
index 5f32c5d0cc..60928f2f10 100644
--- a/include/gpu/GrGeometryProcessor.h
+++ b/include/gpu/GrGeometryProcessor.h
@@ -44,16 +44,10 @@ public:
would generate the same shader code. To test for identical code generation use the
processors' keys computed by the GrBackendEffectFactory. */
bool isEqual(const GrGeometryProcessor& that) const {
- if (&this->getFactory() != &that.getFactory()) {
+ if (&this->getFactory() != &that.getFactory() || !this->hasSameTextureAccesses(that)) {
return false;
}
- bool result = this->onIsEqual(that);
-#ifdef SK_DEBUG
- if (result) {
- this->assertTexturesEqual(that);
- }
-#endif
- return result;
+ return this->onIsEqual(that);
}
protected:
diff --git a/include/gpu/GrProcessor.h b/include/gpu/GrProcessor.h
index ee1266359f..96ce288404 100644
--- a/include/gpu/GrProcessor.h
+++ b/include/gpu/GrProcessor.h
@@ -227,6 +227,8 @@ public:
template <typename T> const T& cast() const { return *static_cast<const T*>(this); }
protected:
+ GrProcessor() : fWillReadFragmentPosition(false) {}
+
/**
* Subclasses call this from their constructor to register GrTextureAccesses. The processor
* subclass manages the lifetime of the accesses (this function only stores a pointer). The
@@ -235,8 +237,7 @@ protected:
*/
void addTextureAccess(const GrTextureAccess* textureAccess);
- GrProcessor()
- : fWillReadFragmentPosition(false) {}
+ bool hasSameTextureAccesses(const GrProcessor&) const;
/**
* If the prcoessor will generate a backend-specific processor that will read the fragment
@@ -245,8 +246,6 @@ protected:
*/
void setWillReadFragmentPosition() { fWillReadFragmentPosition = true; }
- SkDEBUGCODE(void assertTexturesEqual(const GrProcessor& other) const;)
-
private:
/**