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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 #ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED | 121 #ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED |
122 static int sk_read_user_chunk(png_structp png_ptr, png_unknown_chunkp chunk) { | 122 static int sk_read_user_chunk(png_structp png_ptr, png_unknown_chunkp chunk) { |
123 SkPngChunkReader* peeker = (SkPngChunkReader*)png_get_user_chunk_ptr(png_ptr
); | 123 SkPngChunkReader* peeker = (SkPngChunkReader*)png_get_user_chunk_ptr(png_ptr
); |
124 // readChunk() returning true means continue decoding | 124 // readChunk() returning true means continue decoding |
125 return peeker->readChunk((const char*)chunk->name, chunk->data, chunk->size)
? | 125 return peeker->readChunk((const char*)chunk->name, chunk->data, chunk->size)
? |
126 1 : -1; | 126 1 : -1; |
127 } | 127 } |
128 #endif | 128 #endif |
129 | 129 |
130 static void sk_error_fn(png_structp png_ptr, png_const_charp msg) { | 130 static void sk_error_fn(png_structp png_ptr, png_const_charp msg) { |
131 SkDEBUGF(("------ png error %s\n", msg)); | 131 if (!c_suppressPNGImageDecoderWarnings) { |
| 132 SkDEBUGF(("------ png error %s\n", msg)); |
| 133 } |
132 longjmp(png_jmpbuf(png_ptr), 1); | 134 longjmp(png_jmpbuf(png_ptr), 1); |
133 } | 135 } |
134 | 136 |
135 static void skip_src_rows(png_structp png_ptr, uint8_t storage[], int count) { | 137 static void skip_src_rows(png_structp png_ptr, uint8_t storage[], int count) { |
136 for (int i = 0; i < count; i++) { | 138 for (int i = 0; i < count; i++) { |
137 uint8_t* tmp = storage; | 139 uint8_t* tmp = storage; |
138 png_read_rows(png_ptr, &tmp, png_bytepp_NULL, 1); | 140 png_read_rows(png_ptr, &tmp, png_bytepp_NULL, 1); |
139 } | 141 } |
140 } | 142 } |
141 | 143 |
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1010 return SkImageDecoder::kUnknown_Format; | 1012 return SkImageDecoder::kUnknown_Format; |
1011 } | 1013 } |
1012 | 1014 |
1013 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { | 1015 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { |
1014 return (SkImageEncoder::kPNG_Type == t) ? new SkPNGImageEncoder : nullptr; | 1016 return (SkImageEncoder::kPNG_Type == t) ? new SkPNGImageEncoder : nullptr; |
1015 } | 1017 } |
1016 | 1018 |
1017 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory); | 1019 static SkImageDecoder_DecodeReg gDReg(sk_libpng_dfactory); |
1018 static SkImageDecoder_FormatReg gFormatReg(get_format_png); | 1020 static SkImageDecoder_FormatReg gFormatReg(get_format_png); |
1019 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory); | 1021 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory); |
OLD | NEW |