comparison src/video/x11/SDL_x11render.c @ 4572:266ec93f49af

Correctly handle the availability of Xrender in X11_CreateRenderer and X11_DisplayModeChanged. Fixed the XRenderPictureAttributes value in X11_CreateRenderer with graphics_exposures = False. Start work on Xrender specific additions to X11_TextureData and X11_CreateTexture.
author Sunny Sachanandani <sunnysachanandani@gmail.com>
date Wed, 26 May 2010 20:11:56 +0530
parents 97dcf6f6213c
children 6399178be313
comparison
equal deleted inserted replaced
4571:97dcf6f6213c 4572:266ec93f49af
95 int scanline_pad; 95 int scanline_pad;
96 Window xwindow; 96 Window xwindow;
97 Pixmap pixmaps[3]; 97 Pixmap pixmaps[3];
98 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 98 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
99 Picture xwindow_pict; 99 Picture xwindow_pict;
100 Picture pixmap_picts[3];
101 Picture * drawable_pict;
100 XRenderPictFormat* xwindow_pict_fmt; 102 XRenderPictFormat* xwindow_pict_fmt;
101 XRenderPictureAttributes xwindow_pict_attr; 103 XRenderPictureAttributes xwindow_pict_attr;
102 unsigned int xwindow_pict_attr_valuemask; 104 unsigned int xwindow_pict_attr_valuemask;
103 SDL_bool xrender_available; 105 SDL_bool xrender_available;
104 #endif 106 #endif
115 SDL_SW_YUVTexture *yuv; 117 SDL_SW_YUVTexture *yuv;
116 Uint32 format; 118 Uint32 format;
117 Pixmap pixmap; 119 Pixmap pixmap;
118 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 120 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
119 Picture picture; 121 Picture picture;
122 XRenderPictFormat* picture_fmt;
123 XRenderPictureAttributes picture_attr;
124 unsigned int picture_attr_valuemask;
120 #endif 125 #endif
121 XImage *image; 126 XImage *image;
122 #ifndef NO_SHARED_MEMORY 127 #ifndef NO_SHARED_MEMORY
123 /* MIT shared memory extension information */ 128 /* MIT shared memory extension information */
124 XShmSegmentInfo shminfo; 129 XShmSegmentInfo shminfo;
211 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 216 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
212 int event_basep, error_basep; 217 int event_basep, error_basep;
213 if(XRenderQueryExtension(data->display, &event_basep, &error_basep) == True) { 218 if(XRenderQueryExtension(data->display, &event_basep, &error_basep) == True) {
214 data->xrender_available = SDL_TRUE; 219 data->xrender_available = SDL_TRUE;
215 data->xwindow_pict_fmt = XRenderFindVisualFormat(data->display, data->visual); 220 data->xwindow_pict_fmt = XRenderFindVisualFormat(data->display, data->visual);
216 data->xwindow_pict_attr_valuemask = 0; // FIXME 221 data->xwindow_pict_attr.graphics_exposures = False;
217 data->xwindow_pict = XRenderCreatePicture(data->display, 222 data->xwindow_pict_attr_valuemask = CPGraphicsExposure;
218 data->xwindow, 223 data->xwindow_pict = XRenderCreatePicture(data->display, data->xwindow, data->xwindow_pict_fmt,
219 data->xwindow_pict_fmt, 224 data->xwindow_pict_attr_valuemask, &data->xwindow_pict_attr);
220 data->xwindow_pict_attr_valuemask,
221 &data->xwindow_pict_attr);
222 } 225 }
223 else { 226 else {
224 data->xrender_available = SDL_FALSE; 227 data->xrender_available = SDL_FALSE;
225 } 228 }
226 #endif 229 #endif
270 if (data->pixmaps[i] == None) { 273 if (data->pixmaps[i] == None) {
271 X11_DestroyRenderer(renderer); 274 X11_DestroyRenderer(renderer);
272 SDL_SetError("XCreatePixmap() failed"); 275 SDL_SetError("XCreatePixmap() failed");
273 return NULL; 276 return NULL;
274 } 277 }
278 data->pixmap_picts[i] =
279 XCreatePicture(data->display, data->pixmap[i], data->xwindow_pict_fmt,
280 data->xwindow_pict_attr_valuemask, &xwindow_pict_attr);
275 } 281 }
276 if (n > 0) { 282 if (n > 0) {
277 data->drawable = data->pixmaps[0]; 283 data->drawable = data->pixmaps[0];
284 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
285 if(data->xrender_available == SDL_TRUE)
286 data->drawable_pict = &(data->pixmap_picts[0]);
287 #endif
278 data->makedirty = SDL_TRUE; 288 data->makedirty = SDL_TRUE;
279 } else { 289 } else {
280 data->drawable = data->xwindow; 290 data->drawable = data->xwindow;
291 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
292 if(data->xrender_available == SDL_TRUE)
293 data->drawable_pict = &(data->xwindow_pict);
294 #endif
281 data->makedirty = SDL_FALSE; 295 data->makedirty = SDL_FALSE;
282 } 296 }
283 data->current_pixmap = 0; 297 data->current_pixmap = 0;
284 298
285 /* Get the format of the window */ 299 /* Get the format of the window */
323 } 337 }
324 for (i = 0; i < n; ++i) { 338 for (i = 0; i < n; ++i) {
325 if (data->pixmaps[i] != None) { 339 if (data->pixmaps[i] != None) {
326 XFreePixmap(data->display, data->pixmaps[i]); 340 XFreePixmap(data->display, data->pixmaps[i]);
327 data->pixmaps[i] = None; 341 data->pixmaps[i] = None;
342 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
343 data->pictures[i] = None;
344 #endif
328 } 345 }
329 } 346 }
330 for (i = 0; i < n; ++i) { 347 for (i = 0; i < n; ++i) {
331 data->pixmaps[i] = 348 data->pixmaps[i] =
332 XCreatePixmap(data->display, data->xwindow, window->w, window->h, 349 XCreatePixmap(data->display, data->xwindow, window->w, window->h,
333 data->depth); 350 data->depth);
334 if (data->pixmaps[i] == None) { 351 if (data->pixmaps[i] == None) {
335 SDL_SetError("XCreatePixmap() failed"); 352 SDL_SetError("XCreatePixmap() failed");
336 return -1; 353 return -1;
337 } 354 }
355 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
356 data->pictures[i] =
357 XCreatePicture(data->display, data->pixmap[i], data->xwindow_pict_fmt,
358 data->xwindow_pict_attr_valuemask, &data->xwindow_pict_attr);
359 #endif
338 } 360 }
339 if (n > 0) { 361 if (n > 0) {
340 data->drawable = data->pixmaps[0]; 362 data->drawable = data->pixmaps[0];
363 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
364 data->drawable_pict = &(data->pictures[0]);
365 #endif
341 } 366 }
342 data->current_pixmap = 0; 367 data->current_pixmap = 0;
343 368
344 return 0; 369 return 0;
345 } 370 }
358 SDL_OutOfMemory(); 383 SDL_OutOfMemory();
359 return -1; 384 return -1;
360 } 385 }
361 386
362 texture->driverdata = data; 387 texture->driverdata = data;
363
364 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { 388 if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) {
365 data->yuv = 389 data->yuv =
366 SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h); 390 SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h);
367 if (!data->yuv) { 391 if (!data->yuv) {
368 return -1; 392 return -1;
369 } 393 }
370 data->format = display->current_mode.format; 394 data->format = display->current_mode.format;
371 } else { 395 } else {
372 /* The image/pixmap depth must be the same as the window or you 396 /* The image/pixmap depth must be the same as the window or you
373 get a BadMatch error when trying to putimage or copyarea. 397 get a BadMatch error when trying to putimage or copyarea.
398 This BadMatch error
374 */ 399 */
400 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
401 if(renderdata->xrender_available == SDL_False) {
402 if (texture->format != display->current_mode.format) {
403 SDL_SetError("Texture format doesn't match window format");
404 return -1;
405 }
406 }
407 #else
375 if (texture->format != display->current_mode.format) { 408 if (texture->format != display->current_mode.format) {
376 SDL_SetError("Texture format doesn't match window format"); 409 SDL_SetError("Texture format doesn't match window format");
377 return -1; 410 return -1;
378 } 411 }
412 #endif
379 data->format = texture->format; 413 data->format = texture->format;
380 } 414 }
381 data->pitch = texture->w * SDL_BYTESPERPIXEL(data->format); 415 data->pitch = texture->w * SDL_BYTESPERPIXEL(data->format);
382 data->pitch = (data->pitch + pitch_alignmask) & ~pitch_alignmask; 416 data->pitch = (data->pitch + pitch_alignmask) & ~pitch_alignmask;
383 417
453 if (data->pixmap == None) { 487 if (data->pixmap == None) {
454 X11_DestroyTexture(renderer, texture); 488 X11_DestroyTexture(renderer, texture);
455 SDL_SetError("XCreatePixmap() failed"); 489 SDL_SetError("XCreatePixmap() failed");
456 return -1; 490 return -1;
457 } 491 }
492
493 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
494 data->picture_fmt =
495 XRenderFindVisualFormat(renderdata->display,
496 data->picture =
497 XCreatePicture(renderdata->display, data->pixmap,
458 498
459 data->image = 499 data->image =
460 XCreateImage(renderdata->display, renderdata->visual, 500 XCreateImage(renderdata->display, renderdata->visual,
461 renderdata->depth, ZPixmap, 0, NULL, texture->w, 501 renderdata->depth, ZPixmap, 0, NULL, texture->w,
462 texture->h, SDL_BYTESPERPIXEL(data->format) * 8, 502 texture->h, SDL_BYTESPERPIXEL(data->format) * 8,