| 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);
|
|
|