From f89d3e1e2b6e387f4818003ef33b23d499b6722a Mon Sep 17 00:00:00 2001 From: patacongo Date: Sun, 30 Nov 2008 20:09:14 +0000 Subject: X reports 24 bpp depth, but wants 32 bpp size pixels git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1363 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/arch/sim/src/up_x11framebuffer.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) (limited to 'nuttx/arch/sim') diff --git a/nuttx/arch/sim/src/up_x11framebuffer.c b/nuttx/arch/sim/src/up_x11framebuffer.c index 346f1380f..0aa58a6a7 100644 --- a/nuttx/arch/sim/src/up_x11framebuffer.c +++ b/nuttx/arch/sim/src/up_x11framebuffer.c @@ -228,7 +228,7 @@ static void up_x11uninitialize(void) * Name: up_x11mapsharedmem ***************************************************************************/ -static inline int up_x11mapsharedmem(int bpp, unsigned int fblen) +static inline int up_x11mapsharedmem(int depth, unsigned int fblen) { #ifndef CONFIG_SIM_X11NOSHM Status result; @@ -246,8 +246,8 @@ static inline int up_x11mapsharedmem(int bpp, unsigned int fblen) up_x11traperrors(); g_image = XShmCreateImage(g_display, DefaultVisual(g_display, g_screen), - bpp, ZPixmap, NULL, &g_xshminfo, - g_fbpixelwidth, g_fbpixelheight); + depth, ZPixmap, NULL, &g_xshminfo, + g_fbpixelwidth, g_fbpixelheight); if (up_x11untraperrors()) { up_x11uninitialize(); @@ -303,7 +303,7 @@ shmerror: g_framebuffer = (unsigned char*)malloc(fblen); - g_image = XCreateImage(g_display, DefaultVisual(g_display,g_screen), bpp, + g_image = XCreateImage(g_display, DefaultVisual(g_display,g_screen), depth, ZPixmap, 0, (char*)g_framebuffer, g_fbpixelwidth, g_fbpixelheight, 8, 0); @@ -335,6 +335,7 @@ int up_x11initialize(unsigned short width, unsigned short height, unsigned short *stride) { XWindowAttributes windowAttributes; + int depth; int ret; /* Save inputs */ @@ -353,10 +354,20 @@ int up_x11initialize(unsigned short width, unsigned short height, /* Determine the supported pixel bpp of the current window */ XGetWindowAttributes(g_display, DefaultRootWindow(g_display), &windowAttributes); - printf("Pixel bpp is %d bits\n", windowAttributes.depth); - *bpp = windowAttributes.depth; - *stride = (windowAttributes.depth * width / 8); + /* Get the pixel depth. If the depth is 24-bits, use 32 because X expects + * 32-bit aligment anyway. + */ + + depth = windowAttributes.depth; + if (depth == 24) + { + depth = 32; + } + printf("Pixel bpp is %d bits (using %d)\n", windowAttributes.depth, depth); + + *bpp = depth; + *stride = (depth * width / 8); *fblen = (*stride * height); /* Map the window to shared memory */ -- cgit v1.2.3