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 "SkImageEncoder.h" | 8 #include "SkImageEncoder.h" |
9 #include "SkColor.h" | 9 #include "SkColor.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
11 #include "SkDither.h" | 11 #include "SkDither.h" |
12 #include "SkMath.h" | 12 #include "SkMath.h" |
| 13 #include "SkRTConf.h" |
13 #include "SkStream.h" | 14 #include "SkStream.h" |
14 #include "SkTemplates.h" | 15 #include "SkTemplates.h" |
15 #include "SkUtils.h" | 16 #include "SkUtils.h" |
16 #include "transform_scanline.h" | 17 #include "transform_scanline.h" |
17 | 18 |
18 #include "png.h" | 19 #include "png.h" |
19 | 20 |
20 /* These were dropped in libpng >= 1.4 */ | 21 /* These were dropped in libpng >= 1.4 */ |
21 #ifndef png_infopp_NULL | 22 #ifndef png_infopp_NULL |
22 #define png_infopp_NULL nullptr | 23 #define png_infopp_NULL nullptr |
23 #endif | 24 #endif |
24 | 25 |
25 #ifndef png_bytepp_NULL | 26 #ifndef png_bytepp_NULL |
26 #define png_bytepp_NULL nullptr | 27 #define png_bytepp_NULL nullptr |
27 #endif | 28 #endif |
28 | 29 |
29 #ifndef int_p_NULL | 30 #ifndef int_p_NULL |
30 #define int_p_NULL nullptr | 31 #define int_p_NULL nullptr |
31 #endif | 32 #endif |
32 | 33 |
33 #ifndef png_flush_ptr_NULL | 34 #ifndef png_flush_ptr_NULL |
34 #define png_flush_ptr_NULL nullptr | 35 #define png_flush_ptr_NULL nullptr |
35 #endif | 36 #endif |
36 | 37 |
37 #define DEFAULT_FOR_SUPPRESS_PNG_IMAGE_DECODER_WARNINGS true | 38 #define DEFAULT_FOR_SUPPRESS_PNG_IMAGE_DECODER_WARNINGS true |
38 // Suppress most PNG warnings when calling image decode functions. | 39 SK_CONF_DECLARE(bool, c_suppressPNGImageDecoderWarnings, |
39 static const bool c_suppressPNGImageDecoderWarnings{ | 40 "images.png.suppressDecoderWarnings", |
40 DEFAULT_FOR_SUPPRESS_PNG_IMAGE_DECODER_WARNINGS}; | 41 DEFAULT_FOR_SUPPRESS_PNG_IMAGE_DECODER_WARNINGS, |
| 42 "Suppress most PNG warnings when calling image decode " |
| 43 "functions."); |
41 | 44 |
42 /////////////////////////////////////////////////////////////////////////////// | 45 /////////////////////////////////////////////////////////////////////////////// |
43 | 46 |
44 #include "SkColorPriv.h" | 47 #include "SkColorPriv.h" |
45 #include "SkUnPreMultiply.h" | 48 #include "SkUnPreMultiply.h" |
46 | 49 |
47 static void sk_error_fn(png_structp png_ptr, png_const_charp msg) { | 50 static void sk_error_fn(png_structp png_ptr, png_const_charp msg) { |
48 if (!c_suppressPNGImageDecoderWarnings) { | 51 if (!c_suppressPNGImageDecoderWarnings) { |
49 SkDEBUGF(("------ png error %s\n", msg)); | 52 SkDEBUGF(("------ png error %s\n", msg)); |
50 } | 53 } |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 | 335 |
333 /////////////////////////////////////////////////////////////////////////////// | 336 /////////////////////////////////////////////////////////////////////////////// |
334 DEFINE_ENCODER_CREATOR(PNGImageEncoder); | 337 DEFINE_ENCODER_CREATOR(PNGImageEncoder); |
335 /////////////////////////////////////////////////////////////////////////////// | 338 /////////////////////////////////////////////////////////////////////////////// |
336 | 339 |
337 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { | 340 SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type t) { |
338 return (SkImageEncoder::kPNG_Type == t) ? new SkPNGImageEncoder : nullptr; | 341 return (SkImageEncoder::kPNG_Type == t) ? new SkPNGImageEncoder : nullptr; |
339 } | 342 } |
340 | 343 |
341 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory); | 344 static SkImageEncoder_EncodeReg gEReg(sk_libpng_efactory); |
OLD | NEW |