Adds ability to draw rects using a unit square vertex buffer. Useful when matrix/uniform changes are less expensive than sending new verts. 

Adds optional matrix parameters to GrContext drawRect and drawRectToRect so that non-axis-aligned matrices can be drawn using these functions.

codereview Issue 4105049

git-svn-id: http://skia.googlecode.com/svn/trunk@749 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index dca146e..3afd46c 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -512,7 +512,10 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
+#if 0 // not currently being used so don't compile,
+
 // can be used for positions or texture coordinates
+
 class SkRectFanSource {
 public:
     SkRectFanSource(const SkRect& rect) : fRect(rect) {}
@@ -575,6 +578,8 @@
     const SkMatrix& fMatrix;
 };
 
+#endif
+
 ///////////////////////////////////////////////////////////////////////////////
 
 void SkGpuDevice::drawPaint(const SkDraw& draw, const SkPaint& paint) {
@@ -821,23 +826,16 @@
 
     grPaint->setTexture(texture);
     grPaint->fTextureMatrix.setIdentity();
+    GrRect dstRect(0, 0, GrIntToScalar(srcRect.width()), GrIntToScalar(srcRect.height()));
+    GrRect paintRect(GrIntToScalar(srcRect.fLeft)   / texture->allocWidth(),
+                     GrIntToScalar(srcRect.fTop)    / texture->allocHeight(),
+                     GrIntToScalar(srcRect.fRight)  / texture->allocWidth(),
+                     GrIntToScalar(srcRect.fBottom) / texture->allocHeight());
 
-    SkRect paintRect;
-    paintRect.set(SkFixedToScalar((srcRect.fLeft << 16)  / texture->allocWidth()),
-                  SkFixedToScalar((srcRect.fTop << 16)   / texture->allocHeight()),
-                  SkFixedToScalar((srcRect.fRight << 16) / texture->allocWidth()),
-                  SkFixedToScalar((srcRect.fBottom << 16)/ texture->allocHeight()));
+    GrMatrix grMat;
+    SkGr::SkMatrix2GrMatrix(m, &grMat);
 
-    SkRect dstRect;
-    dstRect.set(SkIntToScalar(0),SkIntToScalar(0),
-                SkIntToScalar(srcRect.width()), SkIntToScalar(srcRect.height()));
-
-    SkRectFanSource texSrc(paintRect);
-    fContext->drawCustomVertices(*grPaint,
-                                 GrDrawTarget::kTriangleFan_PrimitiveType,
-                                 SkMatRectFanSource(dstRect, m),
-                                 &texSrc);
-
+    fContext->drawRectToRect(*grPaint, dstRect, paintRect, &grMat);
 }
 
 void SkGpuDevice::drawSprite(const SkDraw& draw, const SkBitmap& bitmap,