… | |
… | |
33 | #ifndef FilterConvolution |
33 | #ifndef FilterConvolution |
34 | #define FilterConvolution "convolution" |
34 | #define FilterConvolution "convolution" |
35 | #endif |
35 | #endif |
36 | |
36 | |
37 | #ifdef HAVE_BG_PIXMAP |
37 | #ifdef HAVE_BG_PIXMAP |
|
|
38 | # if XRENDER |
|
|
39 | static Picture |
|
|
40 | create_xrender_mask (Display *dpy, Drawable drawable, Bool argb, Bool component_alpha) |
|
|
41 | { |
|
|
42 | Pixmap pixmap = XCreatePixmap (dpy, drawable, 1, 1, argb ? 32 : 8); |
|
|
43 | |
|
|
44 | XRenderPictFormat *format = XRenderFindStandardFormat (dpy, argb ? PictStandardARGB32 : PictStandardA8); |
|
|
45 | XRenderPictureAttributes pa; |
|
|
46 | pa.repeat = True; |
|
|
47 | pa.component_alpha = component_alpha; |
|
|
48 | Picture mask = XRenderCreatePicture (dpy, pixmap, format, CPRepeat | CPComponentAlpha, &pa); |
|
|
49 | |
|
|
50 | XFreePixmap (dpy, pixmap); |
|
|
51 | |
|
|
52 | return mask; |
|
|
53 | } |
|
|
54 | # endif |
|
|
55 | |
38 | void |
56 | void |
39 | rxvt_term::bg_destroy () |
57 | rxvt_term::bg_destroy () |
40 | { |
58 | { |
41 | #ifdef HAVE_AFTERIMAGE |
59 | #ifdef HAVE_AFTERIMAGE |
42 | if (original_asim) |
60 | if (original_asim) |
… | |
… | |
181 | { |
199 | { |
182 | bool changed = false; |
200 | bool changed = false; |
183 | int geom_flags = 0; |
201 | int geom_flags = 0; |
184 | int x = 0, y = 0; |
202 | int x = 0, y = 0; |
185 | unsigned int w = 0, h = 0; |
203 | unsigned int w = 0, h = 0; |
186 | unsigned long new_flags = bg_flags & ~BG_GEOMETRY_FLAGS; |
204 | unsigned long new_flags = 0; |
187 | |
205 | |
188 | if (geom == NULL) |
206 | if (geom == NULL) |
189 | return false; |
207 | return false; |
190 | |
208 | |
191 | if (geom[0]) |
209 | if (geom[0]) |
… | |
… | |
201 | x = y = 0; |
219 | x = y = 0; |
202 | geom_flags = WidthValue|HeightValue|XValue|YValue; |
220 | geom_flags = WidthValue|HeightValue|XValue|YValue; |
203 | } |
221 | } |
204 | else if (!strcasecmp (arr[i], "style=aspect-stretched")) |
222 | else if (!strcasecmp (arr[i], "style=aspect-stretched")) |
205 | { |
223 | { |
206 | new_flags = BG_PROP_SCALE; |
224 | new_flags = BG_KEEP_ASPECT; |
207 | w = h = windowScale; |
225 | w = h = windowScale; |
208 | x = y = centerAlign; |
226 | x = y = centerAlign; |
209 | geom_flags = WidthValue|HeightValue|XValue|YValue; |
227 | geom_flags = WidthValue|HeightValue|XValue|YValue; |
210 | } |
228 | } |
211 | else if (!strcasecmp (arr[i], "style=stretched")) |
229 | else if (!strcasecmp (arr[i], "style=stretched")) |
… | |
… | |
227 | w = h = noScale; |
245 | w = h = noScale; |
228 | geom_flags = WidthValue|HeightValue; |
246 | geom_flags = WidthValue|HeightValue; |
229 | } |
247 | } |
230 | else if (!strcasecmp (arr[i], "op=tile")) |
248 | else if (!strcasecmp (arr[i], "op=tile")) |
231 | new_flags |= BG_TILE; |
249 | new_flags |= BG_TILE; |
232 | else if (!strcasecmp (arr[i], "op=pscale")) |
250 | else if (!strcasecmp (arr[i], "op=keep-aspect")) |
233 | new_flags |= BG_PROP_SCALE; |
251 | new_flags |= BG_KEEP_ASPECT; |
234 | else if (!strcasecmp (arr[i], "op=root")) |
252 | else if (!strcasecmp (arr[i], "op=root-align")) |
235 | new_flags |= BG_ROOT_ALIGN; |
253 | new_flags |= BG_ROOT_ALIGN; |
236 | |
254 | |
237 | // deprecated |
255 | // deprecated |
238 | else if (!strcasecmp (arr[i], "tile")) |
256 | else if (!strcasecmp (arr[i], "tile")) |
239 | { |
257 | { |
… | |
… | |
241 | w = h = noScale; |
259 | w = h = noScale; |
242 | geom_flags |= WidthValue|HeightValue; |
260 | geom_flags |= WidthValue|HeightValue; |
243 | } |
261 | } |
244 | else if (!strcasecmp (arr[i], "propscale")) |
262 | else if (!strcasecmp (arr[i], "propscale")) |
245 | { |
263 | { |
246 | new_flags |= BG_PROP_SCALE; |
264 | new_flags |= BG_KEEP_ASPECT; |
|
|
265 | w = h = windowScale; |
|
|
266 | geom_flags |= WidthValue|HeightValue; |
247 | } |
267 | } |
248 | else if (!strcasecmp (arr[i], "hscale")) |
268 | else if (!strcasecmp (arr[i], "hscale")) |
249 | { |
269 | { |
250 | new_flags |= BG_TILE; |
270 | new_flags |= BG_TILE; |
251 | w = windowScale; |
271 | w = windowScale; |
… | |
… | |
281 | geom_flags |= XParseGeometry (arr[i], &x, &y, &w, &h); |
301 | geom_flags |= XParseGeometry (arr[i], &x, &y, &w, &h); |
282 | } /* done parsing ops */ |
302 | } /* done parsing ops */ |
283 | |
303 | |
284 | rxvt_free_strsplit (arr); |
304 | rxvt_free_strsplit (arr); |
285 | } |
305 | } |
|
|
306 | |
|
|
307 | new_flags |= bg_flags & ~BG_GEOMETRY_FLAGS; |
286 | |
308 | |
287 | if (!update) |
309 | if (!update) |
288 | { |
310 | { |
289 | if (!(geom_flags & XValue)) |
311 | if (!(geom_flags & XValue)) |
290 | x = y = defaultAlign; |
312 | x = y = defaultAlign; |
… | |
… | |
322 | int target_height = szHint.height; |
344 | int target_height = szHint.height; |
323 | |
345 | |
324 | w = h_scale * target_width / 100; |
346 | w = h_scale * target_width / 100; |
325 | h = v_scale * target_height / 100; |
347 | h = v_scale * target_height / 100; |
326 | |
348 | |
327 | if (bg_flags & BG_PROP_SCALE) |
349 | if (bg_flags & BG_KEEP_ASPECT) |
328 | { |
350 | { |
329 | float scale = (float)w / image_width; |
351 | float scale = (float)w / image_width; |
330 | min_it (scale, (float)h / image_height); |
352 | min_it (scale, (float)h / image_height); |
331 | w = image_width * scale + 0.5; |
353 | w = image_width * scale + 0.5; |
332 | h = image_height * scale + 0.5; |
354 | h = image_height * scale + 0.5; |
… | |
… | |
370 | if (tr_flags & BG_NEEDS_TINT) |
392 | if (tr_flags & BG_NEEDS_TINT) |
371 | { |
393 | { |
372 | ShadingInfo as_shade; |
394 | ShadingInfo as_shade; |
373 | as_shade.shading = shade; |
395 | as_shade.shading = shade; |
374 | |
396 | |
375 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
397 | rgba c; |
376 | if (bg_flags & BG_TINT_SET) |
|
|
377 | tint.get (c); |
398 | tint.get (c); |
378 | as_shade.tintColor.red = c.r; |
399 | as_shade.tintColor.red = c.r; |
379 | as_shade.tintColor.green = c.g; |
400 | as_shade.tintColor.green = c.g; |
380 | as_shade.tintColor.blue = c.b; |
401 | as_shade.tintColor.blue = c.b; |
381 | |
402 | |
382 | background_tint = shading2tint32 (&as_shade); |
403 | background_tint = shading2tint32 (&as_shade); |
… | |
… | |
806 | Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa); |
827 | Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa); |
807 | |
828 | |
808 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); |
829 | XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual); |
809 | Picture dst = XRenderCreatePicture (dpy, bg_pixmap, dst_format, 0, &pa); |
830 | Picture dst = XRenderCreatePicture (dpy, bg_pixmap, dst_format, 0, &pa); |
810 | |
831 | |
811 | pa.repeat = True; |
832 | Picture mask = create_xrender_mask (dpy, vt, False, False); |
812 | Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8); |
|
|
813 | XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8); |
|
|
814 | Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa); |
|
|
815 | XFreePixmap (dpy, mask_pmap); |
|
|
816 | |
833 | |
817 | XRenderColor mask_c; |
834 | XRenderColor mask_c; |
818 | |
835 | |
819 | mask_c.alpha = 0x8000; |
836 | mask_c.alpha = 0x8000; |
820 | mask_c.red = 0; |
837 | mask_c.red = 0; |
… | |
… | |
951 | } |
968 | } |
952 | |
969 | |
953 | void |
970 | void |
954 | rxvt_term::set_tint_shade_flags () |
971 | rxvt_term::set_tint_shade_flags () |
955 | { |
972 | { |
956 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
973 | rgba c; |
957 | bool has_shade = shade != 100; |
974 | bool has_shade = shade != 100; |
958 | |
975 | |
959 | bg_flags &= ~BG_TINT_FLAGS; |
976 | bg_flags &= ~BG_TINT_FLAGS; |
960 | |
977 | |
961 | if (bg_flags & BG_TINT_SET) |
|
|
962 | { |
|
|
963 | tint.get (c); |
978 | tint.get (c); |
|
|
979 | |
964 | if (!has_shade |
980 | if (!has_shade |
965 | && (c.r <= 0x00ff || c.r >= 0xff00) |
981 | && (c.r <= 0x00ff || c.r >= 0xff00) |
966 | && (c.g <= 0x00ff || c.g >= 0xff00) |
982 | && (c.g <= 0x00ff || c.g >= 0xff00) |
967 | && (c.b <= 0x00ff || c.b >= 0xff00)) |
983 | && (c.b <= 0x00ff || c.b >= 0xff00)) |
968 | bg_flags |= BG_TINT_BITAND; |
984 | bg_flags |= BG_TINT_BITAND; |
969 | } |
|
|
970 | |
985 | |
971 | if (has_shade || (bg_flags & BG_TINT_SET)) |
986 | if (has_shade |
|
|
987 | || c.r < 0xff00 |
|
|
988 | || c.g < 0xff00 |
|
|
989 | || c.b < 0xff00) |
972 | bg_flags |= BG_NEEDS_TINT; |
990 | bg_flags |= BG_NEEDS_TINT; |
973 | } |
991 | } |
974 | |
992 | |
975 | bool |
993 | bool |
976 | rxvt_term::bg_set_tint (rxvt_color &new_tint) |
994 | rxvt_term::bg_set_tint (rxvt_color &new_tint) |
977 | { |
995 | { |
978 | if (!(bg_flags & BG_TINT_SET) || tint != new_tint) |
996 | if (tint != new_tint) |
979 | { |
997 | { |
980 | tint = new_tint; |
998 | tint = new_tint; |
981 | bg_flags |= BG_TINT_SET; |
|
|
982 | set_tint_shade_flags (); |
999 | set_tint_shade_flags (); |
983 | return true; |
1000 | return true; |
984 | } |
1001 | } |
985 | |
1002 | |
986 | return false; |
1003 | return false; |
987 | } |
1004 | } |
988 | |
1005 | |
989 | bool |
1006 | bool |
990 | rxvt_term::bg_set_shade (const char *shade_str) |
1007 | rxvt_term::bg_set_shade (const char *shade_str) |
991 | { |
1008 | { |
992 | int new_shade = (shade_str) ? atoi (shade_str) : 100; |
1009 | int new_shade = atoi (shade_str); |
993 | |
1010 | |
994 | clamp_it (new_shade, -100, 200); |
1011 | clamp_it (new_shade, -100, 200); |
995 | if (new_shade < 0) |
1012 | if (new_shade < 0) |
996 | new_shade = 200 - (100 + new_shade); |
1013 | new_shade = 200 - (100 + new_shade); |
997 | |
1014 | |
… | |
… | |
1031 | bool |
1048 | bool |
1032 | rxvt_term::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height) |
1049 | rxvt_term::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height) |
1033 | { |
1050 | { |
1034 | bool ret = false; |
1051 | bool ret = false; |
1035 | #if XRENDER |
1052 | #if XRENDER |
|
|
1053 | if (!(bg_flags & BG_HAS_RENDER_CONV)) |
|
|
1054 | return false; |
|
|
1055 | |
1036 | int size = max (h_blurRadius, v_blurRadius) * 2 + 1; |
1056 | int size = max (h_blurRadius, v_blurRadius) * 2 + 1; |
1037 | double *kernel = (double *)malloc (size * sizeof (double)); |
1057 | double *kernel = (double *)malloc (size * sizeof (double)); |
1038 | XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); |
1058 | XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); |
1039 | |
1059 | |
1040 | XRenderPictureAttributes pa; |
1060 | XRenderPictureAttributes pa; |
… | |
… | |
1113 | XFillRectangle (dpy, pixmap, gc, 0, 0, width, height); |
1133 | XFillRectangle (dpy, pixmap, gc, 0, 0, width, height); |
1114 | ret = true; |
1134 | ret = true; |
1115 | XFreeGC (dpy, gc); |
1135 | XFreeGC (dpy, gc); |
1116 | } |
1136 | } |
1117 | } |
1137 | } |
1118 | else |
|
|
1119 | { |
|
|
1120 | # if XRENDER |
1138 | # if XRENDER |
1121 | rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); |
1139 | else if (bg_flags & BG_HAS_RENDER) |
|
|
1140 | { |
|
|
1141 | rgba c; |
1122 | |
1142 | |
1123 | if (bg_flags & BG_TINT_SET) |
|
|
1124 | tint.get (c); |
1143 | tint.get (c); |
1125 | |
1144 | |
1126 | if (shade <= 100) |
1145 | if (shade <= 100) |
1127 | { |
1146 | { |
1128 | c.r = c.r * shade / 100; |
1147 | c.r = c.r * shade / 100; |
1129 | c.g = c.g * shade / 100; |
1148 | c.g = c.g * shade / 100; |
… | |
… | |
1134 | c.r = c.r * (200 - shade) / 100; |
1153 | c.r = c.r * (200 - shade) / 100; |
1135 | c.g = c.g * (200 - shade) / 100; |
1154 | c.g = c.g * (200 - shade) / 100; |
1136 | c.b = c.b * (200 - shade) / 100; |
1155 | c.b = c.b * (200 - shade) / 100; |
1137 | } |
1156 | } |
1138 | |
1157 | |
1139 | XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32); |
|
|
1140 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1158 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
1141 | XRenderPictureAttributes pa; |
1159 | XRenderPictureAttributes pa; |
1142 | |
1160 | |
1143 | Picture back_pic = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1161 | Picture back_pic = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); |
1144 | |
1162 | |
1145 | pa.repeat = True; |
1163 | Picture overlay_pic = create_xrender_mask (dpy, pixmap, True, False); |
1146 | |
1164 | |
1147 | Pixmap overlay_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); |
1165 | Picture mask_pic = create_xrender_mask (dpy, pixmap, True, True); |
1148 | Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); |
|
|
1149 | XFreePixmap (dpy, overlay_pmap); |
|
|
1150 | |
|
|
1151 | pa.component_alpha = True; |
|
|
1152 | Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); |
|
|
1153 | Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat | CPComponentAlpha, &pa); |
|
|
1154 | XFreePixmap (dpy, mask_pmap); |
|
|
1155 | |
1166 | |
1156 | XRenderColor mask_c; |
1167 | XRenderColor mask_c; |
1157 | |
1168 | |
1158 | mask_c.alpha = 0xffff; |
1169 | mask_c.alpha = 0xffff; |
1159 | mask_c.red = |
1170 | mask_c.red = |
… | |
… | |
1180 | ret = true; |
1191 | ret = true; |
1181 | |
1192 | |
1182 | XRenderFreePicture (dpy, mask_pic); |
1193 | XRenderFreePicture (dpy, mask_pic); |
1183 | XRenderFreePicture (dpy, overlay_pic); |
1194 | XRenderFreePicture (dpy, overlay_pic); |
1184 | XRenderFreePicture (dpy, back_pic); |
1195 | XRenderFreePicture (dpy, back_pic); |
|
|
1196 | } |
1185 | # endif |
1197 | # endif |
1186 | } |
|
|
1187 | |
1198 | |
1188 | return ret; |
1199 | return ret; |
1189 | } |
1200 | } |
1190 | |
1201 | |
1191 | /* |
1202 | /* |
… | |
… | |
1275 | bg_pmap_width = window_width; |
1286 | bg_pmap_width = window_width; |
1276 | bg_pmap_height = window_height; |
1287 | bg_pmap_height = window_height; |
1277 | } |
1288 | } |
1278 | |
1289 | |
1279 | /* straightforward pixmap copy */ |
1290 | /* straightforward pixmap copy */ |
1280 | while (sx < 0) sx += root_width; |
1291 | while (sx < 0) sx += root_pmap_width; |
1281 | while (sy < 0) sy += root_height; |
1292 | while (sy < 0) sy += root_pmap_height; |
1282 | |
1293 | |
1283 | gcv.tile = recoded_root_pmap; |
1294 | gcv.tile = recoded_root_pmap; |
1284 | gcv.fill_style = FillTiled; |
1295 | gcv.fill_style = FillTiled; |
1285 | gcv.ts_x_origin = -sx; |
1296 | gcv.ts_x_origin = -sx; |
1286 | gcv.ts_y_origin = -sy; |
1297 | gcv.ts_y_origin = -sy; |
… | |
… | |
1292 | result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS); |
1303 | result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS); |
1293 | XFreeGC (dpy, gc); |
1304 | XFreeGC (dpy, gc); |
1294 | |
1305 | |
1295 | if (!(bg_flags & BG_CLIENT_RENDER)) |
1306 | if (!(bg_flags & BG_CLIENT_RENDER)) |
1296 | { |
1307 | { |
1297 | if ((bg_flags & BG_NEEDS_BLUR) |
1308 | if (bg_flags & BG_NEEDS_BLUR) |
1298 | && (bg_flags & BG_HAS_RENDER_CONV)) |
|
|
1299 | { |
1309 | { |
1300 | if (blur_pixmap (bg_pixmap, visual, window_width, window_height)) |
1310 | if (blur_pixmap (bg_pixmap, visual, window_width, window_height)) |
1301 | result &= ~BG_NEEDS_BLUR; |
1311 | result &= ~BG_NEEDS_BLUR; |
1302 | } |
1312 | } |
1303 | if ((bg_flags & BG_NEEDS_TINT) |
1313 | if (bg_flags & BG_NEEDS_TINT) |
1304 | && (bg_flags & (BG_TINT_BITAND | BG_HAS_RENDER))) |
|
|
1305 | { |
1314 | { |
1306 | if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) |
1315 | if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) |
1307 | result &= ~BG_NEEDS_TINT; |
1316 | result &= ~BG_NEEDS_TINT; |
1308 | } |
1317 | } |
1309 | } /* server side rendering completed */ |
1318 | } /* server side rendering completed */ |
… | |
… | |
1323 | new_root_pixmap = get_pixmap_property (xa[XA_ESETROOT_PMAP_ID]); |
1332 | new_root_pixmap = get_pixmap_property (xa[XA_ESETROOT_PMAP_ID]); |
1324 | |
1333 | |
1325 | root_pixmap = new_root_pixmap; |
1334 | root_pixmap = new_root_pixmap; |
1326 | } |
1335 | } |
1327 | # endif /* ENABLE_TRANSPARENCY */ |
1336 | # endif /* ENABLE_TRANSPARENCY */ |
1328 | |
|
|
1329 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
|
|
1330 | static void shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c); |
|
|
1331 | # endif |
|
|
1332 | |
1337 | |
1333 | bool |
1338 | bool |
1334 | rxvt_term::bg_render () |
1339 | rxvt_term::bg_render () |
1335 | { |
1340 | { |
1336 | unsigned long tr_flags = 0; |
1341 | unsigned long tr_flags = 0; |
… | |
… | |
1367 | if (result) |
1372 | if (result) |
1368 | { |
1373 | { |
1369 | /* our own client-side tinting */ |
1374 | /* our own client-side tinting */ |
1370 | //if (tr_flags & BG_NEEDS_TINT) |
1375 | //if (tr_flags & BG_NEEDS_TINT) |
1371 | if (1) |
1376 | if (1) |
1372 | { |
|
|
1373 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
1374 | if (bg_flags & BG_TINT_SET) |
|
|
1375 | tint.get (c); |
|
|
1376 | shade_ximage (DefaultVisual (dpy, display->screen), result, shade, c); |
1377 | tint_ximage (DefaultVisual (dpy, display->screen), result); |
1377 | } |
|
|
1378 | |
1378 | |
1379 | GC gc = XCreateGC (dpy, vt, 0UL, NULL); |
1379 | GC gc = XCreateGC (dpy, vt, 0UL, NULL); |
1380 | |
1380 | |
1381 | if (gc) |
1381 | if (gc) |
1382 | { |
1382 | { |
… | |
… | |
1408 | |
1408 | |
1409 | void |
1409 | void |
1410 | rxvt_term::bg_init () |
1410 | rxvt_term::bg_init () |
1411 | { |
1411 | { |
1412 | #ifdef ENABLE_TRANSPARENCY |
1412 | #ifdef ENABLE_TRANSPARENCY |
|
|
1413 | rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); |
|
|
1414 | tint.set (this, c); |
1413 | shade = 100; |
1415 | shade = 100; |
1414 | #endif |
1416 | #endif |
1415 | |
1417 | |
1416 | bg_flags &= ~(BG_HAS_RENDER | BG_HAS_RENDER_CONV); |
1418 | bg_flags &= ~(BG_HAS_RENDER | BG_HAS_RENDER_CONV); |
1417 | #if XRENDER |
1419 | #if XRENDER |
… | |
… | |
1433 | #endif /* HAVE_BG_PIXMAP */ |
1435 | #endif /* HAVE_BG_PIXMAP */ |
1434 | |
1436 | |
1435 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1437 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1436 | /* based on code from aterm-0.4.2 */ |
1438 | /* based on code from aterm-0.4.2 */ |
1437 | |
1439 | |
1438 | static void |
1440 | static inline void |
1439 | shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c) |
1441 | fill_lut (uint32_t *lookup, uint32_t mask, int sh, unsigned short low, unsigned short high) |
|
|
1442 | { |
|
|
1443 | for (int i = 0; i <= mask >> sh; i++) |
|
|
1444 | { |
|
|
1445 | uint32_t tmp; |
|
|
1446 | tmp = i * high; |
|
|
1447 | tmp += (mask >> sh) * low; |
|
|
1448 | lookup[i] = (tmp / 0xffff) << sh; |
|
|
1449 | } |
|
|
1450 | } |
|
|
1451 | |
|
|
1452 | void |
|
|
1453 | rxvt_term::tint_ximage (Visual *visual, XImage *ximage) |
1440 | { |
1454 | { |
1441 | int sh_r, sh_g, sh_b; |
1455 | int sh_r, sh_g, sh_b; |
1442 | uint32_t mask_r, mask_g, mask_b; |
1456 | uint32_t mask_r, mask_g, mask_b; |
1443 | uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; |
1457 | uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; |
1444 | rgba low; |
1458 | unsigned short low; |
1445 | rgba high; |
|
|
1446 | int i; |
|
|
1447 | int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; |
1459 | int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; |
1448 | |
1460 | |
1449 | if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; |
1461 | if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; |
1450 | |
1462 | |
1451 | /* for convenience */ |
1463 | /* for convenience */ |
… | |
… | |
1510 | break; |
1522 | break; |
1511 | default: |
1523 | default: |
1512 | return; /* we do not support this color depth */ |
1524 | return; /* we do not support this color depth */ |
1513 | } |
1525 | } |
1514 | |
1526 | |
|
|
1527 | rgba c; |
|
|
1528 | |
|
|
1529 | tint.get (c); |
|
|
1530 | |
1515 | /* prepare limits for color transformation (each channel is handled separately) */ |
1531 | /* prepare limits for color transformation (each channel is handled separately) */ |
1516 | if (shade > 100) |
1532 | if (shade > 100) |
1517 | { |
1533 | { |
1518 | shade = 200 - shade; |
|
|
1519 | |
|
|
1520 | high.r = c.r * shade / 100; |
|
|
1521 | high.g = c.g * shade / 100; |
|
|
1522 | high.b = c.b * shade / 100; |
|
|
1523 | |
|
|
1524 | low.r = 65535 * (100 - shade) / 100; |
1534 | c.r = c.r * (200 - shade) / 100; |
1525 | low.g = 65535 * (100 - shade) / 100; |
1535 | c.g = c.g * (200 - shade) / 100; |
1526 | low.b = 65535 * (100 - shade) / 100; |
1536 | c.b = c.b * (200 - shade) / 100; |
|
|
1537 | |
|
|
1538 | low = 0xffff * (shade - 100) / 100; |
1527 | } |
1539 | } |
1528 | else |
1540 | else |
1529 | { |
1541 | { |
1530 | high.r = c.r * shade / 100; |
1542 | c.r = c.r * shade / 100; |
1531 | high.g = c.g * shade / 100; |
1543 | c.g = c.g * shade / 100; |
1532 | high.b = c.b * shade / 100; |
1544 | c.b = c.b * shade / 100; |
1533 | |
1545 | |
1534 | low.r = low.g = low.b = 0; |
1546 | low = 0; |
1535 | } |
1547 | } |
1536 | |
1548 | |
1537 | /* fill our lookup tables */ |
1549 | /* fill our lookup tables */ |
1538 | for (i = 0; i <= mask_r>>sh_r; i++) |
1550 | fill_lut (lookup_r, mask_r, sh_r, low, c.r); |
1539 | { |
1551 | fill_lut (lookup_g, mask_g, sh_g, low, c.g); |
1540 | uint32_t tmp; |
1552 | fill_lut (lookup_b, mask_b, sh_b, low, c.b); |
1541 | tmp = i * high.r; |
|
|
1542 | tmp += (mask_r>>sh_r) * low.r; |
|
|
1543 | lookup_r[i] = (tmp/65535)<<sh_r; |
|
|
1544 | } |
|
|
1545 | for (i = 0; i <= mask_g>>sh_g; i++) |
|
|
1546 | { |
|
|
1547 | uint32_t tmp; |
|
|
1548 | tmp = i * high.g; |
|
|
1549 | tmp += (mask_g>>sh_g) * low.g; |
|
|
1550 | lookup_g[i] = (tmp/65535)<<sh_g; |
|
|
1551 | } |
|
|
1552 | for (i = 0; i <= mask_b>>sh_b; i++) |
|
|
1553 | { |
|
|
1554 | uint32_t tmp; |
|
|
1555 | tmp = i * high.b; |
|
|
1556 | tmp += (mask_b>>sh_b) * low.b; |
|
|
1557 | lookup_b[i] = (tmp/65535)<<sh_b; |
|
|
1558 | } |
|
|
1559 | |
1553 | |
1560 | /* apply table to input image (replacing colors by newly calculated ones) */ |
1554 | /* apply table to input image (replacing colors by newly calculated ones) */ |
1561 | if (ximage->bits_per_pixel == 32 |
1555 | if (ximage->bits_per_pixel == 32 |
1562 | && (ximage->depth == 24 || ximage->depth == 32) |
1556 | && (ximage->depth == 24 || ximage->depth == 32) |
1563 | && ximage->byte_order == host_byte_order) |
1557 | && ximage->byte_order == host_byte_order) |