Index: src/codec/SkCodec.cpp |
diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp |
index a49586ffeb1ecf6ff337b1dc12fd0fe8120be113..1c6e264d023b5a9f6702be448dbb88a755ff6652 100644 |
--- a/src/codec/SkCodec.cpp |
+++ b/src/codec/SkCodec.cpp |
@@ -8,8 +8,10 @@ |
#include "SkCodec.h" |
#include "SkData.h" |
#include "SkCodec_libbmp.h" |
+#include "SkCodec_libgif.h" |
#include "SkCodec_libico.h" |
#include "SkCodec_libpng.h" |
+#include "SkCodecPriv.h" |
#include "SkStream.h" |
struct DecoderProc { |
@@ -19,14 +21,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 +39,22 @@ SkCodec* SkCodec::NewFromStream(SkStream* stream) { |
return NULL; |
} |
if (correctFormat) { |
- return proc.NewFromStream(stream); |
+ codec = proc.NewFromStream(stream); |
+ break; |
} |
} |
- return NULL; |
+ |
+ // Set the max size at 128 MP (512 MB for kN32). |
scroggo
2015/03/27 13:09:36
mega pixel?
msarett
2015/03/27 14:23:20
Haha yeah. I actually googled "megapixel" to find
|
+ // This is about 4x smaller than a test image that takes a few minutes to |
+ // draw. |
scroggo
2015/03/27 13:09:36
decode?
msarett
2015/03/27 14:23:19
This is the test with the very, very large frame s
|
+ const int32_t maxSize = 1 << 27; |
+ if (codec != NULL && |
+ codec->getInfo().width() * codec->getInfo().height() > maxSize) { |
+ SkCodecPrintf("Error: Image size too large, cannot decode.\n"); |
+ return NULL; |
+ } else { |
+ return codec; |
+ } |
} |
SkCodec* SkCodec::NewFromData(SkData* data) { |