diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-11 18:53:23 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-07-11 18:53:23 +0000 |
commit | fea85ac3e31842f80493e2df8a93a28f21cd815f (patch) | |
tree | 63b9c8f1fcc0f4ce0747efabf0b1093995e5566b /include | |
parent | 19393dff0c4e44499d0c8102e6238b8544f7b6dd (diff) |
Minor refactoring to make GrAutoMatrix a nested sub-class of GrContext
http://codereview.appspot.com/6356092/
git-svn-id: http://skia.googlecode.com/svn/trunk@4549 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include')
-rw-r--r-- | include/gpu/GrContext.h | 77 |
1 files changed, 38 insertions, 39 deletions
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h index d718637e04..8f7378f664 100644 --- a/include/gpu/GrContext.h +++ b/include/gpu/GrContext.h @@ -662,6 +662,44 @@ public: GrRenderTarget* fPrevTarget; }; + /** + * Save/restore the view-matrix in the context. + */ + class AutoMatrix : GrNoncopyable { + public: + AutoMatrix() : fContext(NULL) {} + AutoMatrix(GrContext* ctx) : fContext(ctx) { + fMatrix = ctx->getMatrix(); + } + AutoMatrix(GrContext* ctx, const GrMatrix& matrix) : fContext(ctx) { + fMatrix = ctx->getMatrix(); + ctx->setMatrix(matrix); + } + void set(GrContext* ctx) { + if (NULL != fContext) { + fContext->setMatrix(fMatrix); + } + fMatrix = ctx->getMatrix(); + fContext = ctx; + } + void set(GrContext* ctx, const GrMatrix& matrix) { + if (NULL != fContext) { + fContext->setMatrix(fMatrix); + } + fMatrix = ctx->getMatrix(); + ctx->setMatrix(matrix); + fContext = ctx; + } + ~AutoMatrix() { + if (NULL != fContext) { + fContext->setMatrix(fMatrix); + } + } + + private: + GrContext* fContext; + GrMatrix fMatrix; + }; /////////////////////////////////////////////////////////////////////////// // Functions intended for internal use only. @@ -782,45 +820,6 @@ private: }; /** - * Save/restore the view-matrix in the context. - */ -class GrAutoMatrix : GrNoncopyable { -public: - GrAutoMatrix() : fContext(NULL) {} - GrAutoMatrix(GrContext* ctx) : fContext(ctx) { - fMatrix = ctx->getMatrix(); - } - GrAutoMatrix(GrContext* ctx, const GrMatrix& matrix) : fContext(ctx) { - fMatrix = ctx->getMatrix(); - ctx->setMatrix(matrix); - } - void set(GrContext* ctx) { - if (NULL != fContext) { - fContext->setMatrix(fMatrix); - } - fMatrix = ctx->getMatrix(); - fContext = ctx; - } - void set(GrContext* ctx, const GrMatrix& matrix) { - if (NULL != fContext) { - fContext->setMatrix(fMatrix); - } - fMatrix = ctx->getMatrix(); - ctx->setMatrix(matrix); - fContext = ctx; - } - ~GrAutoMatrix() { - if (NULL != fContext) { - fContext->setMatrix(fMatrix); - } - } - -private: - GrContext* fContext; - GrMatrix fMatrix; -}; - -/** * Gets and locks a scratch texture from a descriptor using * either exact or approximate criteria. Unlocks texture in * the destructor. |