| Index: src/images/SkImageDecoder_libico.cpp
|
| diff --git a/src/images/SkImageDecoder_libico.cpp b/src/images/SkImageDecoder_libico.cpp
|
| index ffc59e0003e1ca6706f3ea985cab37d680fdc432..38883c259a38d8a6ba04e131ab60315a9907e394 100644
|
| --- a/src/images/SkImageDecoder_libico.cpp
|
| +++ b/src/images/SkImageDecoder_libico.cpp
|
| @@ -20,6 +20,8 @@ public:
|
| return kICO_Format;
|
| }
|
|
|
| + virtual Format onGetFormat(SkStream*) const SK_OVERRIDE;
|
| +
|
| protected:
|
| virtual bool onDecode(SkStream* stream, SkBitmap* bm, Mode) SK_OVERRIDE;
|
|
|
| @@ -369,13 +371,7 @@ static void editPixelBit32(const int pixelNo, const unsigned char* buf,
|
| *address = SkPreMultiplyARGB(alpha, red, green, blue);
|
| }
|
|
|
| -///////////////////////////////////////////////////////////////////////////////
|
| -DEFINE_DECODER_CREATOR(ICOImageDecoder);
|
| -/////////////////////////////////////////////////////////////////////////////////////////
|
| -
|
| -#include "SkTRegistry.h"
|
| -
|
| -static SkImageDecoder* sk_libico_dfactory(SkStream* stream) {
|
| +static bool is_ico(SkStream* stream) {
|
| // Check to see if the first four bytes are 0,0,1,0
|
| // FIXME: Is that required and sufficient?
|
| SkAutoMalloc autoMal(4);
|
| @@ -385,9 +381,29 @@ static SkImageDecoder* sk_libico_dfactory(SkStream* stream) {
|
| int type = read2Bytes(buf, 2);
|
| if (reserved != 0 || type != 1) {
|
| // This stream does not represent an ICO image.
|
| - return NULL;
|
| + return false;
|
| + }
|
| + return true;
|
| +}
|
| +
|
| +SkImageDecoder::Format SkICOImageDecoder::onGetFormat(SkStream* stream) const {
|
| + if (is_ico(stream)) {
|
| + return kICO_Format;
|
| + }
|
| + return kUnknown_Format;
|
| +}
|
| +
|
| +///////////////////////////////////////////////////////////////////////////////
|
| +DEFINE_DECODER_CREATOR(ICOImageDecoder);
|
| +/////////////////////////////////////////////////////////////////////////////////////////
|
| +
|
| +#include "SkTRegistry.h"
|
| +
|
| +static SkImageDecoder* sk_libico_dfactory(SkStream* stream) {
|
| + if (is_ico(stream)) {
|
| + return SkNEW(SkICOImageDecoder);
|
| }
|
| - return SkNEW(SkICOImageDecoder);
|
| + return NULL;
|
| }
|
|
|
| static SkTRegistry<SkImageDecoder*, SkStream*> gReg(sk_libico_dfactory);
|
|
|