… | |
… | |
1341 | root_pixmap = new_root_pixmap; |
1341 | root_pixmap = new_root_pixmap; |
1342 | } |
1342 | } |
1343 | # endif /* ENABLE_TRANSPARENCY */ |
1343 | # endif /* ENABLE_TRANSPARENCY */ |
1344 | |
1344 | |
1345 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1345 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1346 | static void ShadeXImage(Visual *visual, XImage *srcImage, int shade, const rgba &c); |
1346 | static void shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c); |
1347 | # endif |
1347 | # endif |
1348 | |
1348 | |
1349 | bool |
1349 | bool |
1350 | bgPixmap_t::render () |
1350 | bgPixmap_t::render () |
1351 | { |
1351 | { |
… | |
… | |
1390 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1390 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1391 | { |
1391 | { |
1392 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1392 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1393 | if (flags & tintSet) |
1393 | if (flags & tintSet) |
1394 | tint.get (c); |
1394 | tint.get (c); |
1395 | ShadeXImage (DefaultVisual (target->dpy, target->display->screen), result, shade, c); |
1395 | shade_ximage (DefaultVisual (target->dpy, target->display->screen), result, shade, c); |
1396 | } |
1396 | } |
1397 | |
1397 | |
1398 | GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); |
1398 | GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); |
1399 | |
1399 | |
1400 | if (gc) |
1400 | if (gc) |
… | |
… | |
1505 | |
1505 | |
1506 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1506 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1507 | /* taken from aterm-0.4.2 */ |
1507 | /* taken from aterm-0.4.2 */ |
1508 | |
1508 | |
1509 | static void |
1509 | static void |
1510 | ShadeXImage(Visual *visual, XImage *srcImage, int shade, const rgba &c) |
1510 | shade_ximage (Visual *visual, XImage *ximage, int shade, const rgba &c) |
1511 | { |
1511 | { |
1512 | int sh_r, sh_g, sh_b; |
1512 | int sh_r, sh_g, sh_b; |
1513 | uint32_t mask_r, mask_g, mask_b; |
1513 | uint32_t mask_r, mask_g, mask_b; |
1514 | uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; |
1514 | uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; |
1515 | rgba low; |
1515 | rgba low; |
1516 | rgba high; |
1516 | rgba high; |
1517 | int i; |
1517 | int i; |
1518 | int host_byte_order = byteorder.big_endian () ? MSBFirst : LSBFirst; |
1518 | int host_byte_order = byteorder.big_endian () ? MSBFirst : LSBFirst; |
1519 | |
1519 | |
1520 | if (visual->c_class != TrueColor || srcImage->format != ZPixmap) return; |
1520 | if (visual->c_class != TrueColor || ximage->format != ZPixmap) return; |
1521 | |
1521 | |
1522 | /* for convenience */ |
1522 | /* for convenience */ |
1523 | mask_r = visual->red_mask; |
1523 | mask_r = visual->red_mask; |
1524 | mask_g = visual->green_mask; |
1524 | mask_g = visual->green_mask; |
1525 | mask_b = visual->blue_mask; |
1525 | mask_b = visual->blue_mask; |
1526 | |
1526 | |
1527 | /* boring lookup table pre-initialization */ |
1527 | /* boring lookup table pre-initialization */ |
1528 | switch (srcImage->depth) |
1528 | switch (ximage->depth) |
1529 | { |
1529 | { |
1530 | case 15: |
1530 | case 15: |
1531 | if ((mask_r != 0x7c00) || |
1531 | if ((mask_r != 0x7c00) || |
1532 | (mask_g != 0x03e0) || |
1532 | (mask_g != 0x03e0) || |
1533 | (mask_b != 0x001f)) |
1533 | (mask_b != 0x001f)) |
… | |
… | |
1627 | tmp += (mask_b>>sh_b) * low.b; |
1627 | tmp += (mask_b>>sh_b) * low.b; |
1628 | lookup_b[i] = (tmp/65535)<<sh_b; |
1628 | lookup_b[i] = (tmp/65535)<<sh_b; |
1629 | } |
1629 | } |
1630 | |
1630 | |
1631 | /* apply table to input image (replacing colors by newly calculated ones) */ |
1631 | /* apply table to input image (replacing colors by newly calculated ones) */ |
1632 | if (srcImage->bits_per_pixel == 32 |
1632 | if (ximage->bits_per_pixel == 32 |
1633 | && (srcImage->depth == 24 || srcImage->depth == 32) |
1633 | && (ximage->depth == 24 || ximage->depth == 32) |
1634 | && srcImage->byte_order == host_byte_order) |
1634 | && ximage->byte_order == host_byte_order) |
1635 | { |
1635 | { |
1636 | uint32_t *p1, *pf, *p, *pl; |
1636 | uint32_t *p1, *pf, *p, *pl; |
1637 | p1 = (uint32_t *) srcImage->data; |
1637 | p1 = (uint32_t *) ximage->data; |
1638 | pf = (uint32_t *) (srcImage->data + srcImage->height * srcImage->bytes_per_line); |
1638 | pf = (uint32_t *) (ximage->data + ximage->height * ximage->bytes_per_line); |
1639 | |
1639 | |
1640 | while (p1 < pf) |
1640 | while (p1 < pf) |
1641 | { |
1641 | { |
1642 | p = p1; |
1642 | p = p1; |
1643 | pl = p1 + srcImage->width; |
1643 | pl = p1 + ximage->width; |
1644 | for (; p < pl; p++) |
1644 | for (; p < pl; p++) |
1645 | { |
1645 | { |
1646 | *p = lookup_r[(*p & 0xff0000) >> 16] | |
1646 | *p = lookup_r[(*p & 0xff0000) >> 16] | |
1647 | lookup_g[(*p & 0x00ff00) >> 8] | |
1647 | lookup_g[(*p & 0x00ff00) >> 8] | |
1648 | lookup_b[(*p & 0x0000ff)] | |
1648 | lookup_b[(*p & 0x0000ff)] | |
1649 | (*p & 0xff000000); |
1649 | (*p & 0xff000000); |
1650 | } |
1650 | } |
1651 | p1 = (uint32_t *) ((char *) p1 + srcImage->bytes_per_line); |
1651 | p1 = (uint32_t *) ((char *) p1 + ximage->bytes_per_line); |
1652 | } |
1652 | } |
1653 | } |
1653 | } |
1654 | else |
1654 | else |
1655 | { |
1655 | { |
1656 | for (int y = 0; y < srcImage->height; y++) |
1656 | for (int y = 0; y < ximage->height; y++) |
1657 | for (int x = 0; x < srcImage->width; x++) |
1657 | for (int x = 0; x < ximage->width; x++) |
1658 | { |
1658 | { |
1659 | unsigned long pixel = XGetPixel (srcImage, x, y); |
1659 | unsigned long pixel = XGetPixel (ximage, x, y); |
1660 | pixel = lookup_r[(pixel & mask_r) >> sh_r] | |
1660 | pixel = lookup_r[(pixel & mask_r) >> sh_r] | |
1661 | lookup_g[(pixel & mask_g) >> sh_g] | |
1661 | lookup_g[(pixel & mask_g) >> sh_g] | |
1662 | lookup_b[(pixel & mask_b) >> sh_b]; |
1662 | lookup_b[(pixel & mask_b) >> sh_b]; |
1663 | XPutPixel (srcImage, x, y, pixel); |
1663 | XPutPixel (ximage, x, y, pixel); |
1664 | } |
1664 | } |
1665 | } |
1665 | } |
1666 | |
1666 | |
1667 | free (lookup); |
1667 | free (lookup); |
1668 | } |
1668 | } |