Fix some issues in gpu device with perspective. Add a gm that would have caught them.

Review URL: http://codereview.appspot.com/4994048/



git-svn-id: http://skia.googlecode.com/svn/trunk@2256 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gpu/src/GrDefaultPathRenderer.cpp b/gpu/src/GrDefaultPathRenderer.cpp
index 278c751..fd56c07 100644
--- a/gpu/src/GrDefaultPathRenderer.cpp
+++ b/gpu/src/GrDefaultPathRenderer.cpp
@@ -509,8 +509,19 @@
                                GrIntToScalar(fTarget->getRenderTarget()->width()),
                                GrIntToScalar(fTarget->getRenderTarget()->height()));
                 GrMatrix vmi;
-                if (fTarget->getViewInverse(&vmi)) {
+                // mapRect through persp matrix may not be correct
+                if (!fTarget->getViewMatrix().hasPerspective() &&
+                    fTarget->getViewInverse(&vmi)) {
                     vmi.mapRect(&bounds);
+                } else {
+                    if (stages) {
+                        if (!fTarget->getViewInverse(&vmi)) {
+                            GrPrintf("Could not invert matrix.");
+                            return;
+                        }
+                        fTarget->preConcatSamplerMatrices(stages, vmi);
+                    }
+                    fTarget->setViewMatrix(GrMatrix::I());
                 }
             } else {
                 bounds = fPath->getBounds();