comparison src/video/x11/SDL_x11render.c @ 4581:ef0aa488fff6

Fix X11_FillRects to work with double buffering as well as triple buffering. This requires that the buffer pixmap be cleared after every render.
author Sunny Sachanandani <sunnysachanandani@gmail.com>
date Wed, 02 Jun 2010 11:45:15 +0530
parents cfea5b007bc7
children a17fbd25767b
comparison
equal deleted inserted replaced
4580:cfea5b007bc7 4581:ef0aa488fff6
288 XRenderCreatePicture(data->display, data->pixmaps[i], data->xwindow_pict_fmt, 288 XRenderCreatePicture(data->display, data->pixmaps[i], data->xwindow_pict_fmt,
289 data->xwindow_pict_attr_valuemask, &data->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 XRenderComposite(data->display, PictOpClear, data->pixmap_picts[i], None, data->pixmap_picts[i],
294 0, 0, 0, 0, 0, 0, window->w, window->h);
293 } 295 }
294 #endif 296 #endif
295 } 297 }
296 if (n > 0) { 298 if (n > 0) {
297 data->drawable = data->pixmaps[0]; 299 data->drawable = data->pixmaps[0];
372 XRenderCreatePicture(data->display, data->pixmaps[i], data->xwindow_pict_fmt, 374 XRenderCreatePicture(data->display, data->pixmaps[i], data->xwindow_pict_fmt,
373 data->xwindow_pict_attr_valuemask, &data->xwindow_pict_attr); 375 data->xwindow_pict_attr_valuemask, &data->xwindow_pict_attr);
374 if(!data->pixmap_picts[i]) { 376 if(!data->pixmap_picts[i]) {
375 data->xrender_available = SDL_FALSE; 377 data->xrender_available = SDL_FALSE;
376 } 378 }
379 XRenderComposite(data->display, PictOpClear, data->pixmap_picts[i], None, data->pixmap_picts[i],
380 0, 0, 0, 0, 0, 0, window->w, window->h);
377 } 381 }
378 #endif 382 #endif
379 } 383 }
380 if (n > 0) { 384 if (n > 0) {
381 data->drawable = data->pixmaps[0]; 385 data->drawable = data->pixmaps[0];
732 static int 736 static int
733 X11_SetDrawBlendMode(SDL_Renderer * renderer) 737 X11_SetDrawBlendMode(SDL_Renderer * renderer)
734 { 738 {
735 switch (renderer->blendMode) { 739 switch (renderer->blendMode) {
736 case SDL_BLENDMODE_NONE: 740 case SDL_BLENDMODE_NONE:
741 return 0;
742 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
743 case SDL_BLENDMODE_MASK: // Use src pict as mask
744 case SDL_BLENDMODE_ADD: // PictOpAdd
745 case SDL_BLENDMODE_BLEND: // PictOpOver
746 /* FIXME case SDL_BLENDMODE_MOD: */
747 #endif
737 return 0; 748 return 0;
738 default: 749 default:
739 SDL_Unsupported(); 750 SDL_Unsupported();
740 renderer->blendMode = SDL_BLENDMODE_NONE; 751 renderer->blendMode = SDL_BLENDMODE_NONE;
741 return -1; 752 return -1;
1036 // Premultiply the color channels as well as modulate them to a 16 bit color space 1047 // Premultiply the color channels as well as modulate them to a 16 bit color space
1037 xrender_foreground_color.red = ((unsigned short)renderer->r + 1) * ((unsigned short)renderer->a + 1) - 1; 1048 xrender_foreground_color.red = ((unsigned short)renderer->r + 1) * ((unsigned short)renderer->a + 1) - 1;
1038 xrender_foreground_color.green = ((unsigned short)renderer->g + 1) * ((unsigned short)renderer->a + 1) - 1; 1049 xrender_foreground_color.green = ((unsigned short)renderer->g + 1) * ((unsigned short)renderer->a + 1) - 1;
1039 xrender_foreground_color.blue = ((unsigned short)renderer->b + 1) * ((unsigned short)renderer->a + 1) - 1; 1050 xrender_foreground_color.blue = ((unsigned short)renderer->b + 1) * ((unsigned short)renderer->a + 1) - 1;
1040 xrender_foreground_color.alpha = ((unsigned short)renderer->a + 1) * ((unsigned short)renderer->a + 1) - 1; 1051 xrender_foreground_color.alpha = ((unsigned short)renderer->a + 1) * ((unsigned short)renderer->a + 1) - 1;
1041 XRenderFillRectangles(data->display, PictOpSrc, data->drawable_pict, 1052 XRenderFillRectangles(data->display, PictOpOver, data->drawable_pict,
1042 &xrender_foreground_color, xrects, xcount); 1053 &xrender_foreground_color, xrects, xcount);
1043 } 1054 }
1044 else 1055 else
1045 #endif 1056 #endif
1046 { 1057 {
1239 for (dirty = data->dirty.list; dirty; dirty = dirty->next) { 1250 for (dirty = data->dirty.list; dirty; dirty = dirty->next) {
1240 const SDL_Rect *rect = &dirty->rect; 1251 const SDL_Rect *rect = &dirty->rect;
1241 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 1252 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
1242 if(data->xrender_available == SDL_TRUE) 1253 if(data->xrender_available == SDL_TRUE)
1243 { 1254 {
1244 XRenderComposite(data->display, PictOpSrc, data->drawable_pict, None, data->xwindow_pict, 1255 XRenderComposite(data->display, PictOpOver, data->drawable_pict, None, data->xwindow_pict,
1245 rect->x, rect->y, 0, 0, rect->x, rect->y, rect->w, rect->h); 1256 rect->x, rect->y, 0, 0, rect->x, rect->y, rect->w, rect->h);
1246 } 1257 }
1247 else 1258 else
1248 #endif 1259 #endif
1249 { 1260 {
1251 data->gc, rect->x, rect->y, rect->w, rect->h, 1262 data->gc, rect->x, rect->y, rect->w, rect->h,
1252 rect->x, rect->y); 1263 rect->x, rect->y);
1253 } 1264 }
1254 } 1265 }
1255 SDL_ClearDirtyRects(&data->dirty); 1266 SDL_ClearDirtyRects(&data->dirty);
1267 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
1268 // Clear each pixmap after a render
1269 if(data->xrender_available == SDL_TRUE) {
1270 XRenderComposite(data->display, PictOpClear, data->drawable_pict, None, data->drawable_pict,
1271 0, 0, 0, 0, 0, 0, renderer->window->w, renderer->window->h);
1272 }
1273 #endif
1256 } 1274 }
1257 XSync(data->display, False); 1275 XSync(data->display, False);
1258 1276
1259 /* Update the flipping chain, if any */ 1277 /* Update the flipping chain, if any */
1260 if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) { 1278 if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) {