diff options
author | Chia-I Wu <[email protected]> | 2010-03-09 12:36:34 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2010-03-09 12:51:27 +0800 |
commit | da92f6db5bf0d3ac42732df556eb4f96619c9047 (patch) | |
tree | f9786cffaa9842b441ea8ccc80509f615b6a97a3 /src/gallium | |
parent | 3ab8211be40e3cd835bd1f6947b2c56f9a0c7a59 (diff) |
winsys/xlib: Fix a segfault when USE_XSHM is not defined.
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/winsys/xlib/xlib_sw_winsys.c | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/src/gallium/winsys/xlib/xlib_sw_winsys.c b/src/gallium/winsys/xlib/xlib_sw_winsys.c index 3e8fefb5824..9a4ae39aeb9 100644 --- a/src/gallium/winsys/xlib/xlib_sw_winsys.c +++ b/src/gallium/winsys/xlib/xlib_sw_winsys.c @@ -193,6 +193,26 @@ alloc_shm_ximage(struct xm_displaytarget *xm_dt, #endif /* USE_XSHM */ +static void +alloc_ximage(struct xm_displaytarget *xm_dt, + struct xlib_drawable *xmb, + unsigned width, unsigned height) +{ +#ifdef USE_XSHM + if (xm_dt->shm) { + alloc_shm_ximage(xm_dt, xmb, width, height); + return; + } +#endif + + xm_dt->tempImage = XCreateImage(xm_dt->display, + xmb->visual, + xmb->depth, + ZPixmap, 0, + NULL, width, height, + 8, 0); +} + static boolean xm_is_displaytarget_format_supported( struct sw_winsys *ws, enum pipe_format format ) @@ -265,19 +285,20 @@ xlib_sw_display(struct xlib_drawable *xlib_drawable, if (no_swap) return; + if (xm_dt->tempImage == NULL) + { + assert(util_format_get_blockwidth(xm_dt->format) == 1); + assert(util_format_get_blockheight(xm_dt->format) == 1); + alloc_ximage(xm_dt, xlib_drawable, + xm_dt->stride / util_format_get_blocksize(xm_dt->format), + xm_dt->height); + if (!xm_dt->tempImage) + return; + } + #ifdef USE_XSHM if (xm_dt->shm) { - if (xm_dt->tempImage == NULL) - { - assert(util_format_get_blockwidth(xm_dt->format) == 1); - assert(util_format_get_blockheight(xm_dt->format) == 1); - alloc_shm_ximage(xm_dt, - xlib_drawable, - xm_dt->stride / util_format_get_blocksize(xm_dt->format), - xm_dt->height); - } - ximage = xm_dt->tempImage; ximage->data = xm_dt->data; |