Drawstate on stack

BUG=skia:

Review URL: https://codereview.chromium.org/732693002
diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp
index 0d3ef62..9a9cf32 100644
--- a/src/gpu/GrSoftwarePathRenderer.cpp
+++ b/src/gpu/GrSoftwarePathRenderer.cpp
@@ -11,9 +11,10 @@
 #include "GrSWMaskHelper.h"
 
 ////////////////////////////////////////////////////////////////////////////////
-bool GrSoftwarePathRenderer::canDrawPath(const SkPath&,
+bool GrSoftwarePathRenderer::canDrawPath(const GrDrawTarget*,
+                                         const GrDrawState*,
+                                         const SkPath&,
                                          const SkStrokeRec&,
-                                         const GrDrawTarget*,
                                          bool antiAlias) const {
     if (NULL == fContext) {
         return false;
@@ -22,10 +23,11 @@
     return true;
 }
 
-GrPathRenderer::StencilSupport GrSoftwarePathRenderer::onGetStencilSupport(
-    const SkPath&,
-    const SkStrokeRec&,
-    const GrDrawTarget*) const {
+GrPathRenderer::StencilSupport
+GrSoftwarePathRenderer::onGetStencilSupport(const GrDrawTarget*,
+                                            const GrDrawState*,
+                                            const SkPath&,
+                                            const SkStrokeRec&) const {
     return GrPathRenderer::kNoSupport_StencilSupport;
 }
 
@@ -36,12 +38,13 @@
 // path bounds will be a subset of the clip bounds. returns false if
 // path bounds would be empty.
 bool get_path_and_clip_bounds(const GrDrawTarget* target,
+                              const GrDrawState* drawState,
                               const SkPath& path,
                               const SkMatrix& matrix,
                               SkIRect* devPathBounds,
                               SkIRect* devClipBounds) {
     // compute bounds as intersection of rt size, clip, and path
-    const GrRenderTarget* rt = target->getDrawState().getRenderTarget();
+    const GrRenderTarget* rt = drawState->getRenderTarget();
     if (NULL == rt) {
         return false;
     }
@@ -74,32 +77,33 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 void draw_around_inv_path(GrDrawTarget* target,
+                          GrDrawState* drawState,
                           const SkIRect& devClipBounds,
                           const SkIRect& devPathBounds) {
     GrDrawState::AutoViewMatrixRestore avmr;
-    if (!avmr.setIdentity(target->drawState())) {
+    if (!avmr.setIdentity(drawState)) {
         return;
     }
     SkRect rect;
     if (devClipBounds.fTop < devPathBounds.fTop) {
         rect.iset(devClipBounds.fLeft, devClipBounds.fTop,
                   devClipBounds.fRight, devPathBounds.fTop);
-        target->drawSimpleRect(rect);
+        target->drawSimpleRect(drawState, rect);
     }
     if (devClipBounds.fLeft < devPathBounds.fLeft) {
         rect.iset(devClipBounds.fLeft, devPathBounds.fTop,
                   devPathBounds.fLeft, devPathBounds.fBottom);
-        target->drawSimpleRect(rect);
+        target->drawSimpleRect(drawState, rect);
     }
     if (devClipBounds.fRight > devPathBounds.fRight) {
         rect.iset(devPathBounds.fRight, devPathBounds.fTop,
                   devClipBounds.fRight, devPathBounds.fBottom);
-        target->drawSimpleRect(rect);
+        target->drawSimpleRect(drawState, rect);
     }
     if (devClipBounds.fBottom > devPathBounds.fBottom) {
         rect.iset(devClipBounds.fLeft, devPathBounds.fBottom,
                   devClipBounds.fRight, devClipBounds.fBottom);
-        target->drawSimpleRect(rect);
+        target->drawSimpleRect(drawState, rect);
     }
 }
 
@@ -107,24 +111,23 @@
 
 ////////////////////////////////////////////////////////////////////////////////
 // return true on success; false on failure
-bool GrSoftwarePathRenderer::onDrawPath(const SkPath& path,
+bool GrSoftwarePathRenderer::onDrawPath(GrDrawTarget* target,
+                                        GrDrawState* drawState,
+                                        const SkPath& path,
                                         const SkStrokeRec& stroke,
-                                        GrDrawTarget* target,
                                         bool antiAlias) {
 
     if (NULL == fContext) {
         return false;
     }
 
-    GrDrawState* drawState = target->drawState();
-
     SkMatrix vm = drawState->getViewMatrix();
 
     SkIRect devPathBounds, devClipBounds;
-    if (!get_path_and_clip_bounds(target, path, vm,
+    if (!get_path_and_clip_bounds(target, drawState, path, vm,
                                   &devPathBounds, &devClipBounds)) {
         if (path.isInverseFillType()) {
-            draw_around_inv_path(target, devClipBounds, devPathBounds);
+            draw_around_inv_path(target, drawState, devClipBounds, devPathBounds);
         }
         return true;
     }
@@ -137,10 +140,11 @@
         return false;
     }
 
-    GrSWMaskHelper::DrawToTargetWithPathMask(texture, target, devPathBounds);
+    GrDrawState copy = *drawState;
+    GrSWMaskHelper::DrawToTargetWithPathMask(texture, target, &copy, devPathBounds);
 
     if (path.isInverseFillType()) {
-        draw_around_inv_path(target, devClipBounds, devPathBounds);
+        draw_around_inv_path(target, drawState, devClipBounds, devPathBounds);
     }
 
     return true;