… | |
… | |
201 | x = y = 0; |
201 | x = y = 0; |
202 | geom_flags = WidthValue|HeightValue|XValue|YValue; |
202 | geom_flags = WidthValue|HeightValue|XValue|YValue; |
203 | } |
203 | } |
204 | else if (!strcasecmp (arr[i], "style=aspect-stretched")) |
204 | else if (!strcasecmp (arr[i], "style=aspect-stretched")) |
205 | { |
205 | { |
206 | new_flags = BG_PROP_SCALE; |
206 | new_flags = BG_KEEP_ASPECT; |
207 | w = h = windowScale; |
207 | w = h = windowScale; |
208 | x = y = centerAlign; |
208 | x = y = centerAlign; |
209 | geom_flags = WidthValue|HeightValue|XValue|YValue; |
209 | geom_flags = WidthValue|HeightValue|XValue|YValue; |
210 | } |
210 | } |
211 | else if (!strcasecmp (arr[i], "style=stretched")) |
211 | else if (!strcasecmp (arr[i], "style=stretched")) |
… | |
… | |
227 | w = h = noScale; |
227 | w = h = noScale; |
228 | geom_flags = WidthValue|HeightValue; |
228 | geom_flags = WidthValue|HeightValue; |
229 | } |
229 | } |
230 | else if (!strcasecmp (arr[i], "op=tile")) |
230 | else if (!strcasecmp (arr[i], "op=tile")) |
231 | new_flags |= BG_TILE; |
231 | new_flags |= BG_TILE; |
232 | else if (!strcasecmp (arr[i], "op=pscale")) |
232 | else if (!strcasecmp (arr[i], "op=keep-aspect")) |
233 | new_flags |= BG_PROP_SCALE; |
233 | new_flags |= BG_KEEP_ASPECT; |
234 | else if (!strcasecmp (arr[i], "op=root")) |
234 | else if (!strcasecmp (arr[i], "op=root-align")) |
235 | new_flags |= BG_ROOT_ALIGN; |
235 | new_flags |= BG_ROOT_ALIGN; |
236 | |
236 | |
237 | // deprecated |
237 | // deprecated |
238 | else if (!strcasecmp (arr[i], "tile")) |
238 | else if (!strcasecmp (arr[i], "tile")) |
239 | { |
239 | { |
… | |
… | |
241 | w = h = noScale; |
241 | w = h = noScale; |
242 | geom_flags |= WidthValue|HeightValue; |
242 | geom_flags |= WidthValue|HeightValue; |
243 | } |
243 | } |
244 | else if (!strcasecmp (arr[i], "propscale")) |
244 | else if (!strcasecmp (arr[i], "propscale")) |
245 | { |
245 | { |
246 | new_flags |= BG_PROP_SCALE; |
246 | new_flags |= BG_KEEP_ASPECT; |
|
|
247 | w = h = windowScale; |
|
|
248 | geom_flags |= WidthValue|HeightValue; |
247 | } |
249 | } |
248 | else if (!strcasecmp (arr[i], "hscale")) |
250 | else if (!strcasecmp (arr[i], "hscale")) |
249 | { |
251 | { |
250 | new_flags |= BG_TILE; |
252 | new_flags |= BG_TILE; |
251 | w = windowScale; |
253 | w = windowScale; |
… | |
… | |
299 | w = h; |
301 | w = h; |
300 | |
302 | |
301 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
303 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
302 | } |
304 | } |
303 | |
305 | |
304 | if (check_set_scale_value (geom_flags, WidthValue, h_scale, w) |
306 | if (check_set_scale_value (geom_flags, WidthValue, h_scale, w)) changed = true; |
305 | || check_set_scale_value (geom_flags, HeightValue, v_scale, h) |
307 | if (check_set_scale_value (geom_flags, HeightValue, v_scale, h)) changed = true; |
306 | || check_set_align_value (geom_flags, XValue, h_align, x) |
308 | if (check_set_align_value (geom_flags, XValue, h_align, x)) changed = true; |
307 | || check_set_align_value (geom_flags, YValue, v_align, y)) |
309 | if (check_set_align_value (geom_flags, YValue, v_align, y)) changed = true; |
308 | changed = true; |
|
|
309 | |
310 | |
310 | if (new_flags != bg_flags) |
311 | if (new_flags != bg_flags) |
311 | { |
312 | { |
312 | bg_flags = new_flags; |
313 | bg_flags = new_flags; |
313 | changed = true; |
314 | changed = true; |
… | |
… | |
323 | int target_height = szHint.height; |
324 | int target_height = szHint.height; |
324 | |
325 | |
325 | w = h_scale * target_width / 100; |
326 | w = h_scale * target_width / 100; |
326 | h = v_scale * target_height / 100; |
327 | h = v_scale * target_height / 100; |
327 | |
328 | |
328 | if (bg_flags & BG_PROP_SCALE) |
329 | if (bg_flags & BG_KEEP_ASPECT) |
329 | { |
330 | { |
330 | float scale = (float)w / image_width; |
331 | float scale = (float)w / image_width; |
331 | min_it (scale, (float)h / image_height); |
332 | min_it (scale, (float)h / image_height); |
332 | w = image_width * scale + 0.5; |
333 | w = image_width * scale + 0.5; |
333 | h = image_height * scale + 0.5; |
334 | h = image_height * scale + 0.5; |
… | |
… | |
952 | } |
953 | } |
953 | |
954 | |
954 | void |
955 | void |
955 | rxvt_term::set_tint_shade_flags () |
956 | rxvt_term::set_tint_shade_flags () |
956 | { |
957 | { |
957 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
958 | rgba c; |
958 | bool has_shade = shade != 100; |
959 | bool has_shade = shade != 100; |
959 | |
960 | |
960 | bg_flags &= ~BG_TINT_FLAGS; |
961 | bg_flags &= ~BG_TINT_FLAGS; |
961 | |
962 | |
962 | if (bg_flags & BG_TINT_SET) |
963 | if (bg_flags & BG_TINT_SET) |
… | |
… | |
1032 | bool |
1033 | bool |
1033 | rxvt_term::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height) |
1034 | rxvt_term::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height) |
1034 | { |
1035 | { |
1035 | bool ret = false; |
1036 | bool ret = false; |
1036 | #if XRENDER |
1037 | #if XRENDER |
|
|
1038 | if (!(bg_flags & BG_HAS_RENDER_CONV)) |
|
|
1039 | return false; |
|
|
1040 | |
1037 | int size = max (h_blurRadius, v_blurRadius) * 2 + 1; |
1041 | int size = max (h_blurRadius, v_blurRadius) * 2 + 1; |
1038 | double *kernel = (double *)malloc (size * sizeof (double)); |
1042 | double *kernel = (double *)malloc (size * sizeof (double)); |
1039 | XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); |
1043 | XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); |
1040 | |
1044 | |
1041 | XRenderPictureAttributes pa; |
1045 | XRenderPictureAttributes pa; |
… | |
… | |
1114 | XFillRectangle (dpy, pixmap, gc, 0, 0, width, height); |
1118 | XFillRectangle (dpy, pixmap, gc, 0, 0, width, height); |
1115 | ret = true; |
1119 | ret = true; |
1116 | XFreeGC (dpy, gc); |
1120 | XFreeGC (dpy, gc); |
1117 | } |
1121 | } |
1118 | } |
1122 | } |
1119 | else |
|
|
1120 | { |
|
|
1121 | # if XRENDER |
1123 | # if XRENDER |
|
|
1124 | else if (bg_flags & BG_HAS_RENDER) |
|
|
1125 | { |
1122 | rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); |
1126 | rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); |
1123 | |
1127 | |
1124 | if (bg_flags & BG_TINT_SET) |
1128 | if (bg_flags & BG_TINT_SET) |
1125 | tint.get (c); |
1129 | tint.get (c); |
1126 | |
1130 | |
… | |
… | |
1181 | ret = true; |
1185 | ret = true; |
1182 | |
1186 | |
1183 | XRenderFreePicture (dpy, mask_pic); |
1187 | XRenderFreePicture (dpy, mask_pic); |
1184 | XRenderFreePicture (dpy, overlay_pic); |
1188 | XRenderFreePicture (dpy, overlay_pic); |
1185 | XRenderFreePicture (dpy, back_pic); |
1189 | XRenderFreePicture (dpy, back_pic); |
|
|
1190 | } |
1186 | # endif |
1191 | # endif |
1187 | } |
|
|
1188 | |
1192 | |
1189 | return ret; |
1193 | return ret; |
1190 | } |
1194 | } |
1191 | |
1195 | |
1192 | /* |
1196 | /* |
… | |
… | |
1276 | bg_pmap_width = window_width; |
1280 | bg_pmap_width = window_width; |
1277 | bg_pmap_height = window_height; |
1281 | bg_pmap_height = window_height; |
1278 | } |
1282 | } |
1279 | |
1283 | |
1280 | /* straightforward pixmap copy */ |
1284 | /* straightforward pixmap copy */ |
1281 | while (sx < 0) sx += root_width; |
1285 | while (sx < 0) sx += root_pmap_width; |
1282 | while (sy < 0) sy += root_height; |
1286 | while (sy < 0) sy += root_pmap_height; |
1283 | |
1287 | |
1284 | gcv.tile = recoded_root_pmap; |
1288 | gcv.tile = recoded_root_pmap; |
1285 | gcv.fill_style = FillTiled; |
1289 | gcv.fill_style = FillTiled; |
1286 | gcv.ts_x_origin = -sx; |
1290 | gcv.ts_x_origin = -sx; |
1287 | gcv.ts_y_origin = -sy; |
1291 | gcv.ts_y_origin = -sy; |
… | |
… | |
1293 | result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS); |
1297 | result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS); |
1294 | XFreeGC (dpy, gc); |
1298 | XFreeGC (dpy, gc); |
1295 | |
1299 | |
1296 | if (!(bg_flags & BG_CLIENT_RENDER)) |
1300 | if (!(bg_flags & BG_CLIENT_RENDER)) |
1297 | { |
1301 | { |
1298 | if ((bg_flags & BG_NEEDS_BLUR) |
1302 | if (bg_flags & BG_NEEDS_BLUR) |
1299 | && (bg_flags & BG_HAS_RENDER_CONV)) |
|
|
1300 | { |
1303 | { |
1301 | if (blur_pixmap (bg_pixmap, visual, window_width, window_height)) |
1304 | if (blur_pixmap (bg_pixmap, visual, window_width, window_height)) |
1302 | result &= ~BG_NEEDS_BLUR; |
1305 | result &= ~BG_NEEDS_BLUR; |
1303 | } |
1306 | } |
1304 | if ((bg_flags & BG_NEEDS_TINT) |
1307 | if (bg_flags & BG_NEEDS_TINT) |
1305 | && (bg_flags & (BG_TINT_BITAND | BG_HAS_RENDER))) |
|
|
1306 | { |
1308 | { |
1307 | if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) |
1309 | if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) |
1308 | result &= ~BG_NEEDS_TINT; |
1310 | result &= ~BG_NEEDS_TINT; |
1309 | } |
1311 | } |
1310 | } /* server side rendering completed */ |
1312 | } /* server side rendering completed */ |
… | |
… | |
1324 | new_root_pixmap = get_pixmap_property (xa[XA_ESETROOT_PMAP_ID]); |
1326 | new_root_pixmap = get_pixmap_property (xa[XA_ESETROOT_PMAP_ID]); |
1325 | |
1327 | |
1326 | root_pixmap = new_root_pixmap; |
1328 | root_pixmap = new_root_pixmap; |
1327 | } |
1329 | } |
1328 | # endif /* ENABLE_TRANSPARENCY */ |
1330 | # endif /* ENABLE_TRANSPARENCY */ |
1329 | |
|
|
1330 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
|
|
1331 | static void shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c); |
|
|
1332 | # endif |
|
|
1333 | |
1331 | |
1334 | bool |
1332 | bool |
1335 | rxvt_term::bg_render () |
1333 | rxvt_term::bg_render () |
1336 | { |
1334 | { |
1337 | unsigned long tr_flags = 0; |
1335 | unsigned long tr_flags = 0; |
… | |
… | |
1368 | if (result) |
1366 | if (result) |
1369 | { |
1367 | { |
1370 | /* our own client-side tinting */ |
1368 | /* our own client-side tinting */ |
1371 | //if (tr_flags & BG_NEEDS_TINT) |
1369 | //if (tr_flags & BG_NEEDS_TINT) |
1372 | if (1) |
1370 | if (1) |
1373 | { |
|
|
1374 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
1375 | if (bg_flags & BG_TINT_SET) |
|
|
1376 | tint.get (c); |
|
|
1377 | shade_ximage (DefaultVisual (dpy, display->screen), result, shade, c); |
1371 | tint_ximage (DefaultVisual (dpy, display->screen), result); |
1378 | } |
|
|
1379 | |
1372 | |
1380 | GC gc = XCreateGC (dpy, vt, 0UL, NULL); |
1373 | GC gc = XCreateGC (dpy, vt, 0UL, NULL); |
1381 | |
1374 | |
1382 | if (gc) |
1375 | if (gc) |
1383 | { |
1376 | { |
… | |
… | |
1434 | #endif /* HAVE_BG_PIXMAP */ |
1427 | #endif /* HAVE_BG_PIXMAP */ |
1435 | |
1428 | |
1436 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1429 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1437 | /* based on code from aterm-0.4.2 */ |
1430 | /* based on code from aterm-0.4.2 */ |
1438 | |
1431 | |
1439 | static void |
1432 | static inline void |
1440 | shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c) |
1433 | fill_lut (uint32_t *lookup, uint32_t mask, int sh, unsigned short low, unsigned short high) |
|
|
1434 | { |
|
|
1435 | for (int i = 0; i <= mask >> sh; i++) |
|
|
1436 | { |
|
|
1437 | uint32_t tmp; |
|
|
1438 | tmp = i * high; |
|
|
1439 | tmp += (mask >> sh) * low; |
|
|
1440 | lookup[i] = (tmp / 0xffff) << sh; |
|
|
1441 | } |
|
|
1442 | } |
|
|
1443 | |
|
|
1444 | void |
|
|
1445 | rxvt_term::tint_ximage (Visual *visual, XImage *ximage) |
1441 | { |
1446 | { |
1442 | int sh_r, sh_g, sh_b; |
1447 | int sh_r, sh_g, sh_b; |
1443 | uint32_t mask_r, mask_g, mask_b; |
1448 | uint32_t mask_r, mask_g, mask_b; |
1444 | uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; |
1449 | uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; |
1445 | rgba low; |
1450 | unsigned short low; |
1446 | rgba high; |
|
|
1447 | int i; |
|
|
1448 | int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; |
1451 | int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; |
1449 | |
1452 | |
1450 | if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; |
1453 | if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; |
1451 | |
1454 | |
1452 | /* for convenience */ |
1455 | /* for convenience */ |
… | |
… | |
1511 | break; |
1514 | break; |
1512 | default: |
1515 | default: |
1513 | return; /* we do not support this color depth */ |
1516 | return; /* we do not support this color depth */ |
1514 | } |
1517 | } |
1515 | |
1518 | |
|
|
1519 | rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); |
|
|
1520 | |
|
|
1521 | if (bg_flags & BG_TINT_SET) |
|
|
1522 | tint.get (c); |
|
|
1523 | |
1516 | /* prepare limits for color transformation (each channel is handled separately) */ |
1524 | /* prepare limits for color transformation (each channel is handled separately) */ |
1517 | if (shade > 100) |
1525 | if (shade > 100) |
1518 | { |
1526 | { |
1519 | shade = 200 - shade; |
|
|
1520 | |
|
|
1521 | high.r = c.r * shade / 100; |
|
|
1522 | high.g = c.g * shade / 100; |
|
|
1523 | high.b = c.b * shade / 100; |
|
|
1524 | |
|
|
1525 | low.r = 65535 * (100 - shade) / 100; |
1527 | c.r = c.r * (200 - shade) / 100; |
1526 | low.g = 65535 * (100 - shade) / 100; |
1528 | c.g = c.g * (200 - shade) / 100; |
1527 | low.b = 65535 * (100 - shade) / 100; |
1529 | c.b = c.b * (200 - shade) / 100; |
|
|
1530 | |
|
|
1531 | low = 0xffff * (shade - 100) / 100; |
1528 | } |
1532 | } |
1529 | else |
1533 | else |
1530 | { |
1534 | { |
1531 | high.r = c.r * shade / 100; |
1535 | c.r = c.r * shade / 100; |
1532 | high.g = c.g * shade / 100; |
1536 | c.g = c.g * shade / 100; |
1533 | high.b = c.b * shade / 100; |
1537 | c.b = c.b * shade / 100; |
1534 | |
1538 | |
1535 | low.r = low.g = low.b = 0; |
1539 | low = 0; |
1536 | } |
1540 | } |
1537 | |
1541 | |
1538 | /* fill our lookup tables */ |
1542 | /* fill our lookup tables */ |
1539 | for (i = 0; i <= mask_r>>sh_r; i++) |
1543 | fill_lut (lookup_r, mask_r, sh_r, low, c.r); |
1540 | { |
1544 | fill_lut (lookup_g, mask_g, sh_g, low, c.g); |
1541 | uint32_t tmp; |
1545 | fill_lut (lookup_b, mask_b, sh_b, low, c.b); |
1542 | tmp = i * high.r; |
|
|
1543 | tmp += (mask_r>>sh_r) * low.r; |
|
|
1544 | lookup_r[i] = (tmp/65535)<<sh_r; |
|
|
1545 | } |
|
|
1546 | for (i = 0; i <= mask_g>>sh_g; i++) |
|
|
1547 | { |
|
|
1548 | uint32_t tmp; |
|
|
1549 | tmp = i * high.g; |
|
|
1550 | tmp += (mask_g>>sh_g) * low.g; |
|
|
1551 | lookup_g[i] = (tmp/65535)<<sh_g; |
|
|
1552 | } |
|
|
1553 | for (i = 0; i <= mask_b>>sh_b; i++) |
|
|
1554 | { |
|
|
1555 | uint32_t tmp; |
|
|
1556 | tmp = i * high.b; |
|
|
1557 | tmp += (mask_b>>sh_b) * low.b; |
|
|
1558 | lookup_b[i] = (tmp/65535)<<sh_b; |
|
|
1559 | } |
|
|
1560 | |
1546 | |
1561 | /* apply table to input image (replacing colors by newly calculated ones) */ |
1547 | /* apply table to input image (replacing colors by newly calculated ones) */ |
1562 | if (ximage->bits_per_pixel == 32 |
1548 | if (ximage->bits_per_pixel == 32 |
1563 | && (ximage->depth == 24 || ximage->depth == 32) |
1549 | && (ximage->depth == 24 || ximage->depth == 32) |
1564 | && ximage->byte_order == host_byte_order) |
1550 | && ximage->byte_order == host_byte_order) |