summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2022-03-28 16:28:47 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2022-03-28 16:28:47 +0100
commit01ce05ae65c692dea8421ec2826dc3a39eadaa72 (patch)
tree1c7db10bc1e897a0ef1f16facee52e5079877a61
parent414cb1a851025b99941c61b36e97c9c1342cd340 (diff)
downloadnetsurf-01ce05ae65c692dea8421ec2826dc3a39eadaa72.tar.gz
netsurf-01ce05ae65c692dea8421ec2826dc3a39eadaa72.tar.bz2
Bitmap: Log the bitmap format that gets set.
-rw-r--r--desktop/bitmap.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/desktop/bitmap.c b/desktop/bitmap.c
index d14dd370c..b191043bf 100644
--- a/desktop/bitmap.c
+++ b/desktop/bitmap.c
@@ -87,12 +87,48 @@ static struct bitmap_colour_layout bitmap__get_colour_layout(
}
}
+/**
+ * Get string for given pixel layout.
+ *
+ * \param[in] layout The pixel layout to get string for,
+ * \return String for given layout.
+ */
+static const char *bitmap__layout_to_str(enum bitmap_layout layout)
+{
+ const char *const str[] = {
+ [BITMAP_LAYOUT_R8G8B8A8] = "Byte-wise RGBA",
+ [BITMAP_LAYOUT_B8G8R8A8] = "Byte-wise BGRA",
+ [BITMAP_LAYOUT_A8R8G8B8] = "Byte-wise ARGB",
+ [BITMAP_LAYOUT_A8B8G8R8] = "Byte-wise ABGR",
+ [BITMAP_LAYOUT_RGBA8888] = "0xRRGGBBAA (native endian)",
+ [BITMAP_LAYOUT_BGRA8888] = "0xBBGGRRAA (native endian)",
+ [BITMAP_LAYOUT_ARGB8888] = "0xAARRGGBB (native endian)",
+ [BITMAP_LAYOUT_ABGR8888] = "0xAABBGGRR (native endian)",
+ };
+
+ if (layout >= (sizeof(str)) / sizeof(*str)) {
+ return "Unknown";
+ }
+
+ return str[layout];
+}
+
/* Exported function, documented in include/netsurf/bitmap.h */
void bitmap_set_format(const bitmap_fmt_t *bitmap_format)
{
bitmap_fmt = *bitmap_format;
+ NSLOG(netsurf, INFO, "Setting core bitmap format to: %s%s",
+ bitmap__layout_to_str(bitmap_format->layout),
+ bitmap_format->pma ? " pre multiplied alpha" : "");
+
bitmap_fmt.layout = bitmap_sanitise_bitmap_layout(bitmap_fmt.layout);
+
+ if (bitmap_format->layout != bitmap_fmt.layout) {
+ NSLOG(netsurf, INFO, "Sanitised layout to: %s",
+ bitmap__layout_to_str(bitmap_fmt.layout));
+ }
+
bitmap_layout = bitmap__get_colour_layout(&bitmap_fmt);
}