diff src/video/x11/SDL_x11render.c @ 2916:ffdd533f7add

Fixed pitch alignment problem causing MITSHM error on 16-bit displays
author Sam Lantinga <slouken@libsdl.org>
date Thu, 25 Dec 2008 04:42:28 +0000
parents 133601e3b255
children 2133d2d300fd
line wrap: on
line diff
--- a/src/video/x11/SDL_x11render.c	Wed Dec 24 13:13:38 2008 +0000
+++ b/src/video/x11/SDL_x11render.c	Thu Dec 25 04:42:28 2008 +0000
@@ -83,6 +83,7 @@
     int screen;
     Visual *visual;
     int depth;
+    int scanline_pad;
     Window window;
     Pixmap pixmaps[3];
     int current_pixmap;
@@ -185,6 +186,7 @@
     data->screen = displaydata->screen;
     data->visual = displaydata->visual;
     data->depth = displaydata->depth;
+    data->scanline_pad = displaydata->scanline_pad;
     data->window = windowdata->window;
 
     renderer->DisplayModeChanged = X11_DisplayModeChanged;
@@ -316,6 +318,7 @@
     SDL_Window *window = SDL_GetWindowFromID(renderer->window);
     SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
     X11_TextureData *data;
+    int pitch_alignmask = ((renderdata->scanline_pad / 8) - 1);
 
     data = (X11_TextureData *) SDL_calloc(1, sizeof(*data));
     if (!data) {
@@ -343,6 +346,7 @@
         data->format = texture->format;
     }
     data->pitch = texture->w * SDL_BYTESPERPIXEL(data->format);
+    data->pitch = (data->pitch + pitch_alignmask) & ~pitch_alignmask;
 
     if (data->yuv || texture->access == SDL_TEXTUREACCESS_STREAMING) {
 #ifndef NO_SHARED_MEMORY