| 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 "SkCodecPriv.h" | 8 #include "SkCodecPriv.h" |
| 9 #include "SkColorPriv.h" | 9 #include "SkColorPriv.h" |
| 10 #include "SkColorTable.h" | 10 #include "SkColorTable.h" |
| 11 #include "SkBitmap.h" | 11 #include "SkBitmap.h" |
| 12 #include "SkMath.h" | 12 #include "SkMath.h" |
| 13 #include "SkOpts.h" | 13 #include "SkOpts.h" |
| 14 #include "SkPngCodec.h" | 14 #include "SkPngCodec.h" |
| 15 #include "SkPngFilters.h" | |
| 16 #include "SkSize.h" | 15 #include "SkSize.h" |
| 17 #include "SkStream.h" | 16 #include "SkStream.h" |
| 18 #include "SkSwizzler.h" | 17 #include "SkSwizzler.h" |
| 19 #include "SkTemplates.h" | 18 #include "SkTemplates.h" |
| 20 | 19 |
| 21 // png_struct::read_filter[] was added in libpng 1.5.7. | |
| 22 #if defined(__SSE2__) && PNG_LIBPNG_VER >= 10507 && !defined(PNG_SKIP_SKIA_OPTS) | |
| 23 #include "pngstruct.h" | |
| 24 | |
| 25 extern "C" void sk_png_init_filter_functions_sse2(png_structp png, unsigned
int bpp) { | |
| 26 if (bpp == 3) { | |
| 27 png->read_filter[PNG_FILTER_VALUE_SUB -1] = sk_sub3_sse2; | |
| 28 png->read_filter[PNG_FILTER_VALUE_AVG -1] = sk_avg3_sse2; | |
| 29 png->read_filter[PNG_FILTER_VALUE_PAETH-1] = sk_paeth3_sse2; | |
| 30 } | |
| 31 if (bpp == 4) { | |
| 32 png->read_filter[PNG_FILTER_VALUE_SUB -1] = sk_sub4_sse2; | |
| 33 png->read_filter[PNG_FILTER_VALUE_AVG -1] = sk_avg4_sse2; | |
| 34 png->read_filter[PNG_FILTER_VALUE_PAETH-1] = sk_paeth4_sse2; | |
| 35 } | |
| 36 } | |
| 37 #endif | |
| 38 | |
| 39 /////////////////////////////////////////////////////////////////////////////// | 20 /////////////////////////////////////////////////////////////////////////////// |
| 40 // Callback functions | 21 // Callback functions |
| 41 /////////////////////////////////////////////////////////////////////////////// | 22 /////////////////////////////////////////////////////////////////////////////// |
| 42 | 23 |
| 43 static void sk_error_fn(png_structp png_ptr, png_const_charp msg) { | 24 static void sk_error_fn(png_structp png_ptr, png_const_charp msg) { |
| 44 SkCodecPrintf("------ png error %s\n", msg); | 25 SkCodecPrintf("------ png error %s\n", msg); |
| 45 longjmp(png_jmpbuf(png_ptr), 1); | 26 longjmp(png_jmpbuf(png_ptr), 1); |
| 46 } | 27 } |
| 47 | 28 |
| 48 void sk_warning_fn(png_structp, png_const_charp msg) { | 29 void sk_warning_fn(png_structp, png_const_charp msg) { |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 } | 739 } |
| 759 | 740 |
| 760 if (1 == numberPasses) { | 741 if (1 == numberPasses) { |
| 761 return new SkPngScanlineDecoder(imageInfo, streamDeleter.detach(), chunk
Reader, | 742 return new SkPngScanlineDecoder(imageInfo, streamDeleter.detach(), chunk
Reader, |
| 762 png_ptr, info_ptr, bitDepth); | 743 png_ptr, info_ptr, bitDepth); |
| 763 } | 744 } |
| 764 | 745 |
| 765 return new SkPngInterlacedScanlineDecoder(imageInfo, streamDeleter.detach(),
chunkReader, | 746 return new SkPngInterlacedScanlineDecoder(imageInfo, streamDeleter.detach(),
chunkReader, |
| 766 png_ptr, info_ptr, bitDepth, numbe
rPasses); | 747 png_ptr, info_ptr, bitDepth, numbe
rPasses); |
| 767 } | 748 } |
| OLD | NEW |