summaryrefslogtreecommitdiff
path: root/src/plot/32bpp-xbgr8888.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plot/32bpp-xbgr8888.c')
-rw-r--r--src/plot/32bpp-xbgr8888.c55
1 files changed, 41 insertions, 14 deletions
diff --git a/src/plot/32bpp-xbgr8888.c b/src/plot/32bpp-xbgr8888.c
index a0ed066..2492054 100644
--- a/src/plot/32bpp-xbgr8888.c
+++ b/src/plot/32bpp-xbgr8888.c
@@ -10,13 +10,6 @@
#include <stdbool.h>
#include <stdlib.h>
-#ifndef _WIN32
-#include <endian.h>
-#else
-#define __BYTE_ORDER __BYTE_ORDER__
-#define __BIG_ENDIAN __ORDER_BIG_ENDIAN__
-#endif
-
#include "libnsfb.h"
#include "libnsfb_plot.h"
#include "libnsfb_plot_util.h"
@@ -24,37 +17,71 @@
#include "nsfb.h"
#include "plot.h"
+#define UNUSED __attribute__((unused))
-#define UNUSED __attribute__((unused))
+/**
+ * Get the address of a logical location on the framebuffer
+ */
static inline uint32_t *get_xy_loc(nsfb_t *nsfb, int x, int y)
{
return (void *)(nsfb->ptr + (y * nsfb->linelen) + (x << 2));
}
-#if __BYTE_ORDER == __BIG_ENDIAN
+#ifdef NSFB_BE_BYTE_ORDER
+
+/**
+ * convert a 32bpp big endian pixel value to netsurf colour
+ *
+ * \param nsfb The framebuffer
+ * \param pixel The pixel value
+ * \return The netsurf colour value.
+ */
static inline nsfb_colour_t pixel_to_colour(UNUSED nsfb_t *nsfb, uint32_t pixel)
{
- /* TODO: FIX */
+ /** \todo fix this conversion as it is probably wrong */
return (pixel >> 8) & ~0xFF000000U;
}
-/* convert a colour value to a 32bpp pixel value ready for screen output */
+/**
+ * convert a colour value to a big endian 32bpp pixel value
+ *
+ * \param nsfb The framebuffer
+ * \param c The framebuffer colour
+ * \return A pixel value ready for screen output.
+ */
static inline uint32_t colour_to_pixel(UNUSED nsfb_t *nsfb, nsfb_colour_t c)
{
- return ((c & 0xFF) << 24) | ((c & 0xFF00) << 8) | ((c & 0xFF0000) >> 8);
+ return ((c & 0xFF) << 24) | ((c & 0xFF00) << 8) | ((c & 0xFF0000) >> 8);
}
-#else /* __BYTE_ORDER == __BIG_ENDIAN */
+
+#else
+
+/**
+ * convert a 32bpp little endian pixel value to netsurf colour
+ *
+ * \param nsfb The framebuffer
+ * \param pixel The pixel value
+ * \return The netsurf colour value.
+ */
static inline nsfb_colour_t pixel_to_colour(UNUSED nsfb_t *nsfb, uint32_t pixel)
{
return pixel | 0xFF000000U;
}
-/* convert a colour value to a 32bpp pixel value ready for screen output */
+
+/**
+ * convert a colour value to a little endian 32bpp pixel value
+ *
+ * \param nsfb The framebuffer
+ * \param c The netsurf colour
+ * \return A pixel value ready for screen output.
+ */
static inline uint32_t colour_to_pixel(UNUSED nsfb_t *nsfb, nsfb_colour_t c)
{
return c;
}
+
#endif
#define PLOT_TYPE uint32_t