Gitweb links: ...log http://git.netsurf-browser.org/netsurf.git/shortlog/9dfa8055aa4b335e9f52ef372568fd48912f002b ...commit http://git.netsurf-browser.org/netsurf.git/commit/9dfa8055aa4b335e9f52ef372568fd48912f002b ...tree http://git.netsurf-browser.org/netsurf.git/tree/9dfa8055aa4b335e9f52ef372568fd48912f002b
The branch, tlsa/bitmap has been created at 9dfa8055aa4b335e9f52ef372568fd48912f002b (commit) - Log ----------------------------------------------------------------- commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=9dfa8055aa4b335e9f52ef372568fd48912f002b commit 9dfa8055aa4b335e9f52ef372568fd48912f002b Author: Michael Drake <t...@netsurf-browser.org> Commit: Michael Drake <t...@netsurf-browser.org> WIP: GTK: Set bitmap format to match Cairo format. Cairo format is native endian 0xAARRGGBB. diff --git a/frontends/gtk/bitmap.c b/frontends/gtk/bitmap.c index 1f1a6dc..eaa1ae9 100644 --- a/frontends/gtk/bitmap.c +++ b/frontends/gtk/bitmap.c @@ -221,12 +221,18 @@ static unsigned char *bitmap_get_buffer(void *vbitmap) b = pixels[4 * pixel_loop + 3]; #endif - /* Core bitmaps always have a component order of rgba, - * regardless of system endianness */ - pixels[4 * pixel_loop + 0] = r; + /* We asked core for 0xAARRGGBB (native endian). */ +#if G_BYTE_ORDER == G_LITTLE_ENDIAN + pixels[4 * pixel_loop + 0] = b; pixels[4 * pixel_loop + 1] = g; - pixels[4 * pixel_loop + 2] = b; + pixels[4 * pixel_loop + 2] = r; pixels[4 * pixel_loop + 3] = t; +#else + pixels[4 * pixel_loop + 0] = t; + pixels[4 * pixel_loop + 1] = r; + pixels[4 * pixel_loop + 2] = g; + pixels[4 * pixel_loop + 3] = b; +#endif } } else { /* Alpha image: de-multiply alpha */ @@ -255,10 +261,18 @@ static unsigned char *bitmap_get_buffer(void *vbitmap) r = g = b = 0; } - pixels[4 * pixel_loop + 0] = r; + /* We asked core for 0xAARRGGBB (native endian). */ +#if G_BYTE_ORDER == G_LITTLE_ENDIAN + pixels[4 * pixel_loop + 0] = b; pixels[4 * pixel_loop + 1] = g; - pixels[4 * pixel_loop + 2] = b; + pixels[4 * pixel_loop + 2] = r; pixels[4 * pixel_loop + 3] = t; +#else + pixels[4 * pixel_loop + 0] = t; + pixels[4 * pixel_loop + 1] = r; + pixels[4 * pixel_loop + 2] = g; + pixels[4 * pixel_loop + 3] = b; +#endif } } @@ -333,12 +347,18 @@ static void bitmap_modified(void *vbitmap) if (fmt == CAIRO_FORMAT_RGB24) { /* Opaque image */ for (pixel_loop=0; pixel_loop < pixel_count; pixel_loop++) { - /* Core bitmaps always have a component order of rgba, - * regardless of system endianness */ - r = pixels[4 * pixel_loop + 0]; + /* We asked core for 0xAARRGGBB (native endian). */ +#if G_BYTE_ORDER == G_LITTLE_ENDIAN + b = pixels[4 * pixel_loop + 0]; g = pixels[4 * pixel_loop + 1]; - b = pixels[4 * pixel_loop + 2]; + r = pixels[4 * pixel_loop + 2]; t = pixels[4 * pixel_loop + 3]; +#else + t = pixels[4 * pixel_loop + 0]; + r = pixels[4 * pixel_loop + 1]; + g = pixels[4 * pixel_loop + 2]; + b = pixels[4 * pixel_loop + 3]; +#endif /* Cairo surface is ARGB, written in native endian */ #if G_BYTE_ORDER == G_LITTLE_ENDIAN @@ -356,10 +376,18 @@ static void bitmap_modified(void *vbitmap) } else { /* Alpha image: pre-multiply alpha */ for (pixel_loop=0; pixel_loop < pixel_count; pixel_loop++) { - r = pixels[4 * pixel_loop + 0]; + /* We asked core for 0xAARRGGBB (native endian). */ +#if G_BYTE_ORDER == G_LITTLE_ENDIAN + b = pixels[4 * pixel_loop + 0]; g = pixels[4 * pixel_loop + 1]; - b = pixels[4 * pixel_loop + 2]; + r = pixels[4 * pixel_loop + 2]; t = pixels[4 * pixel_loop + 3]; +#else + t = pixels[4 * pixel_loop + 0]; + r = pixels[4 * pixel_loop + 1]; + g = pixels[4 * pixel_loop + 2]; + b = pixels[4 * pixel_loop + 3]; +#endif if (t != 0) { r = ((r * (t + 1)) >> 8) & 0xff; @@ -369,6 +397,7 @@ static void bitmap_modified(void *vbitmap) r = g = b = 0; } + /* Cairo surface is ARGB, written in native endian */ #if G_BYTE_ORDER == G_LITTLE_ENDIAN pixels[4 * pixel_loop + 0] = b; pixels[4 * pixel_loop + 1] = g; diff --git a/frontends/gtk/gui.c b/frontends/gtk/gui.c index fa9c9cf..628d709 100644 --- a/frontends/gtk/gui.c +++ b/frontends/gtk/gui.c @@ -44,6 +44,7 @@ #include "netsurf/browser.h" #include "netsurf/browser_window.h" #include "netsurf/netsurf.h" +#include "netsurf/bitmap.h" #include "content/fetch.h" #include "content/backing_store.h" #include "desktop/save_complete.h" @@ -980,6 +981,11 @@ static nserror nsgtk_setup(int argc, char** argv, char **respath) browser_set_dpi(gdk_screen_get_resolution(gdk_screen_get_default())); NSLOG(netsurf, INFO, "Set CSS DPI to %d", browser_get_dpi()); + bitmap_set_format(&(bitmap_fmt_t) { + .layout = BITMAP_LAYOUT_ARGB8888, + }); + NSLOG(netsurf, INFO, "Set bitmap format to 0xAARRGGBB (native endian)"); + filepath_sfinddef(respath, buf, "mime.types", "/etc/"); gtk_fetch_filetype_init(buf); ----------------------------------------------------------------------- -- NetSurf Browser _______________________________________________ netsurf-commits mailing list -- netsurf-commits@netsurf-browser.org To unsubscribe send an email to netsurf-commits-le...@netsurf-browser.org