Add a method to convert SkCodec::Result to a string

Bug: b/63909536
Change-Id: Ic91e3401359f80eadd9d1cd79aa8ef642c60b0fc
Reviewed-on: https://skia-review.googlesource.com/94781
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
diff --git a/include/codec/SkCodec.h b/include/codec/SkCodec.h
index 43f0176..9c215c6 100644
--- a/include/codec/SkCodec.h
+++ b/include/codec/SkCodec.h
@@ -108,6 +108,11 @@
     };
 
     /**
+     *  Readable string representing the error code.
+     */
+    static const char* ResultToString(Result);
+
+    /**
      *  If this stream represents an encoded image that we know how to decode,
      *  return an SkCodec that can decode it. Otherwise return NULL.
      *
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp
index 7de083d..d0fb43a 100644
--- a/src/codec/SkCodec.cpp
+++ b/src/codec/SkCodec.cpp
@@ -684,3 +684,31 @@
     }
     return result;
 }
+
+const char* SkCodec::ResultToString(Result result) {
+    switch (result) {
+        case kSuccess:
+            return "success";
+        case kIncompleteInput:
+            return "incomplete input";
+        case kErrorInInput:
+            return "error in input";
+        case kInvalidConversion:
+            return "invalid conversion";
+        case kInvalidScale:
+            return "invalid scale";
+        case kInvalidParameters:
+            return "invalid parameters";
+        case kInvalidInput:
+            return "invalid input";
+        case kCouldNotRewind:
+            return "could not rewind";
+        case kInternalError:
+            return "internal error";
+        case kUnimplemented:
+            return "unimplemented";
+        default:
+            SkASSERT(false);
+            return "bogus result value";
+    }
+}