A bunch of fixes to the libpng binding

svn path=/trunk/netsurf/; revision=5338
This commit is contained in:
John Mark Bell 2008-09-15 22:45:44 +00:00
parent d9c7f033e6
commit 385d274f5b
8 changed files with 51 additions and 25 deletions

View File

@ -231,7 +231,6 @@ endef
$(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 @@ ifeq ($(TARGET),riscos)
$(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 @@ endif
# ----------------------------------------------------------------------------
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 @@ ifeq ($(TARGET),gtk)
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 @@ ifeq ($(TARGET),gtk)
$(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 @@ ifeq ($(TARGET),amiga)
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 @@ ifeq ($(TARGET),debug)
$(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

View File

@ -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 @@ bool nspng_process_data(struct content *c, char *data, unsigned int size)
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 @@ void info_callback(png_structp png, png_infop info)
{
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 @@ void row_callback(png_structp png, png_bytep new_row,
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);
unsigned char *row = c->data.png.bitbuffer +
(c->data.png.rowstride * row_num);
/* Abort if we've not got any data
*/
/* 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 @@ void row_callback(png_structp png, png_bytep new_row,
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 @@ bool nspng_convert(struct content *c, int width, int height)
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 @@ bool nspng_redraw(struct content *c, int x, int y,
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 @@ bool nspng_redraw_tiled(struct content *c, int x, int y, int width, int height,
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;
}

View File

@ -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 @@ bool nspng_redraw_tiled(struct content *c, int x, int y, int width, int height,
float scale, unsigned long background_colour,
bool repeat_x, bool repeat_y);
#endif
#endif

View File

@ -789,8 +789,10 @@ bool box_duplicate_main_tree(struct box *box, struct content *c, int *count)
box->object->type == CONTENT_BMP ||
box->object->type == CONTENT_ICO ||
#endif
#ifdef WITH_MNG
#if defined(WITH_MNG) || defined(WITH_PNG)
box->object->type == CONTENT_PNG ||
#endif
#ifdef WITH_MNG
box->object->type == CONTENT_JNG ||
box->object->type == CONTENT_MNG ||
#endif

View File

@ -62,8 +62,10 @@ static const content_type image_types[] = {
#ifdef WITH_BMP
CONTENT_BMP,
#endif
#ifdef WITH_MNG
#if defined(WITH_MNG) || defined(WITH_PNG)
CONTENT_PNG,
#endif
#ifdef WITH_MNG
CONTENT_JNG,
CONTENT_MNG,
#endif

View File

@ -613,7 +613,7 @@ bool html_process_data(struct content *c, char *data, unsigned int size)
}
#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 @@ void html_convert_css_callback(content_msg msg, struct content *css,
* \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
*/

View File

@ -278,10 +278,12 @@ int ro_content_filetype_from_type(content_type type) {
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;

View File

@ -835,8 +835,10 @@ void ro_gui_save_object_native(struct content *c, char *path)
#ifdef WITH_JPEG
case CONTENT_JPEG:
#endif
#ifdef WITH_MNG
#if defined(WITH_MNG) || defined(WITH_PNG)
case CONTENT_PNG:
#endif
#ifdef WITH_MNG
case CONTENT_JNG:
case CONTENT_MNG:
#endif