Chromium Code Reviews| Index: src/codec/SkCodec.cpp |
| diff --git a/src/codec/SkCodec.cpp b/src/codec/SkCodec.cpp |
| index bb7b26529b9af8fe7c106818e5514c47617cdf76..b53e9268133e60b922f425607a06bb2fdb0b5c73 100644 |
| --- a/src/codec/SkCodec.cpp |
| +++ b/src/codec/SkCodec.cpp |
| @@ -5,20 +5,35 @@ |
| * found in the LICENSE file. |
| */ |
| -#include "SkBmpCodec.h" |
| #include "SkCodec.h" |
| #include "SkCodecPriv.h" |
| #include "SkData.h" |
| +#include "SkStream.h" |
| + |
| +#ifdef SK_CODEC_DECODES_BMP |
|
mtklein
2016/02/16 23:16:01
You might not need to guard all these headers? II
msarett
2016/02/17 14:34:54
Done. Was able to get rid of some but not all of
|
| +#include "SkBmpCodec.h" |
| +#endif |
| +#ifdef SK_CODEC_DECODES_GIF |
| #include "SkGifCodec.h" |
| +#endif |
| +#ifdef SK_CODEC_DECODES_ICO |
| #include "SkIcoCodec.h" |
| +#endif |
| +#ifdef SK_CODEC_DECODES_JPEG |
| #include "SkJpegCodec.h" |
| +#endif |
| +#ifdef SK_CODEC_DECODES_PNG |
| #include "SkPngCodec.h" |
| +#endif |
| #ifdef SK_CODEC_DECODES_RAW |
| #include "SkRawCodec.h" |
| #endif |
| -#include "SkStream.h" |
| +#ifdef SK_CODEC_DECODES_WBMP |
| #include "SkWbmpCodec.h" |
| +#endif |
| +#ifdef SK_CODEC_DECODES_WEBP |
| #include "SkWebpCodec.h" |
| +#endif |
| struct DecoderProc { |
| bool (*IsFormat)(const void*, size_t); |
| @@ -26,16 +41,32 @@ struct DecoderProc { |
| }; |
| static const DecoderProc gDecoderProcs[] = { |
| +#ifdef SK_CODEC_DECODES_JPEG |
| { SkJpegCodec::IsJpeg, SkJpegCodec::NewFromStream }, |
| +#endif |
| +#ifdef SK_CODEC_DECODES_WEBP |
| { SkWebpCodec::IsWebp, SkWebpCodec::NewFromStream }, |
| +#endif |
| +#ifdef SK_CODEC_DECODES_GIF |
| { SkGifCodec::IsGif, SkGifCodec::NewFromStream }, |
| +#endif |
| +#ifdef SK_CODEC_DECODES_ICO |
| { SkIcoCodec::IsIco, SkIcoCodec::NewFromStream }, |
| +#endif |
| +#ifdef SK_CODEC_DECODES_BMP |
| { SkBmpCodec::IsBmp, SkBmpCodec::NewFromStream }, |
| +#endif |
| +#ifdef SK_CODEC_DECODES_WBMP |
| { SkWbmpCodec::IsWbmp, SkWbmpCodec::NewFromStream } |
| +#endif |
| }; |
| size_t SkCodec::MinBufferedBytesNeeded() { |
| +#ifdef SK_CODEC_DECODES_WEBP |
| return WEBP_VP8_HEADER_SIZE; |
| +#else |
| + return 30; |
| +#endif |
| } |
| SkCodec* SkCodec::NewFromStream(SkStream* stream, |
| @@ -77,9 +108,12 @@ SkCodec* SkCodec::NewFromStream(SkStream* stream, |
| // PNG is special, since we want to be able to supply an SkPngChunkReader. |
| // But this code follows the same pattern as the loop. |
| +#ifdef SK_CODEC_DECODES_PNG |
| if (SkPngCodec::IsPng(buffer, bytesRead)) { |
| return SkPngCodec::NewFromStream(streamDeleter.detach(), chunkReader); |
| - } else { |
| + } else |
| +#endif |
| + { |
| for (DecoderProc proc : gDecoderProcs) { |
| if (proc.IsFormat(buffer, bytesRead)) { |
| return proc.NewFromStream(streamDeleter.detach()); |