comparison 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
comparison
equal deleted inserted replaced
2915:deb377097225 2916:ffdd533f7add
81 { 81 {
82 Display *display; 82 Display *display;
83 int screen; 83 int screen;
84 Visual *visual; 84 Visual *visual;
85 int depth; 85 int depth;
86 int scanline_pad;
86 Window window; 87 Window window;
87 Pixmap pixmaps[3]; 88 Pixmap pixmaps[3];
88 int current_pixmap; 89 int current_pixmap;
89 Drawable drawable; 90 Drawable drawable;
90 SDL_PixelFormat *format; 91 SDL_PixelFormat *format;
183 } 184 }
184 data->display = windowdata->videodata->display; 185 data->display = windowdata->videodata->display;
185 data->screen = displaydata->screen; 186 data->screen = displaydata->screen;
186 data->visual = displaydata->visual; 187 data->visual = displaydata->visual;
187 data->depth = displaydata->depth; 188 data->depth = displaydata->depth;
189 data->scanline_pad = displaydata->scanline_pad;
188 data->window = windowdata->window; 190 data->window = windowdata->window;
189 191
190 renderer->DisplayModeChanged = X11_DisplayModeChanged; 192 renderer->DisplayModeChanged = X11_DisplayModeChanged;
191 renderer->CreateTexture = X11_CreateTexture; 193 renderer->CreateTexture = X11_CreateTexture;
192 renderer->QueryTexturePixels = X11_QueryTexturePixels; 194 renderer->QueryTexturePixels = X11_QueryTexturePixels;
314 { 316 {
315 X11_RenderData *renderdata = (X11_RenderData *) renderer->driverdata; 317 X11_RenderData *renderdata = (X11_RenderData *) renderer->driverdata;
316 SDL_Window *window = SDL_GetWindowFromID(renderer->window); 318 SDL_Window *window = SDL_GetWindowFromID(renderer->window);
317 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window); 319 SDL_VideoDisplay *display = SDL_GetDisplayFromWindow(window);
318 X11_TextureData *data; 320 X11_TextureData *data;
321 int pitch_alignmask = ((renderdata->scanline_pad / 8) - 1);
319 322
320 data = (X11_TextureData *) SDL_calloc(1, sizeof(*data)); 323 data = (X11_TextureData *) SDL_calloc(1, sizeof(*data));
321 if (!data) { 324 if (!data) {
322 SDL_OutOfMemory(); 325 SDL_OutOfMemory();
323 return -1; 326 return -1;
341 return -1; 344 return -1;
342 } 345 }
343 data->format = texture->format; 346 data->format = texture->format;
344 } 347 }
345 data->pitch = texture->w * SDL_BYTESPERPIXEL(data->format); 348 data->pitch = texture->w * SDL_BYTESPERPIXEL(data->format);
349 data->pitch = (data->pitch + pitch_alignmask) & ~pitch_alignmask;
346 350
347 if (data->yuv || texture->access == SDL_TEXTUREACCESS_STREAMING) { 351 if (data->yuv || texture->access == SDL_TEXTUREACCESS_STREAMING) {
348 #ifndef NO_SHARED_MEMORY 352 #ifndef NO_SHARED_MEMORY
349 XShmSegmentInfo *shminfo = &data->shminfo; 353 XShmSegmentInfo *shminfo = &data->shminfo;
350 354