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>
This commit is contained in:
Leon Scroggins III 2018-01-16 11:56:54 -05:00 committed by Skia Commit-Bot
parent 5fb009df3c
commit fe3da02e76
2 changed files with 33 additions and 0 deletions

View File

@ -107,6 +107,11 @@ public:
kUnimplemented,
};
/**
* 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.

View File

@ -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";
}
}