103 lines
		
	
	
		
			4.6 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			103 lines
		
	
	
		
			4.6 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
# HG changeset patch
 | 
						|
# User Ozkan Sezer <sezeroz@gmail.com>
 | 
						|
# 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 <png.h>
 | 
						|
 
 | 
						|
 /* 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);
 |