Index: src/codec/SkCodec.cpp |
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp |
index a49586ffeb1ecf6ff337b1dc12fd0fe8120be113..bbf8dfb909acdae00ae791055fc2943b94c4ecf6 100644 |
--- a/src/codec/SkCodec.cpp |
+++ b/src/codec/SkCodec.cpp |
@@ -8,6 +8,7 @@ |
#include "SkCodec.h" |
#include "SkData.h" |
#include "SkCodec_libbmp.h" |
+#include "SkCodec_libgif.h" |
#include "SkCodec_libico.h" |
#include "SkCodec_libpng.h" |
#include "SkStream.h" |
@@ -19,14 +20,17 @@ struct DecoderProc { |
static const DecoderProc gDecoderProcs[] = { |
{ SkPngCodec::IsPng, SkPngCodec::NewFromStream }, |
- { SkIcoCodec::IsIco, SkIcoCodec::NewFromStream }, |
- { SkBmpCodec::IsBmp, SkBmpCodec::NewFromStream } |
+ { SkGifCodec::IsGif, SkGifCodec::NewFromStream }, |
+ { SkBmpCodec::IsBmp, SkBmpCodec::NewFromStream }, |
+ { SkIcoCodec::IsIco, SkIcoCodec::NewFromStream } |
}; |
SkCodec* SkCodec::NewFromStream(SkStream* stream) { |
if (!stream) { |
return NULL; |
} |
+ |
+ SkCodec* codec; |
for (uint32_t i = 0; i < SK_ARRAY_COUNT(gDecoderProcs); i++) { |
DecoderProc proc = gDecoderProcs[i]; |
const bool correctFormat = proc.IsFormat(stream); |
@@ -34,10 +38,19 @@ SkCodec* SkCodec::NewFromStream(SkStream* stream) { |
return NULL; |
} |
if (correctFormat) { |
- return proc.NewFromStream(stream); |
+ codec = proc.NewFromStream(stream); |
+ break; |
} |
} |
- return NULL; |
+ |
+ // TODO: Is this the correct maxSize? This is 512 MB for kN32. |
scroggo
2015/03/26 20:03:53
Maybe explain why it was chosen?
msarett
2015/03/26 22:26:36
Done.
|
+ const int32_t maxSize = 1 << 27; |
+ if (codec->getInfo().width() * codec->getInfo().height() > maxSize) { |
scroggo
2015/03/26 20:03:53
We need to check codec for NULL.
msarett
2015/03/26 22:26:36
Done.
|
+ SkDebugf("Error: Image size too large, cannot decode.\n"); |
scroggo
2015/03/26 20:03:53
Use SkCodecPrintf.
msarett
2015/03/26 22:26:36
Done.
|
+ return NULL; |
+ } else { |
+ return codec; |
+ } |
} |
SkCodec* SkCodec::NewFromData(SkData* data) { |