Fixed pitch alignment problem causing MITSHM error on 16-bit displays
--HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403378
This commit is contained in:
parent
92f0abc075
commit
6a3665cb25
3 changed files with 19 additions and 0 deletions
|
@ -136,6 +136,8 @@ X11_InitModes(_THIS)
|
||||||
SDL_VideoDisplay display;
|
SDL_VideoDisplay display;
|
||||||
SDL_DisplayData *displaydata;
|
SDL_DisplayData *displaydata;
|
||||||
SDL_DisplayMode mode;
|
SDL_DisplayMode mode;
|
||||||
|
XPixmapFormatValues *pixmapFormats;
|
||||||
|
int i, n;
|
||||||
|
|
||||||
if (get_visualinfo(data->display, screen, &vinfo) < 0) {
|
if (get_visualinfo(data->display, screen, &vinfo) < 0) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -155,6 +157,18 @@ X11_InitModes(_THIS)
|
||||||
displaydata->visual = vinfo.visual;
|
displaydata->visual = vinfo.visual;
|
||||||
displaydata->depth = vinfo.depth;
|
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);
|
SDL_zero(display);
|
||||||
display.desktop_mode = mode;
|
display.desktop_mode = mode;
|
||||||
display.current_mode = mode;
|
display.current_mode = mode;
|
||||||
|
|
|
@ -29,6 +29,7 @@ typedef struct
|
||||||
int screen;
|
int screen;
|
||||||
Visual *visual;
|
Visual *visual;
|
||||||
int depth;
|
int depth;
|
||||||
|
int scanline_pad;
|
||||||
|
|
||||||
int use_xinerama;
|
int use_xinerama;
|
||||||
int use_xrandr;
|
int use_xrandr;
|
||||||
|
|
|
@ -83,6 +83,7 @@ typedef struct
|
||||||
int screen;
|
int screen;
|
||||||
Visual *visual;
|
Visual *visual;
|
||||||
int depth;
|
int depth;
|
||||||
|
int scanline_pad;
|
||||||
Window window;
|
Window window;
|
||||||
Pixmap pixmaps[3];
|
Pixmap pixmaps[3];
|
||||||
int current_pixmap;
|
int current_pixmap;
|
||||||
|
@ -185,6 +186,7 @@ X11_CreateRenderer(SDL_Window * window, Uint32 flags)
|
||||||
data->screen = displaydata->screen;
|
data->screen = displaydata->screen;
|
||||||
data->visual = displaydata->visual;
|
data->visual = displaydata->visual;
|
||||||
data->depth = displaydata->depth;
|
data->depth = displaydata->depth;
|
||||||
|
data->scanline_pad = displaydata->scanline_pad;
|
||||||
data->window = windowdata->window;
|
data->window = windowdata->window;
|
||||||
|
|
||||||
renderer->DisplayModeChanged = X11_DisplayModeChanged;
|
renderer->DisplayModeChanged = X11_DisplayModeChanged;
|
||||||
|
@ -316,6 +318,7 @@ X11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||||
SDL_Window *window = SDL_GetWindowFromID(renderer->window);
|
SDL_Window *window = SDL_GetWindowFromID(renderer->window);
|
||||||
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
|
SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
|
||||||
X11_TextureData *data;
|
X11_TextureData *data;
|
||||||
|
int pitch_alignmask = ((renderdata->scanline_pad / 8) - 1);
|
||||||
|
|
||||||
data = (X11_TextureData *) SDL_calloc(1, sizeof(*data));
|
data = (X11_TextureData *) SDL_calloc(1, sizeof(*data));
|
||||||
if (!data) {
|
if (!data) {
|
||||||
|
@ -343,6 +346,7 @@ X11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
|
||||||
data->format = texture->format;
|
data->format = texture->format;
|
||||||
}
|
}
|
||||||
data->pitch = texture->w * SDL_BYTESPERPIXEL(data->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) {
|
if (data->yuv || texture->access == SDL_TEXTUREACCESS_STREAMING) {
|
||||||
#ifndef NO_SHARED_MEMORY
|
#ifndef NO_SHARED_MEMORY
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue