comparison src/video/x11/SDL_x11render.c @ 4584:9907c8cc6015

X11_RenderFillRects and X11_RenderDrawRects use a server side mask pixmap of 1 bit depth now. All drawing on these pixmaps is done by server side functions such as XDrawRectangles and XFillRectangles.
author Sunny Sachanandani <sunnysachanandani@gmail.com>
date Mon, 14 Jun 2010 18:22:48 +0530
parents 5c925d4f220f
children 21600c6d6445
comparison
equal deleted inserted replaced
4583:5c925d4f220f 4584:9907c8cc6015
1 /* 1 /*
2
2 SDL - Simple DirectMedia Layer 3 SDL - Simple DirectMedia Layer
3 Copyright (C) 1997-2010 Sam Lantinga 4 Copyright (C) 1997-2010 Sam Lantinga
4 5
5 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public 7 modify it under the terms of the GNU Lesser General Public
94 int depth; 95 int depth;
95 int scanline_pad; 96 int scanline_pad;
96 Window xwindow; 97 Window xwindow;
97 Pixmap pixmaps[3]; 98 Pixmap pixmaps[3];
98 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 99 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
100 Pixmap mask;
99 Picture xwindow_pict; 101 Picture xwindow_pict;
100 Picture pixmap_picts[3]; 102 Picture pixmap_picts[3];
101 Picture drawable_pict; 103 Picture drawable_pict;
104 Picture mask_pict;
102 XRenderPictFormat* xwindow_pict_fmt; 105 XRenderPictFormat* xwindow_pict_fmt;
103 XRenderPictureAttributes xwindow_pict_attr; 106 GC mask_gc;
104 unsigned int xwindow_pict_attr_valuemask; 107 SDL_bool use_xrender;
105 SDL_bool xrender_available;
106 #endif 108 #endif
107 int current_pixmap; 109 int current_pixmap;
108 Drawable drawable; 110 Drawable drawable;
109 SDL_PixelFormat format; 111 SDL_PixelFormat format;
110 GC gc; 112 GC gc;
120 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 122 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
121 Picture picture; 123 Picture picture;
122 XRenderPictFormat* picture_fmt; 124 XRenderPictFormat* picture_fmt;
123 XRenderPictureAttributes picture_attr; 125 XRenderPictureAttributes picture_attr;
124 unsigned int picture_attr_valuemask; 126 unsigned int picture_attr_valuemask;
125 SDL_bool xrender_available; 127 SDL_bool use_xrender;
126 #endif 128 #endif
127 XImage *image; 129 XImage *image;
128 #ifndef NO_SHARED_MEMORY 130 #ifndef NO_SHARED_MEMORY
129 /* MIT shared memory extension information */ 131 /* MIT shared memory extension information */
130 XShmSegmentInfo shminfo; 132 XShmSegmentInfo shminfo;
215 data->scanline_pad = displaydata->scanline_pad; 217 data->scanline_pad = displaydata->scanline_pad;
216 data->xwindow = windowdata->xwindow; 218 data->xwindow = windowdata->xwindow;
217 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 219 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
218 int event_basep, error_basep; 220 int event_basep, error_basep;
219 if(XRenderQueryExtension(data->display, &event_basep, &error_basep) == True) { 221 if(XRenderQueryExtension(data->display, &event_basep, &error_basep) == True) {
220 data->xrender_available = SDL_TRUE; 222 data->use_xrender = SDL_TRUE;
221 data->xwindow_pict_fmt = XRenderFindVisualFormat(data->display, data->visual); 223 data->xwindow_pict_fmt = XRenderFindVisualFormat(data->display, data->visual);
222 if(!data->xwindow_pict_fmt) { 224 if(!data->xwindow_pict_fmt) {
223 data->xrender_available = SDL_FALSE; 225 data->use_xrender = SDL_FALSE;
226 goto fallback;
224 } 227 }
225 data->xwindow_pict = XRenderCreatePicture(data->display, data->xwindow, data->xwindow_pict_fmt, 228 data->xwindow_pict = XRenderCreatePicture(data->display, data->xwindow, data->xwindow_pict_fmt,
226 0, None); 229 0, NULL);
227 if(!data->xwindow_pict) { 230 if(!data->xwindow_pict) {
228 data->xrender_available = SDL_FALSE; 231 data->use_xrender = SDL_FALSE;
229 } 232 goto fallback;
233 }
234 // Create a 1 bit depth mask
235 data->mask = XCreatePixmap(data->display, data->xwindow, window->w, window->h, 1);
236 data->mask_pict = XRenderCreatePicture(data->display, data->mask,
237 XRenderFindStandardFormat(data->display, PictStandardA1),
238 0, NULL);
239 XGCValues gcv_mask;
240 gcv_mask.foreground = 1;
241 gcv_mask.background = 0;
242 data->mask_gc = XCreateGC(data->display, data->mask, GCBackground | GCForeground, &gcv_mask);
230 } 243 }
231 else { 244 else {
232 data->xrender_available = SDL_FALSE; 245 data->use_xrender = SDL_FALSE;
233 } 246 }
247 fallback:
234 #endif 248 #endif
235 renderer->DisplayModeChanged = X11_DisplayModeChanged; 249 renderer->DisplayModeChanged = X11_DisplayModeChanged;
236 renderer->CreateTexture = X11_CreateTexture; 250 renderer->CreateTexture = X11_CreateTexture;
237 renderer->QueryTexturePixels = X11_QueryTexturePixels; 251 renderer->QueryTexturePixels = X11_QueryTexturePixels;
238 renderer->SetTextureBlendMode = X11_SetTextureBlendMode; 252 renderer->SetTextureBlendMode = X11_SetTextureBlendMode;
279 X11_DestroyRenderer(renderer); 293 X11_DestroyRenderer(renderer);
280 SDL_SetError("XCreatePixmap() failed"); 294 SDL_SetError("XCreatePixmap() failed");
281 return NULL; 295 return NULL;
282 } 296 }
283 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 297 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
284 if(data->xrender_available == SDL_TRUE) { 298 if(data->use_xrender == SDL_TRUE) {
285 data->pixmap_picts[i] = 299 data->pixmap_picts[i] =
286 XRenderCreatePicture(data->display, data->pixmaps[i], data->xwindow_pict_fmt, 300 XRenderCreatePicture(data->display, data->pixmaps[i], data->xwindow_pict_fmt,
287 0, None); 301 0, None);
288 if(!data->pixmap_picts[i]) { 302 if(!data->pixmap_picts[i]) {
289 data->xrender_available = SDL_FALSE; 303 data->use_xrender = SDL_FALSE;
290 } 304 }
291 XRenderComposite(data->display, PictOpClear, data->pixmap_picts[i], None, data->pixmap_picts[i], 305 XRenderComposite(data->display, PictOpClear, data->pixmap_picts[i], None, data->pixmap_picts[i],
292 0, 0, 0, 0, 0, 0, window->w, window->h); 306 0, 0, 0, 0, 0, 0, window->w, window->h);
293 } 307 }
294 #endif 308 #endif
295 } 309 }
296 if (n > 0) { 310 if (n > 0) {
297 data->drawable = data->pixmaps[0]; 311 data->drawable = data->pixmaps[0];
298 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 312 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
299 if(data->xrender_available == SDL_TRUE) 313 if(data->use_xrender == SDL_TRUE)
300 data->drawable_pict = data->pixmap_picts[0]; 314 data->drawable_pict = data->pixmap_picts[0];
301 #endif 315 #endif
302 data->makedirty = SDL_TRUE; 316 data->makedirty = SDL_TRUE;
303 } else { 317 } else {
304 data->drawable = data->xwindow; 318 data->drawable = data->xwindow;
305 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 319 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
306 if(data->xrender_available == SDL_TRUE) 320 if(data->use_xrender == SDL_TRUE)
307 data->drawable_pict = data->xwindow_pict; 321 data->drawable_pict = data->xwindow_pict;
308 #endif 322 #endif
309 data->makedirty = SDL_FALSE; 323 data->makedirty = SDL_FALSE;
310 } 324 }
311 data->current_pixmap = 0; 325 data->current_pixmap = 0;
365 if (data->pixmaps[i] == None) { 379 if (data->pixmaps[i] == None) {
366 SDL_SetError("XCreatePixmap() failed"); 380 SDL_SetError("XCreatePixmap() failed");
367 return -1; 381 return -1;
368 } 382 }
369 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 383 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
370 if(data->xrender_available == SDL_TRUE) { 384 if(data->use_xrender == SDL_TRUE) {
371 data->pixmap_picts[i] = 385 data->pixmap_picts[i] =
372 XRenderCreatePicture(data->display, data->pixmaps[i], data->xwindow_pict_fmt, 386 XRenderCreatePicture(data->display, data->pixmaps[i], data->xwindow_pict_fmt,
373 0, None); 387 0, None);
374 if(!data->pixmap_picts[i]) { 388 if(!data->pixmap_picts[i]) {
375 data->xrender_available = SDL_FALSE; 389 data->use_xrender = SDL_FALSE;
376 } 390 }
377 XRenderComposite(data->display, PictOpClear, data->pixmap_picts[i], None, data->pixmap_picts[i], 391 XRenderComposite(data->display, PictOpClear, data->pixmap_picts[i], None, data->pixmap_picts[i],
378 0, 0, 0, 0, 0, 0, window->w, window->h); 392 0, 0, 0, 0, 0, 0, window->w, window->h);
379 } 393 }
380 #endif 394 #endif
418 Xrender is available at runtime. If it is available there 432 Xrender is available at runtime. If it is available there
419 can be no BadMatch error since Xrender takes care of that. 433 can be no BadMatch error since Xrender takes care of that.
420 */ 434 */
421 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 435 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
422 // Assume the texture is supported by Xrender 436 // Assume the texture is supported by Xrender
423 data->xrender_available = SDL_TRUE; 437 data->use_xrender = SDL_TRUE;
424 if(renderdata->xrender_available == SDL_FALSE) { 438 if(renderdata->use_xrender == SDL_FALSE) {
425 if (texture->format != display->current_mode.format) { 439 if (texture->format != display->current_mode.format) {
426 SDL_SetError("Texture format doesn't match window format"); 440 SDL_SetError("Texture format doesn't match window format");
427 return -1; 441 return -1;
428 } 442 }
429 } 443 }
542 SDL_SetError("XCreateImage() failed"); 556 SDL_SetError("XCreateImage() failed");
543 return -1; 557 return -1;
544 } 558 }
545 } 559 }
546 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 560 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
547 if(renderdata->xrender_available && data->pixmap) { 561 if(renderdata->use_xrender && data->pixmap) {
548 data->xrender_available = SDL_TRUE; 562 data->use_xrender = SDL_TRUE;
549 unsigned long x11_fmt_mask; // Format mask 563 unsigned long x11_fmt_mask; // Format mask
550 XRenderPictFormat x11_templ_fmt; // Format template 564 XRenderPictFormat x11_templ_fmt; // Format template
551 x11_fmt_mask = 565 x11_fmt_mask =
552 (PictFormatDepth | PictFormatRedMask | PictFormatGreenMask 566 (PictFormatDepth | PictFormatRedMask | PictFormatGreenMask
553 | PictFormatBlueMask); 567 | PictFormatBlueMask);
561 x11_templ_fmt.direct.alphaMask = Amask; 575 x11_templ_fmt.direct.alphaMask = Amask;
562 /* Return one matching XRenderPictFormat */ 576 /* Return one matching XRenderPictFormat */
563 data->picture_fmt = 577 data->picture_fmt =
564 XRenderFindFormat(renderdata->display, x11_fmt_mask, &x11_templ_fmt, 1); 578 XRenderFindFormat(renderdata->display, x11_fmt_mask, &x11_templ_fmt, 1);
565 if(!data->picture_fmt) { 579 if(!data->picture_fmt) {
566 data->xrender_available = SDL_FALSE; 580 data->use_xrender = SDL_FALSE;
567 } 581 }
568 data->picture_attr_valuemask = CPGraphicsExposure; 582 data->picture_attr_valuemask = CPGraphicsExposure;
569 (data->picture_attr).graphics_exposures = False; 583 (data->picture_attr).graphics_exposures = False;
570 data->picture = 584 data->picture =
571 XRenderCreatePicture(renderdata->display, data->pixmap, data->picture_fmt, 585 XRenderCreatePicture(renderdata->display, data->pixmap, data->picture_fmt,
572 data->picture_attr_valuemask, &(data->picture_attr)); 586 data->picture_attr_valuemask, &(data->picture_attr));
573 if(!data->picture) { 587 if(!data->picture) {
574 data->xrender_available = SDL_FALSE; 588 data->use_xrender = SDL_FALSE;
575 } 589 }
576 } 590 }
577 /* We thought we could render the texture with Xrender but this was 591 /* We thought we could render the texture with Xrender but this was
578 not possible for some reason. Now we must ensure that texture 592 not possible for some reason. Now we must ensure that texture
579 format and window format match to avoid a BadMatch error. 593 format and window format match to avoid a BadMatch error.
580 */ 594 */
581 if(data->xrender_available == SDL_FALSE) { 595 if(data->use_xrender == SDL_FALSE) {
582 if (texture->format != display->current_mode.format) { 596 if (texture->format != display->current_mode.format) {
583 SDL_SetError("Texture format doesn't match window format"); 597 SDL_SetError("Texture format doesn't match window format");
584 return -1; 598 return -1;
585 } 599 }
586 } 600 }
972 X11_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count) 986 X11_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count)
973 { 987 {
974 X11_RenderData *data = (X11_RenderData *) renderer->driverdata; 988 X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
975 SDL_Window *window = renderer->window; 989 SDL_Window *window = renderer->window;
976 SDL_Rect clip, rect; 990 SDL_Rect clip, rect;
977 unsigned long foreground; 991 int i, xcount;
978 XRectangle *xrects, *xrect; 992 XRectangle *xrects, *xrect;
979 int i, xcount; 993
980
981 clip.x = 0; 994 clip.x = 0;
982 clip.y = 0; 995 clip.y = 0;
983 clip.w = window->w; 996 clip.w = window->w;
984 clip.h = window->h; 997 clip.h = window->h;
985 998
986 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 999 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
987 if(data->xrender_available == SDL_TRUE) { 1000 if(data->use_xrender == SDL_TRUE) {
988 XRenderColor xrender_foreground; 1001 XRectangle xclip;
989 xrender_foreground = xrenderdrawcolor(renderer);
990 1002
991 xrects = SDL_stack_alloc(XRectangle, 4*count); 1003 xclip.x = (short)clip.x;
1004 xclip.y = (short)clip.y;
1005 xclip.width = (unsigned short)clip.w;
1006 xclip.height = (unsigned short)clip.h;
1007
1008 XRenderColor foreground;
1009 foreground = xrenderdrawcolor(renderer);
1010
1011 xrect = xrects = SDL_stack_alloc(XRectangle, count);
992 xcount = 0; 1012 xcount = 0;
993 for(i = 0; i < 4*count; i+=4) { 1013 for (i = 0; i < count; ++i) {
994 if(!SDL_IntersectRect(rects[i], &clip, &rect)) { 1014 xrect->x = (short)rects[i]->x;
995 continue; 1015 xrect->y = (short)rects[i]->y;
996 } 1016 xrect->width = (unsigned short)rects[i]->w;
997 1017 xrect->height = (unsigned short)rects[i]->h;
998 xrects[xcount].x = rect.x; 1018 ++xrect;
999 xrects[xcount].y = rect.y;
1000 xrects[xcount].width = 1;
1001 xrects[xcount].height = rect.h;
1002 ++xcount; 1019 ++xcount;
1003 xrects[xcount].x = rect.x; 1020 }
1004 xrects[xcount].y = rect.y+rect.h; 1021 if (data->makedirty) {
1005 xrects[xcount].width = rect.w; 1022 SDL_AddDirtyRect(&data->dirty, &clip);
1006 xrects[xcount].height = 1; 1023 }
1007 ++xcount; 1024 XRenderComposite(data->display, PictOpClear, data->mask_pict, None, data->mask_pict,
1008 xrects[xcount].x = rect.x+rect.w; 1025 0, 0, 0, 0, 0, 0, window->w, window->h);
1009 xrects[xcount].y = rect.y; 1026 XDrawRectangles(data->display, data->mask, data->mask_gc, xrects, xcount);
1010 xrects[xcount].width = 1; 1027 Picture fill =
1011 xrects[xcount].height = rect.h; 1028 XRenderCreateSolidFill(data->display, &foreground);
1012 ++xcount; 1029 XRenderSetPictureClipRectangles(data->display, data->drawable_pict, 0, 0, &xclip, 1);
1013 xrects[xcount].x = rect.x; 1030 XRenderComposite(data->display, PictOpOver, fill, data->mask_pict, data->drawable_pict,
1014 xrects[xcount].y = rect.y; 1031 0, 0, 0, 0, 0, 0, window->w, window->h);
1015 xrects[xcount].width = rect.w; 1032 XRenderFreePicture(data->display, fill);
1016 xrects[xcount].height = 1; 1033 SDL_stack_free(xrects);
1017 ++xcount;
1018 if(data->makedirty) {
1019 SDL_AddDirtyRect(&data->dirty, &rect);
1020 }
1021 }
1022 XRenderFillRectangles(data->display, PictOpOver, data->drawable_pict,
1023 &xrender_foreground, xrects, xcount);
1024 } 1034 }
1025 else 1035 else
1026 #endif 1036 #endif
1027 { 1037 {
1038
1039 unsigned long foreground;
1040
1028 foreground = renderdrawcolor(renderer, 1); 1041 foreground = renderdrawcolor(renderer, 1);
1029 XSetForeground(data->display, data->gc, foreground); 1042 XSetForeground(data->display, data->gc, foreground);
1030 1043
1031 xrect = xrects = SDL_stack_alloc(XRectangle, count); 1044 xrect = xrects = SDL_stack_alloc(XRectangle, count);
1032 xcount = 0; 1045 xcount = 0;
1060 X11_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count) 1073 X11_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count)
1061 { 1074 {
1062 X11_RenderData *data = (X11_RenderData *) renderer->driverdata; 1075 X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
1063 SDL_Window *window = renderer->window; 1076 SDL_Window *window = renderer->window;
1064 SDL_Rect clip, rect; 1077 SDL_Rect clip, rect;
1065 unsigned long foreground; 1078
1066 XRectangle *xrects, *xrect;
1067 int i, xcount;
1068
1069 clip.x = 0; 1079 clip.x = 0;
1070 clip.y = 0; 1080 clip.y = 0;
1071 clip.w = window->w; 1081 clip.w = window->w;
1072 clip.h = window->h; 1082 clip.h = window->h;
1073 1083
1074 foreground = renderdrawcolor(renderer, 1); 1084 int i, xcount;
1075 XSetForeground(data->display, data->gc, foreground); 1085 XRectangle *xrects, *xrect;
1076 1086
1077 xrect = xrects = SDL_stack_alloc(XRectangle, count); 1087 xrect = xrects = SDL_stack_alloc(XRectangle, count);
1078 xcount = 0; 1088 xcount = 0;
1079 for (i = 0; i < count; ++i) { 1089
1080 if (!SDL_IntersectRect(rects[i], &clip, &rect)) { 1090 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
1081 continue; 1091 if(data->use_xrender == SDL_TRUE) {
1082 } 1092 XRectangle xclip;
1083 1093
1084 xrect->x = (short)rect.x; 1094 xclip.x = (short)clip.x;
1085 xrect->y = (short)rect.y; 1095 xclip.y = (short)clip.y;
1086 xrect->width = (unsigned short)rect.w; 1096 xclip.width = (unsigned short)clip.w;
1087 xrect->height = (unsigned short)rect.h; 1097 xclip.height = (unsigned short)clip.h;
1088 ++xrect; 1098
1089 ++xcount; 1099 XRenderColor foreground;
1090 1100
1101 foreground = xrenderdrawcolor(renderer);
1102
1103 for (i = 0; i < count; ++i) {
1104 xrect->x = (short)rects[i]->x;
1105 xrect->y = (short)rects[i]->y;
1106 xrect->width = (unsigned short)rects[i]->w;
1107 xrect->height = (unsigned short)rects[i]->h;
1108 ++xrect;
1109 ++xcount;
1110 }
1091 if (data->makedirty) { 1111 if (data->makedirty) {
1092 SDL_AddDirtyRect(&data->dirty, &rect); 1112 SDL_AddDirtyRect(&data->dirty, &clip);
1093 } 1113 }
1094 } 1114 XRenderComposite(data->display, PictOpClear, data->mask_pict, None, data->mask_pict,
1095 if (xcount > 0) { 1115 0, 0, 0, 0, 0, 0, window->w, window->h);
1096 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 1116 XFillRectangles(data->display, data->mask, data->mask_gc,
1097 if(data->xrender_available == SDL_TRUE) 1117 xrects, xcount);
1098 { 1118 XRenderSetPictureClipRectangles(data->display, data->drawable_pict, 0, 0, &xclip, 1);
1099 XRenderColor xrender_foreground_color; 1119 Picture fill =
1100 xrender_foreground_color = xrenderdrawcolor(renderer); 1120 XRenderCreateSolidFill(data->display, &foreground);
1101 XRenderFillRectangles(data->display, PictOpOver, data->drawable_pict, 1121 XRenderComposite(data->display, PictOpOver, fill, data->mask_pict, data->drawable_pict,
1102 &xrender_foreground_color, xrects, xcount); 1122 0, 0, 0, 0, 0, 0, window->w, window->h);
1103 } 1123 XRenderFreePicture(data->display, fill);
1104 else 1124 SDL_stack_free(xrects);
1105 #endif 1125
1106 { 1126 }
1127 else
1128 #endif
1129 {
1130 unsigned long foreground;
1131 XRectangle *xrects, *xrect;
1132
1133 foreground = renderdrawcolor(renderer, 1);
1134 XSetForeground(data->display, data->gc, foreground);
1135
1136 xrect = xrects = SDL_stack_alloc(XRectangle, count);
1137 xcount = 0;
1138 for (i = 0; i < count; ++i) {
1139 if (!SDL_IntersectRect(rects[i], &clip, &rect)) {
1140 continue;
1141 }
1142
1143 xrect->x = (short)rect.x;
1144 xrect->y = (short)rect.y;
1145 xrect->width = (unsigned short)rect.w;
1146 xrect->height = (unsigned short)rect.h;
1147 ++xrect;
1148 ++xcount;
1149
1150 if (data->makedirty) {
1151 SDL_AddDirtyRect(&data->dirty, &rect);
1152 }
1153 }
1107 XFillRectangles(data->display, data->drawable, data->gc, 1154 XFillRectangles(data->display, data->drawable, data->gc,
1108 xrects, xcount); 1155 xrects, xcount);
1109 } 1156 SDL_stack_free(xrects);
1110 } 1157 }
1111 SDL_stack_free(xpoints); 1158
1112
1113 return 0; 1159 return 0;
1114 } 1160 }
1115 1161
1116 static int 1162 static int
1117 X11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, 1163 X11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
1297 /* Send the data to the display */ 1343 /* Send the data to the display */
1298 if (!(renderer->info.flags & SDL_RENDERER_SINGLEBUFFER)) { 1344 if (!(renderer->info.flags & SDL_RENDERER_SINGLEBUFFER)) {
1299 for (dirty = data->dirty.list; dirty; dirty = dirty->next) { 1345 for (dirty = data->dirty.list; dirty; dirty = dirty->next) {
1300 const SDL_Rect *rect = &dirty->rect; 1346 const SDL_Rect *rect = &dirty->rect;
1301 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 1347 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
1302 if(data->xrender_available == SDL_TRUE) 1348 if(data->use_xrender == SDL_TRUE)
1303 { 1349 {
1304 XRenderComposite(data->display, PictOpOver, data->drawable_pict, None, data->xwindow_pict, 1350 XRenderComposite(data->display, PictOpOver, data->drawable_pict, None, data->xwindow_pict,
1305 rect->x, rect->y, 0, 0, rect->x, rect->y, rect->w+1, rect->h+1); 1351 rect->x, rect->y, 0, 0, rect->x, rect->y, rect->w, rect->h);
1306 } 1352 }
1307 else 1353 else
1308 #endif 1354 #endif
1309 { 1355 {
1310 XCopyArea(data->display, data->drawable, data->xwindow, 1356 XCopyArea(data->display, data->drawable, data->xwindow,
1311 data->gc, rect->x, rect->y, rect->w, rect->h, 1357 data->gc, rect->x, rect->y, rect->w, rect->h,
1312 rect->x, rect->y); 1358 rect->x, rect->y);
1313 } 1359 }
1314 } 1360 }
1315 SDL_ClearDirtyRects(&data->dirty); 1361 SDL_ClearDirtyRects(&data->dirty);
1316 /*#ifdef SDL_VIDEO_DRIVER_X11_XRENDER 1362 }
1317 // Clear each pixmap after a render
1318 if(data->xrender_available == SDL_TRUE) {
1319 XRenderComposite(data->display, PictOpClear, data->drawable_pict, None, data->drawable_pict,
1320 0, 0, 0, 0, 0, 0, renderer->window->w, renderer->window->h);
1321 }
1322 #endif*/
1323 }
1324 XSync(data->display, False); 1363 XSync(data->display, False);
1325 1364
1326 /* Update the flipping chain, if any */ 1365 /* Update the flipping chain, if any */
1327 if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) { 1366 if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) {
1328 data->current_pixmap = (data->current_pixmap + 1) % 2; 1367 data->current_pixmap = (data->current_pixmap + 1) % 2;
1387 if (data) { 1426 if (data) {
1388 for (i = 0; i < SDL_arraysize(data->pixmaps); ++i) { 1427 for (i = 0; i < SDL_arraysize(data->pixmaps); ++i) {
1389 if (data->pixmaps[i] != None) { 1428 if (data->pixmaps[i] != None) {
1390 XFreePixmap(data->display, data->pixmaps[i]); 1429 XFreePixmap(data->display, data->pixmaps[i]);
1391 } 1430 }
1431 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
1432 if (data->pixmap_picts[i] != None) {
1433 XRenderFreePicture(data->display, data->pixmap_picts[i]);
1434 }
1435 #endif
1392 } 1436 }
1393 if (data->gc) { 1437 if (data->gc) {
1394 XFreeGC(data->display, data->gc); 1438 XFreeGC(data->display, data->gc);
1395 } 1439 }
1440 if (data->drawable) {
1441 XFreePixmap(data->display, data->drawable);
1442 }
1443 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
1444 if (data->mask_gc) {
1445 XFreeGC(data->display, data->gc);
1446 }
1447 if (data->mask_pict) {
1448 XRenderFreePicture(data->display, data->mask_pict);
1449 }
1450 if (data->mask) {
1451 XFreePixmap(data->display, data->mask);
1452 }
1453 if (data->drawable_pict) {
1454 XRenderFreePicture(data->display, data->drawable_pict);
1455 }
1456 if (data->xwindow_pict) {
1457 XRenderFreePicture(data->display, data->xwindow_pict);
1458 }
1459 #endif
1396 SDL_FreeDirtyRects(&data->dirty); 1460 SDL_FreeDirtyRects(&data->dirty);
1397 SDL_free(data); 1461 SDL_free(data);
1398 } 1462 }
1399 SDL_free(renderer); 1463 SDL_free(renderer);
1400 } 1464 }