Mercurial > sdl-ios-xcode
changeset 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 | deb377097225 |
children | 4cecb110195d |
files | src/video/x11/SDL_x11modes.c src/video/x11/SDL_x11modes.h src/video/x11/SDL_x11render.c |
diffstat | 3 files changed, 19 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/video/x11/SDL_x11modes.c Wed Dec 24 13:13:38 2008 +0000 +++ b/src/video/x11/SDL_x11modes.c Thu Dec 25 04:42:28 2008 +0000 @@ -136,6 +136,8 @@ 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 @@ 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;
--- a/src/video/x11/SDL_x11modes.h Wed Dec 24 13:13:38 2008 +0000 +++ b/src/video/x11/SDL_x11modes.h Thu Dec 25 04:42:28 2008 +0000 @@ -29,6 +29,7 @@ int screen; Visual *visual; int depth; + int scanline_pad; int use_xinerama; int use_xrandr;
--- 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