Commit 6a3665cb authored by Sam Lantinga's avatar Sam Lantinga

Fixed pitch alignment problem causing MITSHM error on 16-bit displays

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403378
parent 92f0abc0
......@@ -136,6 +136,8 @@ X11_InitModes(_THIS)
SDL_VideoDisplay display;
SDL_DisplayData *displaydata;
SDL_DisplayMode mode;
XPixmapFormatValues *pixmapFormats;
int i, n;
if (get_visualinfo(data->display, screen, &vinfo) < 0) {
continue;
......@@ -155,6 +157,18 @@ X11_InitModes(_THIS)
displaydata->visual = vinfo.visual;
displaydata->depth = vinfo.depth;
displaydata->scanline_pad = SDL_BYTESPERPIXEL(mode.format)*8;
pixmapFormats = XListPixmapFormats(data->display, &n);
if (pixmapFormats) {
for (i = 0; i < n; ++i) {
if (pixmapFormats[i].depth == displaydata->depth) {
displaydata->scanline_pad = pixmapFormats[i].scanline_pad;
break;
}
}
XFree(pixmapFormats);
}
SDL_zero(display);
display.desktop_mode = mode;
display.current_mode = mode;
......
......@@ -29,6 +29,7 @@ typedef struct
int screen;
Visual *visual;
int depth;
int scanline_pad;
int use_xinerama;
int use_xrandr;
......
......@@ -83,6 +83,7 @@ typedef struct
int screen;
Visual *visual;
int depth;
int scanline_pad;
Window window;
Pixmap pixmaps[3];
int current_pixmap;
......@@ -185,6 +186,7 @@ X11_CreateRenderer(SDL_Window * window, Uint32 flags)
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 @@ X11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
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 @@ X11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment