diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c index 14964c181..ae0e0d461 100644 --- a/src/video/x11/SDL_x11modes.c +++ b/src/video/x11/SDL_x11modes.c @@ -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; diff --git a/src/video/x11/SDL_x11modes.h b/src/video/x11/SDL_x11modes.h index e0e152d1a..67779b808 100644 --- a/src/video/x11/SDL_x11modes.h +++ b/src/video/x11/SDL_x11modes.h @@ -29,6 +29,7 @@ typedef struct int screen; Visual *visual; int depth; + int scanline_pad; int use_xinerama; int use_xrandr; diff --git a/src/video/x11/SDL_x11render.c b/src/video/x11/SDL_x11render.c index 2eadc0005..d90eff301 100644 --- a/src/video/x11/SDL_x11render.c +++ b/src/video/x11/SDL_x11render.c @@ -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