diff options
author | Leon Scroggins III <scroggo@google.com> | 2018-01-16 11:56:54 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-01-16 17:17:58 +0000 |
commit | fe3da02e76a0288d9245e1c1253cdbac07729c4b (patch) | |
tree | ed7ffe463770dab5806de759d75b1830396b0cc5 | |
parent | 5fb009df3c87167762b33483ee82b5fe632837a9 (diff) |
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>
-rw-r--r-- | include/codec/SkCodec.h | 5 | ||||
-rw-r--r-- | src/codec/SkCodec.cpp | 28 |
2 files changed, 33 insertions, 0 deletions
diff --git a/include/codec/SkCodec.h b/include/codec/SkCodec.h index 43f0176081..9c215c6dd4 100644 --- a/include/codec/SkCodec.h +++ b/include/codec/SkCodec.h @@ -108,6 +108,11 @@ public: }; /** + * 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 7de083db3c..d0fb43a053 100644 --- a/src/codec/SkCodec.cpp +++ b/src/codec/SkCodec.cpp @@ -684,3 +684,31 @@ std::vector<SkCodec::FrameInfo> SkCodec::getFrameInfo() { } 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"; + } +} |