Expose SkPath validation as boolean

As a part of serializing SkPaths, I want to be able to know (without
asserting) whether or not a path is valid so that I can discard
potentially malicious deserialized paths.

Currently, SkPath(Ref) both just have asserting validation functions
which can't be used externally.  This patch adds accessors that don't
assert.

Bug: chromium:752755 skia:6955
Change-Id: I4d0ceb31ec660b87e3fda438392ad2b60a27a0da
Reviewed-on: https://skia-review.googlesource.com/31720
Commit-Queue: Mike Klein <mtklein@chromium.org>
Reviewed-by: Mike Reed <reed@google.com>
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index 4f781c4..0978305 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -2219,37 +2219,46 @@
     this->dump(nullptr, false, true);
 }
 
-#ifdef SK_DEBUG
-void SkPath::validate() const {
-    SkASSERT((fFillType & ~3) == 0);
+
+bool SkPath::isValid() const {
+    if ((fFillType & ~3) != 0) {
+        return false;
+    }
 
 #ifdef SK_DEBUG_PATH
     if (!fBoundsIsDirty) {
         SkRect bounds;
 
         bool isFinite = compute_pt_bounds(&bounds, *fPathRef.get());
-        SkASSERT(SkToBool(fIsFinite) == isFinite);
+        if (SkToBool(fIsFinite) != isFinite) {
+            return false;
+        }
 
         if (fPathRef->countPoints() <= 1) {
             // if we're empty, fBounds may be empty but translated, so we can't
             // necessarily compare to bounds directly
             // try path.addOval(2, 2, 2, 2) which is empty, but the bounds will
             // be [2, 2, 2, 2]
-            SkASSERT(bounds.isEmpty());
-            SkASSERT(fBounds.isEmpty());
+            if (!bounds.isEmpty() || !fBounds.isEmpty()) {
+                return false;
+            }
         } else {
             if (bounds.isEmpty()) {
-                SkASSERT(fBounds.isEmpty());
+                if (!fBounds.isEmpty()) {
+                    return false;
+                }
             } else {
                 if (!fBounds.isEmpty()) {
-                    SkASSERT(fBounds.contains(bounds));
+                    if (!fBounds.contains(bounds)) {
+                        return false;
+                    }
                 }
             }
         }
     }
 #endif // SK_DEBUG_PATH
+    return true;
 }
-#endif // SK_DEBUG
 
 ///////////////////////////////////////////////////////////////////////////////