diff options
Diffstat (limited to 'src/plot/24bpp.c')
-rw-r--r-- | src/plot/24bpp.c | 46 |
1 files changed, 32 insertions, 14 deletions
diff --git a/src/plot/24bpp.c b/src/plot/24bpp.c index 011765a..651abe1 100644 --- a/src/plot/24bpp.c +++ b/src/plot/24bpp.c @@ -9,13 +9,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" @@ -23,24 +16,43 @@ #include "nsfb.h" #include "plot.h" -static inline uint8_t * -get_xy_loc(nsfb_t *nsfb, int x, int y) +/** + * Get the address of a logical location on the framebuffer + */ +static inline uint8_t *get_xy_loc(nsfb_t *nsfb, int x, int y) { return (uint8_t *)(nsfb->ptr + (y * nsfb->linelen) + (x * 3)); } -#if __BYTE_ORDER == __BIG_ENDIAN -static inline nsfb_colour_t pixel_to_colour(uint8_t pixel) +#ifdef NSFB_BE_BYTE_ORDER + +/** + * convert a 24bpp big endian pixel value to netsurf colour + */ +static inline nsfb_colour_t pixel_to_colour(uint32_t pixel) { 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 24bpp pixel value + * + * The resulting value is ready for screen output + */ static inline uint32_t colour_to_pixel(nsfb_colour_t c) { return (c << 8); } -#else /* __BYTE_ORDER == __BIG_ENDIAN */ + +#else + +/** + * convert a 24bpp little endian pixel value to netsurf colour + * + * \param nsfb The framebuffer + * \param pixel The pixel values + * \return The netsurf colour value. + */ static inline nsfb_colour_t pixel_to_colour(uint32_t pixel) { return ((pixel & 0xFF) << 16) | @@ -48,11 +60,17 @@ static inline nsfb_colour_t pixel_to_colour(uint32_t pixel) ((pixel & 0xFF0000) >> 16); } -/* convert a colour value to a 32bpp pixel value ready for screen output */ +/** + * convert a colour value to a little endian 24bpp pixel value + * + * \param c The netsurf colour + * \return A pixel value ready for screen output. + */ static inline uint32_t colour_to_pixel(nsfb_colour_t c) { return ((c & 0xff0000) >> 16) | (c & 0xff00) | ((c & 0xff) << 16); } + #endif #define SIGN(x) ((x<0) ? -1 : ((x>0) ? 1 : 0)) |