Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(495)

Unified Diff: src/images/SkImageDecoder.cpp

Issue 14363003: Updates to skimage tool to use it for testing. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: GetFormat -> GetStreamFormat Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/images/SkImageEncoder.h ('k') | src/images/SkImageDecoder_FactoryRegistrar.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkImageDecoder.cpp
diff --git a/src/images/SkImageDecoder.cpp b/src/images/SkImageDecoder.cpp
index c16efcf1f32797330cf39d29d10ed2da2f5ee951..16cba641db4bade629f2ce5be63a779b41930c64 100644
--- a/src/images/SkImageDecoder.cpp
+++ b/src/images/SkImageDecoder.cpp
@@ -18,17 +18,6 @@ SK_DEFINE_INST_COUNT(SkImageDecoder::Peeker)
SK_DEFINE_INST_COUNT(SkImageDecoder::Chooser)
SK_DEFINE_INST_COUNT(SkImageDecoderFactory)
-const char *SkImageDecoder::sFormatName[] = {
- "Unknown Format",
- "BMP",
- "GIF",
- "ICO",
- "JPEG",
- "PNG",
- "WBMP",
- "WEBP",
-};
-
static SkBitmap::Config gDeviceConfig = SkBitmap::kNo_Config;
SkBitmap::Config SkImageDecoder::GetDeviceConfig()
@@ -60,8 +49,27 @@ SkImageDecoder::Format SkImageDecoder::getFormat() const {
}
const char* SkImageDecoder::getFormatName() const {
- SkASSERT(SK_ARRAY_COUNT(sFormatName) == kLastKnownFormat);
- return sFormatName[this->getFormat()];
+ switch (this->getFormat()) {
+ case kUnknown_Format:
+ return "Unknown Format";
+ case kBMP_Format:
+ return "BMP";
+ case kGIF_Format:
+ return "GIF";
+ case kICO_Format:
+ return "ICO";
+ case kJPEG_Format:
+ return "JPEG";
+ case kPNG_Format:
+ return "PNG";
+ case kWBMP_Format:
+ return "WBMP";
+ case kWEBP_Format:
+ return "WEBP";
+ default:
+ SkASSERT(!"Invalid format type!");
+ }
+ return "Unknown Format";
}
SkImageDecoder::Peeker* SkImageDecoder::setPeeker(Peeker* peeker) {
@@ -321,6 +329,11 @@ bool SkImageDecoder::DecodeStream(SkStream* stream, SkBitmap* bm,
success = codec->decode(stream, bm, pref, mode);
if (success && format) {
*format = codec->getFormat();
+ if (kUnknown_Format == *format) {
+ if (stream->rewind()) {
+ *format = GetStreamFormat(stream);
+ }
+ }
}
delete codec;
}
« no previous file with comments | « include/images/SkImageEncoder.h ('k') | src/images/SkImageDecoder_FactoryRegistrar.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698