Replace GrMatrix with SkMatrix.
Review URL: https://codereview.appspot.com/6814067

git-svn-id: http://skia.googlecode.com/svn/trunk@6247 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gm/texdata.cpp b/gm/texdata.cpp
index 18c600f..e36feef 100644
--- a/gm/texdata.cpp
+++ b/gm/texdata.cpp
@@ -101,7 +101,7 @@
 
                 GrPaint paint;
                 paint.setBlendFunc(kOne_GrBlendCoeff, kISA_GrBlendCoeff);
-                GrMatrix vm;
+                SkMatrix vm;
                 if (i) {
                     vm.setRotate(90 * SK_Scalar1,
                                  S * SK_Scalar1,
@@ -110,7 +110,7 @@
                     vm.reset();
                 }
                 ctx->setMatrix(vm);
-                GrMatrix tm;
+                SkMatrix tm;
                 tm = vm;
                 tm.postIDiv(2*S, 2*S);
                 paint.colorStage(0)->setEffect(SkNEW_ARGS(GrSingleTextureEffect,
diff --git a/gyp/gpu.gypi b/gyp/gpu.gypi
index 67cf603..787ffc9 100644
--- a/gyp/gpu.gypi
+++ b/gyp/gpu.gypi
@@ -23,7 +23,6 @@
       '<(skia_include_path)/gpu/GrGlyph.h',
       '<(skia_include_path)/gpu/GrInstanceCounter.h',
       '<(skia_include_path)/gpu/GrKey.h',
-      '<(skia_include_path)/gpu/GrMatrix.h',
       '<(skia_include_path)/gpu/GrNoncopyable.h',
       '<(skia_include_path)/gpu/GrPaint.h',
       '<(skia_include_path)/gpu/GrPoint.h',
@@ -80,7 +79,6 @@
       '<(skia_src_path)/gpu/GrIndexBuffer.h',
       '<(skia_src_path)/gpu/GrInOrderDrawBuffer.cpp',
       '<(skia_src_path)/gpu/GrInOrderDrawBuffer.h',
-      '<(skia_src_path)/gpu/GrMatrix.cpp',
       '<(skia_src_path)/gpu/GrMemory.cpp',
       '<(skia_src_path)/gpu/GrMemoryPool.cpp',
       '<(skia_src_path)/gpu/GrMemoryPool.h',
diff --git a/include/gpu/GrContext.h b/include/gpu/GrContext.h
index 14c550c..08de94f 100644
--- a/include/gpu/GrContext.h
+++ b/include/gpu/GrContext.h
@@ -13,7 +13,7 @@
 #include "GrColor.h"
 #include "GrAARectRenderer.h"
 #include "GrClipData.h"
-#include "GrMatrix.h"
+#include "SkMatrix.h"
 #include "GrPaint.h"
 // not strictly needed but requires WK change in LayerTextureUpdaterCanvas to
 // remove.
@@ -322,13 +322,13 @@
      * Gets the current transformation matrix.
      * @return the current matrix.
      */
-    const GrMatrix& getMatrix() const;
+    const SkMatrix& getMatrix() const;
 
     /**
      * Sets the transformation matrix.
      * @param m the matrix to set.
      */
-    void setMatrix(const GrMatrix& m);
+    void setMatrix(const SkMatrix& m);
 
     /**
      * Sets the current transformation matrix to identity.
@@ -340,7 +340,7 @@
      * current matrix.
      * @param m the matrix to concat.
      */
-    void concatMatrix(const GrMatrix& m) const;
+    void concatMatrix(const SkMatrix& m) const;
 
 
     ///////////////////////////////////////////////////////////////////////////
@@ -389,7 +389,7 @@
     void drawRect(const GrPaint& paint,
                   const GrRect&,
                   SkScalar strokeWidth = -1,
-                  const GrMatrix* matrix = NULL);
+                  const SkMatrix* matrix = NULL);
 
     /**
      * Maps a rect of paint coordinates onto the a rect of destination
@@ -409,8 +409,8 @@
     void drawRectToRect(const GrPaint& paint,
                         const GrRect& dstRect,
                         const GrRect& srcRect,
-                        const GrMatrix* dstMatrix = NULL,
-                        const GrMatrix* srcMatrix = NULL);
+                        const SkMatrix* dstMatrix = NULL,
+                        const SkMatrix* srcMatrix = NULL);
 
     /**
      * Draws a path.
@@ -693,7 +693,7 @@
         /**
          * Initializes by pre-concat'ing the context's current matrix with the preConcat param.
          */
-        void setPreConcat(GrContext* context, const GrMatrix& preConcat, GrPaint* paint = NULL) {
+        void setPreConcat(GrContext* context, const SkMatrix& preConcat, GrPaint* paint = NULL) {
             GrAssert(NULL != context);
 
             this->restore();
@@ -727,7 +727,7 @@
          * Replaces the context's matrix with a new matrix. Returns false if the inverse matrix is
          * required to update a paint but the matrix cannot be inverted.
          */
-        bool set(GrContext* context, const GrMatrix& newMatrix, GrPaint* paint = NULL) {
+        bool set(GrContext* context, const SkMatrix& newMatrix, GrPaint* paint = NULL) {
             if (NULL != paint) {
                 if (!this->setIdentity(context, paint)) {
                     return false;
@@ -749,7 +749,7 @@
          * made, not the matrix at the time AutoMatrix was first initialized. In other words, this
          * performs an incremental update of the paint.
          */
-        void preConcat(const GrMatrix& preConcat, GrPaint* paint = NULL) {
+        void preConcat(const SkMatrix& preConcat, GrPaint* paint = NULL) {
             if (NULL != paint) {
                 paint->sourceCoordChange(preConcat);
             }
@@ -774,7 +774,7 @@
 
     private:
         GrContext*  fContext;
-        GrMatrix    fMatrix;
+        SkMatrix    fMatrix;
     };
 
     class AutoClip : GrNoncopyable {
@@ -930,11 +930,11 @@
 
     bool installPMToUPMEffect(GrTexture* texture,
                               bool swapRAndB,
-                              const GrMatrix& matrix,
+                              const SkMatrix& matrix,
                               GrEffectStage* stage);
     bool installUPMToPMEffect(GrTexture* texture,
                               bool swapRAndB,
-                              const GrMatrix& matrix,
+                              const SkMatrix& matrix,
                               GrEffectStage* stage);
 
     typedef GrRefCnt INHERITED;
diff --git a/include/gpu/GrEffectStage.h b/include/gpu/GrEffectStage.h
index 5cd0af3..f62faee 100644
--- a/include/gpu/GrEffectStage.h
+++ b/include/gpu/GrEffectStage.h
@@ -13,7 +13,7 @@
 
 #include "GrBackendEffectFactory.h"
 #include "GrEffect.h"
-#include "GrMatrix.h"
+#include "SkMatrix.h"
 #include "GrTypes.h"
 
 #include "SkShader.h"
@@ -66,11 +66,11 @@
      *
      * @param matrix    The transformation from the old coord system to the new one.
      */
-    void preConcatCoordChange(const GrMatrix& matrix) { fCoordChangeMatrix.preConcat(matrix); }
+    void preConcatCoordChange(const SkMatrix& matrix) { fCoordChangeMatrix.preConcat(matrix); }
 
     class SavedCoordChange {
     private:
-        GrMatrix fCoordChangeMatrix;
+        SkMatrix fCoordChangeMatrix;
         GR_DEBUGCODE(mutable SkAutoTUnref<const GrEffect> fEffect;)
 
         friend class GrEffectStage;
@@ -103,13 +103,13 @@
     /**
      * Gets the texture matrix. This is will be removed soon and be managed by GrEffect.
      */
-    const GrMatrix& getMatrix() const { return fMatrix; }
+    const SkMatrix& getMatrix() const { return fMatrix; }
 
     /**
      * Gets the matrix to apply at draw time. This is the original texture matrix combined with
      * any coord system changes. This will be removed when the matrix is managed by GrEffect.
      */
-    void getTotalMatrix(GrMatrix* matrix) const {
+    void getTotalMatrix(SkMatrix* matrix) const {
         *matrix = fMatrix;
         matrix->preConcat(fCoordChangeMatrix);
     }
@@ -118,7 +118,7 @@
      * Gets the matrix representing all changes of coordinate system since the GrEffect was
      * installed in the stage.
      */
-    const GrMatrix& getCoordChangeMatrix() const { return fCoordChangeMatrix; }
+    const SkMatrix& getCoordChangeMatrix() const { return fCoordChangeMatrix; }
 
     void reset() {
         GrSafeSetNull(fEffect);
@@ -132,7 +132,7 @@
         return effect;
     }
 
-    const GrEffect* setEffect(const GrEffect* effect, const GrMatrix& matrix) {
+    const GrEffect* setEffect(const GrEffect* effect, const SkMatrix& matrix) {
         GrAssert(0 == fSavedCoordChangeCnt);
         GrSafeAssign(fEffect, effect);
         fMatrix = matrix;
@@ -143,8 +143,8 @@
     const GrEffect* getEffect() const { return fEffect; }
 
 private:
-    GrMatrix            fCoordChangeMatrix;
-    GrMatrix            fMatrix; // TODO: remove this, store in GrEffect
+    SkMatrix            fCoordChangeMatrix;
+    SkMatrix            fMatrix; // TODO: remove this, store in GrEffect
     const GrEffect*     fEffect;
 
     GR_DEBUGCODE(mutable int fSavedCoordChangeCnt;)
diff --git a/include/gpu/GrMatrix.h b/include/gpu/GrMatrix.h
deleted file mode 100644
index 055680a..0000000
--- a/include/gpu/GrMatrix.h
+++ /dev/null
@@ -1,19 +0,0 @@
-
-/*
- * Copyright 2010 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-
-
-#ifndef GrMatrix_DEFINED
-#define GrMatrix_DEFINED
-
-#include "GrRect.h"
-#include "SkMatrix.h"
-
-typedef SkMatrix GrMatrix;
-
-#endif
diff --git a/include/gpu/GrPaint.h b/include/gpu/GrPaint.h
index efafd7f..0fd42f9 100644
--- a/include/gpu/GrPaint.h
+++ b/include/gpu/GrPaint.h
@@ -174,8 +174,8 @@
      * transformation from the old coord system to the new coord system. Returns false if the matrix
      * cannot be inverted.
      */
-    bool sourceCoordChangeByInverse(const GrMatrix& preConcatInverse) {
-        GrMatrix inv;
+    bool sourceCoordChangeByInverse(const SkMatrix& preConcatInverse) {
+        SkMatrix inv;
         bool computed = false;
         for (int i = 0; i < kMaxColorStages; ++i) {
             if (this->isColorStageEnabled(i)) {
@@ -204,7 +204,7 @@
      * Called when the source coord system is changing. preConcat gives the transformation from the
      * old coord system to the new coord system.
      */
-    void sourceCoordChange(const GrMatrix& preConcat) {
+    void sourceCoordChange(const SkMatrix& preConcat) {
         for (int i = 0; i < kMaxColorStages; ++i) {
             if (this->isColorStageEnabled(i)) {
                 fColorStages[i].preConcatCoordChange(preConcat);
diff --git a/include/gpu/GrTexture.h b/include/gpu/GrTexture.h
index 65950a6..d41be11 100644
--- a/include/gpu/GrTexture.h
+++ b/include/gpu/GrTexture.h
@@ -151,8 +151,8 @@
     , fRenderTarget(NULL) {
 
         // only make sense if alloc size is pow2
-        fShiftFixedX = 31 - Gr_clz(fDesc.fWidth);
-        fShiftFixedY = 31 - Gr_clz(fDesc.fHeight);
+        fShiftFixedX = 31 - SkCLZ(fDesc.fWidth);
+        fShiftFixedY = 31 - SkCLZ(fDesc.fHeight);
     }
 
     // GrResource overrides
diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h
index 9723868..3c730df 100644
--- a/include/gpu/GrTypes.h
+++ b/include/gpu/GrTypes.h
@@ -13,6 +13,7 @@
 
 #include "SkTypes.h"
 #include "GrConfig.h"
+#include "SkMath.h"
 
 ////////////////////////////////////////////////////////////////////////////////
 
@@ -137,11 +138,6 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 /**
- *  Return the number of leading zeros in n
- */
-extern int Gr_clz(uint32_t n);
-
-/**
  *  Return true if n is a power of 2
  */
 static inline bool GrIsPow2(unsigned n) {
@@ -152,12 +148,12 @@
  *  Return the next power of 2 >= n.
  */
 static inline uint32_t GrNextPow2(uint32_t n) {
-    return n ? (1 << (32 - Gr_clz(n - 1))) : 1;
+    return n ? (1 << (32 - SkCLZ(n - 1))) : 1;
 }
 
 static inline int GrNextPow2(int n) {
     GrAssert(n >= 0); // this impl only works for non-neg.
-    return n ? (1 << (32 - Gr_clz(n - 1))) : 1;
+    return n ? (1 << (32 - SkCLZ(n - 1))) : 1;
 }
 
 ///////////////////////////////////////////////////////////////////////////////
diff --git a/src/effects/SkBlendImageFilter.cpp b/src/effects/SkBlendImageFilter.cpp
index 9ce5726..c9d27b6 100644
--- a/src/effects/SkBlendImageFilter.cpp
+++ b/src/effects/SkBlendImageFilter.cpp
@@ -208,7 +208,7 @@
     GrContext::AutoRenderTarget art(context, dst->asRenderTarget());
     GrContext::AutoClip ac(context, rect);
 
-    GrMatrix backgroundTexMatrix, foregroundTexMatrix;
+    SkMatrix backgroundTexMatrix, foregroundTexMatrix;
     backgroundTexMatrix.setIDiv(background->width(), background->height());
     foregroundTexMatrix.setIDiv(foreground->width(), foreground->height());
     GrPaint paint;
diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp
index 0e6a318..2c88f53 100644
--- a/src/effects/SkMorphologyImageFilter.cpp
+++ b/src/effects/SkMorphologyImageFilter.cpp
@@ -420,7 +420,7 @@
                            int radius,
                            GrMorphologyEffect::MorphologyType morphType,
                            Gr1DKernelEffect::Direction direction) {
-    GrMatrix sampleM;
+    SkMatrix sampleM;
     sampleM.setIDiv(texture->width(), texture->height());
     GrPaint paint;
     paint.colorStage(0)->setEffect(SkNEW_ARGS(GrMorphologyEffect, (texture, direction, radius, morphType)), sampleM)->unref();
diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp
index 3f4db39..4ac6163 100644
--- a/src/gpu/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/GrAAConvexPathRenderer.cpp
@@ -200,7 +200,7 @@
     }
 }
 
-inline bool get_direction(const SkPath& path, const GrMatrix& m, SkPath::Direction* dir) {
+inline bool get_direction(const SkPath& path, const SkMatrix& m, SkPath::Direction* dir) {
     if (!path.cheapComputeDirection(dir)) {
         return false;
     }
@@ -217,7 +217,7 @@
 }
 
 bool get_segments(const SkPath& path,
-                  const GrMatrix& m,
+                  const SkMatrix& m,
                   SegmentArray* segments,
                   SkPoint* fanPt,
                   int* vCount,
@@ -458,7 +458,7 @@
     if (!adcd.succeeded()) {
         return false;
     }
-    const GrMatrix* vm = &adcd.getOriginalMatrix();
+    const SkMatrix* vm = &adcd.getOriginalMatrix();
 
     GrVertexLayout layout = 0;
     layout |= GrDrawTarget::kEdge_VertexLayoutBit;
@@ -470,7 +470,7 @@
     if (vm->hasPerspective()) {
         origPath.transform(*vm, &tmpPath);
         path = &tmpPath;
-        vm = &GrMatrix::I();
+        vm = &SkMatrix::I();
     }
 
     QuadVertex *verts;
diff --git a/src/gpu/GrAAHairLinePathRenderer.cpp b/src/gpu/GrAAHairLinePathRenderer.cpp
index 5fd2462..cd3f774 100644
--- a/src/gpu/GrAAHairLinePathRenderer.cpp
+++ b/src/gpu/GrAAHairLinePathRenderer.cpp
@@ -352,8 +352,8 @@
     result->fY = SkScalarMul(result->fY, wInv);
 }
 
-void bloat_quad(const SkPoint qpts[3], const GrMatrix* toDevice,
-                const GrMatrix* toSrc, Vertex verts[kVertsPerQuad]) {
+void bloat_quad(const SkPoint qpts[3], const SkMatrix* toDevice,
+                const SkMatrix* toSrc, Vertex verts[kVertsPerQuad]) {
     GrAssert(!toDevice == !toSrc);
     // original quad is specified by tri a,b,c
     SkPoint a = qpts[0];
@@ -430,8 +430,8 @@
 
 void add_quads(const SkPoint p[3],
                int subdiv,
-               const GrMatrix* toDevice,
-               const GrMatrix* toSrc,
+               const SkMatrix* toDevice,
+               const SkMatrix* toSrc,
                Vertex** vert) {
     GrAssert(subdiv >= 0);
     if (subdiv) {
@@ -502,7 +502,7 @@
                                              &devClipBounds);
 
     GrVertexLayout layout = GrDrawTarget::kEdge_VertexLayoutBit;
-    GrMatrix viewM = drawState.getViewMatrix();
+    SkMatrix viewM = drawState.getViewMatrix();
 
     PREALLOC_PTARRAY(128) lines;
     PREALLOC_PTARRAY(128) quads;
@@ -521,9 +521,9 @@
 
     Vertex* verts = reinterpret_cast<Vertex*>(arg->vertices());
 
-    const GrMatrix* toDevice = NULL;
-    const GrMatrix* toSrc = NULL;
-    GrMatrix ivm;
+    const SkMatrix* toDevice = NULL;
+    const SkMatrix* toSrc = NULL;
+    SkMatrix ivm;
 
     if (viewM.hasPerspective()) {
         if (viewM.invert(&ivm)) {
diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp
index c1effd7..2be92dc 100644
--- a/src/gpu/GrClipMaskManager.cpp
+++ b/src/gpu/GrClipMaskManager.cpp
@@ -35,7 +35,7 @@
 
     static const int kMaskStage = GrPaint::kTotalStages+1;
 
-    GrMatrix mat;
+    SkMatrix mat;
     mat.setIDiv(result->width(), result->height());
     mat.preTranslate(SkIntToScalar(-devBound.fLeft),
                      SkIntToScalar(-devBound.fTop));
@@ -491,7 +491,7 @@
     // no AA here since it is encoded in the texture
     drawState->setRenderTarget(target->asRenderTarget());
 
-    GrMatrix sampleM;
+    SkMatrix sampleM;
     sampleM.setIDiv(texture->width(), texture->height());
 
     drawState->createTextureEffect(0, texture, sampleM);
@@ -1121,7 +1121,7 @@
 
     GrSWMaskHelper helper(this->getContext());
 
-    GrMatrix matrix;
+    SkMatrix matrix;
     matrix.setTranslate(SkIntToScalar(-clipDataIn.fOrigin.fX),
                         SkIntToScalar(-clipDataIn.fOrigin.fY));
     helper.init(*devResultBounds, &matrix);
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 3b2e752..2ad5cf8 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -199,7 +199,7 @@
     GrDrawTarget::AutoStateRestore asr(target, GrDrawTarget::kReset_ASRInit);
     GrDrawState* drawState = target->drawState();
     drawState->setRenderTarget(rt);
-    GrMatrix sampleM;
+    SkMatrix sampleM;
     sampleM.setIDiv(texture->width(), texture->height());
     SkAutoTUnref<GrConvolutionEffect> conv(SkNEW_ARGS(GrConvolutionEffect,
                                                       (texture, direction, radius,
@@ -312,7 +312,7 @@
         // texels in the resampled image are copies of texels from
         // the original.
         GrTextureParams params(SkShader::kClamp_TileMode, needsFiltering);
-        drawState->createTextureEffect(0, clampedTexture, GrMatrix::I(), params);
+        drawState->createTextureEffect(0, clampedTexture, SkMatrix::I(), params);
 
         static const GrVertexLayout layout =
                             GrDrawTarget::StageTexCoordVertexLayoutBit(0,0);
@@ -577,7 +577,7 @@
     r.setLTRB(0, 0,
               SkIntToScalar(getRenderTarget()->width()),
               SkIntToScalar(getRenderTarget()->height()));
-    GrMatrix inverse;
+    SkMatrix inverse;
     SkTCopyOnFirstWrite<GrPaint> paint(origPaint);
     AutoMatrix am;
 
@@ -646,8 +646,8 @@
 static bool apply_aa_to_rect(GrDrawTarget* target,
                              const GrRect& rect,
                              SkScalar width,
-                             const GrMatrix* matrix,
-                             GrMatrix* combinedMatrix,
+                             const SkMatrix* matrix,
+                             SkMatrix* combinedMatrix,
                              GrRect* devRect,
                              bool* useVertexCoverage) {
     // we use a simple coverage ramp to do aa on axis-aligned rects
@@ -706,14 +706,14 @@
 void GrContext::drawRect(const GrPaint& paint,
                          const GrRect& rect,
                          SkScalar width,
-                         const GrMatrix* matrix) {
+                         const SkMatrix* matrix) {
     SK_TRACE_EVENT0("GrContext::drawRect");
 
     GrDrawTarget* target = this->prepareToDraw(&paint, DEFAULT_BUFFERING);
     GrDrawState::AutoStageDisable atr(fDrawState);
 
     GrRect devRect = rect;
-    GrMatrix combinedMatrix;
+    SkMatrix combinedMatrix;
     bool useVertexCoverage;
     bool needAA = paint.isAntiAlias() &&
                   !this->getRenderTarget()->isMultisampled();
@@ -792,10 +792,10 @@
             }
             target->setVertexSourceToBuffer(0, sqVB);
             GrDrawState* drawState = target->drawState();
-            GrMatrix m;
+            SkMatrix m;
             m.setAll(rect.width(),    0,             rect.fLeft,
                         0,            rect.height(), rect.fTop,
-                        0,            0,             GrMatrix::I()[8]);
+                        0,            0,             SkMatrix::I()[8]);
 
             if (NULL != matrix) {
                 m.postConcat(*matrix);
@@ -812,8 +812,8 @@
 void GrContext::drawRectToRect(const GrPaint& paint,
                                const GrRect& dstRect,
                                const GrRect& srcRect,
-                               const GrMatrix* dstMatrix,
-                               const GrMatrix* srcMatrix) {
+                               const SkMatrix* dstMatrix,
+                               const SkMatrix* srcMatrix) {
     SK_TRACE_EVENT0("GrContext::drawRectToRect");
 
     // srcRect refers to paint's first color stage
@@ -828,11 +828,11 @@
     GrDrawState::AutoStageDisable atr(fDrawState);
     GrDrawState* drawState = target->drawState();
 
-    GrMatrix m;
+    SkMatrix m;
 
     m.setAll(dstRect.width(), 0,                dstRect.fLeft,
              0,               dstRect.height(), dstRect.fTop,
-             0,               0,                GrMatrix::I()[8]);
+             0,               0,                SkMatrix::I()[8]);
     if (NULL != dstMatrix) {
         m.postConcat(*dstMatrix);
     }
@@ -844,7 +844,7 @@
 
     m.setAll(srcRect.width(), 0,                srcRect.fLeft,
              0,               srcRect.height(), srcRect.fTop,
-             0,               0,                GrMatrix::I()[8]);
+             0,               0,                SkMatrix::I()[8]);
     if (NULL != srcMatrix) {
         m.postConcat(*srcMatrix);
     }
@@ -862,7 +862,7 @@
     GrDrawState::AutoStageDisable atr(fDrawState);
 
     const GrRect* srcRects[GrDrawState::kNumStages] = {NULL};
-    const GrMatrix* srcMatrices[GrDrawState::kNumStages] = {NULL};
+    const SkMatrix* srcMatrices[GrDrawState::kNumStages] = {NULL};
     srcRects[0] = &srcRect;
     srcMatrices[0] = srcMatrix;
 
@@ -998,7 +998,7 @@
 
     GrDrawState* drawState = target->drawState();
     GrDrawState::AutoStageDisable atr(fDrawState);
-    const GrMatrix vm = drawState->getViewMatrix();
+    const SkMatrix vm = drawState->getViewMatrix();
 
     const GrRenderTarget* rt = drawState->getRenderTarget();
     if (NULL == rt) {
@@ -1309,11 +1309,11 @@
         if (texture) {
             GrEffectStage stage;
             // compute a matrix to perform the draw
-            GrMatrix textureMatrix;
+            SkMatrix textureMatrix;
             if (flipY) {
                 textureMatrix.setTranslate(SK_Scalar1 * left,
                                     SK_Scalar1 * (top + height));
-                textureMatrix.set(GrMatrix::kMScaleY, -SK_Scalar1);
+                textureMatrix.set(SkMatrix::kMScaleY, -SK_Scalar1);
             } else {
                 textureMatrix.setTranslate(SK_Scalar1 *left, SK_Scalar1 *top);
             }
@@ -1442,7 +1442,7 @@
     GrDrawTarget::AutoStateRestore asr(fGpu, GrDrawTarget::kReset_ASRInit);
     GrDrawState* drawState = fGpu->drawState();
     drawState->setRenderTarget(dst);
-    GrMatrix sampleM;
+    SkMatrix sampleM;
     sampleM.setIDiv(src->width(), src->height());
     drawState->createTextureEffect(0, src, sampleM);
     SkRect rect = SkRect::MakeXYWH(0, 0,
@@ -1510,7 +1510,7 @@
     }
 
     GrEffectStage stage;
-    GrMatrix textureMatrix;
+    SkMatrix textureMatrix;
     textureMatrix.setIDiv(texture->width(), texture->height());
 
     // allocate a tmp buffer and sw convert the pixels to premul
@@ -1560,7 +1560,7 @@
     GrDrawState* drawState = fGpu->drawState();
     *drawState->stage(0) = stage;
 
-    GrMatrix matrix;
+    SkMatrix matrix;
     matrix.setTranslate(SkIntToScalar(left), SkIntToScalar(top));
     drawState->setViewMatrix(matrix);
     drawState->setRenderTarget(target);
@@ -1645,11 +1645,11 @@
     return fGpu->isConfigRenderable(config);
 }
 
-const GrMatrix& GrContext::getMatrix() const {
+const SkMatrix& GrContext::getMatrix() const {
     return fDrawState->getViewMatrix();
 }
 
-void GrContext::setMatrix(const GrMatrix& m) {
+void GrContext::setMatrix(const SkMatrix& m) {
     fDrawState->setViewMatrix(m);
 }
 
@@ -1657,7 +1657,7 @@
     fDrawState->viewMatrix()->reset();
 }
 
-void GrContext::concatMatrix(const GrMatrix& m) const {
+void GrContext::concatMatrix(const SkMatrix& m) const {
     fDrawState->preConcatViewMatrix(m);
 }
 
@@ -1748,7 +1748,7 @@
 
 bool GrContext::installPMToUPMEffect(GrTexture* texture,
                                      bool swapRAndB,
-                                     const GrMatrix& matrix,
+                                     const SkMatrix& matrix,
                                      GrEffectStage* stage) {
     if (!fDidTestPMConversions) {
         test_pm_conversions(this, &fPMToUPMConversion, &fUPMToPMConversion);
@@ -1766,7 +1766,7 @@
 
 bool GrContext::installUPMToPMEffect(GrTexture* texture,
                                      bool swapRAndB,
-                                     const GrMatrix& matrix,
+                                     const SkMatrix& matrix,
                                      GrEffectStage* stage) {
     if (!fDidTestPMConversions) {
         test_pm_conversions(this, &fPMToUPMConversion, &fUPMToPMConversion);
@@ -1828,7 +1828,7 @@
     paint.reset();
 
     for (int i = 1; i < scaleFactorX || i < scaleFactorY; i *= 2) {
-        GrMatrix matrix;
+        SkMatrix matrix;
         matrix.setIDiv(srcTexture->width(), srcTexture->height());
         this->setRenderTarget(dstTexture->asRenderTarget());
         SkRect dstRect(srcRect);
@@ -1889,7 +1889,7 @@
         clearRect = SkIRect::MakeXYWH(srcIRect.fRight, srcIRect.fTop,
                                       1, srcIRect.height());
         this->clear(&clearRect, 0x0);
-        GrMatrix matrix;
+        SkMatrix matrix;
         // FIXME:  This should be mitchell, not bilinear.
         matrix.setIDiv(srcTexture->width(), srcTexture->height());
         this->setRenderTarget(dstTexture->asRenderTarget());
diff --git a/src/gpu/GrDefaultPathRenderer.cpp b/src/gpu/GrDefaultPathRenderer.cpp
index dfe7ee4..521afd3 100644
--- a/src/gpu/GrDefaultPathRenderer.cpp
+++ b/src/gpu/GrDefaultPathRenderer.cpp
@@ -320,7 +320,7 @@
                                              GrDrawTarget* target,
                                              bool stencilOnly) {
 
-    GrMatrix viewM = target->getDrawState().getViewMatrix();
+    SkMatrix viewM = target->getDrawState().getViewMatrix();
     SkScalar tol = SK_Scalar1;
     tol = GrPathUtils::scaleToleranceToSrc(tol, viewM, path.getBounds());
 
@@ -457,7 +457,7 @@
                 bounds.setLTRB(0, 0,
                                SkIntToScalar(drawState->getRenderTarget()->width()),
                                SkIntToScalar(drawState->getRenderTarget()->height()));
-                GrMatrix vmi;
+                SkMatrix vmi;
                 // mapRect through persp matrix may not be correct
                 if (!drawState->getViewMatrix().hasPerspective() &&
                     drawState->getViewInverse(&vmi)) {
diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp
index a78bcc0..bdb1230 100644
--- a/src/gpu/GrDrawState.cpp
+++ b/src/gpu/GrDrawState.cpp
@@ -56,7 +56,7 @@
 }
 
 void GrDrawState::AutoViewMatrixRestore::set(GrDrawState* drawState,
-                                             const GrMatrix& preconcatMatrix,
+                                             const SkMatrix& preconcatMatrix,
                                              uint32_t explicitCoordStageMask) {
     this->restore();
 
@@ -104,7 +104,7 @@
 
     fViewMatrix = drawState->getViewMatrix();
     fRestoreMask = 0;
-    GrMatrix invVM;
+    SkMatrix invVM;
     bool inverted = false;
 
     for (int s = 0; s < GrDrawState::kNumStages; ++s) {
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index 1a96f18..3b0bff9 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -10,7 +10,7 @@
 
 #include "GrBackendEffectFactory.h"
 #include "GrColor.h"
-#include "GrMatrix.h"
+#include "SkMatrix.h"
 #include "GrRefCnt.h"
 #include "GrEffectStage.h"
 #include "GrStencil.h"
@@ -196,14 +196,14 @@
         GrAssert(!this->getStage(stageIdx).getEffect());
         this->stage(stageIdx)->setEffect(SkNEW_ARGS(GrSingleTextureEffect, (texture)))->unref();
     }
-    void createTextureEffect(int stageIdx, GrTexture* texture, const GrMatrix& matrix) {
+    void createTextureEffect(int stageIdx, GrTexture* texture, const SkMatrix& matrix) {
         GrAssert(!this->getStage(stageIdx).getEffect());
         GrEffect* effect = SkNEW_ARGS(GrSingleTextureEffect, (texture, matrix));
         this->stage(stageIdx)->setEffect(effect)->unref();
     }
     void createTextureEffect(int stageIdx,
                              GrTexture* texture,
-                             const GrMatrix& matrix,
+                             const SkMatrix& matrix,
                              const GrTextureParams& params) {
         GrAssert(!this->getStage(stageIdx).getEffect());
         GrEffect* effect = SkNEW_ARGS(GrSingleTextureEffect, (texture, matrix, params));
@@ -271,7 +271,7 @@
      * Called when the source coord system is changing. preConcat gives the transformation from the
      * old coord system to the new coord system.
      */
-    void preConcatStageMatrices(const GrMatrix& preConcat) {
+    void preConcatStageMatrices(const SkMatrix& preConcat) {
         for (int i = 0; i < kNumStages; ++i) {
             if (this->isStageEnabled(i)) {
                 fStages[i].preConcatCoordChange(preConcat);
@@ -284,8 +284,8 @@
      * transformation from the old coord system to the new coord system. Returns false if the matrix
      * cannot be inverted.
      */
-    bool preConcatStageMatricesWithInverse(const GrMatrix& preConcatInverse) {
-        GrMatrix inv;
+    bool preConcatStageMatricesWithInverse(const SkMatrix& preConcatInverse) {
+        SkMatrix inv;
         bool computed = false;
         for (int i = 0; i < kNumStages; ++i) {
             if (this->isStageEnabled(i)) {
@@ -415,12 +415,12 @@
      * fully covers the render target. (w and h are the width and height of the
      * the rendertarget.)
      */
-    void setViewMatrix(const GrMatrix& m) { fViewMatrix = m; }
+    void setViewMatrix(const SkMatrix& m) { fViewMatrix = m; }
 
     /**
      * Gets a writable pointer to the view matrix.
      */
-    GrMatrix* viewMatrix() { return &fViewMatrix; }
+    SkMatrix* viewMatrix() { return &fViewMatrix; }
 
     /**
      *  Multiplies the current view matrix by a matrix
@@ -432,7 +432,7 @@
      *
      *  @param m the matrix used to modify the view matrix.
      */
-    void preConcatViewMatrix(const GrMatrix& m) { fViewMatrix.preConcat(m); }
+    void preConcatViewMatrix(const SkMatrix& m) { fViewMatrix.preConcat(m); }
 
     /**
      *  Multiplies the current view matrix by a matrix
@@ -444,13 +444,13 @@
      *
      *  @param m the matrix used to modify the view matrix.
      */
-    void postConcatViewMatrix(const GrMatrix& m) { fViewMatrix.postConcat(m); }
+    void postConcatViewMatrix(const SkMatrix& m) { fViewMatrix.postConcat(m); }
 
     /**
      * Retrieves the current view matrix
      * @return the current view matrix.
      */
-    const GrMatrix& getViewMatrix() const { return fViewMatrix; }
+    const SkMatrix& getViewMatrix() const { return fViewMatrix; }
 
     /**
      *  Retrieves the inverse of the current view matrix.
@@ -461,10 +461,10 @@
      *
      * @param matrix if not null, will receive a copy of the current inverse.
      */
-    bool getViewInverse(GrMatrix* matrix) const {
+    bool getViewInverse(SkMatrix* matrix) const {
         // TODO: determine whether we really need to leave matrix unmodified
         // at call sites when inversion fails.
-        GrMatrix inverse;
+        SkMatrix inverse;
         if (fViewMatrix.invert(&inverse)) {
             if (matrix) {
                 *matrix = inverse;
@@ -485,7 +485,7 @@
         AutoViewMatrixRestore() : fDrawState(NULL) {}
 
         AutoViewMatrixRestore(GrDrawState* ds,
-                              const GrMatrix& preconcatMatrix,
+                              const SkMatrix& preconcatMatrix,
                               uint32_t explicitCoordStageMask = 0) {
             fDrawState = NULL;
             this->set(ds, preconcatMatrix, explicitCoordStageMask);
@@ -499,14 +499,14 @@
         void restore();
 
         void set(GrDrawState* drawState,
-                 const GrMatrix& preconcatMatrix,
+                 const SkMatrix& preconcatMatrix,
                  uint32_t explicitCoordStageMask = 0);
 
         bool isSet() const { return NULL != fDrawState; }
 
     private:
         GrDrawState*                        fDrawState;
-        GrMatrix                            fViewMatrix;
+        SkMatrix                            fViewMatrix;
         GrEffectStage::SavedCoordChange     fSavedCoordChanges[GrDrawState::kNumStages];
         uint32_t                            fRestoreMask;
     };
@@ -548,7 +548,7 @@
          * Returns the matrix that was set previously set on the drawState. This is only valid
          * if succeeded returns true.
          */
-        const GrMatrix& getOriginalMatrix() const {
+        const SkMatrix& getOriginalMatrix() const {
             GrAssert(this->succeeded());
             return fViewMatrix;
         }
@@ -560,7 +560,7 @@
 
     private:
         GrDrawState*                        fDrawState;
-        GrMatrix                            fViewMatrix;
+        SkMatrix                            fViewMatrix;
         GrEffectStage::SavedCoordChange     fSavedCoordChanges[GrDrawState::kNumStages];
         uint32_t                            fRestoreMask;
     };
@@ -894,7 +894,7 @@
 
     // These fields are roughly sorted by decreasing likelihood of being different in op==
     GrColor             fColor;
-    GrMatrix            fViewMatrix;
+    SkMatrix            fViewMatrix;
     GrRenderTarget*     fRenderTarget;
     GrBlendCoeff        fSrcBlend;
     GrBlendCoeff        fDstBlend;
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index f652597..8fa39d2 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -323,7 +323,7 @@
         // bits are ordered T0S0, T0S1, T0S2, ..., T1S0, T1S1, ...
         // and start at bit 0.
         GR_STATIC_ASSERT(sizeof(GrVertexLayout) <= sizeof(uint32_t));
-        return (32 - Gr_clz(bit) - 1) / GrDrawState::kNumStages;
+        return (32 - SkCLZ(bit) - 1) / GrDrawState::kNumStages;
     }
     return -1;
 }
@@ -1027,9 +1027,9 @@
 ////////////////////////////////////////////////////////////////////////////////
 
 void GrDrawTarget::drawRect(const GrRect& rect,
-                            const GrMatrix* matrix,
+                            const SkMatrix* matrix,
                             const GrRect* srcRects[],
-                            const GrMatrix* srcMatrices[]) {
+                            const SkMatrix* srcMatrices[]) {
     GrVertexLayout layout = GetRectVertexLayout(srcRects);
 
     AutoReleaseGeometry geo(this, layout, 4, 0);
@@ -1070,9 +1070,9 @@
 // Note: the color parameter will only be used when kColor_VertexLayoutBit
 // is present in 'layout'
 void GrDrawTarget::SetRectVertices(const GrRect& rect,
-                                   const GrMatrix* matrix,
+                                   const SkMatrix* matrix,
                                    const GrRect* srcRects[],
-                                   const GrMatrix* srcMatrices[],
+                                   const SkMatrix* srcMatrices[],
                                    GrColor color,
                                    GrVertexLayout layout,
                                    void* vertices) {
diff --git a/src/gpu/GrDrawTarget.h b/src/gpu/GrDrawTarget.h
index 3a9813b..4d652f6 100644
--- a/src/gpu/GrDrawTarget.h
+++ b/src/gpu/GrDrawTarget.h
@@ -13,7 +13,7 @@
 
 #include "GrDrawState.h"
 #include "GrIndexBuffer.h"
-#include "GrMatrix.h"
+#include "SkMatrix.h"
 #include "GrRefCnt.h"
 #include "GrTemplates.h"
 
@@ -476,9 +476,9 @@
      *                      srcMatrices are desired.
      */
     virtual void drawRect(const GrRect& rect,
-                          const GrMatrix* matrix,
+                          const SkMatrix* matrix,
                           const GrRect* srcRects[],
-                          const GrMatrix* srcMatrices[]);
+                          const SkMatrix* srcMatrices[]);
 
     /**
      * This call is used to draw multiple instances of some geometry with a
@@ -518,7 +518,7 @@
      * matrices.
      */
     void drawSimpleRect(const GrRect& rect,
-                        const GrMatrix* matrix) {
+                        const SkMatrix* matrix) {
          drawRect(rect, matrix, NULL, NULL);
     }
 
@@ -992,9 +992,9 @@
     static GrVertexLayout GetRectVertexLayout(const GrRect* srcRects[]);
 
     static void SetRectVertices(const GrRect& rect,
-                                const GrMatrix* matrix,
+                                const SkMatrix* matrix,
                                 const GrRect* srcRects[],
-                                const GrMatrix* srcMatrices[],
+                                const SkMatrix* srcMatrices[],
                                 GrColor color,
                                 GrVertexLayout layout,
                                 void* vertices);
diff --git a/src/gpu/GrInOrderDrawBuffer.cpp b/src/gpu/GrInOrderDrawBuffer.cpp
index 2f943ae..b2f7963 100644
--- a/src/gpu/GrInOrderDrawBuffer.cpp
+++ b/src/gpu/GrInOrderDrawBuffer.cpp
@@ -75,9 +75,9 @@
 }
 
 void GrInOrderDrawBuffer::drawRect(const GrRect& rect,
-                                   const GrMatrix* matrix,
+                                   const SkMatrix* matrix,
                                    const GrRect* srcRects[],
-                                   const GrMatrix* srcMatrices[]) {
+                                   const SkMatrix* srcMatrices[]) {
 
     GrAssert(!(NULL == fQuadIndexBuffer && fCurrQuad));
     GrAssert(!(fDraws.empty() && fCurrQuad));
@@ -126,7 +126,7 @@
             GrPrintf("Failed to get space for vertices!\n");
             return;
         }
-        GrMatrix combinedMatrix = drawState->getViewMatrix();
+        SkMatrix combinedMatrix = drawState->getViewMatrix();
         // We go to device space so that matrix changes allow us to concat
         // rect draws. When the caller has provided explicit source rects
         // then we don't want to modify the stages' matrices. Otherwise
diff --git a/src/gpu/GrInOrderDrawBuffer.h b/src/gpu/GrInOrderDrawBuffer.h
index 08dd774..e80a2b4 100644
--- a/src/gpu/GrInOrderDrawBuffer.h
+++ b/src/gpu/GrInOrderDrawBuffer.h
@@ -114,9 +114,9 @@
 
     // overrides from GrDrawTarget
     virtual void drawRect(const GrRect& rect,
-                          const GrMatrix* matrix = NULL,
+                          const SkMatrix* matrix = NULL,
                           const GrRect* srcRects[] = NULL,
-                          const GrMatrix* srcMatrices[] = NULL) SK_OVERRIDE;
+                          const SkMatrix* srcMatrices[] = NULL) SK_OVERRIDE;
 
     virtual void drawIndexedInstances(GrPrimitiveType type,
                                       int instanceCount,
diff --git a/src/gpu/GrMatrix.cpp b/src/gpu/GrMatrix.cpp
deleted file mode 100644
index 513525c..0000000
--- a/src/gpu/GrMatrix.cpp
+++ /dev/null
@@ -1,713 +0,0 @@
-
-/*
- * Copyright 2010 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-
-
-#include "GrMatrix.h"
-#include "GrRect.h"
-#include <stddef.h>
-
-#if 0
-#if SK_SCALAR_IS_FLOAT
-    const SkScalar GrMatrix::gRESCALE(SK_Scalar1);
-#else
-    GR_STATIC_ASSERT(SK_SCALAR_IS_FIXED);
-    // fixed point isn't supported right now
-    GR_STATIC_ASSERT(false);
-const SkScalar GrMatrix::gRESCALE(1 << 30);
-#endif
-
-const GrMatrix::MapProc GrMatrix::gMapProcs[] = {
-// Scales are not both zero
-    &GrMatrix::mapIdentity,
-    &GrMatrix::mapScale,
-    &GrMatrix::mapTranslate,
-    &GrMatrix::mapScaleAndTranslate,
-    &GrMatrix::mapSkew,
-    &GrMatrix::mapScaleAndSkew,
-    &GrMatrix::mapSkewAndTranslate,
-    &GrMatrix::mapNonPerspective,
-    // no optimizations for perspective matrices
-    &GrMatrix::mapPerspective,
-    &GrMatrix::mapPerspective,
-    &GrMatrix::mapPerspective,
-    &GrMatrix::mapPerspective,
-    &GrMatrix::mapPerspective,
-    &GrMatrix::mapPerspective,
-    &GrMatrix::mapPerspective,
-    &GrMatrix::mapPerspective,
-
-// Scales are zero (every other is invalid because kScale_TypeBit must be set if
-// kZeroScale_TypeBit is set)
-    &GrMatrix::mapInvalid,
-    &GrMatrix::mapZero,
-    &GrMatrix::mapInvalid,
-    &GrMatrix::mapSetToTranslate,
-    &GrMatrix::mapInvalid,
-    &GrMatrix::mapSwappedScale,
-    &GrMatrix::mapInvalid,
-    &GrMatrix::mapSwappedScaleAndTranslate,
-
-    // no optimizations for perspective matrices
-    &GrMatrix::mapInvalid,
-    &GrMatrix::mapZero,
-    &GrMatrix::mapInvalid,
-    &GrMatrix::mapPerspective,
-    &GrMatrix::mapInvalid,
-    &GrMatrix::mapPerspective,
-    &GrMatrix::mapInvalid,
-    &GrMatrix::mapPerspective,
-};
-
-void GrMatrix::setIdentity() {
-    fM[0] = SK_Scalar1; fM[1] = 0;          fM[2] = 0;
-    fM[3] = 0;          fM[4] = SK_Scalar1; fM[5] = 0;
-    fM[6] = 0;          fM[7] = 0;          fM[8] = gRESCALE;
-    fTypeMask = 0;
-}
-
-void GrMatrix::setTranslate(SkScalar dx, SkScalar dy) {
-    fM[0] = SK_Scalar1; fM[1] = 0;          fM[2] = dx;
-    fM[3] = 0;          fM[4] = SK_Scalar1; fM[5] = dy;
-    fM[6] = 0;          fM[7] = 0;          fM[8] = gRESCALE;
-    fTypeMask = (0 != dx || 0 != dy) ? kTranslate_TypeBit : 0;
-}
-
-void GrMatrix::setScale(SkScalar sx, SkScalar sy) {
-    fM[0] = sx; fM[1] = 0;  fM[2] = 0;
-    fM[3] = 0;  fM[4] = sy; fM[5] = 0;
-    fM[6] = 0;  fM[7] = 0;  fM[8] = gRESCALE;
-    fTypeMask = (SK_Scalar1 != sx || SK_Scalar1 != sy) ? kScale_TypeBit : 0;
-}
-
-void GrMatrix::setSkew(SkScalar skx, SkScalar sky) {
-    fM[0] = SK_Scalar1; fM[1] = skx;        fM[2] = 0;
-    fM[3] = sky;        fM[4] = SK_Scalar1; fM[5] = 0;
-    fM[6] = 0;          fM[7] = 0;          fM[8] = gRESCALE;
-    fTypeMask = (0 != skx || 0 != sky) ? kSkew_TypeBit : 0;
-}
-
-void GrMatrix::setConcat(const GrMatrix& a, const GrMatrix& b) {
-    if (a.isIdentity()) {
-        if (this != &b) {
-            for (int i = 0; i < 9; ++i) {
-                fM[i] = b.fM[i];
-            }
-            fTypeMask = b.fTypeMask;
-        }
-        return;
-    }
-
-    if (b.isIdentity()) {
-        GrAssert(!a.isIdentity());
-        if (this != &a) {
-            for (int i = 0; i < 9; ++i) {
-                    fM[i] = a.fM[i];
-            }
-            fTypeMask = a.fTypeMask;
-        }
-        return;
-    }
-
-    // a and/or b could be this
-    GrMatrix tmp;
-
-    // could do more optimizations based on type bits. Hopefully this call is
-    // low frequency.
-    // TODO: make this work for fixed point
-    if (!((b.fTypeMask | a.fTypeMask) & kPerspective_TypeBit)) {
-        tmp.fM[0] = a.fM[0] * b.fM[0] + a.fM[1] * b.fM[3];
-        tmp.fM[1] = a.fM[0] * b.fM[1] + a.fM[1] * b.fM[4];
-        tmp.fM[2] = a.fM[0] * b.fM[2] + a.fM[1] * b.fM[5] + a.fM[2] * gRESCALE;
-
-        tmp.fM[3] = a.fM[3] * b.fM[0] + a.fM[4] * b.fM[3];
-        tmp.fM[4] = a.fM[3] * b.fM[1] + a.fM[4] * b.fM[4];
-        tmp.fM[5] = a.fM[3] * b.fM[2] + a.fM[4] * b.fM[5] + a.fM[5] * gRESCALE;
-
-        tmp.fM[6] = 0;
-        tmp.fM[7] = 0;
-        tmp.fM[8] = gRESCALE * gRESCALE;
-    } else {
-        tmp.fM[0] = a.fM[0] * b.fM[0] + a.fM[1] * b.fM[3] + a.fM[2] * b.fM[6];
-        tmp.fM[1] = a.fM[0] * b.fM[1] + a.fM[1] * b.fM[4] + a.fM[2] * b.fM[7];
-        tmp.fM[2] = a.fM[0] * b.fM[2] + a.fM[1] * b.fM[5] + a.fM[2] * b.fM[8];
-
-        tmp.fM[3] = a.fM[3] * b.fM[0] + a.fM[4] * b.fM[3] + a.fM[5] * b.fM[6];
-        tmp.fM[4] = a.fM[3] * b.fM[1] + a.fM[4] * b.fM[4] + a.fM[5] * b.fM[7];
-        tmp.fM[5] = a.fM[3] * b.fM[2] + a.fM[4] * b.fM[5] + a.fM[5] * b.fM[8];
-
-        tmp.fM[6] = a.fM[6] * b.fM[0] + a.fM[7] * b.fM[3] + a.fM[8] * b.fM[6];
-        tmp.fM[7] = a.fM[6] * b.fM[1] + a.fM[7] * b.fM[4] + a.fM[8] * b.fM[7];
-        tmp.fM[8] = a.fM[6] * b.fM[2] + a.fM[7] * b.fM[5] + a.fM[8] * b.fM[8];
-    }
-    *this = tmp;
-    this->computeTypeMask();
-}
-
-void GrMatrix::preConcat(const GrMatrix& m) {
-    setConcat(*this, m);
-}
-
-void GrMatrix::postConcat(const GrMatrix& m) {
-    setConcat(m, *this);
-}
-
-double GrMatrix::determinant() const {
-    if (fTypeMask & kPerspective_TypeBit) {
-        return  fM[0]*((double)fM[4]*fM[8] - (double)fM[5]*fM[7]) +
-                fM[1]*((double)fM[5]*fM[6] - (double)fM[3]*fM[8]) +
-                fM[2]*((double)fM[3]*fM[7] - (double)fM[4]*fM[6]);
-    } else {
-        return (double)fM[0]*fM[4]*gRESCALE -
-               (double)fM[1]*fM[3]*gRESCALE;
-    }
-}
-
-bool GrMatrix::invert(GrMatrix* inverted) const {
-
-    if (isIdentity()) {
-        if (inverted != this) {
-            inverted->setIdentity();
-        }
-        return true;
-    }
-    static const double MIN_DETERMINANT_SQUARED = 1.e-16;
-
-    // could do more optimizations based on type bits. Hopefully this call is
-    // low frequency.
-
-    double det = determinant();
-
-    // check if we can't be inverted
-    if (det*det <= MIN_DETERMINANT_SQUARED) {
-        return false;
-    } else if (NULL == inverted) {
-        return true;
-    }
-
-    double t[9];
-
-    if (fTypeMask & kPerspective_TypeBit) {
-        t[0] = ((double)fM[4]*fM[8] - (double)fM[5]*fM[7]);
-        t[1] = ((double)fM[2]*fM[7] - (double)fM[1]*fM[8]);
-        t[2] = ((double)fM[1]*fM[5] - (double)fM[2]*fM[4]);
-        t[3] = ((double)fM[5]*fM[6] - (double)fM[3]*fM[8]);
-        t[4] = ((double)fM[0]*fM[8] - (double)fM[2]*fM[6]);
-        t[5] = ((double)fM[2]*fM[3] - (double)fM[0]*fM[5]);
-        t[6] = ((double)fM[3]*fM[7] - (double)fM[4]*fM[6]);
-        t[7] = ((double)fM[1]*fM[6] - (double)fM[0]*fM[7]);
-        t[8] = ((double)fM[0]*fM[4] - (double)fM[1]*fM[3]);
-        det = 1.0 / det;
-        for (int i = 0; i < 9; ++i) {
-            inverted->fM[i] = (SkScalar)(t[i] * det);
-        }
-    } else {
-        t[0] =  (double)fM[4]*gRESCALE;
-        t[1] = -(double)fM[1]*gRESCALE;
-        t[2] =  (double)fM[1]*fM[5] - (double)fM[2]*fM[4];
-        t[3] = -(double)fM[3]*gRESCALE;
-        t[4] =  (double)fM[0]*gRESCALE;
-        t[5] =  (double)fM[2]*fM[3] - (double)fM[0]*fM[5];
-        //t[6] = 0.0;
-        //t[7] = 0.0;
-        t[8] = (double)fM[0]*fM[4] - (double)fM[1]*fM[3];
-        det = 1.0 / det;
-        for (int i = 0; i < 6; ++i) {
-            inverted->fM[i] = (SkScalar)(t[i] * det);
-        }
-        inverted->fM[6] = 0;
-        inverted->fM[7] = 0;
-        inverted->fM[8] = (SkScalar)(t[8] * det);
-    }
-    inverted->computeTypeMask();
-    return true;
-}
-
-void GrMatrix::mapRect(GrRect* dst, const GrRect& src) const {
-    GrPoint srcPts[4], dstPts[4];
-    srcPts[0].set(src.fLeft, src.fTop);
-    srcPts[1].set(src.fRight, src.fTop);
-    srcPts[2].set(src.fRight, src.fBottom);
-    srcPts[3].set(src.fLeft, src.fBottom);
-    this->mapPoints(dstPts, srcPts, 4);
-    dst->setBounds(dstPts, 4);
-}
-
-bool GrMatrix::hasPerspective() const {
-    GrAssert(!!(kPerspective_TypeBit & fTypeMask) ==
-             (fM[kPersp0] != 0 || fM[kPersp1] != 0 || fM[kPersp2] != gRESCALE));
-    return 0 != (kPerspective_TypeBit & fTypeMask);
-}
-
-bool GrMatrix::isIdentity() const {
-    GrAssert((0 == fTypeMask) ==
-             (SK_Scalar1 == fM[kScaleX] && 0          == fM[kSkewX]  && 0          == fM[kTransX] &&
-              0          == fM[kSkewY]  && SK_Scalar1 == fM[kScaleY] && 0          == fM[kTransY] &&
-              0          == fM[kPersp0] && 0          == fM[kPersp1] && gRESCALE == fM[kPersp2]));
-    return (0 == fTypeMask);
-}
-
-
-bool GrMatrix::preservesAxisAlignment() const {
-
-    // check if matrix is trans and scale only
-    static const int gAllowedMask1 = kScale_TypeBit | kTranslate_TypeBit;
-
-    if (!(~gAllowedMask1 & fTypeMask)) {
-        return true;
-    }
-
-    // check matrix is trans and skew only (0 scale)
-    static const int gAllowedMask2 = kScale_TypeBit | kSkew_TypeBit |
-                                     kTranslate_TypeBit | kZeroScale_TypeBit;
-
-    if (!(~gAllowedMask2 & fTypeMask) && (kZeroScale_TypeBit & fTypeMask)) {
-        return true;
-    }
-
-    return false;
-}
-
-SkScalar GrMatrix::getMaxStretch() const {
-
-    if (fTypeMask & kPerspective_TypeBit) {
-        return -SK_Scalar1;
-    }
-
-    SkScalar stretch;
-
-    if (isIdentity()) {
-        stretch = SK_Scalar1;
-    } else if (!(fTypeMask & kSkew_TypeBit)) {
-        stretch = GrMax(SkScalarAbs(fM[kScaleX]), SkScalarAbs(fM[kScaleY]));
-    } else if (fTypeMask & kZeroScale_TypeBit) {
-        stretch = GrMax(SkScalarAbs(fM[kSkewX]), SkScalarAbs(fM[kSkewY]));
-    } else {
-        // ignore the translation part of the matrix, just look at 2x2 portion.
-        // compute singular values, take largest abs value.
-        // [a b; b c] = A^T*A
-        SkScalar a = SkScalarMul(fM[kScaleX], fM[kScaleX]) + SkScalarMul(fM[kSkewY],  fM[kSkewY]);
-        SkScalar b = SkScalarMul(fM[kScaleX], fM[kSkewX]) +  SkScalarMul(fM[kScaleY], fM[kSkewY]);
-        SkScalar c = SkScalarMul(fM[kSkewX],  fM[kSkewX]) +  SkScalarMul(fM[kScaleY], fM[kScaleY]);
-        // eigenvalues of A^T*A are the squared singular values of A.
-        // characteristic equation is det((A^T*A) - l*I) = 0
-        // l^2 - (a + c)l + (ac-b^2)
-        // solve using quadratic equation (divisor is non-zero since l^2 has 1 coeff
-        // and roots are guaraunteed to be pos and real).
-        SkScalar largerRoot;
-        SkScalar bSqd = SkScalarMul(b,b);
-        // TODO: fixed point tolerance value.
-        if (bSqd < 1e-10) { // will be true if upper left 2x2 is orthogonal, which is common, so save some math
-            largerRoot = GrMax(a, c);
-        } else {
-            SkScalar aminusc = a - c;
-            SkScalar apluscdiv2 = (a + c) / 2;
-            SkScalar x = sqrtf(SkScalarMul(aminusc,aminusc) + SkScalarMul(4,(bSqd))) / 2;
-            largerRoot = apluscdiv2 + x;
-        }
-
-        stretch = sqrtf(largerRoot);
-    }
-#if GR_DEBUG && 0
-    // test a bunch of vectors. None should be scaled by more than stretch
-    // (modulo some error) and we should find a vector that is scaled by almost
-    // stretch.
-    GrPoint pt;
-    SkScalar max = 0;
-    for (int i = 0; i < 1000; ++i) {
-        SkScalar x = (float)rand() / RAND_MAX;
-        SkScalar y = sqrtf(1 - (x*x));
-        pt.fX = fM[kScaleX]*x + fM[kSkewX]*y;
-        pt.fY = fM[kSkewY]*x + fM[kScaleY]*y;
-        SkScalar d = pt.distanceToOrigin();
-        GrAssert(d <= (1.0001 * stretch));
-        max = GrMax(max, pt.distanceToOrigin());
-    }
-    GrAssert((stretch - max) < .05*stretch);
-#endif
-    return stretch;
-}
-
-bool GrMatrix::operator == (const GrMatrix& m) const {
-    if (fTypeMask != m.fTypeMask) {
-        return false;
-    }
-    if (!fTypeMask) {
-        return true;
-    }
-    for (int i = 0; i < 9; ++i) {
-        if (m.fM[i] != fM[i]) {
-            return false;
-        }
-    }
-    return true;
-}
-
-bool GrMatrix::operator != (const GrMatrix& m) const {
-    return !(*this == m);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Matrix transformation procs
-//////
-
-void GrMatrix::mapIdentity(GrPoint* dst, const GrPoint* src, uint32_t count) const {
-    if (src != dst) {
-        for (uint32_t i = 0; i < count; ++i) {
-            dst[i] = src[i];
-        }
-    }
-}
-
-void GrMatrix::mapScale(GrPoint* dst, const GrPoint* src, uint32_t count) const {
-    for (uint32_t i = 0; i < count; ++i) {
-        dst[i].fX = SkScalarMul(src[i].fX, fM[kScaleX]);
-        dst[i].fY = SkScalarMul(src[i].fY, fM[kScaleY]);
-    }
-}
-
-
-void GrMatrix::mapTranslate(GrPoint* dst, const GrPoint* src, uint32_t count) const {
-    for (uint32_t i = 0; i < count; ++i) {
-        dst[i].fX = src[i].fX + fM[kTransX];
-        dst[i].fY = src[i].fY + fM[kTransY];
-    }
-}
-
-void GrMatrix::mapScaleAndTranslate(GrPoint* dst, const GrPoint* src, uint32_t count) const {
-    for (uint32_t i = 0; i < count; ++i) {
-        dst[i].fX = SkScalarMul(src[i].fX, fM[kScaleX]) + fM[kTransX];
-        dst[i].fY = SkScalarMul(src[i].fY, fM[kScaleY]) + fM[kTransY];
-    }
-}
-
-void GrMatrix::mapSkew(GrPoint* dst, const GrPoint* src, uint32_t count) const {
-    if (src != dst) {
-        for (uint32_t i = 0; i < count; ++i) {
-            dst[i].fX = src[i].fX + SkScalarMul(src[i].fY, fM[kSkewX]);
-            dst[i].fY = src[i].fY + SkScalarMul(src[i].fX, fM[kSkewY]);
-        }
-    } else {
-        for (uint32_t i = 0; i < count; ++i) {
-            SkScalar newX = src[i].fX + SkScalarMul(src[i].fY, fM[kSkewX]);
-            dst[i].fY = src[i].fY + SkScalarMul(src[i].fX, fM[kSkewY]);
-            dst[i].fX = newX;
-        }
-    }
-}
-
-void GrMatrix::mapScaleAndSkew(GrPoint* dst, const GrPoint* src, uint32_t count) const {
-    if (src != dst) {
-        for (uint32_t i = 0; i < count; ++i) {
-            dst[i].fX = SkScalarMul(src[i].fX, fM[kScaleX]) + SkScalarMul(src[i].fY, fM[kSkewX]);
-            dst[i].fY = SkScalarMul(src[i].fY, fM[kScaleY]) + SkScalarMul(src[i].fX, fM[kSkewY]);
-        }
-    } else {
-        for (uint32_t i = 0; i < count; ++i) {
-            SkScalar newX = SkScalarMul(src[i].fX, fM[kScaleX]) + SkScalarMul(src[i].fY, fM[kSkewX]);
-            dst[i].fY = SkScalarMul(src[i].fY, fM[kScaleY]) + SkScalarMul(src[i].fX, fM[kSkewY]);
-            dst[i].fX = newX;
-        }
-    }
-}
-
-void GrMatrix::mapSkewAndTranslate(GrPoint* dst, const GrPoint* src, uint32_t count) const {
-    if (src != dst) {
-        for (uint32_t i = 0; i < count; ++i) {
-            dst[i].fX = src[i].fX + SkScalarMul(src[i].fY, fM[kSkewX]) + fM[kTransX];
-            dst[i].fY = src[i].fY + SkScalarMul(src[i].fX, fM[kSkewY]) + fM[kTransY];
-        }
-    } else {
-        for (uint32_t i = 0; i < count; ++i) {
-            SkScalar newX = src[i].fX + SkScalarMul(src[i].fY, fM[kSkewX]) + fM[kTransX];
-            dst[i].fY = src[i].fY + SkScalarMul(src[i].fX, fM[kSkewY]) + fM[kTransY];
-            dst[i].fX = newX;
-        }
-    }
-}
-
-void GrMatrix::mapNonPerspective(GrPoint* dst, const GrPoint* src, uint32_t count) const {
-    if (src != dst) {
-        for (uint32_t i = 0; i < count; ++i) {
-            dst[i].fX = SkScalarMul(fM[kScaleX], src[i].fX) + SkScalarMul(fM[kSkewX], src[i].fY) + fM[kTransX];
-            dst[i].fY = SkScalarMul(fM[kSkewY], src[i].fX) + SkScalarMul(fM[kScaleY], src[i].fY) + fM[kTransY];
-        }
-    } else {
-        for (uint32_t i = 0; i < count; ++i) {
-            SkScalar newX = SkScalarMul(fM[kScaleX], src[i].fX) + SkScalarMul(fM[kSkewX], src[i].fY) + fM[kTransX];
-            dst[i].fY = SkScalarMul(fM[kSkewY], src[i].fX) + SkScalarMul(fM[kScaleY], src[i].fY) + fM[kTransY];
-            dst[i].fX = newX;
-        }
-    }
-}
-
-void GrMatrix::mapPerspective(GrPoint* dst, const GrPoint* src, uint32_t count) const {
-    for (uint32_t i = 0; i < count; ++i) {
-        SkScalar x, y, w;
-        x = SkScalarMul(fM[kScaleX], src[i].fX) + SkScalarMul(fM[kSkewX], src[i].fY) + fM[kTransX];
-        y = SkScalarMul(fM[kSkewY], src[i].fX) + SkScalarMul(fM[kScaleY], src[i].fY) + fM[kTransY];
-        w = SkScalarMul(fM[kPersp0], src[i].fX) + SkScalarMul(fM[kPersp1], src[i].fY) + fM[kPersp2];
-        // TODO need fixed point invert
-        if (w) {
-            w = 1 / w;
-        }
-        dst[i].fX = SkScalarMul(x, w);
-        dst[i].fY = SkScalarMul(y, w);
-    }
-}
-
-void GrMatrix::mapInvalid(GrPoint* dst, const GrPoint* src, uint32_t count) const {
-    GrAssert(0);
-}
-
-void GrMatrix::mapZero(GrPoint* dst, const GrPoint* src, uint32_t count) const {
-    memset(dst, 0, sizeof(GrPoint)*count);
-}
-
-void GrMatrix::mapSetToTranslate(GrPoint* dst, const GrPoint* src, uint32_t count) const {
-    for (uint32_t i = 0; i < count; ++i) {
-        dst[i].fX = fM[kTransX];
-        dst[i].fY = fM[kTransY];
-    }
-}
-
-void GrMatrix::mapSwappedScale(GrPoint* dst, const GrPoint* src, uint32_t count) const {
-    if (src != dst) {
-        for (uint32_t i = 0; i < count; ++i) {
-            dst[i].fX = SkScalarMul(src[i].fY, fM[kSkewX]);
-            dst[i].fY = SkScalarMul(src[i].fX, fM[kSkewY]);
-        }
-    } else {
-        for (uint32_t i = 0; i < count; ++i) {
-            SkScalar newX = SkScalarMul(src[i].fY, fM[kSkewX]);
-            dst[i].fY = SkScalarMul(src[i].fX, fM[kSkewY]);
-            dst[i].fX = newX;
-        }
-    }
-}
-
-void GrMatrix::mapSwappedScaleAndTranslate(GrPoint* dst, const GrPoint* src, uint32_t count) const {
-    if (src != dst) {
-        for (uint32_t i = 0; i < count; ++i) {
-            dst[i].fX = SkScalarMul(src[i].fY, fM[kSkewX]) + fM[kTransX];
-            dst[i].fY = SkScalarMul(src[i].fX, fM[kSkewY]) + fM[kTransY];
-        }
-    } else {
-        for (uint32_t i = 0; i < count; ++i) {
-            SkScalar newX = SkScalarMul(src[i].fY, fM[kSkewX]) + fM[kTransX];
-            dst[i].fY = SkScalarMul(src[i].fX, fM[kSkewY]) + fM[kTransY];
-            dst[i].fX = newX;
-        }
-    }
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Unit test
-//////
-
-#include "GrRandom.h"
-
-#if GR_DEBUG
-enum MatrixType {
-    kRotate_MatrixType,
-    kScaleX_MatrixType,
-    kScaleY_MatrixType,
-    kSkewX_MatrixType,
-    kSkewY_MatrixType,
-    kTranslateX_MatrixType,
-    kTranslateY_MatrixType,
-    kSwapScaleXY_MatrixType,
-    kPersp_MatrixType,
-
-    kMatrixTypeCount
-};
-
-static void create_matrix(GrMatrix* matrix, GrRandom& rand) {
-    MatrixType type = (MatrixType)(rand.nextU() % kMatrixTypeCount);
-    switch (type) {
-        case kRotate_MatrixType: {
-            float angle = rand.nextF() * 2 *3.14159265358979323846f;
-            SkScalar cosa = SkFloatToScalar(cosf(angle));
-            SkScalar sina = SkFloatToScalar(sinf(angle));
-            matrix->setAll(cosa,      -sina,           0,
-                           sina,       cosa,           0,
-                           0,          0,              GrMatrix::I()[8]);
-        } break;
-        case kScaleX_MatrixType: {
-            SkScalar scale = SkFloatToScalar(rand.nextF(-2, 2));
-            matrix->setAll(scale,      0,              0,
-                           0,          SK_Scalar1,     0,
-                           0,          0,              GrMatrix::I()[8]);
-        } break;
-        case kScaleY_MatrixType: {
-            SkScalar scale = SkFloatToScalar(rand.nextF(-2, 2));
-            matrix->setAll(SK_Scalar1, 0,              0,
-                           0,          scale,          0,
-                           0,          0,              GrMatrix::I()[8]);
-        } break;
-        case kSkewX_MatrixType: {
-            SkScalar skew = SkFloatToScalar(rand.nextF(-2, 2));
-            matrix->setAll(SK_Scalar1, skew,           0,
-                           0,          SK_Scalar1,     0,
-                           0,          0,              GrMatrix::I()[8]);
-        } break;
-        case kSkewY_MatrixType: {
-            SkScalar skew = SkFloatToScalar(rand.nextF(-2, 2));
-            matrix->setAll(SK_Scalar1, 0,              0,
-                           skew,       SK_Scalar1,     0,
-                           0,          0,              GrMatrix::I()[8]);
-        } break;
-        case kTranslateX_MatrixType: {
-            SkScalar trans = SkFloatToScalar(rand.nextF(-10, 10));
-            matrix->setAll(SK_Scalar1, 0,              trans,
-                           0,          SK_Scalar1,     0,
-                           0,          0,              GrMatrix::I()[8]);
-        } break;
-        case kTranslateY_MatrixType: {
-            SkScalar trans = SkFloatToScalar(rand.nextF(-10, 10));
-            matrix->setAll(SK_Scalar1, 0,              0,
-                           0,          SK_Scalar1,     trans,
-                           0,          0,              GrMatrix::I()[8]);
-        } break;
-        case kSwapScaleXY_MatrixType: {
-            SkScalar xy = SkFloatToScalar(rand.nextF(-2, 2));
-            SkScalar yx = SkFloatToScalar(rand.nextF(-2, 2));
-            matrix->setAll(0,          xy,             0,
-                           yx,         0,              0,
-                           0,          0,              GrMatrix::I()[8]);
-        } break;
-        case kPersp_MatrixType: {
-            SkScalar p0 = SkFloatToScalar(rand.nextF(-2, 2));
-            SkScalar p1 = SkFloatToScalar(rand.nextF(-2, 2));
-            SkScalar p2 = SkFloatToScalar(rand.nextF(-0.5f, 0.75f));
-            matrix->setAll(SK_Scalar1, 0,              0,
-                           0,          SK_Scalar1,     0,
-                           p0,         p1,             SkScalarMul(p2,GrMatrix::I()[8]));
-        } break;
-        default:
-            GrAssert(0);
-            break;
-    }
-}
-#endif
-
-void GrMatrix::UnitTest() {
-    GrRandom rand;
-
-    // Create a bunch of matrices and test point mapping, max stretch calc,
-    // inversion and multiply-by-inverse.
-#if GR_DEBUG
-    for (int i = 0; i < 10000; ++i) {
-        GrMatrix a, b;
-        a.setIdentity();
-        int num = rand.nextU() % 6;
-        // force testing of I and swapXY
-        if (0 == i) {
-            num = 0;
-            GrAssert(a.isIdentity());
-        } else if (1 == i) {
-            num = 0;
-            a.setAll(0, SK_Scalar1, 0,
-                     SK_Scalar1, 0, 0,
-                     0, 0, I()[8]);
-        }
-        for (int j = 0; j < num; ++j) {
-            create_matrix(&b, rand);
-            a.preConcat(b);
-        }
-
-        SkScalar maxStretch = a.getMaxStretch();
-        if (maxStretch > 0) {
-            maxStretch = SkScalarMul(SK_Scalar1 + SK_Scalar1 / 100, maxStretch);
-        }
-        GrPoint origin = a.mapPoint(GrPoint::Make(0,0));
-
-        for (int j = 0; j < 9; ++j) {
-            int mask, origMask = a.fTypeMask;
-            SkScalar old = a[j];
-
-            a.set(j, SK_Scalar1);
-            mask = a.fTypeMask;
-            a.computeTypeMask();
-            GrAssert(mask == a.fTypeMask);
-
-            a.set(j, 0);
-            mask = a.fTypeMask;
-            a.computeTypeMask();
-            GrAssert(mask == a.fTypeMask);
-
-            a.set(j, 10 * SK_Scalar1);
-            mask = a.fTypeMask;
-            a.computeTypeMask();
-            GrAssert(mask == a.fTypeMask);
-
-            a.set(j, old);
-            GrAssert(a.fTypeMask == origMask);
-        }
-
-        for (int j = 0; j < 100; ++j) {
-            GrPoint pt;
-            pt.fX = SkFloatToScalar(rand.nextF(-10, 10));
-            pt.fY = SkFloatToScalar(rand.nextF(-10, 10));
-
-            GrPoint t0, t1, t2;
-            t0 = a.mapPoint(pt);             // map to a new point
-            t1 = pt;
-            a.mapPoints(&t1, &t1, 1);        // in place
-            a.mapPerspective(&t2, &pt, 1);   // full mult
-            GrAssert(t0 == t1 && t1 == t2);
-            if (maxStretch >= 0.f) {
-                GrVec vec = origin - t0;
-//                vec.setBetween(t0, origin);
-                SkScalar stretch = vec.length() / pt.distanceToOrigin();
-                GrAssert(stretch <= maxStretch);
-            }
-        }
-        double det = a.determinant();
-        if (fabs(det) > 1e-3 && a.invert(&b)) {
-            GrMatrix c;
-            c.setConcat(a,b);
-            for (int i = 0; i < 9; ++i) {
-                SkScalar diff = SkScalarAbs(c[i] - I()[i]);
-                GrAssert(diff < (5*SK_Scalar1 / 100));
-            }
-        }
-    }
-#endif
-}
-
-///////////////////////////////////////////////////////////////////////////////
-#endif
-
-int Gr_clz(uint32_t n) {
-    if (0 == n) {
-        return 32;
-    }
-
-    int count = 0;
-    if (0 == (n & 0xFFFF0000)) {
-        count += 16;
-        n <<= 16;
-    }
-    if (0 == (n & 0xFF000000)) {
-        count += 8;
-        n <<= 8;
-    }
-    if (0 == (n & 0xF0000000)) {
-        count += 4;
-        n <<= 4;
-    }
-    if (0 == (n & 0xC0000000)) {
-        count += 2;
-        n <<= 2;
-    }
-    if (0 == (n & 0x80000000)) {
-        count += 1;
-    }
-    return count;
-}
diff --git a/src/gpu/GrPathUtils.cpp b/src/gpu/GrPathUtils.cpp
index 36f0ffa..4092959 100644
--- a/src/gpu/GrPathUtils.cpp
+++ b/src/gpu/GrPathUtils.cpp
@@ -12,7 +12,7 @@
 #include "SkGeometry.h"
 
 SkScalar GrPathUtils::scaleToleranceToSrc(SkScalar devTol,
-                                          const GrMatrix& viewM,
+                                          const SkMatrix& viewM,
                                           const GrRect& pathBounds) {
     // In order to tesselate the path we get a bound on how much the matrix can
     // stretch when mapping to screen coordinates.
@@ -23,7 +23,7 @@
         // take worst case mapRadius amoung four corners.
         // (less than perfect)
         for (int i = 0; i < 4; ++i) {
-            GrMatrix mat;
+            SkMatrix mat;
             mat.setTranslate((i % 2) ? pathBounds.fLeft : pathBounds.fRight,
                              (i < 2) ? pathBounds.fTop : pathBounds.fBottom);
             mat.postConcat(viewM);
diff --git a/src/gpu/GrPathUtils.h b/src/gpu/GrPathUtils.h
index 4ad0e8b..2d6045e 100644
--- a/src/gpu/GrPathUtils.h
+++ b/src/gpu/GrPathUtils.h
@@ -10,16 +10,18 @@
 #ifndef GrPathUtils_DEFINED
 #define GrPathUtils_DEFINED
 
-#include "GrMatrix.h"
+#include "GrRect.h"
 #include "SkPath.h"
 #include "SkTArray.h"
 
+class SkMatrix;
+
 /**
  *  Utilities for evaluating paths.
  */
 namespace GrPathUtils {
     SkScalar scaleToleranceToSrc(SkScalar devTol,
-                                 const GrMatrix& viewM,
+                                 const SkMatrix& viewM,
                                  const GrRect& pathBounds);
 
     /// Since we divide by tol if we're computing exact worst-case bounds,
diff --git a/src/gpu/GrRectanizer.cpp b/src/gpu/GrRectanizer.cpp
index 87ea92e..652cc29 100644
--- a/src/gpu/GrRectanizer.cpp
+++ b/src/gpu/GrRectanizer.cpp
@@ -48,7 +48,7 @@
 
     static int HeightToRowIndex(int height) {
         GrAssert(height >= MIN_HEIGHT_POW2);
-        return 32 - Gr_clz(height - 1);
+        return 32 - SkCLZ(height - 1);
     }
 
     int fNextStripY;
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index 4a81eb1..4aad051 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -100,7 +100,7 @@
 }
 
 bool GrSWMaskHelper::init(const GrIRect& resultBounds,
-                          const GrMatrix* matrix) {
+                          const SkMatrix* matrix) {
     if (NULL != matrix) {
         fMatrix = *matrix;
     } else {
@@ -177,7 +177,7 @@
                                                  const GrIRect& resultBounds,
                                                  GrPathFill fill,
                                                  bool antiAlias,
-                                                 GrMatrix* matrix) {
+                                                 SkMatrix* matrix) {
     GrAutoScratchTexture ast;
 
     GrSWMaskHelper helper(context);
diff --git a/src/gpu/GrSWMaskHelper.h b/src/gpu/GrSWMaskHelper.h
index c780769..3c35794 100644
--- a/src/gpu/GrSWMaskHelper.h
+++ b/src/gpu/GrSWMaskHelper.h
@@ -9,7 +9,7 @@
 #define GrSWMaskHelper_DEFINED
 
 #include "GrColor.h"
-#include "GrMatrix.h"
+#include "SkMatrix.h"
 #include "GrNoncopyable.h"
 #include "SkBitmap.h"
 #include "SkDraw.h"
@@ -47,7 +47,7 @@
     // may be accumulated in the helper during creation, "resultBounds"
     // allows the caller to specify the region of interest - to limit the
     // amount of work.
-    bool init(const GrIRect& resultBounds, const GrMatrix* matrix);
+    bool init(const GrIRect& resultBounds, const SkMatrix* matrix);
 
     // Draw a single rect into the accumulation bitmap using the specified op
     void draw(const GrRect& rect, SkRegion::Op op,
@@ -77,7 +77,7 @@
                                             const GrIRect& resultBounds,
                                             GrPathFill fill,
                                             bool antiAlias,
-                                            GrMatrix* matrix);
+                                            SkMatrix* matrix);
 
     // This utility routine is used to add a path's mask to some other draw.
     // The ClipMaskManager uses it to accumulate clip masks while the
@@ -96,7 +96,7 @@
 protected:
 private:
     GrContext*      fContext;
-    GrMatrix        fMatrix;
+    SkMatrix        fMatrix;
     SkBitmap        fBM;
     SkDraw          fDraw;
     SkRasterClip    fRasterClip;
diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp
index 3dd9606..6d91ef9 100644
--- a/src/gpu/GrSoftwarePathRenderer.cpp
+++ b/src/gpu/GrSoftwarePathRenderer.cpp
@@ -36,7 +36,7 @@
 // path bounds would be empty.
 bool get_path_and_clip_bounds(const GrDrawTarget* target,
                               const SkPath& path,
-                              const GrMatrix& matrix,
+                              const SkMatrix& matrix,
                               GrIRect* devPathBounds,
                               GrIRect* devClipBounds) {
     // compute bounds as intersection of rt size, clip, and path
@@ -117,7 +117,7 @@
 
     GrDrawState* drawState = target->drawState();
 
-    GrMatrix vm = drawState->getViewMatrix();
+    SkMatrix vm = drawState->getViewMatrix();
 
     GrIRect devPathBounds, devClipBounds;
     if (!get_path_and_clip_bounds(target, path, vm,
diff --git a/src/gpu/GrStencilAndCoverPathRenderer.cpp b/src/gpu/GrStencilAndCoverPathRenderer.cpp
index a6ae12b..9749f1d 100644
--- a/src/gpu/GrStencilAndCoverPathRenderer.cpp
+++ b/src/gpu/GrStencilAndCoverPathRenderer.cpp
@@ -98,7 +98,7 @@
             0xffff,
             0x0000,
             0xffff);
-        GrMatrix vmi;
+        SkMatrix vmi;
         bounds.setLTRB(0, 0,
                        SkIntToScalar(drawState->getRenderTarget()->width()),
                        SkIntToScalar(drawState->getRenderTarget()->height()));
diff --git a/src/gpu/GrTextContext.cpp b/src/gpu/GrTextContext.cpp
index bf7ed04..bb434b6 100644
--- a/src/gpu/GrTextContext.cpp
+++ b/src/gpu/GrTextContext.cpp
@@ -34,7 +34,7 @@
         GrAssert(GrIsALIGN4(fCurrVertex));
         GrAssert(fCurrTexture);
         GrTextureParams params(SkShader::kRepeat_TileMode, false);
-        drawState->createTextureEffect(kGlyphMaskStage, fCurrTexture, GrMatrix::I(), params);
+        drawState->createTextureEffect(kGlyphMaskStage, fCurrTexture, SkMatrix::I(), params);
 
         if (!GrPixelConfigIsAlphaOnly(fCurrTexture->config())) {
             if (kOne_GrBlendCoeff != fPaint.getSrcBlendCoeff() ||
@@ -143,7 +143,7 @@
         int x = vx >> 16;
         int y = vy >> 16;
         if (fClipRect.quickReject(x, y, x + width, y + height)) {
-//            Gr_clz(3);    // so we can set a break-point in the debugger
+//            SkCLZ(3);    // so we can set a break-point in the debugger
             return;
         }
     }
@@ -174,7 +174,7 @@
         }
 
         GrContext::AutoMatrix am;
-        GrMatrix translate;
+        SkMatrix translate;
         translate.setTranslate(SkFixedToScalar(vx - SkIntToFixed(glyph->fBounds.fLeft)),
                                SkFixedToScalar(vy - SkIntToFixed(glyph->fBounds.fTop)));
         GrPaint tmpPaint(fPaint);
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 512faa5..4a4259e 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -854,7 +854,7 @@
         GrContext::AutoMatrix am;
 
         // Draw hard shadow to pathTexture with path top-left at origin using tempPaint.
-        GrMatrix translate;
+        SkMatrix translate;
         translate.setTranslate(offset.fX, offset.fY);
         am.set(context, translate);
         context->drawPath(tempPaint, devPath, pathFillType);
@@ -871,7 +871,7 @@
         if (!isNormalBlur) {
             context->setIdentityMatrix();
             GrPaint paint;
-            GrMatrix matrix;
+            SkMatrix matrix;
             matrix.setIDiv(pathTexture->width(), pathTexture->height());
             // Blend pathTexture over blurTexture.
             context->setRenderTarget(blurTexture->asRenderTarget());
@@ -901,7 +901,7 @@
     // we assume the last mask index is available for use
     GrAssert(!grp->isCoverageStageEnabled(MASK_IDX));
 
-    GrMatrix matrix;
+    SkMatrix matrix;
     matrix.setTranslate(-finalRect.fLeft, -finalRect.fTop);
     matrix.postIDiv(blurTexture->width(), blurTexture->height());
 
@@ -958,7 +958,7 @@
     // we assume the last mask index is available for use
     GrAssert(!grp->isCoverageStageEnabled(MASK_IDX));
 
-    GrMatrix m;
+    SkMatrix m;
     m.setTranslate(-dstM.fBounds.fLeft*SK_Scalar1, -dstM.fBounds.fTop*SK_Scalar1);
     m.postIDiv(texture->width(), texture->height());
 
@@ -1456,7 +1456,7 @@
     GrContext::AutoRenderTarget art(context, dstTexture->asRenderTarget());
     GrContext::AutoClip acs(context, rect);
 
-    GrMatrix sampleM;
+    SkMatrix sampleM;
     sampleM.setIDiv(srcTexture->width(), srcTexture->height());
     GrPaint paint;
     paint.colorStage(0)->setEffect(effect, sampleM);
diff --git a/src/gpu/effects/GrConfigConversionEffect.cpp b/src/gpu/effects/GrConfigConversionEffect.cpp
index 29ba405..7ccea74 100644
--- a/src/gpu/effects/GrConfigConversionEffect.cpp
+++ b/src/gpu/effects/GrConfigConversionEffect.cpp
@@ -221,7 +221,7 @@
 bool GrConfigConversionEffect::InstallEffect(GrTexture* texture,
                                              bool swapRedAndBlue,
                                              PMConversion pmConversion,
-                                             const GrMatrix& matrix,
+                                             const SkMatrix& matrix,
                                              GrEffectStage* stage) {
     if (!swapRedAndBlue && kNone_PMConversion == pmConversion) {
         // If we returned a GrConfigConversionEffect that was equivalent to a GrSingleTextureEffect
diff --git a/src/gpu/effects/GrConfigConversionEffect.h b/src/gpu/effects/GrConfigConversionEffect.h
index 5b531d4..6a10c25 100644
--- a/src/gpu/effects/GrConfigConversionEffect.h
+++ b/src/gpu/effects/GrConfigConversionEffect.h
@@ -37,7 +37,7 @@
     static bool InstallEffect(GrTexture*,
                               bool swapRedAndBlue,
                               PMConversion pmConversion,
-                              const GrMatrix& matrix,
+                              const SkMatrix& matrix,
                               GrEffectStage* stage);
 
     static const char* Name() { return "Config Conversion"; }
diff --git a/src/gpu/effects/GrSingleTextureEffect.cpp b/src/gpu/effects/GrSingleTextureEffect.cpp
index 0f3b614..0afa184 100644
--- a/src/gpu/effects/GrSingleTextureEffect.cpp
+++ b/src/gpu/effects/GrSingleTextureEffect.cpp
@@ -77,20 +77,20 @@
     fMatrix.reset();
 }
 
-GrSingleTextureEffect::GrSingleTextureEffect(GrTexture* texture, const GrMatrix& m)
+GrSingleTextureEffect::GrSingleTextureEffect(GrTexture* texture, const SkMatrix& m)
     : INHERITED(1)
     , fTextureAccess(texture)
     , fMatrix(m) {
 }
 
-GrSingleTextureEffect::GrSingleTextureEffect(GrTexture* texture, const GrMatrix& m, bool bilerp)
+GrSingleTextureEffect::GrSingleTextureEffect(GrTexture* texture, const SkMatrix& m, bool bilerp)
     : INHERITED(1)
     , fTextureAccess(texture, bilerp)
     , fMatrix(m) {
 }
 
 GrSingleTextureEffect::GrSingleTextureEffect(GrTexture* texture,
-                                             const GrMatrix& m,
+                                             const SkMatrix& m,
                                              const GrTextureParams& params)
     : INHERITED(1)
     , fTextureAccess(texture, params)
diff --git a/src/gpu/effects/GrSingleTextureEffect.h b/src/gpu/effects/GrSingleTextureEffect.h
index 23b416d..e598f2f 100644
--- a/src/gpu/effects/GrSingleTextureEffect.h
+++ b/src/gpu/effects/GrSingleTextureEffect.h
@@ -9,7 +9,7 @@
 #define GrSingleTextureEffect_DEFINED
 
 #include "GrEffect.h"
-#include "GrMatrix.h"
+#include "SkMatrix.h"
 
 class GrGLSingleTextureEffect;
 
@@ -25,9 +25,9 @@
     GrSingleTextureEffect(GrTexture* texture, const GrTextureParams&);
 
     /** These three constructors take an explicit matrix */
-    GrSingleTextureEffect(GrTexture*, const GrMatrix&); /* unfiltered, clamp mode */
-    GrSingleTextureEffect(GrTexture*, const GrMatrix&, bool bilerp); /* clamp mode */
-    GrSingleTextureEffect(GrTexture*, const GrMatrix&, const GrTextureParams&);
+    GrSingleTextureEffect(GrTexture*, const SkMatrix&); /* unfiltered, clamp mode */
+    GrSingleTextureEffect(GrTexture*, const SkMatrix&, bool bilerp); /* clamp mode */
+    GrSingleTextureEffect(GrTexture*, const SkMatrix&, const GrTextureParams&);
 
     virtual ~GrSingleTextureEffect();
 
@@ -35,7 +35,7 @@
 
     static const char* Name() { return "Single Texture"; }
 
-    const GrMatrix& getMatrix() const { return fMatrix; }
+    const SkMatrix& getMatrix() const { return fMatrix; }
 
     typedef GrGLSingleTextureEffect GLEffect;
 
@@ -49,7 +49,7 @@
     GR_DECLARE_EFFECT_TEST;
 
     GrTextureAccess fTextureAccess;
-    GrMatrix        fMatrix;
+    SkMatrix        fMatrix;
 
     typedef GrEffect INHERITED;
 };
diff --git a/src/gpu/gl/GrGLProgram.cpp b/src/gpu/gl/GrGLProgram.cpp
index ff1296a..911b5e4 100644
--- a/src/gpu/gl/GrGLProgram.cpp
+++ b/src/gpu/gl/GrGLProgram.cpp
@@ -72,7 +72,7 @@
     fFShaderID = 0;
     fProgramID = 0;
 
-    fViewMatrix = GrMatrix::InvalidMatrix();
+    fViewMatrix = SkMatrix::InvalidMatrix();
     fViewportSize.set(-1, -1);
     fColor = GrColor_ILLEGAL;
     fColorFilterColor = GrColor_ILLEGAL;
@@ -80,7 +80,7 @@
 
     for (int s = 0; s < GrDrawState::kNumStages; ++s) {
         fEffects[s] = NULL;
-        fTextureMatrices[s] = GrMatrix::InvalidMatrix();
+        fTextureMatrices[s] = SkMatrix::InvalidMatrix();
         // this is arbitrary, just initialize to something
         fTextureOrigin[s] = GrSurface::kBottomLeft_Origin;
     }
diff --git a/src/gpu/gl/GrGLProgram.h b/src/gpu/gl/GrGLProgram.h
index a023de7..bc7b3bc 100644
--- a/src/gpu/gl/GrGLProgram.h
+++ b/src/gpu/gl/GrGLProgram.h
@@ -240,7 +240,7 @@
 
     // The matrix sent to GL is determined by both the client's matrix and
     // the size of the viewport.
-    GrMatrix  fViewMatrix;
+    SkMatrix  fViewMatrix;
     SkISize   fViewportSize;
 
     // these reflect the current values of uniforms
@@ -250,7 +250,7 @@
     GrColor                     fColorFilterColor;
     int                         fRTHeight;
     /// When it is sent to GL, the texture matrix will be flipped if the texture origin requires.
-    GrMatrix                    fTextureMatrices[GrDrawState::kNumStages];
+    SkMatrix                    fTextureMatrices[GrDrawState::kNumStages];
     GrSurface::Origin           fTextureOrigin[GrDrawState::kNumStages];
 
     GrGLEffect*                 fEffects[GrDrawState::kNumStages];
diff --git a/src/gpu/gl/GrGpuGL.h b/src/gpu/gl/GrGpuGL.h
index f56d783..34af3fd 100644
--- a/src/gpu/gl/GrGpuGL.h
+++ b/src/gpu/gl/GrGpuGL.h
@@ -146,7 +146,7 @@
     const GrGLContextInfo& glContextInfo() const { return fGLContextInfo; }
 
     // adjusts texture matrix to account for orientation
-    static void AdjustTextureMatrix(const GrTexture* texture, GrMatrix* matrix);
+    static void AdjustTextureMatrix(const GrTexture* texture, SkMatrix* matrix);
 
     // This helper determines if what optimizations can be applied to the matrix after any coord
     // adjustments are applied. The return is a bitfield of GrGLProgram::StageDesc::OptFlags.
@@ -353,10 +353,10 @@
     } fHWAAState;
 
     struct {
-        GrMatrix    fViewMatrix;
+        SkMatrix    fViewMatrix;
         SkISize     fRTSize;
         void invalidate() {
-            fViewMatrix = GrMatrix::InvalidMatrix();
+            fViewMatrix = SkMatrix::InvalidMatrix();
             fRTSize.fWidth = -1; // just make the first value compared illegal.
         }
     } fHWPathMatrixState;
diff --git a/src/gpu/gl/GrGpuGL_program.cpp b/src/gpu/gl/GrGpuGL_program.cpp
index 9677ba7..d14b1e8 100644
--- a/src/gpu/gl/GrGpuGL_program.cpp
+++ b/src/gpu/gl/GrGpuGL_program.cpp
@@ -89,14 +89,14 @@
     const GrGLIRect& viewport = rt->getViewport();
     viewportSize.set(viewport.fWidth, viewport.fHeight);
 
-    const GrMatrix& vm = this->getDrawState().getViewMatrix();
+    const SkMatrix& vm = this->getDrawState().getViewMatrix();
 
     if (kStencilPath_DrawType == type) {
         if (fHWPathMatrixState.fViewMatrix != vm ||
             fHWPathMatrixState.fRTSize != viewportSize) {
             // rescale the coords from skia's "device" coords to GL's normalized coords,
             // and perform a y-flip.
-            GrMatrix m;
+            SkMatrix m;
             m.setScale(SkIntToScalar(2) / rt->width(), SkIntToScalar(-2) / rt->height());
             m.postTranslate(-SK_Scalar1, SK_Scalar1);
             m.preConcat(vm);
@@ -104,25 +104,25 @@
             // GL wants a column-major 4x4.
             GrGLfloat mv[]  = {
                 // col 0
-                SkScalarToFloat(m[GrMatrix::kMScaleX]),
-                SkScalarToFloat(m[GrMatrix::kMSkewY]),
+                SkScalarToFloat(m[SkMatrix::kMScaleX]),
+                SkScalarToFloat(m[SkMatrix::kMSkewY]),
                 0,
-                SkScalarToFloat(m[GrMatrix::kMPersp0]),
+                SkScalarToFloat(m[SkMatrix::kMPersp0]),
 
                 // col 1
-                SkScalarToFloat(m[GrMatrix::kMSkewX]),
-                SkScalarToFloat(m[GrMatrix::kMScaleY]),
+                SkScalarToFloat(m[SkMatrix::kMSkewX]),
+                SkScalarToFloat(m[SkMatrix::kMScaleY]),
                 0,
-                SkScalarToFloat(m[GrMatrix::kMPersp1]),
+                SkScalarToFloat(m[SkMatrix::kMPersp1]),
 
                 // col 2
                 0, 0, 0, 0,
 
                 // col3
-                SkScalarToFloat(m[GrMatrix::kMTransX]),
-                SkScalarToFloat(m[GrMatrix::kMTransY]),
+                SkScalarToFloat(m[SkMatrix::kMTransX]),
+                SkScalarToFloat(m[SkMatrix::kMTransY]),
                 0.0f,
-                SkScalarToFloat(m[GrMatrix::kMPersp2])
+                SkScalarToFloat(m[SkMatrix::kMPersp2])
             };
             GL_CALL(MatrixMode(GR_GL_PROJECTION));
             GL_CALL(LoadMatrixf(mv));
@@ -131,25 +131,25 @@
         }
     } else if (!fCurrentProgram->fViewMatrix.cheapEqualTo(vm) ||
                fCurrentProgram->fViewportSize != viewportSize) {
-        GrMatrix m;
+        SkMatrix m;
         m.setAll(
             SkIntToScalar(2) / viewportSize.fWidth, 0, -SK_Scalar1,
             0,-SkIntToScalar(2) / viewportSize.fHeight, SK_Scalar1,
-            0, 0, GrMatrix::I()[8]);
+            0, 0, SkMatrix::I()[8]);
         m.setConcat(m, vm);
 
         // ES doesn't allow you to pass true to the transpose param,
         // so do our own transpose
         GrGLfloat mt[]  = {
-            SkScalarToFloat(m[GrMatrix::kMScaleX]),
-            SkScalarToFloat(m[GrMatrix::kMSkewY]),
-            SkScalarToFloat(m[GrMatrix::kMPersp0]),
-            SkScalarToFloat(m[GrMatrix::kMSkewX]),
-            SkScalarToFloat(m[GrMatrix::kMScaleY]),
-            SkScalarToFloat(m[GrMatrix::kMPersp1]),
-            SkScalarToFloat(m[GrMatrix::kMTransX]),
-            SkScalarToFloat(m[GrMatrix::kMTransY]),
-            SkScalarToFloat(m[GrMatrix::kMPersp2])
+            SkScalarToFloat(m[SkMatrix::kMScaleX]),
+            SkScalarToFloat(m[SkMatrix::kMSkewY]),
+            SkScalarToFloat(m[SkMatrix::kMPersp0]),
+            SkScalarToFloat(m[SkMatrix::kMSkewX]),
+            SkScalarToFloat(m[SkMatrix::kMScaleY]),
+            SkScalarToFloat(m[SkMatrix::kMPersp1]),
+            SkScalarToFloat(m[SkMatrix::kMTransX]),
+            SkScalarToFloat(m[SkMatrix::kMTransY]),
+            SkScalarToFloat(m[SkMatrix::kMPersp2])
         };
         fCurrentProgram->fUniformManager.setMatrix3f(fCurrentProgram->fUniforms.fViewMatrixUni, mt);
         fCurrentProgram->fViewMatrix = vm;
@@ -161,14 +161,14 @@
 
 // helpers for texture matrices
 
-void GrGpuGL::AdjustTextureMatrix(const GrTexture* texture, GrMatrix* matrix) {
+void GrGpuGL::AdjustTextureMatrix(const GrTexture* texture, SkMatrix* matrix) {
     GrAssert(NULL != texture);
     GrAssert(NULL != matrix);
     if (GrSurface::kBottomLeft_Origin == texture->origin()) {
-        GrMatrix invY;
+        SkMatrix invY;
         invY.setAll(SK_Scalar1, 0,           0,
                     0,          -SK_Scalar1, SK_Scalar1,
-                    0,          0,           GrMatrix::I()[8]);
+                    0,          0,           SkMatrix::I()[8]);
         matrix->postConcat(invY);
     }
 }
@@ -176,7 +176,7 @@
 int GrGpuGL::TextureMatrixOptFlags(const GrGLTexture* texture,
                                    const GrEffectStage& stage) {
     GrAssert(NULL != texture);
-    GrMatrix matrix;
+    SkMatrix matrix;
     stage.getTotalMatrix(&matrix);
 
     bool canBeIndentity = GrSurface::kTopLeft_Origin == texture->origin();
@@ -206,28 +206,28 @@
 
         UniformHandle matrixUni = fCurrentProgram->fUniforms.fStages[s].fTextureMatrixUni;
 
-        const GrMatrix& hwMatrix = fCurrentProgram->fTextureMatrices[s];
-        GrMatrix samplerMatrix;
+        const SkMatrix& hwMatrix = fCurrentProgram->fTextureMatrices[s];
+        SkMatrix samplerMatrix;
         drawState.getStage(s).getTotalMatrix(&samplerMatrix);
 
         if (kInvalidUniformHandle != matrixUni &&
             (originChange || !hwMatrix.cheapEqualTo(samplerMatrix))) {
 
-            GrMatrix m = samplerMatrix;
+            SkMatrix m = samplerMatrix;
             AdjustTextureMatrix(texture, &m);
 
             // ES doesn't allow you to pass true to the transpose param,
             // so do our own transpose
             GrGLfloat mt[]  = {
-                SkScalarToFloat(m[GrMatrix::kMScaleX]),
-                SkScalarToFloat(m[GrMatrix::kMSkewY]),
-                SkScalarToFloat(m[GrMatrix::kMPersp0]),
-                SkScalarToFloat(m[GrMatrix::kMSkewX]),
-                SkScalarToFloat(m[GrMatrix::kMScaleY]),
-                SkScalarToFloat(m[GrMatrix::kMPersp1]),
-                SkScalarToFloat(m[GrMatrix::kMTransX]),
-                SkScalarToFloat(m[GrMatrix::kMTransY]),
-                SkScalarToFloat(m[GrMatrix::kMPersp2])
+                SkScalarToFloat(m[SkMatrix::kMScaleX]),
+                SkScalarToFloat(m[SkMatrix::kMSkewY]),
+                SkScalarToFloat(m[SkMatrix::kMPersp0]),
+                SkScalarToFloat(m[SkMatrix::kMSkewX]),
+                SkScalarToFloat(m[SkMatrix::kMScaleY]),
+                SkScalarToFloat(m[SkMatrix::kMPersp1]),
+                SkScalarToFloat(m[SkMatrix::kMTransX]),
+                SkScalarToFloat(m[SkMatrix::kMTransY]),
+                SkScalarToFloat(m[SkMatrix::kMPersp2])
             };
 
             fCurrentProgram->fUniformManager.setMatrix3f(matrixUni, mt);
@@ -656,7 +656,7 @@
 
             if (effect->numTextures() > 0) {
                 const GrGLTexture* texture = static_cast<const GrGLTexture*>(effect->texture(0));
-                GrMatrix samplerMatrix;
+                SkMatrix samplerMatrix;
                 stage.getTotalMatrix(&samplerMatrix);
                 if (NULL != texture) {
                     // We call this helper function rather then simply checking the client-specified
diff --git a/src/gpu/gr_unittests.cpp b/src/gpu/gr_unittests.cpp
index a0f0c18..1d7653b 100644
--- a/src/gpu/gr_unittests.cpp
+++ b/src/gpu/gr_unittests.cpp
@@ -10,7 +10,7 @@
 
 #include "GrBinHashKey.h"
 #include "GrDrawTarget.h"
-#include "GrMatrix.h"
+#include "SkMatrix.h"
 #include "GrRedBlackTree.h"
 #include "GrTDArray.h"
 
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index fccdd65..56dbea4 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -188,7 +188,7 @@
     GrConfigConversionEffect::InstallEffect(NULL,
                                             false,
                                             GrConfigConversionEffect::kNone_PMConversion,
-                                            GrMatrix::I(),
+                                            SkMatrix::I(),
                                             &dummyStage);
     SkScalar matrix[20];
     SkColorMatrixFilter cmf(matrix);