OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include "SkImageDecoder.h" | 10 #include "SkImageDecoder.h" |
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1079 return true; | 1079 return true; |
1080 } | 1080 } |
1081 | 1081 |
1082 /////////////////////////////////////////////////////////////////////////////// | 1082 /////////////////////////////////////////////////////////////////////////////// |
1083 DEFINE_DECODER_CREATOR(PNGImageDecoder); | 1083 DEFINE_DECODER_CREATOR(PNGImageDecoder); |
1084 DEFINE_ENCODER_CREATOR(PNGImageEncoder); | 1084 DEFINE_ENCODER_CREATOR(PNGImageEncoder); |
1085 /////////////////////////////////////////////////////////////////////////////// | 1085 /////////////////////////////////////////////////////////////////////////////// |
1086 | 1086 |
1087 #include "SkTRegistry.h" | 1087 #include "SkTRegistry.h" |
1088 | 1088 |
1089 #ifdef SK_ENABLE_LIBPNG | |
1090 SkImageDecoder* sk_libpng_dfactory(SkStream*); | |
1091 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type); | |
1092 #endif | |
1093 | |
1094 SkImageDecoder* sk_libpng_dfactory(SkStream* stream) { | 1089 SkImageDecoder* sk_libpng_dfactory(SkStream* stream) { |
1095 char buf[PNG_BYTES_TO_CHECK]; | 1090 char buf[PNG_BYTES_TO_CHECK]; |
1096 if (stream->read(buf, PNG_BYTES_TO_CHECK) == PNG_BYTES_TO_CHECK && | 1091 if (stream->read(buf, PNG_BYTES_TO_CHECK) == PNG_BYTES_TO_CHECK && |
1097 !png_sig_cmp((png_bytep) buf, (png_size_t)0, PNG_BYTES_TO_CHECK)) { | 1092 !png_sig_cmp((png_bytep) buf, (png_size_t)0, PNG_BYTES_TO_CHECK)) { |
1098 return SkNEW(SkPNGImageDecoder); | 1093 return SkNEW(SkPNGImageDecoder); |
1099 } | 1094 } |
1100 return NULL; | 1095 return NULL; |
1101 } | 1096 } |
1102 | 1097 |
1103 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { | 1098 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { |
1104 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL; | 1099 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL; |
1105 } | 1100 } |
1106 | 1101 |
1107 static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(sk_libpng_efacto
ry); | 1102 static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(sk_libpng_efacto
ry); |
1108 static SkTRegistry<SkImageDecoder*, SkStream*> gDReg(sk_libpng_dfactory); | 1103 static SkTRegistry<SkImageDecoder*, SkStream*> gDReg(sk_libpng_dfactory); |
OLD | NEW |