Rearrange GRTC::drawPath()

Check for rrects first. Don't recreate path if shape simplified it to check
for nested rects.

Change-Id: I3c82c4269abf8b579ba7e92be76a33c956a01602
Reviewed-on: https://skia-review.googlesource.com/89182
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index 4f566ba..c2b25d8 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -1491,13 +1491,14 @@
                                      GrPaint&& paint,
                                      GrAA aa,
                                      const SkMatrix& viewMatrix,
-                                     const SkPath& originalPath,
+                                     const SkPath& path,
                                      const GrStyle& style) {
     ASSERT_SINGLE_OWNER
     RETURN_IF_ABANDONED
     SkDEBUGCODE(this->validate();)
             GR_CREATE_TRACE_MARKER_CONTEXT("GrRenderTargetContextPriv", "drawPath", fContext);
-    GrShape shape(originalPath, style);
+
+    GrShape shape(path, style);
     if (shape.isEmpty()) {
         if (shape.inverseFilled()) {
             this->drawPaint(clip, std::move(paint), viewMatrix);
@@ -1507,27 +1508,6 @@
 
     AutoCheckFlush acf(this->drawingManager());
 
-    GrAAType aaType = this->chooseAAType(aa, GrAllowMixedSamples::kNo);
-    if (GrAAType::kCoverage == aaType) {
-        // TODO: Make GrShape check for nested rects.
-        SkPath path;
-        shape.asPath(&path);
-        SkRect rects[2];
-        if (shape.style().isSimpleFill() && fills_as_nested_rects(viewMatrix, path, rects)) {
-            // Concave AA paths are expensive - try to avoid them for special cases
-            SkRect rects[2];
-
-            if (fills_as_nested_rects(viewMatrix, path, rects)) {
-                std::unique_ptr<GrDrawOp> op =
-                        GrRectOpFactory::MakeAAFillNestedRects(std::move(paint), viewMatrix, rects);
-                if (op) {
-                    this->addDrawOp(clip, std::move(op));
-                }
-                // A null return indicates that there is nothing to draw in this case.
-                return;
-            }
-        }
-    }
     if (!shape.style().hasPathEffect()) {
         SkRRect rrect;
         // We can ignore the starting point and direction since there is no path effect.
@@ -1546,6 +1526,25 @@
         }
     }
 
+    GrAAType aaType = this->chooseAAType(aa, GrAllowMixedSamples::kNo);
+    if (GrAAType::kCoverage == aaType) {
+        // TODO: Make GrShape check for nested rects.
+        SkRect rects[2];
+        if (shape.style().isSimpleFill() && fills_as_nested_rects(viewMatrix, path, rects)) {
+            // Concave AA paths are expensive - try to avoid them for special cases
+            SkRect rects[2];
+
+            if (fills_as_nested_rects(viewMatrix, path, rects)) {
+                std::unique_ptr<GrDrawOp> op =
+                        GrRectOpFactory::MakeAAFillNestedRects(std::move(paint), viewMatrix, rects);
+                if (op) {
+                    this->addDrawOp(clip, std::move(op));
+                }
+                // A null return indicates that there is nothing to draw in this case.
+                return;
+            }
+        }
+    }
     this->drawShapeUsingPathRenderer(clip, std::move(paint), aa, viewMatrix, shape);
 }