Index: src/images/SkImageDecoder.cpp |
diff --git a/src/images/SkImageDecoder.cpp b/src/images/SkImageDecoder.cpp |
index c16efcf1f32797330cf39d29d10ed2da2f5ee951..c3d0f126e1d4d8de2c9db7d342fc0a5be919638b 100644 |
--- a/src/images/SkImageDecoder.cpp |
+++ b/src/images/SkImageDecoder.cpp |
@@ -8,6 +8,7 @@ |
#include "SkImageDecoder.h" |
#include "SkBitmap.h" |
+#include "SkErrorInternals.h" |
#include "SkImagePriv.h" |
#include "SkPixelRef.h" |
#include "SkStream.h" |
@@ -18,17 +19,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() |
@@ -59,9 +49,43 @@ SkImageDecoder::Format SkImageDecoder::getFormat() const { |
return kUnknown_Format; |
} |
+SkImageDecoder::Format SkImageDecoder::onGetFormat(SkStream*) const { |
+ return kUnknown_Format; |
+} |
+ |
+SkImageDecoder::Format SkImageDecoder::getFormat(SkStream* stream) const { |
+ Format format = this->onGetFormat(stream); |
epoger
2013/04/23 16:03:41
It bugs me that SkImageDecoder::getFormat(SkStream
scroggo
2013/04/24 18:00:05
I've replaced this function with a static function
|
+ if (!stream->rewind()) { |
+ SkErrorInternals::SetError(kInvalidOperation_SkError, |
+ "Unable to rewind the image stream\n"); |
+ } |
+ return format; |
+} |
+ |
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"; |
+ case kMultiple_Formats: |
+ return "Multiple formats"; |
+ default: |
+ SkASSERT(!"Invalid format type!"); |
+ } |
+ return "Unknown Format"; |
} |
SkImageDecoder::Peeker* SkImageDecoder::setPeeker(Peeker* peeker) { |