OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkImageDecoder.h" | 8 #include "SkImageDecoder.h" |
9 #include "SkImageEncoder.h" | 9 #include "SkImageEncoder.h" |
10 #include "SkColor.h" | 10 #include "SkColor.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 SkStreamRewindable* sk_stream = (SkStreamRewindable*) png_get_io_ptr(png_ptr
); | 136 SkStreamRewindable* sk_stream = (SkStreamRewindable*) png_get_io_ptr(png_ptr
); |
137 if (!sk_stream->rewind()) { | 137 if (!sk_stream->rewind()) { |
138 png_error(png_ptr, "Failed to rewind stream!"); | 138 png_error(png_ptr, "Failed to rewind stream!"); |
139 } | 139 } |
140 (void)sk_stream->skip(offset); | 140 (void)sk_stream->skip(offset); |
141 } | 141 } |
142 #endif | 142 #endif |
143 | 143 |
144 #ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED | 144 #ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED |
145 static int sk_read_user_chunk(png_structp png_ptr, png_unknown_chunkp chunk) { | 145 static int sk_read_user_chunk(png_structp png_ptr, png_unknown_chunkp chunk) { |
146 SkImageDecoder::Peeker* peeker = | 146 SkChunkReader* peeker = (SkChunkReader*)png_get_user_chunk_ptr(png_ptr); |
147 (SkImageDecoder::Peeker*)png_get_user_chunk_ptr(png_ptr); | 147 // readChunk() returning true means continue decoding |
148 // peek() returning true means continue decoding | 148 return peeker->readChunk((const char*)chunk->name, chunk->data, chunk->size)
? |
149 return peeker->peek((const char*)chunk->name, chunk->data, chunk->size) ? | |
150 1 : -1; | 149 1 : -1; |
151 } | 150 } |
152 #endif | 151 #endif |
153 | 152 |
154 static void sk_error_fn(png_structp png_ptr, png_const_charp msg) { | 153 static void sk_error_fn(png_structp png_ptr, png_const_charp msg) { |
155 SkDEBUGF(("------ png error %s\n", msg)); | 154 SkDEBUGF(("------ png error %s\n", msg)); |
156 longjmp(png_jmpbuf(png_ptr), 1); | 155 longjmp(png_jmpbuf(png_ptr), 1); |
157 } | 156 } |
158 | 157 |
159 static void skip_src_rows(png_structp png_ptr, uint8_t storage[], int count) { | 158 static void skip_src_rows(png_structp png_ptr, uint8_t storage[], int count) { |
(...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1280 return SkImageDecoder::kUnknown_Format; | 1279 return SkImageDecoder::kUnknown_Format; |
1281 } | 1280 } |
1282 | 1281 |
1283 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { | 1282 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { |
1284 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL; | 1283 return (SkImageEncoder::kPNG_Type == t) ? SkNEW(SkPNGImageEncoder) : NULL; |
1285 } | 1284 } |
1286 | 1285 |
1287 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory); | 1286 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory); |
1288 static SkImageDecoder_FormatReg gFormatReg(get_format_png); | 1287 static SkImageDecoder_FormatReg gFormatReg(get_format_png); |
1289 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory); | 1288 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory); |
OLD | NEW |