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