return false;
}
+ if (fCoordChangeMatrixSet != other.fCoordChangeMatrixSet) {
+ return false;
+ }
+
+ if (!fCoordChangeMatrixSet) {
+ return true;
+ }
+
return fCoordChangeMatrix == other.fCoordChangeMatrix;
}
GrEffectStage& operator =(const GrEffectStage& other) {
GrSafeAssign(fEffectRef, other.fEffectRef);
- if (NULL != fEffectRef) {
+ fCoordChangeMatrixSet = other.fCoordChangeMatrixSet;
+ if (NULL != fEffectRef && fCoordChangeMatrixSet) {
fCoordChangeMatrix = other.fCoordChangeMatrix;
}
return *this;
* @param matrix The transformation from the old coord system in which geometry is specified
* to the new one from which it will actually be drawn.
*/
- void localCoordChange(const SkMatrix& matrix) { fCoordChangeMatrix.preConcat(matrix); }
+ void localCoordChange(const SkMatrix& matrix) {
+ if (fCoordChangeMatrixSet) {
+ fCoordChangeMatrix.preConcat(matrix);
+ } else {
+ fCoordChangeMatrixSet = true;
+ fCoordChangeMatrix = matrix;
+ }
+ }
class SavedCoordChange {
private:
+ bool fCoordChangeMatrixSet;
SkMatrix fCoordChangeMatrix;
GR_DEBUGCODE(mutable SkAutoTUnref<const GrEffectRef> fEffectRef;)
* restore the previous coord system (e.g. temporarily draw in device coords).
*/
void saveCoordChange(SavedCoordChange* savedCoordChange) const {
- savedCoordChange->fCoordChangeMatrix = fCoordChangeMatrix;
+ savedCoordChange->fCoordChangeMatrixSet = fCoordChangeMatrixSet;
+ if (fCoordChangeMatrixSet) {
+ savedCoordChange->fCoordChangeMatrix = fCoordChangeMatrix;
+ }
GrAssert(NULL == savedCoordChange->fEffectRef.get());
GR_DEBUGCODE(GrSafeRef(fEffectRef);)
GR_DEBUGCODE(savedCoordChange->fEffectRef.reset(fEffectRef);)
* This balances the saveCoordChange call.
*/
void restoreCoordChange(const SavedCoordChange& savedCoordChange) {
- fCoordChangeMatrix = savedCoordChange.fCoordChangeMatrix;
+ fCoordChangeMatrixSet = savedCoordChange.fCoordChangeMatrixSet;
+ if (fCoordChangeMatrixSet) {
+ fCoordChangeMatrix = savedCoordChange.fCoordChangeMatrix;
+ }
GrAssert(savedCoordChange.fEffectRef.get() == fEffectRef);
GR_DEBUGCODE(--fSavedCoordChangeCnt);
GR_DEBUGCODE(savedCoordChange.fEffectRef.reset(NULL);)
if (NULL != stage.fEffectRef) {
stage.fEffectRef->get()->incDeferredRefCounts();
fEffect = stage.fEffectRef->get();
- fCoordChangeMatrix = stage.fCoordChangeMatrix;
+ fCoordChangeMatrixSet = stage.fCoordChangeMatrixSet;
+ if (fCoordChangeMatrixSet) {
+ fCoordChangeMatrix = stage.fCoordChangeMatrix;
+ }
fVertexAttribIndices[0] = stage.fVertexAttribIndices[0];
fVertexAttribIndices[1] = stage.fVertexAttribIndices[1];
}
const GrEffectRef* oldEffectRef = stage->fEffectRef;
if (NULL != fEffect) {
stage->fEffectRef = GrEffect::CreateEffectRef(fEffect);
- stage->fCoordChangeMatrix = fCoordChangeMatrix;
+ stage->fCoordChangeMatrixSet = fCoordChangeMatrixSet;
+ if (fCoordChangeMatrixSet) {
+ stage->fCoordChangeMatrix = fCoordChangeMatrix;
+ }
stage->fVertexAttribIndices[0] = fVertexAttribIndices[0];
stage->fVertexAttribIndices[1] = fVertexAttribIndices[1];
} else {
return false;
}
+ if (fCoordChangeMatrixSet != stage.fCoordChangeMatrixSet) {
+ return false;
+ }
+
+ if (!fCoordChangeMatrixSet) {
+ return true;
+ }
+
return fCoordChangeMatrix == stage.fCoordChangeMatrix;
}
private:
const GrEffect* fEffect;
+ bool fCoordChangeMatrixSet;
SkMatrix fCoordChangeMatrix;
int fVertexAttribIndices[2];
SkDEBUGCODE(bool fInitialized;)
* Gets the matrix representing all changes of coordinate system since the GrEffect was
* installed in the stage.
*/
- const SkMatrix& getCoordChangeMatrix() const { return fCoordChangeMatrix; }
+ const SkMatrix& getCoordChangeMatrix() const {
+ if (fCoordChangeMatrixSet) {
+ return fCoordChangeMatrix;
+ } else {
+ return SkMatrix::I();
+ }
+ }
void reset() {
GrSafeSetNull(fEffectRef);
const GrEffectRef* setEffect(const GrEffectRef* EffectRef) {
GrAssert(0 == fSavedCoordChangeCnt);
GrSafeAssign(fEffectRef, EffectRef);
- fCoordChangeMatrix.reset();
+ fCoordChangeMatrixSet = false;
fVertexAttribIndices[0] = -1;
fVertexAttribIndices[1] = -1;
const GrEffectRef* setEffect(const GrEffectRef* EffectRef, int attr0, int attr1 = -1) {
GrAssert(0 == fSavedCoordChangeCnt);
GrSafeAssign(fEffectRef, EffectRef);
- fCoordChangeMatrix.reset();
+ fCoordChangeMatrixSet = false;
fVertexAttribIndices[0] = attr0;
fVertexAttribIndices[1] = attr1;
int getVertexAttribIndexCount() const { return fEffectRef->get()->numVertexAttribs(); }
private:
+ bool fCoordChangeMatrixSet;
SkMatrix fCoordChangeMatrix;
const GrEffectRef* fEffectRef;
int fVertexAttribIndices[2];