comparison src/video/x11/SDL_x11render.c @ 4603:dffa432f0e2b

Massive speed-up. Fixed the format that is set for the renderer. Included runtime checks for XDamage.
author Sunny Sachanandani <sunnysachanandani@gmail.com>
date Mon, 19 Jul 2010 18:57:02 +0530
parents 4fbf64d504cf
children d7535d7a40ea
comparison
equal deleted inserted replaced
4602:4fbf64d504cf 4603:dffa432f0e2b
31 #include "../SDL_pixels_c.h" 31 #include "../SDL_pixels_c.h"
32 #include "../SDL_yuv_sw_c.h" 32 #include "../SDL_yuv_sw_c.h"
33 33
34 #include <X11/extensions/Xdamage.h> 34 #include <X11/extensions/Xdamage.h>
35 #include <X11/extensions/Xfixes.h> 35 #include <X11/extensions/Xfixes.h>
36
37 #define SDL_VIDEO_DRIVER_X11_XDAMAGE
36 38
37 /* X11 renderer implementation */ 39 /* X11 renderer implementation */
38 40
39 static SDL_Renderer *X11_CreateRenderer(SDL_Window * window, Uint32 flags); 41 static SDL_Renderer *X11_CreateRenderer(SDL_Window * window, Uint32 flags);
40 static int X11_DisplayModeChanged(SDL_Renderer * renderer); 42 static int X11_DisplayModeChanged(SDL_Renderer * renderer);
106 Picture xwindow_pict; 108 Picture xwindow_pict;
107 Picture pixmap_picts[3]; 109 Picture pixmap_picts[3];
108 Picture drawable_pict; 110 Picture drawable_pict;
109 Picture stencil_pict; 111 Picture stencil_pict;
110 int blend_op; 112 int blend_op;
111 XRenderPictFormat* xwindow_pict_fmt; 113 XRenderPictFormat *xwindow_pict_fmt;
114 XRenderPictFormat *drawable_pict_fmt;
112 GC stencil_gc; 115 GC stencil_gc;
113 SDL_bool use_xrender; 116 SDL_bool use_xrender;
117 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
118 SDL_bool use_xdamage;
114 Damage stencil_damage; 119 Damage stencil_damage;
115 XserverRegion stencil_parts; 120 XserverRegion stencil_parts;
121 #endif
116 #endif 122 #endif
117 int current_pixmap; 123 int current_pixmap;
118 Drawable drawable; 124 Drawable drawable;
119 SDL_PixelFormat format; 125 SDL_PixelFormat format;
120 GC gc; 126 GC gc;
253 259
254 renderer->info.flags = SDL_RENDERER_ACCELERATED; 260 renderer->info.flags = SDL_RENDERER_ACCELERATED;
255 261
256 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 262 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
257 data->use_xrender = SDL_FALSE; 263 data->use_xrender = SDL_FALSE;
264 data->use_xdamage = SDL_FALSE;
265 int event_basep, error_basep;
258 if (SDL_X11_HAVE_XRENDER) { 266 if (SDL_X11_HAVE_XRENDER) {
259 // Query the extension. This is the server runtime check. 267 /* Query the extension. This is the server runtime check. */
260 int event_basep, error_basep;
261 if(XRenderQueryExtension(data->display, 268 if(XRenderQueryExtension(data->display,
262 &event_basep, &error_basep) == True) 269 &event_basep, &error_basep) == True)
263 data->use_xrender = SDL_TRUE; 270 data->use_xrender = SDL_TRUE;
264 } 271 }
272 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
265 if (data->use_xrender) { 273 if (data->use_xrender) {
266 // Find the PictFormat from the visual. 274 /* Query XDamage and XFixes */
267 // Should be an RGB PictFormat most of the time. 275 if(XDamageQueryExtension(data->display,
276 &event_basep,
277 &error_basep) == True &&
278 (XFixesQueryExtension(data->display,
279 &event_basep,
280 &error_basep) == True)) {
281 int major_version, minor_version;
282 XFixesQueryVersion(data->display,
283 &major_version,
284 &minor_version);
285 /* Only XFixes v 2 or greater
286 * Required for XFixesSetPictureClipRegion() */
287 if(major_version >= 2)
288 data->use_xdamage = SDL_TRUE;
289 }
290 #endif
291 /* Find the PictFormat from the visual.
292 * Should be an RGB PictFormat most of the time. */
268 data->xwindow_pict_fmt = XRenderFindVisualFormat(data->display, 293 data->xwindow_pict_fmt = XRenderFindVisualFormat(data->display,
269 data->visual); 294 data->visual);
270 if (!data->xwindow_pict_fmt) { 295 if (!data->xwindow_pict_fmt) {
271 SDL_SetError("XRenderFindVisualFormat() failed"); 296 SDL_SetError("XRenderFindVisualFormat() failed");
272 return NULL; 297 return NULL;
287 data->xwindow_pict, 312 data->xwindow_pict,
288 0, 0, 313 0, 0,
289 0, 0, 314 0, 0,
290 0, 0, 315 0, 0,
291 window->w, window->h); 316 window->w, window->h);
292 // Add some blending modes to the list of supported blending modes 317 /* Add some blending modes to the list of supported blending modes */
293 renderer->info.blend_modes |= 318 renderer->info.blend_modes |=
294 (SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MASK); 319 (SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MASK);
295 // Create a clip mask that is used for rendering primitives. 320 /* Create a clip mask that is used for rendering primitives. */
296 data->stencil = XCreatePixmap(data->display, data->xwindow, 321 data->stencil = XCreatePixmap(data->display, data->xwindow,
297 window->w, window->h, 8); 322 window->w, window->h, 8);
298 323
299 // Create the GC for the clip mask. 324 /* Create the GC for the clip mask. */
300 data->stencil_gc = XCreateGC(data->display, data->stencil, 325 data->stencil_gc = XCreateGC(data->display, data->stencil,
301 GCGraphicsExposures, &gcv); 326 GCGraphicsExposures, &gcv);
302 XSetBackground(data->display, data->stencil_gc, 0x00); 327 XSetBackground(data->display, data->stencil_gc, 0x00);
303 XSetForeground(data->display, data->stencil_gc, 0x00); 328 XSetForeground(data->display, data->stencil_gc, 0x00);
304 XFillRectangle(data->display, data->stencil, data->stencil_gc, 329 XFillRectangle(data->display, data->stencil, data->stencil_gc,
307 data->stencil_pict = 332 data->stencil_pict =
308 XRenderCreatePicture(data->display, data->stencil, 333 XRenderCreatePicture(data->display, data->stencil,
309 XRenderFindStandardFormat(data->display, 334 XRenderFindStandardFormat(data->display,
310 PictStandardA8), 335 PictStandardA8),
311 0, NULL); 336 0, NULL);
312 data->stencil_damage = 337 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
313 XDamageCreate(data->display, data->stencil, XDamageReportNonEmpty); 338 if (data->use_xdamage) {
314 XDamageSubtract(data->display, data->stencil_damage, None, data->stencil_parts); 339 data->stencil_damage =
340 XDamageCreate(data->display, data->stencil, XDamageReportNonEmpty);
341 XDamageSubtract(data->display, data->stencil_damage, None, data->stencil_parts);
342 }
343 #endif
315 data->brush = 344 data->brush =
316 XCreatePixmap(data->display, data->xwindow, 1, 1, 32); 345 XCreatePixmap(data->display, data->xwindow, 1, 1, 32);
317 XRenderPictureAttributes brush_attr; 346 XRenderPictureAttributes brush_attr;
318 brush_attr.repeat = RepeatNormal; 347 brush_attr.repeat = RepeatNormal;
319 data->brush_pict = 348 data->brush_pict =
339 n = 3; 368 n = 3;
340 } else { 369 } else {
341 renderer->info.flags |= SDL_RENDERER_PRESENTCOPY; 370 renderer->info.flags |= SDL_RENDERER_PRESENTCOPY;
342 n = 1; 371 n = 1;
343 } 372 }
373 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
374 if (data->use_xrender) {
375 if (n > 0)
376 data->drawable_pict_fmt =
377 XRenderFindStandardFormat(data->display, PictStandardARGB32);
378 else
379 data->drawable_pict_fmt = data->xwindow_pict_fmt;
380 }
381 #endif
344 for (i = 0; i < n; ++i) { 382 for (i = 0; i < n; ++i) {
345 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 383 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
346 if (data->use_xrender) { 384 if (data->use_xrender) {
347 data->pixmaps[i] = XCreatePixmap(data->display, 385 data->pixmaps[i] = XCreatePixmap(data->display,
348 data->xwindow, 386 data->xwindow,
362 SDL_SetError("XCreatePixmap() failed"); 400 SDL_SetError("XCreatePixmap() failed");
363 return NULL; 401 return NULL;
364 } 402 }
365 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 403 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
366 if (data->use_xrender) { 404 if (data->use_xrender) {
367 // Create xrender pictures for each of the pixmaps 405 /* Create xrender pictures for each of the pixmaps
368 // and clear the pixmaps. 406 * and clear the pixmaps. */
369 data->pixmap_picts[i] = 407 data->pixmap_picts[i] =
370 XRenderCreatePicture(data->display, 408 XRenderCreatePicture(data->display,
371 data->pixmaps[i], 409 data->pixmaps[i],
372 XRenderFindStandardFormat(data->display, 410 XRenderFindStandardFormat(data->display,
373 PictStandardARGB32), 411 PictStandardARGB32),
404 #endif 442 #endif
405 data->makedirty = SDL_FALSE; 443 data->makedirty = SDL_FALSE;
406 } 444 }
407 data->current_pixmap = 0; 445 data->current_pixmap = 0;
408 446
409 /* Get the format of the window */ 447 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
410 if (!SDL_PixelFormatEnumToMasks 448 if (data->use_xrender) {
411 (display->current_mode.format, &bpp, &Rmask, &Gmask, &Bmask, 449 bpp = data->drawable_pict_fmt->depth;
412 &Amask)) { 450 Rmask = ((data->drawable_pict_fmt->direct.redMask)
413 SDL_SetError("Unknown display format"); 451 << (data->drawable_pict_fmt->direct.red));
414 X11_DestroyRenderer(renderer); 452 Gmask = ((data->drawable_pict_fmt->direct.greenMask)
415 return NULL; 453 << (data->drawable_pict_fmt->direct.green));
454 Bmask = ((data->drawable_pict_fmt->direct.blueMask)
455 << (data->drawable_pict_fmt->direct.blue));
456 Amask = ((data->drawable_pict_fmt->direct.alphaMask)
457 << (data->drawable_pict_fmt->direct.alpha));
458 }
459 else
460 #endif
461 {
462 /* Get the format of the window */
463 if (!SDL_PixelFormatEnumToMasks
464 (display->current_mode.format, &bpp, &Rmask, &Gmask, &Bmask,
465 &Amask)) {
466 SDL_SetError("Unknown display format");
467 X11_DestroyRenderer(renderer);
468 return NULL;
469 }
416 } 470 }
417 SDL_InitFormat(&data->format, bpp, Rmask, Gmask, Bmask, Amask); 471 SDL_InitFormat(&data->format, bpp, Rmask, Gmask, Bmask, Amask);
418 472
419 /* Create the drawing context */ 473 /* Create the drawing context */
420 gcv.graphics_exposures = False; 474 gcv.graphics_exposures = False;
1009 { 1063 {
1010 X11_RenderData *data = (X11_RenderData *) renderer->driverdata; 1064 X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
1011 SDL_Window *window = renderer->window; 1065 SDL_Window *window = renderer->window;
1012 XPoint *xpoints, *xpoint; 1066 XPoint *xpoints, *xpoint;
1013 int i, xcount; 1067 int i, xcount;
1014 SDL_Rect clip, rect; 1068 SDL_Rect clip;
1015 /*Damage damage;
1016 XserverRegion parts;*/
1017 1069
1018 clip.x = 0; 1070 clip.x = 0;
1019 clip.y = 0; 1071 clip.y = 0;
1020 clip.w = window->w; 1072 clip.w = window->w;
1021 clip.h = window->h; 1073 clip.h = window->h;
1022 if (data->makedirty) { 1074 if (data->makedirty) {
1075 SDL_Rect rect;
1023 1076
1024 /* Get the smallest rectangle that contains everything */ 1077 /* Get the smallest rectangle that contains everything */
1025 rect.x = 0; 1078 rect.x = 0;
1026 rect.y = 0; 1079 rect.y = 0;
1027 rect.w = window->w; 1080 rect.w = window->w;
1046 ++xpoint; 1099 ++xpoint;
1047 ++xcount; 1100 ++xcount;
1048 } 1101 }
1049 1102
1050 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 1103 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
1051 if (data->use_xrender) { 1104 if (data->use_xrender &&
1105 (renderer->blendMode != SDL_BLENDMODE_NONE) &&
1106 !(renderer->a == 0xFF &&
1107 renderer->blendMode != SDL_BLENDMODE_ADD &&
1108 renderer->blendMode != SDL_BLENDMODE_MOD))
1109 {
1052 XSetForeground(data->display, data->stencil_gc, 0x00); 1110 XSetForeground(data->display, data->stencil_gc, 0x00);
1053 XFixesSetGCClipRegion(data->display, data->stencil_gc, 0, 0, data->stencil_parts); 1111 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
1112 if (data->use_xdamage)
1113 {
1114 /* Update only those parts which were changed
1115 * in the previous drawing operation */
1116 XFixesSetGCClipRegion(data->display, data->stencil_gc,
1117 0, 0, data->stencil_parts);
1118 }
1119 #endif
1054 XFillRectangle(data->display, data->stencil, data->stencil_gc, 1120 XFillRectangle(data->display, data->stencil, data->stencil_gc,
1055 rect.x, rect.y, rect.w, rect.h); 1121 0, 0, window->w, window->h);
1056 XFixesSetGCClipRegion(data->display, data->stencil_gc, 0, 0, None); 1122 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
1123 if (data->use_xdamage)
1124 {
1125 XFixesSetGCClipRegion(data->display, data->stencil_gc, 0, 0, None);
1126 }
1127 #endif
1057 XSetForeground(data->display, data->stencil_gc, 0xFF); 1128 XSetForeground(data->display, data->stencil_gc, 0xFF);
1058 /*damage = 1129
1059 XDamageCreate(data->display, data->stencil, XDamageReportRawRectangles);*/
1060 XDrawPoints(data->display, data->stencil, data->stencil_gc, xpoints, xcount, 1130 XDrawPoints(data->display, data->stencil, data->stencil_gc, xpoints, xcount,
1061 CoordModeOrigin); 1131 CoordModeOrigin);
1062 XDamageSubtract(data->display, data->stencil_damage, None, data->stencil_parts); 1132 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
1063 } 1133 if (data->use_xdamage)
1064 #endif 1134 {
1065 } 1135 /* Store the damaged region in stencil_parts */
1066 1136 XDamageSubtract(data->display, data->stencil_damage, None, data->stencil_parts);
1067 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 1137 }
1068 if (data->use_xrender) { 1138 #endif
1139 }
1140 #endif
1141 }
1142
1143 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
1144 if (data->use_xrender &&
1145 (renderer->blendMode != SDL_BLENDMODE_NONE) &&
1146 !(renderer->a == 0xFF &&
1147 renderer->blendMode != SDL_BLENDMODE_ADD &&
1148 renderer->blendMode != SDL_BLENDMODE_MOD))
1149 {
1069 XRenderColor foreground; 1150 XRenderColor foreground;
1070 foreground = xrenderdrawcolor(renderer); 1151 foreground = xrenderdrawcolor(renderer);
1152
1071 XRenderFillRectangle(data->display, PictOpSrc, data->brush_pict, 1153 XRenderFillRectangle(data->display, PictOpSrc, data->brush_pict,
1072 &foreground, 0, 0, 1, 1); 1154 &foreground, 0, 0, 1, 1);
1073 XFixesSetPictureClipRegion(data->display, data->drawable_pict, 0, 0, data->stencil_parts); 1155 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
1156 if (data->use_xdamage)
1157 {
1158 /* Update only those parts which drawn
1159 * to in the current drawing operation */
1160 XFixesSetPictureClipRegion(data->display, data->drawable_pict,
1161 0, 0, data->stencil_parts);
1162 }
1163 #endif
1074 XRenderComposite(data->display, data->blend_op, data->brush_pict, 1164 XRenderComposite(data->display, data->blend_op, data->brush_pict,
1075 data->stencil_pict, data->drawable_pict, 1165 data->stencil_pict, data->drawable_pict,
1076 rect.x, rect.y, rect.x, rect.y, rect.x, rect.y, rect.w, rect.h); 1166 0, 0, 0, 0, 0, 0, window->w, window->h);
1077 XFixesSetPictureClipRegion(data->display, data->drawable_pict, 0, 0, None); 1167 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
1078 //XDamageDestroy(data->display, damage); 1168 if (data->use_xdamage)
1169 {
1170 XFixesSetPictureClipRegion(data->display, data->drawable_pict, 0, 0, None);
1171 }
1172 #endif
1079 } 1173 }
1080 else 1174 else
1081 #endif 1175 #endif
1082 { 1176 {
1083 unsigned long foreground = renderdrawcolor(renderer, 1); 1177 unsigned long foreground = renderdrawcolor(renderer, 1);
1105 unsigned long foreground; 1199 unsigned long foreground;
1106 XPoint *xpoints, *xpoint; 1200 XPoint *xpoints, *xpoint;
1107 int i, xcount; 1201 int i, xcount;
1108 int minx, miny; 1202 int minx, miny;
1109 int maxx, maxy; 1203 int maxx, maxy;
1110 XserverRegion parts;
1111 Damage damage;
1112 1204
1113 clip.x = 0; 1205 clip.x = 0;
1114 clip.y = 0; 1206 clip.y = 0;
1115 clip.w = window->w; 1207 clip.w = window->w;
1116 clip.h = window->h; 1208 clip.h = window->h;
1117 { 1209 {
1118 Pixmap drawable; 1210 Pixmap drawable;
1119 GC gc; 1211 GC gc;
1120 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 1212 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
1121 if (data->use_xrender) { 1213 if (data->use_xrender &&
1214 (renderer->blendMode != SDL_BLENDMODE_NONE) &&
1215 !(renderer->a == 0xFF &&
1216 renderer->blendMode != SDL_BLENDMODE_ADD &&
1217 renderer->blendMode != SDL_BLENDMODE_MOD))
1218 {
1122 drawable = data->stencil; 1219 drawable = data->stencil;
1123 gc = data->stencil_gc; 1220 gc = data->stencil_gc;
1221
1124 XSetForeground(data->display, data->stencil_gc, 0x00); 1222 XSetForeground(data->display, data->stencil_gc, 0x00);
1125 XFixesSetGCClipRegion(data->display, data->stencil_gc, 0, 0, data->stencil_parts); 1223 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
1224 if (data->use_xdamage)
1225 XFixesSetGCClipRegion(data->display, data->stencil_gc,
1226 0, 0, data->stencil_parts);
1227 #endif
1126 XFillRectangle(data->display, data->stencil, data->stencil_gc, 1228 XFillRectangle(data->display, data->stencil, data->stencil_gc,
1127 0, 0, window->w, window->h); 1229 0, 0, window->w, window->h);
1128 XFixesSetGCClipRegion(data->display, data->stencil_gc, 0, 0, None); 1230 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
1231 if (data->use_xdamage)
1232 XFixesSetGCClipRegion(data->display, data->stencil_gc,
1233 0, 0, None);
1234 #endif
1129 XSetForeground(data->display, data->stencil_gc, 0xFF); 1235 XSetForeground(data->display, data->stencil_gc, 0xFF);
1130 /*damage =
1131 XDamageCreate(data->display, data->stencil, XDamageReportRawRectangles);*/
1132 } 1236 }
1133 else 1237 else
1134 #endif 1238 #endif
1135 { 1239 {
1136 drawable = data->drawable; 1240 drawable = data->drawable;
1253 SDL_AddDirtyRect(&data->dirty, &rect); 1357 SDL_AddDirtyRect(&data->dirty, &rect);
1254 } 1358 }
1255 } 1359 }
1256 } 1360 }
1257 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 1361 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
1258 if (data->use_xrender) { 1362 if (data->use_xrender &&
1363 (renderer->blendMode != SDL_BLENDMODE_NONE) &&
1364 !(renderer->a == 0xFF &&
1365 renderer->blendMode != SDL_BLENDMODE_ADD &&
1366 renderer->blendMode != SDL_BLENDMODE_MOD))
1367 {
1259 XRenderColor xrforeground = xrenderdrawcolor(renderer); 1368 XRenderColor xrforeground = xrenderdrawcolor(renderer);
1260 XRenderFillRectangle(data->display, PictOpSrc, data->brush_pict, 1369 XRenderFillRectangle(data->display, PictOpSrc, data->brush_pict,
1261 &xrforeground, 0, 0, 1, 1); 1370 &xrforeground, 0, 0, 1, 1);
1262 XDamageSubtract(data->display, data->stencil_damage, None, data->stencil_parts); 1371 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
1263 XFixesSetPictureClipRegion(data->display, data->drawable_pict, 0, 0, data->stencil_parts); 1372 if (data->use_xdamage)
1373 {
1374 XDamageSubtract(data->display, data->stencil_damage, None, data->stencil_parts);
1375
1376 XFixesSetPictureClipRegion(data->display, data->drawable_pict,
1377 0, 0, data->stencil_parts);
1378 }
1379 #endif
1264 XRenderComposite(data->display, data->blend_op, data->brush_pict, 1380 XRenderComposite(data->display, data->blend_op, data->brush_pict,
1265 data->stencil_pict, data->drawable_pict, 1381 data->stencil_pict, data->drawable_pict,
1266 0, 0, 0, 0, 0, 0, window->w, window->h); 1382 0, 0, 0, 0, 0, 0, window->w, window->h);
1267 XFixesSetPictureClipRegion(data->display, data->drawable_pict, 0, 0, None); 1383 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
1268 //XDamageDestroy(data->display, damage); 1384 if (data->use_xdamage)
1385 XFixesSetPictureClipRegion(data->display, data->drawable_pict,
1386 0, 0, None);
1387 #endif
1269 } 1388 }
1270 #endif 1389 #endif
1271 SDL_stack_free(xpoints); 1390 SDL_stack_free(xpoints);
1272 1391
1273 return 0; 1392 return 0;
1304 1423
1305 if (data->makedirty) { 1424 if (data->makedirty) {
1306 SDL_AddDirtyRect(&data->dirty, &rect); 1425 SDL_AddDirtyRect(&data->dirty, &rect);
1307 } 1426 }
1308 } 1427 }
1309 /* 1428 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
1310 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 1429 if (data->use_xrender &&
1311 if (data->use_xrender) { 1430 (renderer->blendMode != SDL_BLENDMODE_NONE) &&
1431 !(renderer->a == 0xFF &&
1432 renderer->blendMode != SDL_BLENDMODE_ADD &&
1433 renderer->blendMode != SDL_BLENDMODE_MOD))
1434 {
1312 XSetForeground(data->display, data->stencil_gc, 0x00); 1435 XSetForeground(data->display, data->stencil_gc, 0x00);
1436 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
1437 if (data->use_xdamage)
1438 XFixesSetGCClipRegion(data->display, data->stencil_gc,
1439 0, 0, data->stencil_parts);
1440 #endif
1313 XFillRectangle(data->display, data->stencil, data->stencil_gc, 1441 XFillRectangle(data->display, data->stencil, data->stencil_gc,
1314 0, 0, window->w, window->h); 1442 0, 0, window->w, window->h);
1443 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
1444 if (data->use_xdamage)
1445 XFixesSetGCClipRegion(data->display, data->stencil_gc,
1446 0, 0, None);
1447 #endif
1315 XSetForeground(data->display, data->stencil_gc, 0xFF); 1448 XSetForeground(data->display, data->stencil_gc, 0xFF);
1316 1449
1317 XDrawRectangles(data->display, data->stencil, data->stencil_gc, xrects, xcount); 1450 XDrawRectangles(data->display, data->stencil, data->stencil_gc, xrects, xcount);
1318 } 1451
1319 #endif 1452 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
1320 */ 1453 if (data->use_xdamage)
1321 } 1454 XDamageSubtract(data->display, data->stencil_damage,
1322 /* 1455 None, data->stencil_parts);
1323 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 1456 #endif
1324 if (data->use_xrender) { 1457 }
1458 #endif
1459 }
1460 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
1461 if (data->use_xrender &&
1462 (renderer->blendMode != SDL_BLENDMODE_NONE) &&
1463 !(renderer->a == 0xFF &&
1464 renderer->blendMode != SDL_BLENDMODE_ADD &&
1465 renderer->blendMode != SDL_BLENDMODE_MOD))
1466 {
1325 XRenderColor foreground; 1467 XRenderColor foreground;
1326 foreground = xrenderdrawcolor(renderer); 1468 foreground = xrenderdrawcolor(renderer);
1327
1328 XRenderFillRectangle(data->display, PictOpSrc, data->brush_pict, 1469 XRenderFillRectangle(data->display, PictOpSrc, data->brush_pict,
1329 &foreground, 0, 0, 1, 1); 1470 &foreground, 0, 0, 1, 1);
1471 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
1472 if (data->use_xdamage)
1473 XFixesSetPictureClipRegion(data->display, data->drawable_pict,
1474 0, 0, data->stencil_parts);
1475 #endif
1330 XRenderComposite(data->display, data->blend_op, data->brush_pict, 1476 XRenderComposite(data->display, data->blend_op, data->brush_pict,
1331 data->stencil_pict, data->drawable_pict, 1477 data->stencil_pict, data->drawable_pict,
1332 0, 0, 0, 0, 0, 0, window->w, window->h); 1478 0, 0, 0, 0, 0, 0, window->w, window->h);
1479 #ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE
1480 if (data->use_xdamage)
1481 XFixesSetPictureClipRegion(data->display, data->drawable_pict,
1482 0, 0, None);
1483 #endif
1333 } 1484 }
1334 else 1485 else
1335 #endif 1486 #endif
1336 */
1337 { 1487 {
1338 unsigned long foreground; 1488 unsigned long foreground;
1339 1489
1340 foreground = renderdrawcolor(renderer, 1); 1490 foreground = renderdrawcolor(renderer, 1);
1341 XSetForeground(data->display, data->gc, foreground); 1491 XSetForeground(data->display, data->gc, foreground);