From 480b2353d815540dca310edc8496da1d3f1b3295 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sun, 30 Sep 2012 09:40:46 +0100 Subject: Split 32bpp support into xrgba, xbgr, and common. Should allow for BGR surfaces as well as RGB. --- src/plot/32bpp-xrgb8888.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 src/plot/32bpp-xrgb8888.c (limited to 'src/plot/32bpp-xrgb8888.c') diff --git a/src/plot/32bpp-xrgb8888.c b/src/plot/32bpp-xrgb8888.c new file mode 100644 index 0000000..548c970 --- /dev/null +++ b/src/plot/32bpp-xrgb8888.c @@ -0,0 +1,74 @@ +/* + * Copyright 2009 Vincent Sanders + * Copyright 2010 Michael Drake + * + * This file is part of libnsfb, http://www.netsurf-browser.org/ + * Licenced under the MIT License, + * http://www.opensource.org/licenses/mit-license.php + */ + +#include +#include +#include + +#include "libnsfb.h" +#include "libnsfb_plot.h" +#include "libnsfb_plot_util.h" + +#include "nsfb.h" +#include "plot.h" + + +#define UNUSED __attribute__((unused)) + +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 +static inline nsfb_colour_t pixel_to_colour(UNUSED nsfb_t *nsfb, uint32_t pixel) +{ + return (pixel >> 8) & ~0xFF000000U; +} + +/* convert a colour value to a 32bpp pixel value ready for screen output */ +static inline uint32_t colour_to_pixel(UNUSED nsfb_t *nsfb, nsfb_colour_t c) +{ + return (c << 8); +} +#else /* __BYTE_ORDER == __BIG_ENDIAN */ +static inline nsfb_colour_t pixel_to_colour(UNUSED nsfb_t *nsfb, uint32_t pixel) +{ + return ((pixel & 0xFF) << 16) | + ((pixel & 0xFF00)) | + ((pixel & 0xFF0000) >> 16); +} + +/* convert a colour value to a 32bpp pixel value ready for screen output */ +static inline uint32_t colour_to_pixel(UNUSED nsfb_t *nsfb, nsfb_colour_t c) +{ + return ((c & 0xff0000) >> 16) | (c & 0xff00) | ((c & 0xff) << 16); +} +#endif + +#define PLOT_TYPE uint32_t +#define PLOT_LINELEN(ll) ((ll) >> 2) + +#include "32bpp-common.c" + +const nsfb_plotter_fns_t _nsfb_32bpp_xrgb8888_plotters = { + .line = line, + .fill = fill, + .point = point, + .bitmap = bitmap, + .glyph8 = glyph8, + .glyph1 = glyph1, + .readrect = readrect, +}; + +/* + * Local Variables: + * c-basic-offset:8 + * End: + */ -- cgit v1.2.3