summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2022-03-27 13:31:56 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2022-03-27 13:31:56 +0100
commit9dfa8055aa4b335e9f52ef372568fd48912f002b (patch)
tree380ded58280ceef7446f058cda9e5baa2a7be206
parentd0da09a7ca5a2b7878c0af4aab86efaf38d628ac (diff)
downloadnetsurf-9dfa8055aa4b335e9f52ef372568fd48912f002b.tar.gz
netsurf-9dfa8055aa4b335e9f52ef372568fd48912f002b.tar.bz2
WIP: GTK: Set bitmap format to match Cairo format.
Cairo format is native endian 0xAARRGGBB.
-rw-r--r--frontends/gtk/bitmap.c53
-rw-r--r--frontends/gtk/gui.c6
2 files changed, 47 insertions, 12 deletions
diff --git a/frontends/gtk/bitmap.c b/frontends/gtk/bitmap.c
index 1f1a6dcd2..eaa1ae919 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 fa9c9cf2c..628d709fe 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);