diff options
author | tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-05-01 12:48:07 +0000 |
---|---|---|
committer | tomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-05-01 12:48:07 +0000 |
commit | b88bbd2a5388ec2a5574d0ef7e43160c0ac37a3b (patch) | |
tree | 93db361f3c08336c0142b704b75c7d25d1648c24 /include/gpu | |
parent | 7c2578d392adf76476cbae4aa3847504f8df1487 (diff) |
Make GrSamplerState::operator==() use GrCustomStage::isEquivalent() rather
than just bit-compare all fields.
git-svn-id: http://skia.googlecode.com/svn/trunk@3805 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/gpu')
-rw-r--r-- | include/gpu/GrCustomStage.h | 8 | ||||
-rw-r--r-- | include/gpu/GrSamplerState.h | 20 |
2 files changed, 23 insertions, 5 deletions
diff --git a/include/gpu/GrCustomStage.h b/include/gpu/GrCustomStage.h index 82ad3ab9f8..4fe13bf34d 100644 --- a/include/gpu/GrCustomStage.h +++ b/include/gpu/GrCustomStage.h @@ -30,7 +30,13 @@ public: /** This pointer, besides creating back-end-specific helper objects, is used for run-time-type-identification. Every subclass must return a consistent unique value for it. */ - virtual GrGLProgramStageFactory* getGLFactory() = 0; + virtual GrGLProgramStageFactory* getGLFactory() const = 0; + + /** Returns true if the other custom stage will generate + a compatible/equivalent shader. Must only be called if + the two are already known to be of the same type (i.e. + they return the same value from getGLFactory()). */ + virtual bool isEquivalent(const GrCustomStage *) const = 0; }; diff --git a/include/gpu/GrSamplerState.h b/include/gpu/GrSamplerState.h index 50fe240c8d..3fd39c560a 100644 --- a/include/gpu/GrSamplerState.h +++ b/include/gpu/GrSamplerState.h @@ -111,10 +111,10 @@ public: * unfiltered, and use identity matrix. */ GrSamplerState() - : fCustomStage (NULL) - , fRadial2CenterX1() + : fRadial2CenterX1() , fRadial2Radius0() - , fRadial2PosRoot() { + , fRadial2PosRoot() + , fCustomStage (NULL) { this->reset(); } @@ -123,7 +123,19 @@ public: } bool operator ==(const GrSamplerState& s) const { - return !memcmp(this, &s, sizeof(GrSamplerState)); + /* We must be bit-identical as far as the CustomStage; + there may be multiple CustomStages that will produce + the same shader code and so are equivalent. + Can't take the address of fWrapX because it's :8 */ + int bitwiseRegion = (intptr_t) &fCustomStage - (intptr_t) this; + GrAssert(sizeof(GrSamplerState) == + bitwiseRegion + sizeof(fCustomStage)); + return !memcmp(this, &s, bitwiseRegion) && + ((fCustomStage == s.fCustomStage) || + (fCustomStage && s.fCustomStage && + (fCustomStage->getGLFactory() == + s.fCustomStage->getGLFactory()) && + fCustomStage->isEquivalent(s.fCustomStage))); } bool operator !=(const GrSamplerState& s) const { return !(*this == s); } |