summaryrefslogtreecommitdiff
path: root/src/plot
diff options
context:
space:
mode:
authorMichael Drake <tlsa@netsurf-browser.org>2012-09-30 09:40:46 +0100
committerMichael Drake <tlsa@netsurf-browser.org>2012-09-30 09:40:46 +0100
commit480b2353d815540dca310edc8496da1d3f1b3295 (patch)
tree1103a068d8674cca5c38047f172ba1167cafde74 /src/plot
parent1fbc4a8b2dfc030f174aaf475f7ea6820864d1a3 (diff)
downloadlibnsfb-480b2353d815540dca310edc8496da1d3f1b3295.tar.gz
libnsfb-480b2353d815540dca310edc8496da1d3f1b3295.tar.bz2
Split 32bpp support into xrgba, xbgr, and common. Should allow for BGR surfaces as well as RGB.
Diffstat (limited to 'src/plot')
-rw-r--r--src/plot/32bpp-common.c (renamed from src/plot/32bpp.c)58
-rw-r--r--src/plot/32bpp-xbgr8888.c74
-rw-r--r--src/plot/32bpp-xrgb8888.c74
-rw-r--r--src/plot/Makefile2
-rw-r--r--src/plot/generic.c7
5 files changed, 153 insertions, 62 deletions
diff --git a/src/plot/32bpp.c b/src/plot/32bpp-common.c
index aae1b39..9626acf 100644
--- a/src/plot/32bpp.c
+++ b/src/plot/32bpp-common.c
@@ -7,54 +7,6 @@
* http://www.opensource.org/licenses/mit-license.php
*/
-#include <stdbool.h>
-#include <endian.h>
-#include <stdlib.h>
-
-#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 "common.c"
static bool fill(nsfb_t *nsfb, nsfb_bbox_t *rect, nsfb_colour_t c)
@@ -104,16 +56,6 @@ static bool fill(nsfb_t *nsfb, nsfb_bbox_t *rect, nsfb_colour_t c)
return true;
}
-const nsfb_plotter_fns_t _nsfb_32bpp_plotters = {
- .line = line,
- .fill = fill,
- .point = point,
- .bitmap = bitmap,
- .glyph8 = glyph8,
- .glyph1 = glyph1,
- .readrect = readrect,
-};
-
/*
* Local Variables:
* c-basic-offset:8
diff --git a/src/plot/32bpp-xbgr8888.c b/src/plot/32bpp-xbgr8888.c
new file mode 100644
index 0000000..9050903
--- /dev/null
+++ b/src/plot/32bpp-xbgr8888.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2009 Vincent Sanders <vince@simtec.co.uk>
+ * Copyright 2010 Michael Drake <tlsa@netsurf-browser.org>
+ *
+ * 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 <stdbool.h>
+#include <endian.h>
+#include <stdlib.h>
+
+#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)
+{
+ /* TODO: FIX */
+ 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)
+{
+ /* TODO: FIX */
+ 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 | 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;
+}
+#endif
+
+#define PLOT_TYPE uint32_t
+#define PLOT_LINELEN(ll) ((ll) >> 2)
+
+#include "32bpp-common.c"
+
+const nsfb_plotter_fns_t _nsfb_32bpp_xbgr8888_plotters = {
+ .line = line,
+ .fill = fill,
+ .point = point,
+ .bitmap = bitmap,
+ .glyph8 = glyph8,
+ .glyph1 = glyph1,
+ .readrect = readrect,
+};
+
+/*
+ * Local Variables:
+ * c-basic-offset:8
+ * End:
+ */
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 <vince@simtec.co.uk>
+ * Copyright 2010 Michael Drake <tlsa@netsurf-browser.org>
+ *
+ * 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 <stdbool.h>
+#include <endian.h>
+#include <stdlib.h>
+
+#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:
+ */
diff --git a/src/plot/Makefile b/src/plot/Makefile
index e99f440..71ebc61 100644
--- a/src/plot/Makefile
+++ b/src/plot/Makefile
@@ -1,4 +1,4 @@
# Sources
-DIR_SOURCES := api.c util.c generic.c 32bpp.c 16bpp.c 8bpp.c
+DIR_SOURCES := api.c util.c generic.c 32bpp-xrgb8888.c 32bpp-xbgr8888.c 16bpp.c 8bpp.c
include $(NSBUILD)/Makefile.subdir
diff --git a/src/plot/generic.c b/src/plot/generic.c
index 6a627ff..0c3d9e8 100644
--- a/src/plot/generic.c
+++ b/src/plot/generic.c
@@ -28,7 +28,8 @@ extern const nsfb_plotter_fns_t _nsfb_1bpp_plotters;
extern const nsfb_plotter_fns_t _nsfb_8bpp_plotters;
extern const nsfb_plotter_fns_t _nsfb_16bpp_plotters;
extern const nsfb_plotter_fns_t _nsfb_24bpp_plotters;
-extern const nsfb_plotter_fns_t _nsfb_32bpp_plotters;
+extern const nsfb_plotter_fns_t _nsfb_32bpp_xrgb8888_plotters;
+extern const nsfb_plotter_fns_t _nsfb_32bpp_xbgr8888_plotters;
static bool set_clip(nsfb_t *nsfb, nsfb_bbox_t *clip)
{
@@ -860,13 +861,13 @@ bool select_plotters(nsfb_t *nsfb)
case NSFB_FMT_XBGR8888: /* 32bpp Unused Blue Green Red */
case NSFB_FMT_ABGR8888: /* 32bpp Alpha Blue Green Red */
- table = &_nsfb_32bpp_plotters;
+ table = &_nsfb_32bpp_xbgr8888_plotters;
nsfb->bpp = 32;
break;
case NSFB_FMT_XRGB8888: /* 32bpp Unused Red Green Blue */
case NSFB_FMT_ARGB8888: /* 32bpp Alpha Red Green Blue */
- table = &_nsfb_32bpp_plotters;
+ table = &_nsfb_32bpp_xrgb8888_plotters;
nsfb->bpp = 32;
break;