Index: src/images/SkImageDecoder_astc.cpp |
diff --git a/src/images/SkImageDecoder_astc.cpp b/src/images/SkImageDecoder_astc.cpp |
index 79e98047d6b214c59db963c7d26aa25253295a3e..3e950d7f0c0927f344c710ee44b537c547305485 100644 |
--- a/src/images/SkImageDecoder_astc.cpp |
+++ b/src/images/SkImageDecoder_astc.cpp |
@@ -4,10 +4,10 @@ |
* Use of this source code is governed by a BSD-style license that can be |
* found in the LICENSE file. |
*/ |
+#include "SkImageDecoder_astc.h" |
#include "SkEndian.h" |
#include "SkColorPriv.h" |
-#include "SkImageDecoder.h" |
#include "SkScaledBitmapSampler.h" |
#include "SkStream.h" |
#include "SkStreamPriv.h" |
@@ -176,34 +176,20 @@ bool SkASTCImageDecoder::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) { |
return true; |
} |
-///////////////////////////////////////////////////////////////////////////////////////// |
-DEFINE_DECODER_CREATOR(ASTCImageDecoder); |
-///////////////////////////////////////////////////////////////////////////////////////// |
- |
-static bool is_astc(SkStreamRewindable* stream) { |
+SkImageDecoder::Format SkDetectFormatASTCImageDecoder(SkStreamRewindable* stream) { |
// Read the ASTC header and make sure it's valid. |
uint32_t magic; |
- if (stream->read((void*)&magic, 4) != 4) { |
- return false; |
+ if (stream->read((void*)&magic, 4) == 4) { |
+ if (kASTCMagicNumber == SkEndian_SwapLE32(magic)) |
+ return SkImageDecoder::kASTC_Format; |
} |
- |
- return kASTCMagicNumber == SkEndian_SwapLE32(magic); |
+ return SkImageDecoder::kUnknown_Format; |
} |
-static SkImageDecoder* sk_libastc_dfactory(SkStreamRewindable* stream) { |
- if (is_astc(stream)) { |
+SkImageDecoder* SkCreateASTCImageDecoder(SkStreamRewindable* stream) { |
+ if (SkDetectFormatASTCImageDecoder(stream) == SkImageDecoder::kASTC_Format) { |
return SkNEW(SkASTCImageDecoder); |
} |
return NULL; |
} |
-static SkImageDecoder_DecodeReg gReg(sk_libastc_dfactory); |
- |
-static SkImageDecoder::Format get_format_astc(SkStreamRewindable* stream) { |
- if (is_astc(stream)) { |
- return SkImageDecoder::kASTC_Format; |
- } |
- return SkImageDecoder::kUnknown_Format; |
-} |
- |
-static SkImageDecoder_FormatReg gFormatReg(get_format_astc); |