Index: src/gpu/GrDrawState.h |
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h |
index 36e2b3a2fb1f3fc3b86eb684542375b2cc5f1c1b..1f469d537efd7f4d27fcd327a10ba396188ce8dc 100644 |
--- a/src/gpu/GrDrawState.h |
+++ b/src/gpu/GrDrawState.h |
@@ -306,40 +306,41 @@ public: |
//////////////////////////////////////////////////////////////////////////// |
/** |
- * Preconcats the current view matrix and restores the previous view matrix in the destructor. |
- * Effect matrices are automatically adjusted to compensate and adjusted back in the destructor. |
+ * Sets the viewmatrix to identity and restores it in the destructor. |
+ * TODO remove vm off of drawstate |
*/ |
class AutoViewMatrixRestore : public ::SkNoncopyable { |
public: |
- AutoViewMatrixRestore() : fDrawState(NULL) {} |
- |
- AutoViewMatrixRestore(GrDrawState* ds, const SkMatrix& preconcatMatrix) { |
+ AutoViewMatrixRestore() { |
fDrawState = NULL; |
- this->set(ds, preconcatMatrix); |
} |
- ~AutoViewMatrixRestore() { this->restore(); } |
- |
- /** |
- * Can be called prior to destructor to restore the original matrix. |
- */ |
- void restore(); |
+ AutoViewMatrixRestore(GrDrawState* ds) { |
+ SkASSERT(ds); |
+ fDrawState = ds; |
+ fViewMatrix = fDrawState->fViewMatrix; |
+ fDrawState->fViewMatrix = SkMatrix::I(); |
+ } |
- void set(GrDrawState* drawState, const SkMatrix& preconcatMatrix); |
+ void setIdentity(GrDrawState* ds) { |
+ SkASSERT(ds); |
+ fDrawState = ds; |
+ fViewMatrix = fDrawState->fViewMatrix; |
+ fDrawState->fViewMatrix = SkMatrix::I(); |
+ } |
- /** Sets the draw state's matrix to identity. This can fail because the current view matrix |
- is not invertible. */ |
- bool setIdentity(GrDrawState* drawState); |
+ ~AutoViewMatrixRestore() { |
+ if (fDrawState) { |
+ fDrawState->fViewMatrix = fViewMatrix; |
+ } |
+ } |
private: |
- void doEffectCoordChanges(const SkMatrix& coordChangeMatrix); |
- |
GrDrawState* fDrawState; |
SkMatrix fViewMatrix; |
- int fNumColorStages; |
- SkAutoSTArray<8, GrFragmentStage::SavedCoordChange> fSavedCoordChanges; |
}; |
+ |
/// @} |
/////////////////////////////////////////////////////////////////////////// |