Chromium Code Reviews| Index: src/codec/SkCodec.cpp |
| diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp |
| index 33cc9e1c00b7d0e314cb96dbc57a87569b3bbc72..4aa422c184e5b2b5e9c322787e80bb410b2c152d 100644 |
| --- a/src/codec/SkCodec.cpp |
| +++ b/src/codec/SkCodec.cpp |
| @@ -8,9 +8,11 @@ |
| #include "SkCodec.h" |
| #include "SkData.h" |
| #include "SkCodec_libbmp.h" |
| +#include "SkCodec_libgif.h" |
| #include "SkCodec_libico.h" |
| #include "SkCodec_libpng.h" |
| #include "SkCodec_wbmp.h" |
| +#include "SkCodecPriv.h" |
| #include "SkStream.h" |
| struct DecoderProc { |
| @@ -20,6 +22,7 @@ struct DecoderProc { |
| static const DecoderProc gDecoderProcs[] = { |
| { SkPngCodec::IsPng, SkPngCodec::NewFromStream }, |
| + { SkGifCodec::IsGif, SkGifCodec::NewFromStream }, |
| { SkIcoCodec::IsIco, SkIcoCodec::NewFromStream }, |
| { SkBmpCodec::IsBmp, SkBmpCodec::NewFromStream }, |
| { SkWbmpCodec::IsWbmp, SkWbmpCodec::NewFromStream } |
| @@ -29,6 +32,8 @@ SkCodec* SkCodec::NewFromStream(SkStream* stream) { |
| if (!stream) { |
| return NULL; |
| } |
| + |
| + SkCodec* codec = NULL; |
| for (uint32_t i = 0; i < SK_ARRAY_COUNT(gDecoderProcs); i++) { |
| DecoderProc proc = gDecoderProcs[i]; |
| const bool correctFormat = proc.IsFormat(stream); |
| @@ -36,10 +41,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 megapixels (512 MB for kN32). |
| + // This is about 4x smaller than a test image that takes a few minutes for |
| + // dm to decode and draw. |
| + const int32_t maxSize = 1 << 27; |
| + if (codec != NULL && |
| + codec->getInfo().width() * codec->getInfo().height() > maxSize) { |
|
scroggo
2015/03/31 18:39:56
This may never/rarely come up in practice, but I'm
msarett
2015/03/31 20:11:40
Yeah that is certainly possible. Maybe this isn't
scroggo
2015/03/31 20:39:11
You are correct. JPEG supports downscaling by powe
|
| + SkCodecPrintf("Error: Image size too large, cannot decode.\n"); |
| + return NULL; |
| + } else { |
| + return codec; |
| + } |
| } |
| SkCodec* SkCodec::NewFromData(SkData* data) { |