In AAConvexPathRenderer, don't assume that path direction can be computed

With a perspective view matrix, we transform the path, which can
collapse it down and cause CheapComputeFirstDirection to fail. In that
case, just skip drawing the path, rather than asserting.

Change-Id: I59ee3c74d02d41913136626a653c64f825a9d56a
Bug: https://bugs.fuchsia.dev/p/fuchsia/issues/detail?id=37330
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/244298
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
diff --git a/src/gpu/ops/GrAAConvexPathRenderer.cpp b/src/gpu/ops/GrAAConvexPathRenderer.cpp
index 4aa860f..59a0871 100644
--- a/src/gpu/ops/GrAAConvexPathRenderer.cpp
+++ b/src/gpu/ops/GrAAConvexPathRenderer.cpp
@@ -219,21 +219,25 @@
     }
 }
 
-static inline SkPathPriv::FirstDirection get_direction(const SkPath& path, const SkMatrix& m) {
+static inline bool get_direction(const SkPath& path, const SkMatrix& m,
+                                 SkPathPriv::FirstDirection* dir) {
     // At this point, we've already returned true from canDraw(), which checked that the path's
     // direction could be determined, so this should just be fetching the cached direction.
-    SkPathPriv::FirstDirection dir;
-    SkAssertResult(SkPathPriv::CheapComputeFirstDirection(path, &dir));
+    // However, if perspective is involved, we're operating on a transformed path, which may no
+    // longer have a computable direction.
+    if (!SkPathPriv::CheapComputeFirstDirection(path, dir)) {
+        return false;
+    }
 
     // check whether m reverses the orientation
     SkASSERT(!m.hasPerspective());
     SkScalar det2x2 = m.get(SkMatrix::kMScaleX) * m.get(SkMatrix::kMScaleY) -
                       m.get(SkMatrix::kMSkewX)  * m.get(SkMatrix::kMSkewY);
     if (det2x2 < 0) {
-        dir = SkPathPriv::OppositeFirstDirection(dir);
+        *dir = SkPathPriv::OppositeFirstDirection(*dir);
     }
 
-    return dir;
+    return true;
 }
 
 static inline void add_line_to_segment(const SkPoint& pt,
@@ -283,7 +287,10 @@
     // line paths. We detect paths that are very close to a line (zero area) and
     // draw nothing.
     DegenerateTestData degenerateData;
-    SkPathPriv::FirstDirection dir = get_direction(path, m);
+    SkPathPriv::FirstDirection dir;
+    if (!get_direction(path, m, &dir)) {
+        return false;
+    }
 
     for (;;) {
         SkPoint pts[4];