Attempt to reland 8264-5 with warning-as-error fixes.




git-svn-id: http://skia.googlecode.com/svn/trunk@8272 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrSWMaskHelper.cpp b/src/gpu/GrSWMaskHelper.cpp
index fe9fd82..2cf56d6 100644
--- a/src/gpu/GrSWMaskHelper.cpp
+++ b/src/gpu/GrSWMaskHelper.cpp
@@ -197,18 +197,29 @@
         // && edge rendering (kEdgeEffectStage in GrContext)
         kPathMaskStage = GrPaint::kTotalStages,
     };
-    GrAssert(!drawState->isStageEnabled(kPathMaskStage));
-    drawState->createTextureEffect(kPathMaskStage, texture, SkMatrix::I());
-    SkScalar w = SkIntToScalar(rect.width());
-    SkScalar h = SkIntToScalar(rect.height());
-    GrRect maskRect = GrRect::MakeWH(w / texture->width(),
-                                     h / texture->height());
 
     GrRect dstRect = GrRect::MakeLTRB(
                             SK_Scalar1 * rect.fLeft,
                             SK_Scalar1 * rect.fTop,
                             SK_Scalar1 * rect.fRight,
                             SK_Scalar1 * rect.fBottom);
-    target->drawRect(dstRect, NULL, &maskRect, NULL, kPathMaskStage);
+
+    // We want to use device coords to compute the texture coordinates. We set our matrix to be
+    // equal to the view matrix followed by a translation so that the top-left of the device bounds
+    // maps to 0,0, and then a scaling matrix to normalized coords. We apply this matrix to the
+    // vertex positions rather than local coords.
+    SkMatrix maskMatrix;
+    maskMatrix.setIDiv(texture->width(), texture->height());
+    maskMatrix.preTranslate(SkIntToScalar(-rect.fLeft), SkIntToScalar(-rect.fTop));
+    maskMatrix.preConcat(drawState->getViewMatrix());
+
+    GrAssert(!drawState->isStageEnabled(kPathMaskStage));
+    drawState->setEffect(kPathMaskStage,
+                         GrSimpleTextureEffect::Create(texture,
+                                                       maskMatrix,
+                                                       false,
+                                                       GrEffect::kPosition_CoordsType))->unref();
+
+    target->drawSimpleRect(dstRect);
     drawState->disableStage(kPathMaskStage);
 }