From 4a97785ce68e81d9b468c01939bf714f0026e7de Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Sun, 20 Jan 2019 23:41:00 +0100 Subject: [PATCH] patch SDL_image-1.2 for libpng 1.6.x --- 3rdparty/Makefile | 5 +- 3rdparty/SDL_image-1.2.12-png1.6.patch | 263 ++++++++++++++++++ .../SDL_image-1.2.12-png_const_colorp.patch | 27 ++ 3rdparty/SDL_image-1.2.12-png_const_fix.patch | 102 +++++++ 4 files changed, 396 insertions(+), 1 deletion(-) create mode 100644 3rdparty/SDL_image-1.2.12-png1.6.patch create mode 100644 3rdparty/SDL_image-1.2.12-png_const_colorp.patch create mode 100644 3rdparty/SDL_image-1.2.12-png_const_fix.patch diff --git a/3rdparty/Makefile b/3rdparty/Makefile index 071d9a22..50fb80ce 100644 --- a/3rdparty/Makefile +++ b/3rdparty/Makefile @@ -6,7 +6,10 @@ SDLIMAGEARCH = SDL_image-1.2.12.tar.gz SDLIMAGEURL = https://www.libsdl.org/projects/SDL_image/release/$(SDLIMAGEARCH) SDLIMAGEPATCHES = SDL_image-1.2.12.XCF_infinite_loop.patch \ SDL_image-1.2.12.XCF_v11_64bits_offsets.patch \ - SDL_image_XCF_v11_load_level.patch + SDL_image_XCF_v11_load_level.patch \ + SDL_image-1.2.12-png1.6.patch \ + SDL_image-1.2.12-png_const_colorp.patch \ + SDL_image-1.2.12-png_const_fix.patch SDLTTF=SDL_ttf-2.0.11 SDLTTFARCH=$(SDLTTF).tar.gz SDLTTFURL=https://www.libsdl.org/projects/SDL_ttf/release/$(SDLTTFARCH) diff --git a/3rdparty/SDL_image-1.2.12-png1.6.patch b/3rdparty/SDL_image-1.2.12-png1.6.patch new file mode 100644 index 00000000..0549144e --- /dev/null +++ b/3rdparty/SDL_image-1.2.12-png1.6.patch @@ -0,0 +1,263 @@ +# HG changeset patch +# User Ozkan Sezer +# Date 1539518450 -10800 +# Node ID 98b284005f5e191244510f16f645c93c860d2e2c +# Parent f5f1e8452f745f79711763131058668b0d9dd748 +png: fixes for building against libpng-1.6, and fn.pointer type fixes. + +from default branch commits f83e70f2ec6c, 4c41cee3e961, 777206f89dd2, +4c73e89f2551, 43873c313f32, e729829dbfc2, 4078e65827ea, ace61a625208, +218eb926ba90, 71f0d661144f, and 4b70bfe18fb7 -- bugs 1884, 1912, 3082, +and 3214. + +diff -r f5f1e8452f74 -r 98b284005f5e IMG_png.c +--- a/IMG_png.c Sat Oct 13 17:21:40 2018 +0300 ++++ b/IMG_png.c Sun Oct 14 15:00:50 2018 +0300 +@@ -71,33 +71,44 @@ + #include + + /* Check for the older version of libpng */ +-#if (PNG_LIBPNG_VER_MAJOR == 1) && (PNG_LIBPNG_VER_MINOR < 4) ++#if (PNG_LIBPNG_VER_MAJOR == 1) ++#if (PNG_LIBPNG_VER_MINOR < 5) + #define LIBPNG_VERSION_12 ++typedef png_bytep png_const_bytep; ++typedef png_color *png_const_colorp; ++#endif ++#if (PNG_LIBPNG_VER_MINOR < 6) ++typedef png_structp png_const_structrp; ++typedef png_infop png_const_inforp; ++typedef png_structp png_structrp; ++typedef png_infop png_inforp; ++#endif + #endif + + static struct { + int loaded; + void *handle; +- png_infop (*png_create_info_struct) (png_structp png_ptr); ++ png_infop (*png_create_info_struct) (png_const_structrp png_ptr); + png_structp (*png_create_read_struct) (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn); + void (*png_destroy_read_struct) (png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr); +- png_uint_32 (*png_get_IHDR) (png_structp png_ptr, png_infop info_ptr, png_uint_32 *width, png_uint_32 *height, int *bit_depth, int *color_type, int *interlace_method, int *compression_method, int *filter_method); +- png_voidp (*png_get_io_ptr) (png_structp png_ptr); +- png_byte (*png_get_channels) (png_structp png_ptr, png_infop info_ptr); +- png_uint_32 (*png_get_PLTE) (png_structp png_ptr, png_infop info_ptr, png_colorp *palette, int *num_palette); +- png_uint_32 (*png_get_tRNS) (png_structp png_ptr, png_infop info_ptr, png_bytep *trans, int *num_trans, png_color_16p *trans_values); +- png_uint_32 (*png_get_valid) (png_structp png_ptr, png_infop info_ptr, png_uint_32 flag); +- void (*png_read_image) (png_structp png_ptr, png_bytepp image); +- void (*png_read_info) (png_structp png_ptr, png_infop info_ptr); +- void (*png_read_update_info) (png_structp png_ptr, png_infop info_ptr); +- void (*png_set_expand) (png_structp png_ptr); +- void (*png_set_gray_to_rgb) (png_structp png_ptr); +- void (*png_set_packing) (png_structp png_ptr); +- void (*png_set_read_fn) (png_structp png_ptr, png_voidp io_ptr, png_rw_ptr read_data_fn); +- void (*png_set_strip_16) (png_structp png_ptr); +- int (*png_sig_cmp) (png_bytep sig, png_size_t start, png_size_t num_to_check); ++ png_uint_32 (*png_get_IHDR) (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 *width, png_uint_32 *height, int *bit_depth, int *color_type, int *interlace_method, int *compression_method, int *filter_method); ++ png_voidp (*png_get_io_ptr) (png_const_structrp png_ptr); ++ png_byte (*png_get_channels) (png_const_structrp png_ptr, png_const_inforp info_ptr); ++ png_uint_32 (*png_get_PLTE) (png_const_structrp png_ptr, png_inforp info_ptr, png_colorp *palette, int *num_palette); ++ png_uint_32 (*png_get_tRNS) (png_const_structrp png_ptr, png_inforp info_ptr, png_bytep *trans, int *num_trans, png_color_16p *trans_values); ++ png_uint_32 (*png_get_valid) (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 flag); ++ void (*png_read_image) (png_structrp png_ptr, png_bytepp image); ++ void (*png_read_info) (png_structrp png_ptr, png_inforp info_ptr); ++ void (*png_read_update_info) (png_structrp png_ptr, png_inforp info_ptr); ++ void (*png_set_expand) (png_structrp png_ptr); ++ void (*png_set_gray_to_rgb) (png_structrp png_ptr); ++ void (*png_set_packing) (png_structrp png_ptr); ++ void (*png_set_read_fn) (png_structrp png_ptr, png_voidp io_ptr, png_rw_ptr read_data_fn); ++ void (*png_set_strip_16) (png_structrp png_ptr); ++ int (*png_set_interlace_handling) (png_structp png_ptr); ++ int (*png_sig_cmp) (png_const_bytep sig, png_size_t start, png_size_t num_to_check); + #ifndef LIBPNG_VERSION_12 +- jmp_buf* (*png_set_longjmp_fn) (png_structp, png_longjmp_ptr, size_t); ++ jmp_buf* (*png_set_longjmp_fn) (png_structrp, png_longjmp_ptr, size_t); + #endif + } lib; + +@@ -110,14 +121,14 @@ + return -1; + } + lib.png_create_info_struct = +- (png_infop (*) (png_structp)) ++ (png_infop (*) (png_const_structrp)) + SDL_LoadFunction(lib.handle, "png_create_info_struct"); + if ( lib.png_create_info_struct == NULL ) { + SDL_UnloadObject(lib.handle); + return -1; + } + lib.png_create_read_struct = +- (png_structp (*) (png_const_charp, png_voidp, png_error_ptr, png_error_ptr)) ++ (png_structrp (*) (png_const_charp, png_voidp, png_error_ptr, png_error_ptr)) + SDL_LoadFunction(lib.handle, "png_create_read_struct"); + if ( lib.png_create_read_struct == NULL ) { + SDL_UnloadObject(lib.handle); +@@ -131,105 +142,112 @@ + return -1; + } + lib.png_get_IHDR = +- (png_uint_32 (*) (png_structp, png_infop, png_uint_32 *, png_uint_32 *, int *, int *, int *, int *, int *)) ++ (png_uint_32 (*) (png_const_structrp, png_const_inforp, png_uint_32 *, png_uint_32 *, int *, int *, int *, int *, int *)) + SDL_LoadFunction(lib.handle, "png_get_IHDR"); + if ( lib.png_get_IHDR == NULL ) { + SDL_UnloadObject(lib.handle); + return -1; + } + lib.png_get_channels = +- (png_byte (*) (png_structp, png_infop)) ++ (png_byte (*) (png_const_structrp, png_const_inforp)) + SDL_LoadFunction(lib.handle, "png_get_channels"); + if ( lib.png_get_channels == NULL ) { + SDL_UnloadObject(lib.handle); + return -1; + } + lib.png_get_io_ptr = +- (png_voidp (*) (png_structp)) ++ (png_voidp (*) (png_const_structrp)) + SDL_LoadFunction(lib.handle, "png_get_io_ptr"); + if ( lib.png_get_io_ptr == NULL ) { + SDL_UnloadObject(lib.handle); + return -1; + } + lib.png_get_PLTE = +- (png_uint_32 (*) (png_structp, png_infop, png_colorp *, int *)) ++ (png_uint_32 (*) (png_const_structrp, png_inforp, png_colorp *, int *)) + SDL_LoadFunction(lib.handle, "png_get_PLTE"); + if ( lib.png_get_PLTE == NULL ) { + SDL_UnloadObject(lib.handle); + return -1; + } + lib.png_get_tRNS = +- (png_uint_32 (*) (png_structp, png_infop, png_bytep *, int *, png_color_16p *)) ++ (png_uint_32 (*) (png_const_structrp, png_inforp, png_bytep *, int *, png_color_16p *)) + SDL_LoadFunction(lib.handle, "png_get_tRNS"); + if ( lib.png_get_tRNS == NULL ) { + SDL_UnloadObject(lib.handle); + return -1; + } + lib.png_get_valid = +- (png_uint_32 (*) (png_structp, png_infop, png_uint_32)) ++ (png_uint_32 (*) (png_const_structrp, png_const_inforp, png_uint_32)) + SDL_LoadFunction(lib.handle, "png_get_valid"); + if ( lib.png_get_valid == NULL ) { + SDL_UnloadObject(lib.handle); + return -1; + } + lib.png_read_image = +- (void (*) (png_structp, png_bytepp)) ++ (void (*) (png_structrp, png_bytepp)) + SDL_LoadFunction(lib.handle, "png_read_image"); + if ( lib.png_read_image == NULL ) { + SDL_UnloadObject(lib.handle); + return -1; + } + lib.png_read_info = +- (void (*) (png_structp, png_infop)) ++ (void (*) (png_structrp, png_inforp)) + SDL_LoadFunction(lib.handle, "png_read_info"); + if ( lib.png_read_info == NULL ) { + SDL_UnloadObject(lib.handle); + return -1; + } + lib.png_read_update_info = +- (void (*) (png_structp, png_infop)) ++ (void (*) (png_structrp, png_inforp)) + SDL_LoadFunction(lib.handle, "png_read_update_info"); + if ( lib.png_read_update_info == NULL ) { + SDL_UnloadObject(lib.handle); + return -1; + } + lib.png_set_expand = +- (void (*) (png_structp)) ++ (void (*) (png_structrp)) + SDL_LoadFunction(lib.handle, "png_set_expand"); + if ( lib.png_set_expand == NULL ) { + SDL_UnloadObject(lib.handle); + return -1; + } + lib.png_set_gray_to_rgb = +- (void (*) (png_structp)) ++ (void (*) (png_structrp)) + SDL_LoadFunction(lib.handle, "png_set_gray_to_rgb"); + if ( lib.png_set_gray_to_rgb == NULL ) { + SDL_UnloadObject(lib.handle); + return -1; + } + lib.png_set_packing = +- (void (*) (png_structp)) ++ (void (*) (png_structrp)) + SDL_LoadFunction(lib.handle, "png_set_packing"); + if ( lib.png_set_packing == NULL ) { + SDL_UnloadObject(lib.handle); + return -1; + } + lib.png_set_read_fn = +- (void (*) (png_structp, png_voidp, png_rw_ptr)) ++ (void (*) (png_structrp, png_voidp, png_rw_ptr)) + SDL_LoadFunction(lib.handle, "png_set_read_fn"); + if ( lib.png_set_read_fn == NULL ) { + SDL_UnloadObject(lib.handle); + return -1; + } + lib.png_set_strip_16 = +- (void (*) (png_structp)) ++ (void (*) (png_structrp)) + SDL_LoadFunction(lib.handle, "png_set_strip_16"); + if ( lib.png_set_strip_16 == NULL ) { + SDL_UnloadObject(lib.handle); + return -1; + } ++ lib.png_set_interlace_handling = ++ (void (*) (png_structp)) ++ SDL_LoadFunction(lib.handle, "png_set_interlace_handling"); ++ if ( lib.png_set_interlace_handling == NULL ) { ++ SDL_UnloadObject(lib.handle); ++ return -1; ++ } + lib.png_sig_cmp = +- (int (*) (png_bytep, png_size_t, png_size_t)) ++ (int (*) (png_const_bytep, png_size_t, png_size_t)) + SDL_LoadFunction(lib.handle, "png_sig_cmp"); + if ( lib.png_sig_cmp == NULL ) { + SDL_UnloadObject(lib.handle); +@@ -237,7 +255,7 @@ + } + #ifndef LIBPNG_VERSION_12 + lib.png_set_longjmp_fn = +- (jmp_buf * (*) (png_structp, png_longjmp_ptr, size_t)) ++ (jmp_buf * (*) (png_structrp, png_longjmp_ptr, size_t)) + SDL_LoadFunction(lib.handle, "png_set_longjmp_fn"); + if ( lib.png_set_longjmp_fn == NULL ) { + SDL_UnloadObject(lib.handle); +@@ -280,6 +298,7 @@ + lib.png_set_packing = png_set_packing; + lib.png_set_read_fn = png_set_read_fn; + lib.png_set_strip_16 = png_set_strip_16; ++ lib.png_set_interlace_handling = png_set_interlace_handling; + lib.png_sig_cmp = png_sig_cmp; + #ifndef LIBPNG_VERSION_12 + lib.png_set_longjmp_fn = png_set_longjmp_fn; +@@ -404,6 +423,9 @@ + /* tell libpng to strip 16 bit/color files down to 8 bits/color */ + lib.png_set_strip_16(png_ptr) ; + ++ /* tell libpng to de-interlace (if the image is interlaced) */ ++ lib.png_set_interlace_handling(png_ptr) ; ++ + /* Extract multiple pixels with bit depths of 1, 2, and 4 from a single + * byte into separate bytes (useful for paletted and grayscale images). + */ +@@ -515,9 +537,9 @@ + if(color_type == PNG_COLOR_TYPE_GRAY) { + palette->ncolors = 256; + for(i = 0; i < 256; i++) { +- palette->colors[i].r = i; +- palette->colors[i].g = i; +- palette->colors[i].b = i; ++ palette->colors[i].r = (Uint8)i; ++ palette->colors[i].g = (Uint8)i; ++ palette->colors[i].b = (Uint8)i; + } + } else if (png_num_palette > 0 ) { + palette->ncolors = png_num_palette; diff --git a/3rdparty/SDL_image-1.2.12-png_const_colorp.patch b/3rdparty/SDL_image-1.2.12-png_const_colorp.patch new file mode 100644 index 00000000..239a0039 --- /dev/null +++ b/3rdparty/SDL_image-1.2.12-png_const_colorp.patch @@ -0,0 +1,27 @@ +# HG changeset patch +# User Ozkan Sezer +# Date 1539674510 -10800 +# Node ID e7abf44fc35ca01960d2d86184c0587d97bd6363 +# Parent 93d1be43b70a5dab21202d12126c536f7c89cba9 +png_const_colorp isn't used in SDL_image-1.2.x. + +diff -r 93d1be43b70a -r e7abf44fc35c IMG_png.c +--- a/IMG_png.c Sun Oct 14 17:05:20 2018 +0300 ++++ b/IMG_png.c Tue Oct 16 10:21:50 2018 +0300 +@@ -75,7 +75,6 @@ + #if (PNG_LIBPNG_VER_MINOR < 5) + #define LIBPNG_VERSION_12 + typedef png_bytep png_const_bytep; +-typedef png_color *png_const_colorp; + #endif + #if (PNG_LIBPNG_VER_MINOR < 6) + typedef png_structp png_const_structrp; +@@ -542,7 +541,7 @@ + palette->colors[i].b = (Uint8)i; + } + } else if (png_num_palette > 0 ) { +- palette->ncolors = png_num_palette; ++ palette->ncolors = png_num_palette; + for( i=0; icolors[i].b = png_palette[i].blue; + palette->colors[i].g = png_palette[i].green; diff --git a/3rdparty/SDL_image-1.2.12-png_const_fix.patch b/3rdparty/SDL_image-1.2.12-png_const_fix.patch new file mode 100644 index 00000000..c59ba62a --- /dev/null +++ b/3rdparty/SDL_image-1.2.12-png_const_fix.patch @@ -0,0 +1,102 @@ +# HG changeset patch +# User Ozkan Sezer +# Date 1540324802 -10800 +# Node ID 89225c8816d6d487bee10642d0380442dc19490d +# Parent b39ee38ead194ebc11c33170782a0e6fcf24d9ca +fix warnings when building with libpng-1.4/1.5 and --disable-png-shared + +ugly perhaps, but does the job. +closes https://bugzilla.libsdl.org/show_bug.cgi?id=4311 + +diff -r b39ee38ead19 -r 89225c8816d6 IMG_png.c +--- a/IMG_png.c Thu Oct 18 11:55:14 2018 +0300 ++++ b/IMG_png.c Tue Oct 23 23:00:02 2018 +0300 +@@ -71,29 +71,46 @@ + #include + + /* Check for the older version of libpng */ +-#if (PNG_LIBPNG_VER_MAJOR == 1) ++#if (PNG_LIBPNG_VER_MAJOR == 1) + #if (PNG_LIBPNG_VER_MINOR < 5) + #define LIBPNG_VERSION_12 + typedef png_bytep png_const_bytep; + #endif ++#if (PNG_LIBPNG_VER_MINOR < 4) ++typedef png_structp png_const_structp; ++typedef png_infop png_const_infop; ++#endif + #if (PNG_LIBPNG_VER_MINOR < 6) +-typedef png_structp png_const_structrp; +-typedef png_infop png_const_inforp; + typedef png_structp png_structrp; + typedef png_infop png_inforp; ++typedef png_const_structp png_const_structrp; ++typedef png_const_infop png_const_inforp; ++/* noconst15: version < 1.6 doesn't have const, >= 1.6 adds it */ ++/* noconst16: version < 1.6 does have const, >= 1.6 removes it */ ++typedef png_structp png_noconst15_structrp; ++typedef png_inforp png_noconst15_inforp; ++typedef png_const_inforp png_noconst16_inforp; ++#else ++typedef png_const_structp png_noconst15_structrp; ++typedef png_const_inforp png_noconst15_inforp; ++typedef png_inforp png_noconst16_inforp; + #endif ++#else ++typedef png_const_structp png_noconst15_structrp; ++typedef png_const_inforp png_noconst15_inforp; ++typedef png_inforp png_noconst16_inforp; + #endif + + static struct { + int loaded; + void *handle; +- png_infop (*png_create_info_struct) (png_const_structrp png_ptr); ++ png_infop (*png_create_info_struct) (png_noconst15_structrp png_ptr); + png_structp (*png_create_read_struct) (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn); + void (*png_destroy_read_struct) (png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr); +- png_uint_32 (*png_get_IHDR) (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 *width, png_uint_32 *height, int *bit_depth, int *color_type, int *interlace_method, int *compression_method, int *filter_method); +- png_voidp (*png_get_io_ptr) (png_const_structrp png_ptr); ++ png_uint_32 (*png_get_IHDR) (png_noconst15_structrp png_ptr, png_noconst15_inforp info_ptr, png_uint_32 *width, png_uint_32 *height, int *bit_depth, int *color_type, int *interlace_method, int *compression_method, int *filter_method); ++ png_voidp (*png_get_io_ptr) (png_noconst15_structrp png_ptr); + png_byte (*png_get_channels) (png_const_structrp png_ptr, png_const_inforp info_ptr); +- png_uint_32 (*png_get_PLTE) (png_const_structrp png_ptr, png_inforp info_ptr, png_colorp *palette, int *num_palette); ++ png_uint_32 (*png_get_PLTE) (png_const_structrp png_ptr, png_noconst16_inforp info_ptr, png_colorp *palette, int *num_palette); + png_uint_32 (*png_get_tRNS) (png_const_structrp png_ptr, png_inforp info_ptr, png_bytep *trans, int *num_trans, png_color_16p *trans_values); + png_uint_32 (*png_get_valid) (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 flag); + void (*png_read_image) (png_structrp png_ptr, png_bytepp image); +@@ -120,7 +137,7 @@ + return -1; + } + lib.png_create_info_struct = +- (png_infop (*) (png_const_structrp)) ++ (png_infop (*) (png_noconst15_structrp)) + SDL_LoadFunction(lib.handle, "png_create_info_struct"); + if ( lib.png_create_info_struct == NULL ) { + SDL_UnloadObject(lib.handle); +@@ -141,7 +158,7 @@ + return -1; + } + lib.png_get_IHDR = +- (png_uint_32 (*) (png_const_structrp, png_const_inforp, png_uint_32 *, png_uint_32 *, int *, int *, int *, int *, int *)) ++ (png_uint_32 (*) (png_noconst15_structrp, png_noconst15_inforp, png_uint_32 *, png_uint_32 *, int *, int *, int *, int *, int *)) + SDL_LoadFunction(lib.handle, "png_get_IHDR"); + if ( lib.png_get_IHDR == NULL ) { + SDL_UnloadObject(lib.handle); +@@ -155,14 +172,14 @@ + return -1; + } + lib.png_get_io_ptr = +- (png_voidp (*) (png_const_structrp)) ++ (png_voidp (*) (png_noconst15_structrp)) + SDL_LoadFunction(lib.handle, "png_get_io_ptr"); + if ( lib.png_get_io_ptr == NULL ) { + SDL_UnloadObject(lib.handle); + return -1; + } + lib.png_get_PLTE = +- (png_uint_32 (*) (png_const_structrp, png_inforp, png_colorp *, int *)) ++ (png_uint_32 (*) (png_const_structrp, png_noconst16_inforp, png_colorp *, int *)) + SDL_LoadFunction(lib.handle, "png_get_PLTE"); + if ( lib.png_get_PLTE == NULL ) { + SDL_UnloadObject(lib.handle);