comparison src/video/x11/SDL_x11render.c @ 4599:ce0643707bb0 experimental

Minor changes.
author Sunny Sachanandani <sunnysachanandani@gmail.com>
date Sun, 18 Jul 2010 18:42:33 +0530
parents 66e13a224bd6
children
comparison
equal deleted inserted replaced
4598:66e13a224bd6 4599:ce0643707bb0
30 #include "../SDL_rect_c.h" 30 #include "../SDL_rect_c.h"
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 #include "SDL_surface.h" 33 #include "SDL_surface.h"
34 34
35 //#define EXPT 35 #define EXPT
36 36
37 /* X11 renderer implementation */ 37 /* X11 renderer implementation */
38 38
39 static SDL_Renderer *X11_CreateRenderer(SDL_Window * window, Uint32 flags); 39 static SDL_Renderer *X11_CreateRenderer(SDL_Window * window, Uint32 flags);
40 static int X11_DisplayModeChanged(SDL_Renderer * renderer); 40 static int X11_DisplayModeChanged(SDL_Renderer * renderer);
1057 /* Nothing to draw */ 1057 /* Nothing to draw */
1058 return 0; 1058 return 0;
1059 } 1059 }
1060 SDL_AddDirtyRect(&data->dirty, &rect); 1060 SDL_AddDirtyRect(&data->dirty, &rect);
1061 } 1061 }
1062 /* 1062
1063 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 1063 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
1064 #ifndef NO_SHARED_MEMORY 1064 #ifndef NO_SHARED_MEMORY
1065 #ifdef EXPT 1065 #ifdef EXPT
1066 if (data->use_xrender && data->stencil_image && data->stencil_surface) { 1066 if (data->use_xrender && data->stencil_image && data->stencil_surface) {
1067 SDL_FillRect(data->stencil_surface, &rect, 0x00); 1067 SDL_FillRect(data->stencil_surface, &rect, 0x00);
1076 XSync(data->display, False); 1076 XSync(data->display, False);
1077 } else 1077 } else
1078 #endif 1078 #endif
1079 #endif 1079 #endif
1080 #endif 1080 #endif
1081 */ 1081
1082 { 1082 {
1083 xpoint = xpoints = SDL_stack_alloc(XPoint, count); 1083 xpoint = xpoints = SDL_stack_alloc(XPoint, count);
1084 xcount = 0; 1084 xcount = 0;
1085 for (i = 0; i < count; ++i) { 1085 for (i = 0; i < count; ++i) {
1086 int x = points[i].x; 1086 int x = points[i].x;
1091 xpoint->x = (short)x; 1091 xpoint->x = (short)x;
1092 xpoint->y = (short)y; 1092 xpoint->y = (short)y;
1093 ++xpoint; 1093 ++xpoint;
1094 ++xcount; 1094 ++xcount;
1095 } 1095 }
1096 /* 1096
1097 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 1097 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
1098 if (data->use_xrender) { 1098 if (data->use_xrender) {
1099 XSetForeground(data->display, data->stencil_gc, 0x00); 1099 XSetForeground(data->display, data->stencil_gc, 0x00);
1100 XFillRectangle(data->display, data->stencil, data->stencil_gc, 1100 XFillRectangle(data->display, data->stencil, data->stencil_gc,
1101 rect.x, rect.y, rect.w, rect.h); 1101 rect.x, rect.y, rect.w, rect.h);
1102 XSetForeground(data->display, data->stencil_gc, 0xFF); 1102 XSetForeground(data->display, data->stencil_gc, 0xFF);
1103 XDrawPoints(data->display, data->stencil, data->stencil_gc, xpoints, xcount, 1103 XDrawPoints(data->display, data->stencil, data->stencil_gc, xpoints, xcount,
1104 CoordModeOrigin); 1104 CoordModeOrigin);
1105 } 1105 }
1106 #endif*/ 1106 #endif
1107 } 1107 }
1108 /* 1108
1109 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 1109 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
1110 if (data->use_xrender) { 1110 if (data->use_xrender) {
1111 XRenderColor foreground; 1111 XRenderColor foreground;
1112 foreground = xrenderdrawcolor(renderer); 1112 foreground = xrenderdrawcolor(renderer);
1113 XRenderFillRectangle(data->display, PictOpSrc, data->brush_pict, 1113 XRenderFillRectangle(data->display, PictOpSrc, data->brush_pict,
1116 data->stencil_pict, data->drawable_pict, 1116 data->stencil_pict, data->drawable_pict,
1117 rect.x, rect.y, rect.x, rect.y, rect.x, rect.y, rect.w, rect.h); 1117 rect.x, rect.y, rect.x, rect.y, rect.x, rect.y, rect.w, rect.h);
1118 } 1118 }
1119 else 1119 else
1120 #endif 1120 #endif
1121 */ 1121
1122 { 1122 {
1123 unsigned long foreground = renderdrawcolor(renderer, 1); 1123 unsigned long foreground = renderdrawcolor(renderer, 1);
1124 XSetForeground(data->display, data->gc, foreground); 1124 XSetForeground(data->display, data->gc, foreground);
1125 1125
1126 1126
1150 1150
1151 clip.x = 0; 1151 clip.x = 0;
1152 clip.y = 0; 1152 clip.y = 0;
1153 clip.w = window->w; 1153 clip.w = window->w;
1154 clip.h = window->h; 1154 clip.h = window->h;
1155 /* 1155
1156 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 1156 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
1157 #ifndef NO_SHARED_MEMORY 1157 #ifndef NO_SHARED_MEMORY
1158 #ifdef EXPT 1158 #ifdef EXPT
1159 if (data->use_xrender && data->stencil_image && data->stencil_surface) { 1159 if (data->use_xrender && data->stencil_image && data->stencil_surface) {
1160 SDL_FillRect(data->stencil_surface, NULL, 0x00); 1160 SDL_FillRect(data->stencil_surface, NULL, 0x00);
1169 XSync(data->display, False); 1169 XSync(data->display, False);
1170 } else 1170 } else
1171 #endif 1171 #endif
1172 #endif 1172 #endif
1173 #endif 1173 #endif
1174 */ 1174
1175 { 1175 {
1176 Pixmap drawable; 1176 Pixmap drawable;
1177 GC gc; 1177 GC gc;
1178 /* 1178
1179 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 1179 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
1180 if (data->use_xrender) { 1180 if (data->use_xrender) {
1181 drawable = data->stencil; 1181 drawable = data->stencil;
1182 gc = data->stencil_gc; 1182 gc = data->stencil_gc;
1183 XSetForeground(data->display, data->stencil_gc, 0x00); 1183 XSetForeground(data->display, data->stencil_gc, 0x00);
1185 0, 0, window->w, window->h); 1185 0, 0, window->w, window->h);
1186 XSetForeground(data->display, data->stencil_gc, 0xFF); 1186 XSetForeground(data->display, data->stencil_gc, 0xFF);
1187 } 1187 }
1188 else 1188 else
1189 #endif 1189 #endif
1190 */ 1190
1191 { 1191 {
1192 drawable = data->drawable; 1192 drawable = data->drawable;
1193 gc = data->gc; 1193 gc = data->gc;
1194 } 1194 }
1195 1195
1308 rect.h = (maxy - miny) + 1; 1308 rect.h = (maxy - miny) + 1;
1309 SDL_AddDirtyRect(&data->dirty, &rect); 1309 SDL_AddDirtyRect(&data->dirty, &rect);
1310 } 1310 }
1311 } 1311 }
1312 } 1312 }
1313 /* 1313
1314 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 1314 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
1315 if (data->use_xrender) { 1315 if (data->use_xrender) {
1316 XRenderColor xrforeground = xrenderdrawcolor(renderer); 1316 XRenderColor xrforeground = xrenderdrawcolor(renderer);
1317 XRenderFillRectangle(data->display, PictOpSrc, data->brush_pict, 1317 XRenderFillRectangle(data->display, PictOpSrc, data->brush_pict,
1318 &xrforeground, 0, 0, 1, 1); 1318 &xrforeground, 0, 0, 1, 1);
1319 XRenderComposite(data->display, data->blend_op, data->brush_pict, 1319 XRenderComposite(data->display, data->blend_op, data->brush_pict,
1320 data->stencil_pict, data->drawable_pict, 1320 data->stencil_pict, data->drawable_pict,
1321 0, 0, 0, 0, 0, 0, window->w, window->h); 1321 0, 0, 0, 0, 0, 0, window->w, window->h);
1322 } 1322 }
1323 #endif 1323 #endif
1324 */ 1324
1325 SDL_stack_free(xpoints); 1325 SDL_stack_free(xpoints);
1326 1326
1327 return 0; 1327 return 0;
1328 } 1328 }
1329 1329
1340 1340
1341 clip.x = 0; 1341 clip.x = 0;
1342 clip.y = 0; 1342 clip.y = 0;
1343 clip.w = window->w; 1343 clip.w = window->w;
1344 clip.h = window->h; 1344 clip.h = window->h;
1345 /* 1345
1346 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 1346 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
1347 #ifndef NO_SHARED_MEMORY 1347 #ifndef NO_SHARED_MEMORY
1348 #ifdef EXPT 1348 #ifdef EXPT
1349 if (data->use_xrender && data->stencil_image && data->stencil_surface) { 1349 if (data->use_xrender && data->stencil_image && data->stencil_surface) {
1350 SDL_FillRect(data->stencil_surface, NULL, 0x00); 1350 SDL_FillRect(data->stencil_surface, NULL, 0x00);
1360 } 1360 }
1361 else 1361 else
1362 #endif 1362 #endif
1363 #endif 1363 #endif
1364 #endif 1364 #endif
1365 */ 1365
1366 { 1366 {
1367 1367
1368 for (i = 0; i < count; ++i) { 1368 for (i = 0; i < count; ++i) {
1369 if (!SDL_IntersectRect(rects[i], &clip, &rect)) { 1369 if (!SDL_IntersectRect(rects[i], &clip, &rect)) {
1370 continue; 1370 continue;
1379 1379
1380 if (data->makedirty) { 1380 if (data->makedirty) {
1381 SDL_AddDirtyRect(&data->dirty, &rect); 1381 SDL_AddDirtyRect(&data->dirty, &rect);
1382 } 1382 }
1383 } 1383 }
1384 /* 1384
1385 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 1385 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
1386 if (data->use_xrender) { 1386 if (data->use_xrender) {
1387 XSetForeground(data->display, data->stencil_gc, 0x00); 1387 XSetForeground(data->display, data->stencil_gc, 0x00);
1388 XFillRectangle(data->display, data->stencil, data->stencil_gc, 1388 XFillRectangle(data->display, data->stencil, data->stencil_gc,
1389 0, 0, window->w, window->h); 1389 0, 0, window->w, window->h);
1390 XSetForeground(data->display, data->stencil_gc, 0xFF); 1390 XSetForeground(data->display, data->stencil_gc, 0xFF);
1391 1391
1392 XDrawRectangles(data->display, data->stencil, data->stencil_gc, xrects, xcount); 1392 XDrawRectangles(data->display, data->stencil, data->stencil_gc, xrects, xcount);
1393 } 1393 }
1394 #endif 1394 #endif
1395 */ 1395
1396 } 1396 }
1397 /* 1397
1398 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER 1398 #ifdef SDL_VIDEO_DRIVER_X11_XRENDER
1399 if (data->use_xrender) { 1399 if (data->use_xrender) {
1400 XRenderColor foreground; 1400 XRenderColor foreground;
1401 foreground = xrenderdrawcolor(renderer); 1401 foreground = xrenderdrawcolor(renderer);
1402 1402
1406 data->stencil_pict, data->drawable_pict, 1406 data->stencil_pict, data->drawable_pict,
1407 0, 0, 0, 0, 0, 0, window->w, window->h); 1407 0, 0, 0, 0, 0, 0, window->w, window->h);
1408 } 1408 }
1409 else 1409 else
1410 #endif 1410 #endif
1411 */ 1411
1412 { 1412 {
1413 unsigned long foreground; 1413 unsigned long foreground;
1414 1414
1415 foreground = renderdrawcolor(renderer, 1); 1415 foreground = renderdrawcolor(renderer, 1);
1416 XSetForeground(data->display, data->gc, foreground); 1416 XSetForeground(data->display, data->gc, foreground);