r5338 jmb - in /trunk/netsurf: Makefile image/png.c image/png.h render/box.c render/box_construct.c render/html.c riscos/filetype.c riscos/save.c

netsurf at semichrome.net netsurf at semichrome.net
Mon Sep 15 23:45:45 BST 2008


Author: jmb
Date: Mon Sep 15 17:45:44 2008
New Revision: 5338

URL: http://source.netsurf-browser.org?rev=5338&view=rev
Log:
A bunch of fixes to the libpng binding

Modified:
    trunk/netsurf/Makefile
    trunk/netsurf/image/png.c
    trunk/netsurf/image/png.h
    trunk/netsurf/render/box.c
    trunk/netsurf/render/box_construct.c
    trunk/netsurf/render/html.c
    trunk/netsurf/riscos/filetype.c
    trunk/netsurf/riscos/save.c

Modified: trunk/netsurf/Makefile
URL: http://source.netsurf-browser.org/trunk/netsurf/Makefile?rev=5338&r1=5337&r2=5338&view=diff
==============================================================================
--- trunk/netsurf/Makefile (original)
+++ trunk/netsurf/Makefile Mon Sep 15 17:45:44 2008
@@ -231,7 +231,6 @@
 
 $(eval $(call feature_enabled,JPEG,-DWITH_JPEG,-ljpeg,JPEG support))
 $(eval $(call feature_enabled,MNG,-DWITH_MNG,-lmng,MNG support))
-$(eval $(call feature_enabled,PNG,-DWITH_PNG,-lpng,PNG support))
 
 $(eval $(call feature_enabled,HARU_PDF,-DWITH_PDF_EXPORT,-lhpdf -lpng,PDF export))
 $(eval $(call feature_enabled,LIBICONV_PLUG,-DLIBICONV_PLUG,,glibc internal iconv))
@@ -263,14 +262,16 @@
     $(eval $(call feature_enabled,HUBBUB,-DWITH_HUBBUB,-lhubbub -lparserutils,Hubbub HTML parser))
     $(eval $(call feature_enabled,BMP,-DWITH_BMP,-lnsbmp,NetSurf BMP decoder))
     $(eval $(call feature_enabled,GIF,-DWITH_GIF,-lnsgif,NetSurf GIF decoder))
+    $(eval $(call feature_enabled,PNG,-DWITH_PNG,-lpng,PNG support (libpng)))
   else
     NETSURF_FEATURE_HUBBUB_CFLAGS := -DWITH_HUBBUB
     NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP
     NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF
+    NETSURF_FEATURE_PNG_CFLAGS := -DWITH_PNG
     $(eval $(call pkg_config_find_and_add,HUBBUB,libhubbub,Hubbub HTML parser))
     $(eval $(call pkg_config_find_and_add,BMP,libnsbmp,NetSurf BMP decoder))
     $(eval $(call pkg_config_find_and_add,GIF,libnsgif,NetSurf GIF decoder))
-    $(eval $(call pkg_config_find_and_add,PNG,libpng,PNG library))
+    $(eval $(call pkg_config_find_and_add,PNG,libpng,PNG support (libpng)))
   endif
 endif
 
@@ -279,6 +280,8 @@
 # ----------------------------------------------------------------------------
 
 ifeq ($(HOST),beos)
+  $(eval $(call feature_enabled,PNG,-DWITH_PNG,-lpng,PNG support (libpng)))
+
   LDFLAGS += -L/boot/home/config/lib
   # some people do *not* have libm...
   LDFLAGS += -lxml2 -lz -lcurl -lssl -lcrypto -liconv
@@ -297,6 +300,7 @@
   NETSURF_FEATURE_HUBBUB_CFLAGS := -DWITH_HUBBUB
   NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP
   NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF
+  NETSURF_FEATURE_PNG_CFLAGS := -DWITH_PNG
 
   # add a line similar to below for each optional pkg-configed lib here
   $(eval $(call pkg_config_find_and_add,RSVG,librsvg-2.0,SVG rendering))
