Push isEqual/onIsEqual down from GrProcessor to subclasses.
R=joshualitt@google.com
Review URL: https://codereview.chromium.org/654273002
diff --git a/include/gpu/GrGeometryProcessor.h b/include/gpu/GrGeometryProcessor.h
index 61659cf..fe7905a 100644
--- a/include/gpu/GrGeometryProcessor.h
+++ b/include/gpu/GrGeometryProcessor.h
@@ -37,6 +37,19 @@
const VertexAttribArray& getVertexAttribs() const { return fVertexAttribs; }
+ bool isEqual(const GrGeometryProcessor& that) const {
+ if (&this->getFactory() != &that.getFactory()) {
+ return false;
+ }
+ bool result = this->onIsEqual(that);
+#ifdef SK_DEBUG
+ if (result) {
+ this->assertTexturesEqual(that);
+ }
+#endif
+ return result;
+ }
+
protected:
/**
* Subclasses call this from their constructor to register vertex attributes (at most
@@ -49,6 +62,8 @@
}
private:
+ virtual bool onIsEqual(const GrGeometryProcessor&) const = 0;
+
SkSTArray<kMaxVertexAttribs, GrShaderVar, true> fVertexAttribs;
typedef GrProcessor INHERITED;
diff --git a/include/gpu/GrProcessor.h b/include/gpu/GrProcessor.h
index a8188ca..7991a06 100644
--- a/include/gpu/GrProcessor.h
+++ b/include/gpu/GrProcessor.h
@@ -175,27 +175,6 @@
*/
virtual const GrBackendProcessorFactory& getFactory() const = 0;
- /** Returns true if this and other effect conservatively draw identically. It can only return
- true when the two effects are of the same subclass (i.e. they return the same object from
- from getFactory()).
-
- A return value of true from isEqual() should not be used to test whether the effects would
- generate the same shader code. To test for identical code generation use the effects' keys
- computed by the GrBackendEffectFactory.
- */
- bool isEqual(const GrProcessor& other) const {
- if (&this->getFactory() != &other.getFactory()) {
- return false;
- }
- bool result = this->onIsEqual(other);
-#ifdef SK_DEBUG
- if (result) {
- this->assertEquality(other);
- }
-#endif
- return result;
- }
-
/** Human-meaningful string to identify this effect; may be embedded
in generated shader code. */
const char* name() const;
@@ -246,13 +225,9 @@
*/
void setWillReadFragmentPosition() { fWillReadFragmentPosition = true; }
-private:
- SkDEBUGCODE(void assertEquality(const GrProcessor& other) const;)
+ SkDEBUGCODE(void assertTexturesEqual(const GrProcessor& other) const;)
- /** Subclass implements this to support isEqual(). It will only be called if it is known that
- the two effects are of the same subclass (i.e. they return the same object from
- getFactory()).*/
- virtual bool onIsEqual(const GrProcessor& other) const = 0;
+private:
/**
* Subclass implements this to support getConstantColorComponents(...).
@@ -286,6 +261,26 @@
/** Will this effect read the source color value? */
bool willUseInputColor() const { return fWillUseInputColor; }
+ /** Returns true if this and other effect conservatively draw identically. It can only return
+ true when the two effects are of the same subclass (i.e. they return the same object from
+ from getFactory()).
+
+ A return value of true from isEqual() should not be used to test whether the effects would
+ generate the same shader code. To test for identical code generation use the effects' keys
+ computed by the GrBackendEffectFactory. */
+ bool isEqual(const GrFragmentProcessor& other) const {
+ if (&this->getFactory() != &other.getFactory()) {
+ return false;
+ }
+ bool result = this->onIsEqual(other);
+#ifdef SK_DEBUG
+ if (result) {
+ this->assertTexturesEqual(other);
+ }
+#endif
+ return result;
+ }
+
protected:
/**
* Fragment Processor subclasses call this from their constructor to register coordinate
@@ -312,6 +307,11 @@
void setWillNotUseInputColor() { fWillUseInputColor = false; }
private:
+ /** Subclass implements this to support isEqual(). It will only be called if it is known that
+ the two effects are of the same subclass (i.e. they return the same object from
+ getFactory()).*/
+ virtual bool onIsEqual(const GrFragmentProcessor& other) const = 0;
+
SkSTArray<4, const GrCoordTransform*, true> fCoordTransforms;
bool fWillReadDstColor;
bool fWillUseInputColor;