Gitweb links:
...log
http://git.netsurf-browser.org/libnsfb.git/shortlog/480b2353d815540dca310...
...commit
http://git.netsurf-browser.org/libnsfb.git/commit/480b2353d815540dca310ed...
...tree
http://git.netsurf-browser.org/libnsfb.git/tree/480b2353d815540dca310edc8...
The branch, master has been updated
via 480b2353d815540dca310edc8496da1d3f1b3295 (commit)
via 1fbc4a8b2dfc030f174aaf475f7ea6820864d1a3 (commit)
from 0804bb7e067e66d4b05a6c45f9736b1e20505b96 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/libnsfb.git/commitdiff/480b2353d815540dca3...
commit 480b2353d815540dca310edc8496da1d3f1b3295
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Split 32bpp support into xrgba, xbgr, and common. Should allow for BGR surfaces as
well as RGB.
diff --git a/src/plot/32bpp-common.c b/src/plot/32bpp-common.c
new file mode 100644
index 0000000..9626acf
--- /dev/null
+++ b/src/plot/32bpp-common.c
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2009 Vincent Sanders <vince(a)simtec.co.uk>
+ * Copyright 2010 Michael Drake <tlsa(a)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 "common.c"
+
+static bool fill(nsfb_t *nsfb, nsfb_bbox_t *rect, nsfb_colour_t c)
+{
+ int w;
+ uint32_t *pvid;
+ uint32_t ent;
+ uint32_t llen;
+ uint32_t width;
+ uint32_t height;
+
+ if (!nsfb_plot_clip_ctx(nsfb, rect))
+ return true; /* fill lies outside current clipping region */
+
+ ent = colour_to_pixel(nsfb, c);
+ width = rect->x1 - rect->x0;
+ height = rect->y1 - rect->y0;
+ llen = (nsfb->linelen >> 2) - width;
+
+ pvid = get_xy_loc(nsfb, rect->x0, rect->y0);
+
+ while (height-- > 0) {
+ w = width;
+ while (w >= 16) {
+ *pvid++ = ent; *pvid++ = ent;
+ *pvid++ = ent; *pvid++ = ent;
+ *pvid++ = ent; *pvid++ = ent;
+ *pvid++ = ent; *pvid++ = ent;
+ *pvid++ = ent; *pvid++ = ent;
+ *pvid++ = ent; *pvid++ = ent;
+ *pvid++ = ent; *pvid++ = ent;
+ *pvid++ = ent; *pvid++ = ent;
+ w-=16;
+ }
+ while (w >= 4) {
+ *pvid++ = ent; *pvid++ = ent;
+ *pvid++ = ent; *pvid++ = ent;
+ w-=4;
+ }
+ while (w > 0) {
+ *pvid++ = ent;
+ w--;
+ }
+ pvid += llen;
+ }
+
+ return true;
+}
+
+/*
+ * Local Variables:
+ * c-basic-offset:8
+ * End:
+ */
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(a)simtec.co.uk>
+ * Copyright 2010 Michael Drake <tlsa(a)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(a)simtec.co.uk>
+ * Copyright 2010 Michael Drake <tlsa(a)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/32bpp.c b/src/plot/32bpp.c
deleted file mode 100644
index aae1b39..0000000
--- a/src/plot/32bpp.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright 2009 Vincent Sanders <vince(a)simtec.co.uk>
- * Copyright 2010 Michael Drake <tlsa(a)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 "common.c"
-
-static bool fill(nsfb_t *nsfb, nsfb_bbox_t *rect, nsfb_colour_t c)
-{
- int w;
- uint32_t *pvid;
- uint32_t ent;
- uint32_t llen;
- uint32_t width;
- uint32_t height;
-
- if (!nsfb_plot_clip_ctx(nsfb, rect))
- return true; /* fill lies outside current clipping region */
-
- ent = colour_to_pixel(nsfb, c);
- width = rect->x1 - rect->x0;
- height = rect->y1 - rect->y0;
- llen = (nsfb->linelen >> 2) - width;
-
- pvid = get_xy_loc(nsfb, rect->x0, rect->y0);
-
- while (height-- > 0) {
- w = width;
- while (w >= 16) {
- *pvid++ = ent; *pvid++ = ent;
- *pvid++ = ent; *pvid++ = ent;
- *pvid++ = ent; *pvid++ = ent;
- *pvid++ = ent; *pvid++ = ent;
- *pvid++ = ent; *pvid++ = ent;
- *pvid++ = ent; *pvid++ = ent;
- *pvid++ = ent; *pvid++ = ent;
- *pvid++ = ent; *pvid++ = ent;
- w-=16;
- }
- while (w >= 4) {
- *pvid++ = ent; *pvid++ = ent;
- *pvid++ = ent; *pvid++ = ent;
- w-=4;
- }
- while (w > 0) {
- *pvid++ = ent;
- w--;
- }
- pvid += llen;
- }
-
- 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
- * 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;
diff --git a/src/surface/sdl.c b/src/surface/sdl.c
index 0554e26..48052a8 100644
--- a/src/surface/sdl.c
+++ b/src/surface/sdl.c
@@ -411,7 +411,8 @@ sdlcopy(nsfb_t *nsfb, nsfb_bbox_t *srcbox, nsfb_bbox_t *dstbox)
}
-static int sdl_set_geometry(nsfb_t *nsfb, int width, int height, enum nsfb_format_e
format)
+static int sdl_set_geometry(nsfb_t *nsfb, int width, int height,
+ enum nsfb_format_e format)
{
if (nsfb->surface_priv != NULL)
return -1; /* fail if surface already initialised */
@@ -431,6 +432,8 @@ static int sdl_set_geometry(nsfb_t *nsfb, int width, int height, enum
nsfb_forma
static int sdl_initialise(nsfb_t *nsfb)
{
SDL_Surface *sdl_screen;
+ SDL_PixelFormat *sdl_fmt;
+ enum nsfb_format_e fmt;
if (nsfb->surface_priv != NULL)
return -1;
@@ -455,6 +458,32 @@ static int sdl_initialise(nsfb_t *nsfb)
return -1;
}
+ /* find out what pixel format we got */
+ sdl_fmt = sdl_screen->format;
+
+ switch (sdl_fmt->BitsPerPixel) {
+ case 32:
+ if (sdl_fmt->Rshift == 0)
+ fmt = NSFB_FMT_XBGR8888;
+ else
+ fmt = NSFB_FMT_XRGB8888;
+ break;
+
+ default:
+ fmt = nsfb->format;
+ break;
+ }
+
+ /* If we didn't get what we asked for, reselect plotters */
+ if (nsfb->format != fmt) {
+ nsfb->format = fmt;
+
+ if (sdl_set_geometry(nsfb, nsfb->width, nsfb->height,
+ nsfb->format) != 0) {
+ return -1;
+ }
+ }
+
nsfb->surface_priv = sdl_screen;
if (nsfb->bpp == 8) {
commitdiff
http://git.netsurf-browser.org/libnsfb.git/commitdiff/1fbc4a8b2dfc030f174...
commit 1fbc4a8b2dfc030f174aaf475f7ea6820864d1a3
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Fix error text.
diff --git a/src/plot/common.c b/src/plot/common.c
index c9f9dc1..f8c4a70 100644
--- a/src/plot/common.c
+++ b/src/plot/common.c
@@ -10,7 +10,7 @@
*/
#ifndef PLOT_TYPE
-#error PLOT_TYPE must be set to uint16_6 or uint32_t
+#error PLOT_TYPE must be set to uint8_t, uint16_t, or uint32_t
#endif
#ifndef PLOT_LINELEN
#error PLOT_LINELEN must be a macro to increment a line length
-----------------------------------------------------------------------
Summary of changes:
src/plot/{32bpp.c => 32bpp-common.c} | 58 -------------------------
src/plot/32bpp-xbgr8888.c | 74 ++++++++++++++++++++++++++++++++
src/plot/{32bpp.c => 32bpp-xrgb8888.c} | 51 +---------------------
src/plot/Makefile | 2 +-
src/plot/common.c | 2 +-
src/plot/generic.c | 7 ++-
src/surface/sdl.c | 31 +++++++++++++-
7 files changed, 112 insertions(+), 113 deletions(-)
copy src/plot/{32bpp.c => 32bpp-common.c} (55%)
create mode 100644 src/plot/32bpp-xbgr8888.c
rename src/plot/{32bpp.c => 32bpp-xrgb8888.c} (53%)
diff --git a/src/plot/32bpp.c b/src/plot/32bpp-common.c
similarity index 55%
copy from src/plot/32bpp.c
copy to 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(a)simtec.co.uk>
+ * Copyright 2010 Michael Drake <tlsa(a)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.c b/src/plot/32bpp-xrgb8888.c
similarity index 53%
rename from src/plot/32bpp.c
rename to src/plot/32bpp-xrgb8888.c
index aae1b39..548c970 100644
--- a/src/plot/32bpp.c
+++ b/src/plot/32bpp-xrgb8888.c
@@ -55,56 +55,9 @@ static inline uint32_t colour_to_pixel(UNUSED nsfb_t *nsfb,
nsfb_colour_t c)
#define PLOT_TYPE uint32_t
#define PLOT_LINELEN(ll) ((ll) >> 2)
-#include "common.c"
+#include "32bpp-common.c"
-static bool fill(nsfb_t *nsfb, nsfb_bbox_t *rect, nsfb_colour_t c)
-{
- int w;
- uint32_t *pvid;
- uint32_t ent;
- uint32_t llen;
- uint32_t width;
- uint32_t height;
-
- if (!nsfb_plot_clip_ctx(nsfb, rect))
- return true; /* fill lies outside current clipping region */
-
- ent = colour_to_pixel(nsfb, c);
- width = rect->x1 - rect->x0;
- height = rect->y1 - rect->y0;
- llen = (nsfb->linelen >> 2) - width;
-
- pvid = get_xy_loc(nsfb, rect->x0, rect->y0);
-
- while (height-- > 0) {
- w = width;
- while (w >= 16) {
- *pvid++ = ent; *pvid++ = ent;
- *pvid++ = ent; *pvid++ = ent;
- *pvid++ = ent; *pvid++ = ent;
- *pvid++ = ent; *pvid++ = ent;
- *pvid++ = ent; *pvid++ = ent;
- *pvid++ = ent; *pvid++ = ent;
- *pvid++ = ent; *pvid++ = ent;
- *pvid++ = ent; *pvid++ = ent;
- w-=16;
- }
- while (w >= 4) {
- *pvid++ = ent; *pvid++ = ent;
- *pvid++ = ent; *pvid++ = ent;
- w-=4;
- }
- while (w > 0) {
- *pvid++ = ent;
- w--;
- }
- pvid += llen;
- }
-
- return true;
-}
-
-const nsfb_plotter_fns_t _nsfb_32bpp_plotters = {
+const nsfb_plotter_fns_t _nsfb_32bpp_xrgb8888_plotters = {
.line = line,
.fill = fill,
.point = point,
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/common.c b/src/plot/common.c
index c9f9dc1..f8c4a70 100644
--- a/src/plot/common.c
+++ b/src/plot/common.c
@@ -10,7 +10,7 @@
*/
#ifndef PLOT_TYPE
-#error PLOT_TYPE must be set to uint16_6 or uint32_t
+#error PLOT_TYPE must be set to uint8_t, uint16_t, or uint32_t
#endif
#ifndef PLOT_LINELEN
#error PLOT_LINELEN must be a macro to increment a line length
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;
diff --git a/src/surface/sdl.c b/src/surface/sdl.c
index 0554e26..48052a8 100644
--- a/src/surface/sdl.c
+++ b/src/surface/sdl.c
@@ -411,7 +411,8 @@ sdlcopy(nsfb_t *nsfb, nsfb_bbox_t *srcbox, nsfb_bbox_t *dstbox)
}
-static int sdl_set_geometry(nsfb_t *nsfb, int width, int height, enum nsfb_format_e
format)
+static int sdl_set_geometry(nsfb_t *nsfb, int width, int height,
+ enum nsfb_format_e format)
{
if (nsfb->surface_priv != NULL)
return -1; /* fail if surface already initialised */
@@ -431,6 +432,8 @@ static int sdl_set_geometry(nsfb_t *nsfb, int width, int height, enum
nsfb_forma
static int sdl_initialise(nsfb_t *nsfb)
{
SDL_Surface *sdl_screen;
+ SDL_PixelFormat *sdl_fmt;
+ enum nsfb_format_e fmt;
if (nsfb->surface_priv != NULL)
return -1;
@@ -455,6 +458,32 @@ static int sdl_initialise(nsfb_t *nsfb)
return -1;
}
+ /* find out what pixel format we got */
+ sdl_fmt = sdl_screen->format;
+
+ switch (sdl_fmt->BitsPerPixel) {
+ case 32:
+ if (sdl_fmt->Rshift == 0)
+ fmt = NSFB_FMT_XBGR8888;
+ else
+ fmt = NSFB_FMT_XRGB8888;
+ break;
+
+ default:
+ fmt = nsfb->format;
+ break;
+ }
+
+ /* If we didn't get what we asked for, reselect plotters */
+ if (nsfb->format != fmt) {
+ nsfb->format = fmt;
+
+ if (sdl_set_geometry(nsfb, nsfb->width, nsfb->height,
+ nsfb->format) != 0) {
+ return -1;
+ }
+ }
+
nsfb->surface_priv = sdl_screen;
if (nsfb->bpp == 8) {
--
NetSurf Framebuffer library