@@ -304,7 +308,7 @@
   $(eval $(call pkg_config_find_and_add,HUBBUB,libhubbub,Hubbub HTML parser))
   $(eval $(call pkg_config_find_and_add,BMP,libnsbmp,NetSurf BMP decoder))
   $(eval $(call pkg_config_find_and_add,GIF,libnsgif,NetSurf GIF decoder))
-  $(eval $(call pkg_config_find_and_add,PNG,libpng,PNG library))
+  $(eval $(call pkg_config_find_and_add,PNG,libpng,PNG support (libpng)))
 
   GTKCFLAGS := -std=c99 -Dgtk -Dnsgtk \
 		-DGTK_DISABLE_DEPRECATED \
@@ -423,11 +427,13 @@
   NETSURF_FEATURE_HUBBUB_CFLAGS := -DWITH_HUBBUB
   NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP
   NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF
+  NETSURF_FEATURE_PNG_CFLAGS := -DWITH_PNG
 
     $(eval $(call feature_enabled,ROSPRITE,-DWITH_NSSPRITE,-lrosprite,RISC OS Sprite decoder))
     $(eval $(call feature_enabled,HUBBUB,-DWITH_HUBBUB,-lhubbub -lparserutils,Hubbub HTML parser))
     $(eval $(call feature_enabled,BMP,-DWITH_BMP,-lnsbmp,NetSurf BMP decoder))
     $(eval $(call feature_enabled,GIF,-DWITH_GIF,-lnsgif,NetSurf GIF decoder))
+    $(eval $(call feature_enabled,PNG,-DWITH_PNG,-lpng,PNG support (libpng)))
 
   CFLAGS += -mcrt=newlib -D__USE_INLINE__ -std=c99 -I . -Dnsamiga
   LDFLAGS += -lxml2 -lcurl -lm -lsocket -lpthread -lregex -lauto -lraauto -lssl -lcrypto -lamisslauto -mcrt=newlib
@@ -451,7 +457,7 @@
   $(eval $(call pkg_config_find_and_add,RSVG,librsvg-2.0,SVG rendering))
   $(eval $(call pkg_config_find_and_add,ROSPRITE,librosprite,RISC OS sprite rendering))
   $(eval $(call pkg_config_find_and_add,HUBBUB,libhubbub,Hubbub HTML parser))
-  $(eval $(call pkg_config_find_and_add,HUBBUB,libparserutils,Hubbub HTML parser))
+
 LDFLAGS += $(shell $(PKG_CONFIG) --libs libnsgif libnsbmp)
 endif
 

Modified: trunk/netsurf/image/png.c
URL: http://source.netsurf-browser.org/trunk/netsurf/image/png.c?rev=5338&r1=5337&r2=5338&view=diff
==============================================================================
--- trunk/netsurf/image/png.c (original)
+++ trunk/netsurf/image/png.c Mon Sep 15 17:45:44 2008
@@ -23,7 +23,8 @@
 #include <string.h>
 #include <stdlib.h>
 
-#include <png.h>
+/* Ugh -- setjmp.h weirdness ensues if this isn't first... */
+#include "image/png.h"
 
 #include "utils/config.h"
 
@@ -113,7 +114,8 @@
 		return false;
 	}
 
-	png_process_data(c->data.png.png, c->data.png.info, data, size);
+	png_process_data(c->data.png.png, c->data.png.info, 
+			(uint8_t *) data, size);
 
 	return true;
 }
