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.177 by sf-exg, Wed Dec 14 12:07:12 2011 UTC vs.
Revision 1.183 by sf-exg, Sun Dec 25 17:05:53 2011 UTC

953} 953}
954 954
955void 955void
956rxvt_term::set_tint_shade_flags () 956rxvt_term::set_tint_shade_flags ()
957{ 957{
958 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 958 rgba c;
959 bool has_shade = shade != 100; 959 bool has_shade = shade != 100;
960 960
961 bg_flags &= ~BG_TINT_FLAGS; 961 bg_flags &= ~BG_TINT_FLAGS;
962 962
963 if (bg_flags & BG_TINT_SET) 963 if (bg_flags & BG_TINT_SET)
1033bool 1033bool
1034rxvt_term::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height) 1034rxvt_term::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height)
1035{ 1035{
1036 bool ret = false; 1036 bool ret = false;
1037#if XRENDER 1037#if XRENDER
1038 if (!(bg_flags & BG_HAS_RENDER_CONV))
1039 return false;
1040
1038 int size = max (h_blurRadius, v_blurRadius) * 2 + 1; 1041 int size = max (h_blurRadius, v_blurRadius) * 2 + 1;
1039 double *kernel = (double *)malloc (size * sizeof (double)); 1042 double *kernel = (double *)malloc (size * sizeof (double));
1040 XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); 1043 XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed));
1041 1044
1042 XRenderPictureAttributes pa; 1045 XRenderPictureAttributes pa;
1115 XFillRectangle (dpy, pixmap, gc, 0, 0, width, height); 1118 XFillRectangle (dpy, pixmap, gc, 0, 0, width, height);
1116 ret = true; 1119 ret = true;
1117 XFreeGC (dpy, gc); 1120 XFreeGC (dpy, gc);
1118 } 1121 }
1119 } 1122 }
1120 else
1121 {
1122# if XRENDER 1123# if XRENDER
1124 else if (bg_flags & BG_HAS_RENDER)
1125 {
1123 rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); 1126 rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC);
1124 1127
1125 if (bg_flags & BG_TINT_SET) 1128 if (bg_flags & BG_TINT_SET)
1126 tint.get (c); 1129 tint.get (c);
1127 1130
1182 ret = true; 1185 ret = true;
1183 1186
1184 XRenderFreePicture (dpy, mask_pic); 1187 XRenderFreePicture (dpy, mask_pic);
1185 XRenderFreePicture (dpy, overlay_pic); 1188 XRenderFreePicture (dpy, overlay_pic);
1186 XRenderFreePicture (dpy, back_pic); 1189 XRenderFreePicture (dpy, back_pic);
1190 }
1187# endif 1191# endif
1188 }
1189 1192
1190 return ret; 1193 return ret;
1191} 1194}
1192 1195
1193/* 1196/*
1277 bg_pmap_width = window_width; 1280 bg_pmap_width = window_width;
1278 bg_pmap_height = window_height; 1281 bg_pmap_height = window_height;
1279 } 1282 }
1280 1283
1281 /* straightforward pixmap copy */ 1284 /* straightforward pixmap copy */
1282 while (sx < 0) sx += root_width; 1285 while (sx < 0) sx += root_pmap_width;
1283 while (sy < 0) sy += root_height; 1286 while (sy < 0) sy += root_pmap_height;
1284 1287
1285 gcv.tile = recoded_root_pmap; 1288 gcv.tile = recoded_root_pmap;
1286 gcv.fill_style = FillTiled; 1289 gcv.fill_style = FillTiled;
1287 gcv.ts_x_origin = -sx; 1290 gcv.ts_x_origin = -sx;
1288 gcv.ts_y_origin = -sy; 1291 gcv.ts_y_origin = -sy;
1294 result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS); 1297 result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS);
1295 XFreeGC (dpy, gc); 1298 XFreeGC (dpy, gc);
1296 1299
1297 if (!(bg_flags & BG_CLIENT_RENDER)) 1300 if (!(bg_flags & BG_CLIENT_RENDER))
1298 { 1301 {
1299 if ((bg_flags & BG_NEEDS_BLUR) 1302 if (bg_flags & BG_NEEDS_BLUR)
1300 && (bg_flags & BG_HAS_RENDER_CONV))
1301 { 1303 {
1302 if (blur_pixmap (bg_pixmap, visual, window_width, window_height)) 1304 if (blur_pixmap (bg_pixmap, visual, window_width, window_height))
1303 result &= ~BG_NEEDS_BLUR; 1305 result &= ~BG_NEEDS_BLUR;
1304 } 1306 }
1305 if ((bg_flags & BG_NEEDS_TINT) 1307 if (bg_flags & BG_NEEDS_TINT)
1306 && (bg_flags & (BG_TINT_BITAND | BG_HAS_RENDER)))
1307 { 1308 {
1308 if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) 1309 if (tint_pixmap (bg_pixmap, visual, window_width, window_height))
1309 result &= ~BG_NEEDS_TINT; 1310 result &= ~BG_NEEDS_TINT;
1310 } 1311 }
1311 } /* server side rendering completed */ 1312 } /* server side rendering completed */
1325 new_root_pixmap = get_pixmap_property (xa[XA_ESETROOT_PMAP_ID]); 1326 new_root_pixmap = get_pixmap_property (xa[XA_ESETROOT_PMAP_ID]);
1326 1327
1327 root_pixmap = new_root_pixmap; 1328 root_pixmap = new_root_pixmap;
1328} 1329}
1329# endif /* ENABLE_TRANSPARENCY */ 1330# endif /* ENABLE_TRANSPARENCY */
1330
1331#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE)
1332static void shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c);
1333# endif
1334 1331
1335bool 1332bool
1336rxvt_term::bg_render () 1333rxvt_term::bg_render ()
1337{ 1334{
1338 unsigned long tr_flags = 0; 1335 unsigned long tr_flags = 0;
1369 if (result) 1366 if (result)
1370 { 1367 {
1371 /* our own client-side tinting */ 1368 /* our own client-side tinting */
1372 //if (tr_flags & BG_NEEDS_TINT) 1369 //if (tr_flags & BG_NEEDS_TINT)
1373 if (1) 1370 if (1)
1374 {
1375 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
1376 if (bg_flags & BG_TINT_SET)
1377 tint.get (c);
1378 shade_ximage (DefaultVisual (dpy, display->screen), result, shade, c); 1371 tint_ximage (DefaultVisual (dpy, display->screen), result);
1379 }
1380 1372
1381 GC gc = XCreateGC (dpy, vt, 0UL, NULL); 1373 GC gc = XCreateGC (dpy, vt, 0UL, NULL);
1382 1374
1383 if (gc) 1375 if (gc)
1384 { 1376 {
1435#endif /* HAVE_BG_PIXMAP */ 1427#endif /* HAVE_BG_PIXMAP */
1436 1428
1437#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) 1429#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE)
1438/* based on code from aterm-0.4.2 */ 1430/* based on code from aterm-0.4.2 */
1439 1431
1440static void 1432static inline void
1441shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c) 1433fill_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
1444void
1445rxvt_term::tint_ximage (Visual *visual, XImage *ximage)
1442{ 1446{
1443 int sh_r, sh_g, sh_b; 1447 int sh_r, sh_g, sh_b;
1444 uint32_t mask_r, mask_g, mask_b; 1448 uint32_t mask_r, mask_g, mask_b;
1445 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; 1449 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b;
1446 rgba low; 1450 unsigned short low;
1447 rgba high; 1451 rgba high;
1448 int i;
1449 int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; 1452 int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst;
1450 1453
1451 if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; 1454 if (visual->c_class != TrueColor || ximage->format != ZPixmap) return;
1452 1455
1453 /* for convenience */ 1456 /* for convenience */
1512 break; 1515 break;
1513 default: 1516 default:
1514 return; /* we do not support this color depth */ 1517 return; /* we do not support this color depth */
1515 } 1518 }
1516 1519
1520 rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC);
1521
1522 if (bg_flags & BG_TINT_SET)
1523 tint.get (c);
1524
1517 /* prepare limits for color transformation (each channel is handled separately) */ 1525 /* prepare limits for color transformation (each channel is handled separately) */
1518 if (shade > 100) 1526 if (shade > 100)
1519 { 1527 {
1520 shade = 200 - shade; 1528 high.r = c.r * (200 - shade) / 100;
1529 high.g = c.g * (200 - shade) / 100;
1530 high.b = c.b * (200 - shade) / 100;
1521 1531
1532 low = 0xffff * (shade - 100) / 100;
1533 }
1534 else
1535 {
1522 high.r = c.r * shade / 100; 1536 high.r = c.r * shade / 100;
1523 high.g = c.g * shade / 100; 1537 high.g = c.g * shade / 100;
1524 high.b = c.b * shade / 100; 1538 high.b = c.b * shade / 100;
1525 1539
1526 low.r = 65535 * (100 - shade) / 100; 1540 low = 0;
1527 low.g = 65535 * (100 - shade) / 100;
1528 low.b = 65535 * (100 - shade) / 100;
1529 }
1530 else
1531 {
1532 high.r = c.r * shade / 100;
1533 high.g = c.g * shade / 100;
1534 high.b = c.b * shade / 100;
1535
1536 low.r = low.g = low.b = 0;
1537 } 1541 }
1538 1542
1539 /* fill our lookup tables */ 1543 /* fill our lookup tables */
1540 for (i = 0; i <= mask_r>>sh_r; i++) 1544 fill_lut (lookup_r, mask_r, sh_r, low, high.r);
1541 { 1545 fill_lut (lookup_g, mask_g, sh_g, low, high.g);
1542 uint32_t tmp; 1546 fill_lut (lookup_b, mask_b, sh_b, low, high.b);
1543 tmp = i * high.r;
1544 tmp += (mask_r>>sh_r) * low.r;
1545 lookup_r[i] = (tmp/65535)<<sh_r;
1546 }
1547 for (i = 0; i <= mask_g>>sh_g; i++)
1548 {
1549 uint32_t tmp;
1550 tmp = i * high.g;
1551 tmp += (mask_g>>sh_g) * low.g;
1552 lookup_g[i] = (tmp/65535)<<sh_g;
1553 }
1554 for (i = 0; i <= mask_b>>sh_b; i++)
1555 {
1556 uint32_t tmp;
1557 tmp = i * high.b;
1558 tmp += (mask_b>>sh_b) * low.b;
1559 lookup_b[i] = (tmp/65535)<<sh_b;
1560 }
1561 1547
1562 /* apply table to input image (replacing colors by newly calculated ones) */ 1548 /* apply table to input image (replacing colors by newly calculated ones) */
1563 if (ximage->bits_per_pixel == 32 1549 if (ximage->bits_per_pixel == 32
1564 && (ximage->depth == 24 || ximage->depth == 32) 1550 && (ximage->depth == 24 || ximage->depth == 32)
1565 && ximage->byte_order == host_byte_order) 1551 && ximage->byte_order == host_byte_order)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines