OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
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 "SkCodec_libpng.h" | 8 #include "SkCodec_libpng.h" |
9 #include "SkCodecPriv.h" | 9 #include "SkCodecPriv.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 252 |
253 // FIXME: Could we use the return value of setjmp to specify the type of | 253 // FIXME: Could we use the return value of setjmp to specify the type of |
254 // error? | 254 // error? |
255 if (setjmp(png_jmpbuf(png_ptr))) { | 255 if (setjmp(png_jmpbuf(png_ptr))) { |
256 return false; | 256 return false; |
257 } | 257 } |
258 | 258 |
259 png_set_read_fn(png_ptr, static_cast<void*>(stream), sk_read_fn); | 259 png_set_read_fn(png_ptr, static_cast<void*>(stream), sk_read_fn); |
260 | 260 |
261 #ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED | 261 #ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED |
262 // FIXME: Does this need to be installed so early? | 262 // Hookup our chunkReader so we can see any user-chunks the caller may be in
terested in. |
263 // hookup our chunkReader so we can see any user-chunks the caller may be in
terested in | 263 // This needs to be installed before we read the png header. Android may st
ore ninepatch |
| 264 // chunks in the header. |
264 if (chunkReader) { | 265 if (chunkReader) { |
265 png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_ALWAYS, (png_byte*
)"", 0); | 266 png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_ALWAYS, (png_byte*
)"", 0); |
266 png_set_read_user_chunk_fn(png_ptr, (png_voidp) chunkReader, sk_read_use
r_chunk); | 267 png_set_read_user_chunk_fn(png_ptr, (png_voidp) chunkReader, sk_read_use
r_chunk); |
267 } | 268 } |
268 #endif | 269 #endif |
269 | 270 |
270 // The call to png_read_info() gives us all of the information from the | 271 // The call to png_read_info() gives us all of the information from the |
271 // PNG file before the first IDAT (image data chunk). | 272 // PNG file before the first IDAT (image data chunk). |
272 png_read_info(png_ptr, info_ptr); | 273 png_read_info(png_ptr, info_ptr); |
273 png_uint_32 origWidth, origHeight; | 274 png_uint_32 origWidth, origHeight; |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 } | 859 } |
859 | 860 |
860 if (1 == numberPasses) { | 861 if (1 == numberPasses) { |
861 return new SkPngScanlineDecoder(imageInfo, streamDeleter.detach(), chunk
Reader, | 862 return new SkPngScanlineDecoder(imageInfo, streamDeleter.detach(), chunk
Reader, |
862 png_ptr, info_ptr, bitDepth); | 863 png_ptr, info_ptr, bitDepth); |
863 } | 864 } |
864 | 865 |
865 return new SkPngInterlacedScanlineDecoder(imageInfo, streamDeleter.detach(),
chunkReader, | 866 return new SkPngInterlacedScanlineDecoder(imageInfo, streamDeleter.detach(),
chunkReader, |
866 png_ptr, info_ptr, bitDepth, numbe
rPasses); | 867 png_ptr, info_ptr, bitDepth, numbe
rPasses); |
867 } | 868 } |
OLD | NEW |