@@ -128,7 +130,6 @@
 {
 	int bit_depth, color_type, interlace, intent;
 	double gamma;
-	unsigned int rowbytes, sprite_size;
 	unsigned long width, height;
 	struct content *c = png_get_progressive_ptr(png);
         
@@ -193,23 +194,22 @@
 	struct content *c = png_get_progressive_ptr(png);
 	unsigned long i, j, rowbytes = c->data.png.rowbytes;
 	unsigned int start, step;
-        unsigned char *row = c->data.png.bitbuffer + (c->data.png.rowstride * row_num);
-
-	/*	Abort if we've not got any data
-	*/
+        unsigned char *row = c->data.png.bitbuffer + 
+			(c->data.png.rowstride * row_num);
+
+	/* Abort if we've not got any data */
 	if (new_row == 0)
 		return;
 
-	/*	Handle interlaced sprites using the Adam7 algorithm
-	*/
+	/* Handle interlaced sprites using the Adam7 algorithm */
 	if (c->data.png.interlace) {
 		start = interlace_start[pass];
  		step = interlace_step[pass];
 		row_num = interlace_row_start[pass] +
 				interlace_row_step[pass] * row_num;
 
-		/*	Copy the data to our current row taking into consideration interlacing
-		*/
+		/* Copy the data to our current row taking interlacing
+		 * into consideration */
                 row = c->data.png.bitbuffer + (c->data.png.rowstride * row_num);
 		for (j = 0, i = start; i < rowbytes; i += step) {
 			row[i++] = new_row[j++];
@@ -218,8 +218,7 @@
 			row[i++] = new_row[j++];
 		}
 	} else {
-		/*	Do a fast memcpy of the row data
-		*/
+		/* Do a fast memcpy of the row data */
 		memcpy(row, new_row, rowbytes);
 	}
 }
@@ -240,9 +239,10 @@
 
 	c->title = malloc(NSPNG_TITLE_LEN);
 	
-        if (c->title != NULL)
+        if (c->title != NULL) {
 		snprintf(c->title, NSPNG_TITLE_LEN, messages_get("PNGTitle"),
                          c->width, c->height, c->source_size);
+	}
         
 	c->size += (c->width * c->height * 4) + NSPNG_TITLE_LEN;
         
@@ -268,8 +268,11 @@
 		int clip_x0, int clip_y0, int clip_x1, int clip_y1,
 		float scale, unsigned long background_colour)
 {
-        if (c->bitmap != NULL)
-                plot.bitmap(x, y, width, height, c->bitmap, background_colour, c);
+	if (c->bitmap != NULL) {
+		return plot.bitmap(x, y, width, height, c->bitmap, 
+				background_colour, c);
+	}
+
 	return true;
 }
 
@@ -278,6 +281,11 @@
 		float scale, unsigned long background_colour,
 		bool repeat_x, bool repeat_y)
 {
+	if (c->bitmap != NULL) {
+		return plot.bitmap_tile(x, y, width, height, c->bitmap, 
+				background_colour, repeat_x, repeat_y, c);
+	}
+
 	return true;
 }
 

Modified: trunk/netsurf/image/png.h
URL: http://source.netsurf-browser.org/trunk/netsurf/image/png.h?rev=5338&r1=5337&r2=5338&view=diff
==============================================================================
--- trunk/netsurf/image/png.h (original)
+++ trunk/netsurf/image/png.h Mon Sep 15 17:45:44 2008
@@ -20,6 +20,9 @@
 #ifndef _NETSURF_RISCOS_PNG_H_
 #define _NETSURF_RISCOS_PNG_H_
 
+#include "utils/config.h"
+
+#ifdef WITH_PNG
 #include <stdbool.h>
 #include <png.h>
 
@@ -49,3 +52,5 @@
                         float scale, unsigned long background_colour,
                         bool repeat_x, bool repeat_y);
 #endif
+
+#endif

Modified: trunk/netsurf/render/box.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/box.c?rev=5338&r1=5337&r2=5338&view=diff
==============================================================================
--- trunk/netsurf/render/box.c (original)
+++ trunk/netsurf/render/box.c Mon Sep 15 17:45:44 2008
@@ -789,8 +789,10 @@
 			box->object->type ==  CONTENT_BMP ||
 			box->object->type == CONTENT_ICO ||
 #endif
+#if defined(WITH_MNG) || defined(WITH_PNG)
+			box->object->type == CONTENT_PNG ||
+#endif
 #ifdef WITH_MNG
-			box->object->type == CONTENT_PNG ||
 			box->object->type == CONTENT_JNG ||
 			box->object->type == CONTENT_MNG ||
 #endif

Modified: trunk/netsurf/render/box_construct.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/box_construct.c?rev=5338&r1=5337&r2=5338&view=diff
==============================================================================
--- trunk/netsurf/render/box_construct.c (original)
+++ trunk/netsurf/render/box_construct.c Mon Sep 15 17:45:44 2008
@@ -62,8 +62,10 @@
 #ifdef WITH_BMP
 	CONTENT_BMP,
 #endif
+#if defined(WITH_MNG) || defined(WITH_PNG)
+	CONTENT_PNG,
+#endif
 #ifdef WITH_MNG
-	CONTENT_PNG,
 	CONTENT_JNG,
 	CONTENT_MNG,
 #endif

Modified: trunk/netsurf/render/html.c
URL: http://source.netsurf-browser.org/trunk/netsurf/render/html.c?rev=5338&r1=5337&r2=5338&view=diff
==============================================================================
--- trunk/netsurf/render/html.c (original)
+++ trunk/netsurf/render/html.c Mon Sep 15 17:45:44 2008
@@ -613,7 +613,7 @@
 	}
 
 #ifdef WITH_HUBBUB
-	LOG(("Parsing %d bytes", (size - x)));
+	LOG(("Parsing %lu bytes", (size - x)));
 	err = hubbub_parser_parse_chunk(
 			c->data.html.parser, 
 			(uint8_t *) data + x, (size - x));
@@ -1679,7 +1679,6 @@
  * \param  available_width   estimate of width of object
  * \param  available_height  estimate of height of object
  * \param  background        this is a background image
- * \param  frame             name of frame, or 0 if not a frame (copied)
  * \return  true on success, false on memory exhaustion
  */
 

Modified: trunk/netsurf/riscos/filetype.c
URL: http://source.netsurf-browser.org/trunk/netsurf/riscos/filetype.c?rev=5338&r1=5337&r2=5338&view=diff
==============================================================================
--- trunk/netsurf/riscos/filetype.c (original)
+++ trunk/netsurf/riscos/filetype.c Mon Sep 15 17:45:44 2008
@@ -278,10 +278,12 @@
 		case CONTENT_HTML:	return 0xfaf;
 		case CONTENT_TEXTPLAIN:	return 0xfff;
 		case CONTENT_CSS:	return 0xf79;
+#if defined(WITH_MNG) || defined(WITH_PNG)
+		case CONTENT_PNG:	return 0xb60;
+#endif
 #ifdef WITH_MNG
 		case CONTENT_JNG:	return 0xf78;
 		case CONTENT_MNG:	return 0xf84;
-		case CONTENT_PNG:	return 0xb60;
 #endif
 #ifdef WITH_JPEG
 		case CONTENT_JPEG:	return 0xc85;

Modified: trunk/netsurf/riscos/save.c
URL: http://source.netsurf-browser.org/trunk/netsurf/riscos/save.c?rev=5338&r1=5337&r2=5338&view=diff
==============================================================================
--- trunk/netsurf/riscos/save.c (original)
+++ trunk/netsurf/riscos/save.c Mon Sep 15 17:45:44 2008
@@ -835,8 +835,10 @@
 #ifdef WITH_JPEG
 		case CONTENT_JPEG:
 #endif
+#if defined(WITH_MNG) || defined(WITH_PNG)
+		case CONTENT_PNG:
+#endif
 #ifdef WITH_MNG
-		case CONTENT_PNG:
 		case CONTENT_JNG:
 		case CONTENT_MNG:
 #endif




More information about the netsurf-commits mailing list