Index: src/images/SkImageDecoder_astc.cpp |
diff --git a/src/images/SkImageDecoder_astc.cpp b/src/images/SkImageDecoder_astc.cpp |
index 30f42f05df2980456785feaa457f3b4e7681d389..89c01a5612234c1db8759e572276bcba9275c998 100644 |
--- a/src/images/SkImageDecoder_astc.cpp |
+++ b/src/images/SkImageDecoder_astc.cpp |
@@ -4,16 +4,14 @@ |
* Use of this source code is governed by a BSD-style license that can be |
* found in the LICENSE file. |
*/ |
- |
-#include "SkEndian.h" |
+#include "SkImageDecoder_astc.h" |
#include "SkColorPriv.h" |
-#include "SkImageDecoder.h" |
+#include "SkEndian.h" |
#include "SkScaledBitmapSampler.h" |
#include "SkStream.h" |
#include "SkStreamPriv.h" |
-#include "SkTypes.h" |
- |
#include "SkTextureCompressor.h" |
+#include "SkTypes.h" |
class SkASTCImageDecoder : public SkImageDecoder { |
public: |
@@ -177,34 +175,18 @@ SkImageDecoder::Result SkASTCImageDecoder::onDecode(SkStream* stream, SkBitmap* |
return kSuccess; |
} |
-///////////////////////////////////////////////////////////////////////////////////////// |
-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; |
- } |
- |
- return kASTCMagicNumber == SkEndian_SwapLE32(magic); |
-} |
- |
-static SkImageDecoder* sk_libastc_dfactory(SkStreamRewindable* stream) { |
- if (is_astc(stream)) { |
- return SkNEW(SkASTCImageDecoder); |
- } |
- return NULL; |
-} |
- |
-static SkImageDecoder_DecodeReg gReg(sk_libastc_dfactory); |
- |
-static SkImageDecoder::Format get_format_astc(SkStreamRewindable* stream) { |
- if (is_astc(stream)) { |
+ if (stream->read((void*)&magic, 4) == 4 && |
+ kASTCMagicNumber == SkEndian_SwapLE32(magic)) { |
return SkImageDecoder::kASTC_Format; |
} |
return SkImageDecoder::kUnknown_Format; |
} |
-static SkImageDecoder_FormatReg gFormatReg(get_format_astc); |
+SkImageDecoder* SkCreateASTCImageDecoder(SkImageDecoder::Format format) { |
+ SkASSERT(SkImageDecoder::kASTC_Format == format); |
+ return SkNEW(SkASTCImageDecoder); |
+} |
+ |