Add comparison and assignment operators to GrSamplerState.

http://codereview.appspot.com/6137058/



git-svn-id: http://skia.googlecode.com/svn/trunk@3803 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
tomhudson@google.com 2012-04-30 20:19:07 +00:00
parent 443e5a52b7
commit 02b1ea24fd
3 changed files with 21 additions and 12 deletions

View File

@ -27,10 +27,11 @@ public:
stage guaranteed to produce an opaque output? */
virtual bool isOpaque(bool inputTextureIsOpaque) const;
/** 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;
protected:
};
#endif

View File

@ -122,6 +122,16 @@ public:
GrSafeUnref(fCustomStage);
}
bool operator ==(const GrSamplerState& s) const {
return !memcmp(this, &s, sizeof(GrSamplerState));
}
bool operator !=(const GrSamplerState& s) const { return !(*this == s); }
GrSamplerState& operator =(const GrSamplerState s) {
memcpy(this, &s, sizeof(GrSamplerState));
return *this;
}
WrapMode getWrapX() const { return fWrapX; }
WrapMode getWrapY() const { return fWrapY; }
FilterDirection getFilterDirection() const { return fFilterDirection; }
@ -258,12 +268,6 @@ private:
bool fSwapRAndB;
GrRect fTextureDomain;
/// BUG! Ganesh only works correctly so long as fCustomStage is
/// NULL; we need to have a complex ID system here so that we can
/// have an equality-like comparison to determine whether two
/// fCustomStages are equal.
GrCustomStage* fCustomStage;
// these are undefined unless fSampleMode == kRadial2_SampleMode
GrScalar fRadial2CenterX1;
GrScalar fRadial2Radius0;
@ -272,6 +276,12 @@ private:
// These are undefined unless fFilter == kConvolution_Filter
uint8_t fKernelWidth;
float fKernel[MAX_KERNEL_WIDTH];
/// BUG! Ganesh only works correctly so long as fCustomStage is
/// NULL; we need to have a complex ID system here so that we can
/// have an equality-like comparison to determine whether two
/// fCustomStages are equal.
GrCustomStage* fCustomStage;
};
#endif

View File

@ -757,8 +757,7 @@ public:
for (int i = 0; i < kNumStages; i++) {
if (fTextures[i] &&
memcmp(&this->fSamplerStates[i], &s.fSamplerStates[i],
sizeof(GrSamplerState))) {
this->fSamplerStates[i] != s.fSamplerStates[i]) {
return false;
}
}
@ -786,8 +785,7 @@ public:
for (int i = 0; i < kNumStages; i++) {
if (s.fTextures[i]) {
memcpy(&this->fSamplerStates[i], &s.fSamplerStates[i],
sizeof(GrSamplerState));
this->fSamplerStates[i] = s.fSamplerStates[i];
}
}
if (kColorMatrix_StateBit & s.fFlagBits) {