summaryrefslogtreecommitdiff
path: root/src/surface/sdl.c
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/surface/sdl.c
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/surface/sdl.c')
-rw-r--r--src/surface/sdl.c31
1 files changed, 30 insertions, 1 deletions
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) {