st/xlib: Fix XImage stride calculation

Fixes window skew seen while running gnome on a 16-bit screen over vnc.

NOTE: This is a candidate for stable release branches.

Reviewed-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Richard Sandiford <rsandifo@linux.vnet.ibm.com>
(cherry picked from commit c132c2978b)
This commit is contained in:
Richard Sandiford 2013-06-17 12:13:25 -04:00 committed by Ian Romanick
parent 2cfc0072a8
commit 8ed60f7f7f

View file

@ -1366,7 +1366,7 @@ XMesaBindTexImage(Display *dpy, XMesaBuffer drawable, int buffer,
enum pipe_format internal_format = res->format;
struct pipe_transfer *tex_xfer;
char *map;
int line, ximage_stride;
int line, byte_width;
XImage *img;
internal_format = choose_pixel_format(drawable->xm_visual);
@ -1393,12 +1393,12 @@ XMesaBindTexImage(Display *dpy, XMesaBuffer drawable, int buffer,
}
/* The pipe transfer has a pitch rounded up to the nearest 64 pixels. */
ximage_stride = w * ((img->bits_per_pixel + 7) / 8);
byte_width = w * ((img->bits_per_pixel + 7) / 8);
for (line = 0; line < h; line++)
memcpy(&map[line * tex_xfer->stride],
&img->data[line * ximage_stride],
ximage_stride);
&img->data[line * img->bytes_per_line],
byte_width);
pipe_transfer_unmap(pipe, tex_xfer);