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.178 by mikachu, Sat Dec 17 01:05:09 2011 UTC vs.
Revision 1.179 by sf-exg, Sat Dec 24 09:44:10 2011 UTC

1435#endif /* HAVE_BG_PIXMAP */ 1435#endif /* HAVE_BG_PIXMAP */
1436 1436
1437#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) 1437#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE)
1438/* based on code from aterm-0.4.2 */ 1438/* based on code from aterm-0.4.2 */
1439 1439
1440static inline void
1441fill_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
1440static void 1452static void
1441shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c) 1453shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c)
1442{ 1454{
1443 int sh_r, sh_g, sh_b; 1455 int sh_r, sh_g, sh_b;
1444 uint32_t mask_r, mask_g, mask_b; 1456 uint32_t mask_r, mask_g, mask_b;
1445 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; 1457 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b;
1446 rgba low; 1458 rgba low;
1447 rgba high; 1459 rgba high;
1448 int i;
1449 int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst; 1460 int host_byte_order = ecb_big_endian () ? MSBFirst : LSBFirst;
1450 1461
1451 if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; 1462 if (visual->c_class != TrueColor || ximage->format != ZPixmap) return;
1452 1463
1453 /* for convenience */ 1464 /* for convenience */
1535 1546
1536 low.r = low.g = low.b = 0; 1547 low.r = low.g = low.b = 0;
1537 } 1548 }
1538 1549
1539 /* fill our lookup tables */ 1550 /* fill our lookup tables */
1540 for (i = 0; i <= mask_r>>sh_r; i++) 1551 fill_lut (lookup_r, mask_r, sh_r, low.r, high.r);
1541 { 1552 fill_lut (lookup_g, mask_g, sh_g, low.g, high.g);
1542 uint32_t tmp; 1553 fill_lut (lookup_b, mask_b, sh_b, low.b, 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 1554
1562 /* apply table to input image (replacing colors by newly calculated ones) */ 1555 /* apply table to input image (replacing colors by newly calculated ones) */
1563 if (ximage->bits_per_pixel == 32 1556 if (ximage->bits_per_pixel == 32
1564 && (ximage->depth == 24 || ximage->depth == 32) 1557 && (ximage->depth == 24 || ximage->depth == 32)
1565 && ximage->byte_order == host_byte_order) 1558 && ximage->byte_order == host_byte_order)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines