Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(633)

Unified Diff: src/images/SkImageDecoder_pkm.cpp

Issue 670453002: Remove image decoder and encoder autoregistration (Closed) Base URL: https://skia.googlesource.com/skia.git@separate-image-decoder-01-skpicture
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/images/SkImageDecoder_pkm.h ('k') | src/images/SkImageDecoder_wbmp.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/images/SkImageDecoder_pkm.cpp
diff --git a/src/images/SkImageDecoder_pkm.cpp b/src/images/SkImageDecoder_pkm.cpp
index 746ae40c4c287a44839ad6d22d4fa84acd402742..347f162a4d8aa5e836c9a6b93bc3c7cb28fe7e13 100644
--- a/src/images/SkImageDecoder_pkm.cpp
+++ b/src/images/SkImageDecoder_pkm.cpp
@@ -4,9 +4,8 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
-
+#include "SkImageDecoder_pkm.h"
#include "SkColorPriv.h"
-#include "SkImageDecoder.h"
#include "SkScaledBitmapSampler.h"
#include "SkStream.h"
#include "SkStreamPriv.h"
@@ -102,34 +101,17 @@ SkImageDecoder::Result SkPKMImageDecoder::onDecode(SkStream* stream, SkBitmap* b
return kSuccess;
}
-/////////////////////////////////////////////////////////////////////////////////////////
-DEFINE_DECODER_CREATOR(PKMImageDecoder);
-/////////////////////////////////////////////////////////////////////////////////////////
-
-static bool is_pkm(SkStreamRewindable* stream) {
- // Read the PKM header and make sure it's valid.
+SkImageDecoder::Format SkDetectFormatPKMImageDecoder(SkStreamRewindable* stream) {
unsigned char buf[ETC_PKM_HEADER_SIZE];
- if (stream->read((void*)buf, ETC_PKM_HEADER_SIZE) != ETC_PKM_HEADER_SIZE) {
- return false;
- }
-
- return SkToBool(etc1_pkm_is_valid(buf));
-}
-
-static SkImageDecoder* sk_libpkm_dfactory(SkStreamRewindable* stream) {
- if (is_pkm(stream)) {
- return SkNEW(SkPKMImageDecoder);
+ if (stream->read((void*)buf, ETC_PKM_HEADER_SIZE) != ETC_PKM_HEADER_SIZE ||
+ !etc1_pkm_is_valid(buf)) {
+ return SkImageDecoder::kUnknown_Format;
}
- return NULL;
+ return SkImageDecoder::kPKM_Format;
}
-static SkImageDecoder_DecodeReg gReg(sk_libpkm_dfactory);
-
-static SkImageDecoder::Format get_format_pkm(SkStreamRewindable* stream) {
- if (is_pkm(stream)) {
- return SkImageDecoder::kPKM_Format;
- }
- return SkImageDecoder::kUnknown_Format;
+SkImageDecoder* SkCreatePKMImageDecoder(SkImageDecoder::Format format) {
+ SkASSERT(SkImageDecoder::kPKM_Format == format);
+ return SkNEW(SkPKMImageDecoder);
}
-static SkImageDecoder_FormatReg gFormatReg(get_format_pkm);
« no previous file with comments | « src/images/SkImageDecoder_pkm.h ('k') | src/images/SkImageDecoder_wbmp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698