diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-11-30 20:09:14 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-11-30 20:09:14 +0000 |
commit | f89d3e1e2b6e387f4818003ef33b23d499b6722a (patch) | |
tree | fad4bd41afe5baad5eba144471d93fbbc35971e8 /nuttx/arch/sim | |
parent | 35fca0444f23f80018b537db7e70a3abb3f0c5d5 (diff) | |
download | px4-nuttx-f89d3e1e2b6e387f4818003ef33b23d499b6722a.tar.gz px4-nuttx-f89d3e1e2b6e387f4818003ef33b23d499b6722a.tar.bz2 px4-nuttx-f89d3e1e2b6e387f4818003ef33b23d499b6722a.zip |
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
Diffstat (limited to 'nuttx/arch/sim')
-rw-r--r-- | nuttx/arch/sim/src/up_x11framebuffer.c | 25 |
1 files changed, 18 insertions, 7 deletions
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 */ |