Index: src/images/SkImageDecoder_libico.cpp |
diff --git a/src/images/SkImageDecoder_libico.cpp b/src/images/SkImageDecoder_libico.cpp |
index 5240d09b8672dbdd1980b27bf7d959b8dbcb425f..66e56ce8228593a96b9ae42849cf5e7f1c1f85d1 100644 |
--- a/src/images/SkImageDecoder_libico.cpp |
+++ b/src/images/SkImageDecoder_libico.cpp |
@@ -5,6 +5,7 @@ |
* found in the LICENSE file. |
*/ |
+#include "SkImageDecoder_libico.h" |
#include "SkColorPriv.h" |
#include "SkImageDecoder.h" |
#include "SkStream.h" |
@@ -398,36 +399,23 @@ static void editPixelBit32(const int pixelNo, const unsigned char* buf, |
*address = SkPreMultiplyARGB(alpha, red, green, blue); |
} |
-/////////////////////////////////////////////////////////////////////////////// |
-DEFINE_DECODER_CREATOR(ICOImageDecoder); |
-///////////////////////////////////////////////////////////////////////////////////////// |
- |
-static bool is_ico(SkStreamRewindable* stream) { |
+SkImageDecoder::Format SkDetectFormatICOImageDecoder(SkStreamRewindable* stream) { |
// Check to see if the first four bytes are 0,0,1,0 |
// FIXME: Is that required and sufficient? |
char buf[4]; |
if (stream->read((void*)buf, 4) != 4) { |
- return false; |
+ return SkImageDecoder::kUnknown_Format; |
} |
int reserved = read2Bytes(buf, 0); |
int type = read2Bytes(buf, 2); |
- return 0 == reserved && 1 == type; |
-} |
- |
-static SkImageDecoder* sk_libico_dfactory(SkStreamRewindable* stream) { |
- if (is_ico(stream)) { |
- return SkNEW(SkICOImageDecoder); |
+ if (0 != reserved || 1 != type) { |
+ return SkImageDecoder::kUnknown_Format; |
} |
- return NULL; |
+ return SkImageDecoder::kICO_Format; |
} |
-static SkImageDecoder_DecodeReg gReg(sk_libico_dfactory); |
- |
-static SkImageDecoder::Format get_format_ico(SkStreamRewindable* stream) { |
- if (is_ico(stream)) { |
- return SkImageDecoder::kICO_Format; |
- } |
- return SkImageDecoder::kUnknown_Format; |
+SkImageDecoder* SkCreateICOImageDecoder(SkImageDecoder::Format format) { |
+ SkASSERT(SkImageDecoder::kICO_Format == format); |
+ return SkNEW(SkICOImageDecoder); |
} |
-static SkImageDecoder_FormatReg gFormatReg(get_format_ico); |