comparison src/video/x11/SDL_x11render.c @ 4577:87a2d87786d4

Modified configure.in to allow building with Xrender. Fixed all problems that prevented compilation. Builds fine now :)
author Sunny Sachanandani <sunnysachanandani@gmail.com>
date Mon, 31 May 2010 13:27:27 +0530
parents 2b98162b536a
children cb338fa6535c
comparison
equal deleted inserted replaced
4576:2b98162b536a 4577:87a2d87786d4
217 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 217 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
218 int event_basep, error_basep; 218 int event_basep, error_basep;
219 if(XRenderQueryExtension(data->display, &event_basep, &error_basep) == True) { 219 if(XRenderQueryExtension(data->display, &event_basep, &error_basep) == True) {
220 data->xrender_available = SDL_TRUE; 220 data->xrender_available = SDL_TRUE;
221 data->xwindow_pict_fmt = XRenderFindVisualFormat(data->display, data->visual); 221 data->xwindow_pict_fmt = XRenderFindVisualFormat(data->display, data->visual);
222 if(!xwindow_pict_fmt) { 222 if(!data->xwindow_pict_fmt) {
223 data->xrender_available = SDL_FALSE; 223 data->xrender_available = SDL_FALSE;
224 } 224 }
225 data->xwindow_pict_attr.graphics_exposures = False; 225 data->xwindow_pict_attr.graphics_exposures = False;
226 data->xwindow_pict_attr_valuemask = CPGraphicsExposure; 226 data->xwindow_pict_attr_valuemask = CPGraphicsExposure;
227 data->xwindow_pict = XRenderCreatePicture(data->display, data->xwindow, data->xwindow_pict_fmt, 227 data->xwindow_pict = XRenderCreatePicture(data->display, data->xwindow, data->xwindow_pict_fmt,
283 return NULL; 283 return NULL;
284 } 284 }
285 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 285 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
286 if(data->xrender_available == SDL_TRUE) { 286 if(data->xrender_available == SDL_TRUE) {
287 data->pixmap_picts[i] = 287 data->pixmap_picts[i] =
288 XCreatePicture(data->display, data->pixmap[i], data->xwindow_pict_fmt, 288 XRenderCreatePicture(data->display, data->pixmaps[i], data->xwindow_pict_fmt,
289 data->xwindow_pict_attr_valuemask, &xwindow_pict_attr); 289 data->xwindow_pict_attr_valuemask, &data->xwindow_pict_attr);
290 if(!data->pixmap_picts[i]) { 290 if(!data->pixmap_picts[i]) {
291 data->xrender_available = SDL_FALSE; 291 data->xrender_available = SDL_FALSE;
292 } 292 }
293 } 293 }
294 #endif 294 #endif
352 for (i = 0; i < n; ++i) { 352 for (i = 0; i < n; ++i) {
353 if (data->pixmaps[i] != None) { 353 if (data->pixmaps[i] != None) {
354 XFreePixmap(data->display, data->pixmaps[i]); 354 XFreePixmap(data->display, data->pixmaps[i]);
355 data->pixmaps[i] = None; 355 data->pixmaps[i] = None;
356 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 356 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
357 data->pictures[i] = None; 357 data->pixmap_picts[i] = None;
358 #endif 358 #endif
359 } 359 }
360 } 360 }
361 for (i = 0; i < n; ++i) { 361 for (i = 0; i < n; ++i) {
362 data->pixmaps[i] = 362 data->pixmaps[i] =
366 SDL_SetError("XCreatePixmap() failed"); 366 SDL_SetError("XCreatePixmap() failed");
367 return -1; 367 return -1;
368 } 368 }
369 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 369 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
370 if(data->xrender_available == SDL_TRUE) { 370 if(data->xrender_available == SDL_TRUE) {
371 data->pictures[i] = 371 data->pixmap_picts[i] =
372 XCreatePicture(data->display, data->pixmap[i], data->xwindow_pict_fmt, 372 XRenderCreatePicture(data->display, data->pixmaps[i], data->xwindow_pict_fmt,
373 data->xwindow_pict_attr_valuemask, &data->xwindow_pict_attr); 373 data->xwindow_pict_attr_valuemask, &data->xwindow_pict_attr);
374 if(!data->pictures[i]) { 374 if(!data->pixmap_picts[i]) {
375 data->xrender_available = SDL_FALSE; 375 data->xrender_available = SDL_FALSE;
376 } 376 }
377 } 377 }
378 #endif 378 #endif
379 } 379 }
380 if (n > 0) { 380 if (n > 0) {
381 data->drawable = data->pixmaps[0]; 381 data->drawable = data->pixmaps[0];
382 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 382 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
383 data->drawable_pict = data->pictures[0]; 383 data->drawable_pict = data->pixmap_picts[0];
384 #endif 384 #endif
385 } 385 }
386 data->current_pixmap = 0; 386 data->current_pixmap = 0;
387 387
388 return 0; 388 return 0;
417 can be no BadMatch error since Xrender takes care of that. 417 can be no BadMatch error since Xrender takes care of that.
418 */ 418 */
419 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 419 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
420 // Assume the texture is supported by Xrender 420 // Assume the texture is supported by Xrender
421 data->xrender_available = SDL_TRUE; 421 data->xrender_available = SDL_TRUE;
422 if(renderdata->xrender_available == SDL_False) { 422 if(renderdata->xrender_available == SDL_FALSE) {
423 if (texture->format != display->current_mode.format) { 423 if (texture->format != display->current_mode.format) {
424 SDL_SetError("Texture format doesn't match window format"); 424 SDL_SetError("Texture format doesn't match window format");
425 return -1; 425 return -1;
426 } 426 }
427 } 427 }
521 unsigned long x11_fmt_mask; // Format mask 521 unsigned long x11_fmt_mask; // Format mask
522 XRenderPictFormat x11_templ_fmt; // Format template 522 XRenderPictFormat x11_templ_fmt; // Format template
523 x11_fmt_mask = 523 x11_fmt_mask =
524 (PictFormatDepth | PictFormatRedMask | PictFormatGreenMask 524 (PictFormatDepth | PictFormatRedMask | PictFormatGreenMask
525 | PictFormatBlueMask); 525 | PictFormatBlueMask);
526 x11_templ_fmt.depth = (data->format).BitsPerPixel; 526 Uint32 Rmask, Gmask, Bmask, Amask;
527 x11_temp_fmt.direct.redMask = (data->format).Rmask; 527 int bpp;
528 x11_temp_fmt.direct.greenMask = (data->format).Gmask; 528 SDL_PixelFormatEnumToMasks(data->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask);
529 x11_temp_fmt.direct.blueMask = (data->format).Bmask; 529 x11_templ_fmt.depth = bpp;
530 x11_temp_fmt.direct.alphaMask = (data->format).Amask; 530 x11_templ_fmt.direct.redMask = Rmask;
531 x11_templ_fmt.direct.greenMask = Gmask;
532 x11_templ_fmt.direct.blueMask = Bmask;
533 x11_templ_fmt.direct.alphaMask = Amask;
531 /* Return one matching XRenderPictFormat */ 534 /* Return one matching XRenderPictFormat */
532 data->pict_fmt = 535 data->picture_fmt =
533 XRenderFindFormat(renderdata->display, x11_fmt_mask, &x11_templ_fmt, 1); 536 XRenderFindFormat(renderdata->display, x11_fmt_mask, &x11_templ_fmt, 1);
534 if(!data->pict_fmt) { 537 if(!data->picture_fmt) {
535 data->xrender_available = SDL_FALSE; 538 data->xrender_available = SDL_FALSE;
536 } 539 }
537 data->picture_attr_valuemask = CPGraphicsExposure; 540 data->picture_attr_valuemask = CPGraphicsExposure;
538 (data->picture_attr).graphics_exposures = False; 541 (data->picture_attr).graphics_exposures = False;
539 data->picture = 542 data->picture =
540 XCreatePicture(renderdata->display, data->pixmap, data->picture_fmt, 543 XRenderCreatePicture(renderdata->display, data->pixmap, data->picture_fmt,
541 data->picture_attr_valuemask, &(data->picture_attr)); 544 data->picture_attr_valuemask, &(data->picture_attr));
542 if(!data->picture) { 545 if(!data->picture) {
543 data->xrender_available = SDL_FALSE; 546 data->xrender_available = SDL_FALSE;
544 } 547 }
545 } 548 }
995 } 998 }
996 if (xcount > 0) { 999 if (xcount > 0) {
997 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 1000 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
998 if(data->xrender_available == SDL_TRUE) 1001 if(data->xrender_available == SDL_TRUE)
999 { 1002 {
1003 XRenderColor xrender_foreground_color;
1004 xrender_foreground_color.red = renderer->r;
1005 xrender_foreground_color.green = renderer->g;
1006 xrender_foreground_color.blue = renderer->b;
1007 xrender_foreground_color.alpha = renderer->a;
1000 XRenderFillRectangles(data->display, PictOpSrc, data->drawable_pict, 1008 XRenderFillRectangles(data->display, PictOpSrc, data->drawable_pict,
1001 (XRenderColor)foreground, xrects, xcount); 1009 &xrender_foreground_color, xrects, xcount);
1002 } 1010 }
1003 else 1011 else
1004 #endif 1012 #endif
1005 { 1013 {
1006 XFillRectangles(data->display, data->drawable, data->gc, 1014 XFillRectangles(data->display, data->drawable, data->gc,