ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/background.C
(Generate patch)

Comparing rxvt-unicode/src/background.C (file contents):
Revision 1.63 by sf-exg, Sun Oct 3 21:44:39 2010 UTC vs.
Revision 1.64 by sf-exg, Mon Oct 4 14:31:00 2010 UTC

1047 } 1047 }
1048 1048
1049 return false; 1049 return false;
1050} 1050}
1051 1051
1052bool
1053bgPixmap_t::tint_pixmap (Pixmap pixmap)
1054{
1055 Window root = target->display->root;
1056 Display *dpy = target->dpy;
1057 int window_width = target->szHint.width;
1058 int window_height = target->szHint.height;
1059 bool ret = false;
1060
1061 if (flags & tintWholesome)
1062 {
1063 XGCValues gcv;
1064 GC gc;
1065
1066 /* In this case we can tint image server-side getting significant
1067 * performance improvements, as we eliminate XImage transfer
1068 */
1069 gcv.foreground = Pixel (tint);
1070 gcv.function = GXand;
1071 gcv.fill_style = FillSolid;
1072 gc = XCreateGC (dpy, root, GCFillStyle | GCForeground | GCFunction, &gcv);
1073 if (gc)
1074 {
1075 XFillRectangle (dpy, pixmap, gc, 0, 0, window_width, window_height);
1076 ret = true;
1077 XFreeGC (dpy, gc);
1078 }
1079 }
1080 else
1081 {
1082# if XFT
1083 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
1084
1085 if (flags & tintSet)
1086 tint.get (c);
1087
1088 if (shade > 0 && shade < 100)
1089 {
1090 c.r = (c.r * shade) / 100;
1091 c.g = (c.g * shade) / 100;
1092 c.b = (c.b * shade) / 100;
1093 }
1094 else if (shade > 100 && shade < 200)
1095 {
1096 c.r = (c.r * (200 - shade)) / 100;
1097 c.g = (c.g * (200 - shade)) / 100;
1098 c.b = (c.b * (200 - shade)) / 100;
1099 }
1100
1101 XRenderPictFormat pf;
1102 pf.type = PictTypeDirect;
1103 pf.depth = 32;
1104 pf.direct.redMask = 0xff;
1105 pf.direct.greenMask = 0xff;
1106 pf.direct.blueMask = 0xff;
1107 pf.direct.alphaMask = 0xff;
1108
1109 XRenderPictFormat *solid_format = XRenderFindFormat (dpy,
1110 (PictFormatType|
1111 PictFormatDepth|
1112 PictFormatRedMask|
1113 PictFormatGreenMask|
1114 PictFormatBlueMask|
1115 PictFormatAlphaMask),
1116 &pf,
1117 0);
1118 XRenderPictFormat *root_format = XRenderFindVisualFormat (dpy, DefaultVisualOfScreen (ScreenOfDisplay (dpy, target->display->screen)));
1119 XRenderPictureAttributes pa;
1120
1121 Picture back_pic = XRenderCreatePicture (dpy, pixmap, root_format, 0, &pa);
1122
1123 pa.repeat = True;
1124
1125 Pixmap overlay_pmap = XCreatePixmap (dpy, root, 1, 1, 32);
1126 Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa);
1127 XFreePixmap (dpy, overlay_pmap);
1128
1129 pa.component_alpha = True;
1130 Pixmap mask_pmap = XCreatePixmap (dpy, root, 1, 1, 32);
1131 Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa);
1132 XFreePixmap (dpy, mask_pmap);
1133
1134 if (mask_pic && overlay_pic && back_pic)
1135 {
1136 XRenderColor mask_c;
1137
1138 memset (&mask_c, (shade > 100) ? 0xFF : 0x0, sizeof (mask_c));
1139 mask_c.alpha = 0xffff;
1140 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1);
1141
1142 mask_c.alpha = 0;
1143 mask_c.red = 0xffff - c.r;
1144 mask_c.green = 0xffff - c.g;
1145 mask_c.blue = 0xffff - c.b;
1146 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1);
1147 XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height);
1148 ret = true;
1149 }
1150
1151 XRenderFreePicture (dpy, mask_pic);
1152 XRenderFreePicture (dpy, overlay_pic);
1153 XRenderFreePicture (dpy, back_pic);
1154# if DO_TIMING_TEST
1155 XSync (dpy, False);
1156# endif
1157# endif
1158 }
1159
1160 return ret;
1161}
1162
1052/* make_transparency_pixmap() 1163/* make_transparency_pixmap()
1053 * Builds a pixmap sized the same as terminal window, with depth same as the root window 1164 * Builds a pixmap sized the same as terminal window, with depth same as the root window
1054 * that pixmap contains tiled portion of the root pixmap that is supposed to be covered by 1165 * that pixmap contains tiled portion of the root pixmap that is supposed to be covered by
1055 * our window. 1166 * our window.
1056 */ 1167 */
1184 { 1295 {
1185 if (!need_client_side_rendering ()) 1296 if (!need_client_side_rendering ())
1186 { 1297 {
1187 if ((flags & tintNeeded)) 1298 if ((flags & tintNeeded))
1188 { 1299 {
1189 if (flags & tintWholesome) 1300 if (tint_pixmap (tiled_root_pmap))
1190 {
1191 /* In this case we can tint image server-side getting significant
1192 * performance improvements, as we eliminate XImage transfer
1193 */
1194 gcv.foreground = Pixel (tint);
1195 gcv.function = GXand;
1196 gcv.fill_style = FillSolid;
1197 if (gc)
1198 XChangeGC (dpy, gc, GCFillStyle | GCForeground | GCFunction, &gcv);
1199 else
1200 gc = XCreateGC (dpy, root, GCFillStyle | GCForeground | GCFunction, &gcv);
1201 if (gc)
1202 {
1203 XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height);
1204 result |= transpPmapTinted; 1301 result |= transpPmapTinted;
1205 }
1206 }
1207 else
1208 {
1209# if XFT
1210 Picture back_pic = 0;
1211 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
1212
1213 if (flags & tintSet)
1214 tint.get (c);
1215
1216 if (shade > 0 && shade < 100)
1217 {
1218 c.r = (c.r * shade) / 100;
1219 c.g = (c.g * shade) / 100;
1220 c.b = (c.b * shade) / 100;
1221 }
1222 else if (shade > 100 && shade < 200)
1223 {
1224 c.r = (c.r * (200 - shade)) / 100;
1225 c.g = (c.g * (200 - shade)) / 100;
1226 c.b = (c.b * (200 - shade)) / 100;
1227 }
1228
1229 XRenderPictFormat pf;
1230 pf.type = PictTypeDirect;
1231 pf.depth = 32;
1232 pf.direct.redMask = 0xff;
1233 pf.direct.greenMask = 0xff;
1234 pf.direct.blueMask = 0xff;
1235 pf.direct.alphaMask = 0xff;
1236
1237 XRenderPictFormat *solid_format = XRenderFindFormat (dpy,
1238 (PictFormatType|
1239 PictFormatDepth|
1240 PictFormatRedMask|
1241 PictFormatGreenMask|
1242 PictFormatBlueMask|
1243 PictFormatAlphaMask),
1244 &pf,
1245 0);
1246 XRenderPictFormat *root_format = XRenderFindVisualFormat (dpy, DefaultVisualOfScreen (ScreenOfDisplay (dpy, target->display->screen)));
1247 XRenderPictureAttributes pa ;
1248
1249 back_pic = XRenderCreatePicture (dpy, tiled_root_pmap, root_format, 0, &pa);
1250
1251 pa.repeat = True;
1252
1253 Pixmap overlay_pmap = XCreatePixmap (dpy, root, 1, 1, 32);
1254 Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa);
1255 XFreePixmap (dpy, overlay_pmap);
1256
1257 pa.component_alpha = True;
1258 Pixmap mask_pmap = XCreatePixmap (dpy, root, 1, 1, 32);
1259 Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa);
1260 XFreePixmap (dpy, mask_pmap);
1261
1262 if (mask_pic && overlay_pic && back_pic)
1263 {
1264 XRenderColor mask_c;
1265
1266 memset (&mask_c, (shade > 100) ? 0xFF : 0x0, sizeof (mask_c));
1267 mask_c.alpha = 0xffff;
1268 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1);
1269
1270 mask_c.alpha = 0;
1271 mask_c.red = 0xffff - c.r;
1272 mask_c.green = 0xffff - c.g;
1273 mask_c.blue = 0xffff - c.b;
1274 XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1);
1275 XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height);
1276 result |= transpPmapTinted;
1277 }
1278
1279 XRenderFreePicture (dpy, mask_pic);
1280 XRenderFreePicture (dpy, overlay_pic);
1281 XRenderFreePicture (dpy, back_pic);
1282# if DO_TIMING_TEST
1283 XSync (dpy, False);
1284# endif
1285# endif
1286 }
1287 } 1302 }
1288 } /* server side rendering completed */ 1303 } /* server side rendering completed */
1289 1304
1290 if (pixmap) 1305 if (pixmap)
1291 XFreePixmap (dpy, pixmap); 1306 XFreePixmap (dpy, pixmap);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines