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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 SkStream* sk_stream = (SkStream*) png_get_io_ptr(png_ptr); | 117 SkStream* sk_stream = (SkStream*) png_get_io_ptr(png_ptr); |
118 size_t bytes = sk_stream->read(data, length); | 118 size_t bytes = sk_stream->read(data, length); |
119 if (bytes != length) { | 119 if (bytes != length) { |
120 png_error(png_ptr, "Read Error!"); | 120 png_error(png_ptr, "Read Error!"); |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 #ifdef SK_BUILD_FOR_ANDROID | 124 #ifdef SK_BUILD_FOR_ANDROID |
125 static void sk_seek_fn(png_structp png_ptr, png_uint_32 offset) { | 125 static void sk_seek_fn(png_structp png_ptr, png_uint_32 offset) { |
126 SkStream* sk_stream = (SkStream*) png_get_io_ptr(png_ptr); | 126 SkStream* sk_stream = (SkStream*) png_get_io_ptr(png_ptr); |
127 sk_stream->rewind(); | 127 if (!sk_stream->rewind()) { |
| 128 png_error(png_ptr, "Failed to rewind stream!"); |
| 129 } |
128 (void)sk_stream->skip(offset); | 130 (void)sk_stream->skip(offset); |
129 } | 131 } |
130 #endif | 132 #endif |
131 | 133 |
132 static int sk_read_user_chunk(png_structp png_ptr, png_unknown_chunkp chunk) { | 134 static int sk_read_user_chunk(png_structp png_ptr, png_unknown_chunkp chunk) { |
133 SkImageDecoder::Peeker* peeker = | 135 SkImageDecoder::Peeker* peeker = |
134 (SkImageDecoder::Peeker*)png_get_user_chunk_ptr(png_ptr); | 136 (SkImageDecoder::Peeker*)png_get_user_chunk_ptr(png_ptr); |
135 // peek() returning true means continue decoding | 137 // peek() returning true means continue decoding |
136 return peeker->peek((const char*)chunk->name, chunk->data, chunk->size) ? | 138 return peeker->peek((const char*)chunk->name, chunk->data, chunk->size) ? |
137 1 : -1; | 139 1 : -1; |
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1197 return SkImageDecoder::kUnknown_Format; | 1199 return SkImageDecoder::kUnknown_Format; |
1198 } | 1200 } |
1199 | 1201 |
1200 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { | 1202 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { |
1201 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL; | 1203 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL; |
1202 } | 1204 } |
1203 | 1205 |
1204 static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(sk_libpng_efacto
ry); | 1206 static SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> gEReg(sk_libpng_efacto
ry); |
1205 static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_png)
; | 1207 static SkTRegistry<SkImageDecoder::Format, SkStream*> gFormatReg(get_format_png)
; |
1206 static SkTRegistry<SkImageDecoder*, SkStream*> gDReg(sk_libpng_dfactory); | 1208 static SkTRegistry<SkImageDecoder*, SkStream*> gDReg(sk_libpng_dfactory); |
OLD | NEW |