diff --git a/Makefile b/Makefile index 86c71f9ec..87d103c17 100644 --- a/Makefile +++ b/Makefile @@ -442,6 +442,7 @@ ifeq ($(TARGET),gtk) NETSURF_FEATURE_BMP_CFLAGS := -DWITH_BMP NETSURF_FEATURE_GIF_CFLAGS := -DWITH_GIF NETSURF_FEATURE_PNG_CFLAGS := -DWITH_PNG + NETSURF_FEATURE_WEBP_CFLAGS := -DWITH_WEBP # 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)) @@ -451,6 +452,9 @@ ifeq ($(TARGET),gtk) $(eval $(call pkg_config_find_and_add,GIF,libnsgif,GIF)) $(eval $(call pkg_config_find_and_add,PNG,libpng,PNG )) + # no pkg-config for this library + $(eval $(call feature_enabled,WEBP,-DWITH_WEBP,-lwebp -lvpx,WebP (libwebp))) + GTKCFLAGS := -std=c99 -Dgtk -Dnsgtk \ -DGTK_DISABLE_DEPRECATED \ -D_BSD_SOURCE \ diff --git a/Makefile.defaults b/Makefile.defaults index 29e5c22a0..0980bcc0a 100644 --- a/Makefile.defaults +++ b/Makefile.defaults @@ -51,7 +51,7 @@ NETSURF_USE_PNG := YES # Enable NetSurf's use of libmng for displaying MNGs, JNGs and PNGs # Valid options: YES, NO (at least one of PNG/MNG highly recommended) -NETSURF_USE_MNG := YES +NETSURF_USE_MNG := NO # Enable NetSurf's use of libwebp/libvpx for displaying WebPs # Valid options: YES, NO @@ -146,6 +146,10 @@ ifeq ($(TARGET),gtk) # Valid options: YES, NO, AUTO NETSURF_USE_ROSPRITE := AUTO + # Enable NetSurf's use of libwebp/libvpx for displaying WebPs + # Valid options: YES, NO + NETSURF_USE_WEBP := YES + # Configuration overrides for Mac OS X ifeq ($(HOST),macosx) NETSURF_USE_LIBICONV_PLUG := NO diff --git a/gtk/gtk_filetype.c b/gtk/gtk_filetype.c index 43660055a..51b632db8 100644 --- a/gtk/gtk_filetype.c +++ b/gtk/gtk_filetype.c @@ -64,6 +64,8 @@ void gtk_fetch_filetype_init(const char *mimefile) hash_add(mime_hash, "gif", "image/gif"); hash_add(mime_hash, "png", "image/png"); hash_add(mime_hash, "jng", "image/jng"); + hash_add(mime_hash, "mng", "image/mng"); + hash_add(mime_hash, "webp", "image/webp"); hash_add(mime_hash, "spr", "image/x-riscos-sprite"); if (fh == NULL) { diff --git a/image/webp.c b/image/webp.c index 7df6ccf35..3da1af7a7 100644 --- a/image/webp.c +++ b/image/webp.c @@ -48,6 +48,8 @@ bool webp_convert(struct content *c) unsigned long size; uint8 *Y = NULL, *U = NULL, *V = NULL; uint32 width = 0, height = 0; + uint32 x = 0, y = 0, offset = 0; + uint8 r, g, b, a; char title[100]; WebPResult res = webp_success; @@ -81,8 +83,22 @@ bool webp_convert(struct content *c) if(Y) free(Y); - /* I think we may need to reverse the byte order here, as it is fixed - * to RGBA on both big- and little-endian platforms. */ + /* Data is RGBA on both big- and little-endian platforms, + * so reverse the byte order. */ + + for (y = 0; y < height; y++) { + for (x = 0; x < width; x++) { + offset = 4 * (y * width + x); + r = imagebuf[offset+3]; + g = imagebuf[offset+2]; + b = imagebuf[offset+1]; + a = imagebuf[offset]; + imagebuf[offset] = r; + imagebuf[offset+1] = g; + imagebuf[offset+2] = b; + imagebuf[offset+3] = a; + } + } c->width = width; c->height = height;