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.111 by sf-exg, Fri Nov 5 17:27:58 2010 UTC vs.
Revision 1.116 by sf-exg, Thu Nov 11 11:58:10 2010 UTC

666 if (result) 666 if (result)
667 { 667 {
668 XGCValues gcv; 668 XGCValues gcv;
669 GC gc; 669 GC gc;
670 670
671 if (pixmap)
672 {
673 if (pmap_width != new_pmap_width
674 || pmap_height != new_pmap_height
675 || pmap_depth != target->depth)
676 {
677 XFreePixmap (target->dpy, pixmap);
678 pixmap = None;
679 }
680 }
681
682 /* create Pixmap */ 671 /* create Pixmap */
683 if (pixmap == None) 672 if (pixmap == None
673 || pmap_width != new_pmap_width
674 || pmap_height != new_pmap_height
675 || pmap_depth != target->depth)
684 { 676 {
677 if (pixmap)
678 XFreePixmap (target->dpy, pixmap);
685 pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth); 679 pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth);
686 pmap_width = new_pmap_width; 680 pmap_width = new_pmap_width;
687 pmap_height = new_pmap_height; 681 pmap_height = new_pmap_height;
688 pmap_depth = target->depth; 682 pmap_depth = target->depth;
689 } 683 }
797 new_pmap_width = min (image_width, target_width); 791 new_pmap_width = min (image_width, target_width);
798 new_pmap_height = min (image_height, target_height); 792 new_pmap_height = min (image_height, target_height);
799 } 793 }
800 } 794 }
801 795
802 if (pixmap)
803 {
804 if (pmap_width != new_pmap_width
805 || pmap_height != new_pmap_height
806 || pmap_depth != target->depth)
807 {
808 XFreePixmap (target->dpy, pixmap);
809 pixmap = None;
810 }
811 }
812
813 if (pixmap == None) 796 if (pixmap == None
797 || pmap_width != new_pmap_width
798 || pmap_height != new_pmap_height
799 || pmap_depth != target->depth)
814 { 800 {
801 if (pixmap)
802 XFreePixmap (target->dpy, pixmap);
815 pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth); 803 pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth);
816 pmap_width = new_pmap_width; 804 pmap_width = new_pmap_width;
817 pmap_height = new_pmap_height; 805 pmap_height = new_pmap_height;
818 pmap_depth = target->depth; 806 pmap_depth = target->depth;
819 } 807 }
1239 1227
1240 if (mask_pic && overlay_pic && back_pic) 1228 if (mask_pic && overlay_pic && back_pic)
1241 { 1229 {
1242 XRenderColor mask_c; 1230 XRenderColor mask_c;
1243 1231
1244 memset (&mask_c, (shade > 100) ? 0xFF : 0x0, sizeof (mask_c)); 1232 mask_c.red = mask_c.green = mask_c.blue = shade > 100 ? 0xffff : 0;
1245 mask_c.alpha = 0xffff; 1233 mask_c.alpha = 0xffff;
1246 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); 1234 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1);
1247 1235
1248 mask_c.alpha = 0; 1236 mask_c.alpha = 0;
1249 mask_c.red = 0xffff - c.r; 1237 mask_c.red = 0xffff - c.r;
1367 if (gc) 1355 if (gc)
1368 { 1356 {
1369 XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); 1357 XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height);
1370 result |= transpPmapTiled; 1358 result |= transpPmapTiled;
1371 XFreeGC (dpy, gc); 1359 XFreeGC (dpy, gc);
1372 }
1373 1360
1374 if (tiled_root_pmap != None)
1375 {
1376 if (!need_client_side_rendering ()) 1361 if (!need_client_side_rendering ())
1377 { 1362 {
1378 if ((flags & blurNeeded) 1363 if ((flags & blurNeeded)
1379 && (flags & HAS_RENDER_CONV)) 1364 && (flags & HAS_RENDER_CONV))
1380 { 1365 {
1395 pixmap = tiled_root_pmap; 1380 pixmap = tiled_root_pmap;
1396 pmap_width = window_width; 1381 pmap_width = window_width;
1397 pmap_height = window_height; 1382 pmap_height = window_height;
1398 pmap_depth = target->depth; 1383 pmap_depth = target->depth;
1399 } 1384 }
1385 else
1386 XFreePixmap (dpy, tiled_root_pmap);
1400 1387
1401 if (recoded_root_pmap != root_pixmap) 1388 if (recoded_root_pmap != root_pixmap)
1402 XFreePixmap (dpy, recoded_root_pmap); 1389 XFreePixmap (dpy, recoded_root_pmap);
1403 1390
1404 return result; 1391 return result;
1413 1400
1414 root_pixmap = new_root_pixmap; 1401 root_pixmap = new_root_pixmap;
1415} 1402}
1416# endif /* ENABLE_TRANSPARENCY */ 1403# endif /* ENABLE_TRANSPARENCY */
1417 1404
1418# ifndef HAVE_AFTERIMAGE 1405#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE)
1419static void ShadeXImage(Visual *visual, XImage *srcImage, int shade, int rm, int gm, int bm); 1406static void ShadeXImage(Visual *visual, XImage *srcImage, int shade, const rgba &c);
1420# endif 1407# endif
1421 1408
1422bool 1409bool
1423bgPixmap_t::render () 1410bgPixmap_t::render ()
1424{ 1411{
1447 if (render_image (background_flags)) 1434 if (render_image (background_flags))
1448 flags = flags & ~isInvalid; 1435 flags = flags & ~isInvalid;
1449 } 1436 }
1450# endif 1437# endif
1451 1438
1452# if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) && !XRENDER 1439# if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE)
1453 XImage *result = NULL; 1440 XImage *result = NULL;
1454 1441
1455 if (background_flags && (flags & isInvalid)) 1442 if (background_flags && (flags & isInvalid))
1456 { 1443 {
1457 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); 1444 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap);
1463 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) 1450 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded))
1464 { 1451 {
1465 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 1452 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
1466 if (flags & tintSet) 1453 if (flags & tintSet)
1467 tint.get (c); 1454 tint.get (c);
1468 ShadeXImage (DefaultVisual (target->dpy, target->display->screen), result, shade, c.r, c.g, c.b); 1455 ShadeXImage (DefaultVisual (target->dpy, target->display->screen), result, shade, c);
1469 } 1456 }
1470 1457
1471 GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); 1458 GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL);
1472 1459
1473 if (gc) 1460 if (gc)
1574 flags |= hasChanged; 1561 flags |= hasChanged;
1575} 1562}
1576 1563
1577#endif /* HAVE_BG_PIXMAP */ 1564#endif /* HAVE_BG_PIXMAP */
1578 1565
1579#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) && !XRENDER 1566#if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE)
1580/* taken from aterm-0.4.2 */ 1567/* taken from aterm-0.4.2 */
1581 1568
1582static void 1569static void
1583ShadeXImage(Visual *visual, XImage *srcImage, int shade, int rm, int gm, int bm) 1570ShadeXImage(Visual *visual, XImage *srcImage, int shade, const rgba &c)
1584{ 1571{
1585 int sh_r, sh_g, sh_b; 1572 int sh_r, sh_g, sh_b;
1586 uint32_t mask_r, mask_g, mask_b; 1573 uint32_t mask_r, mask_g, mask_b;
1587 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; 1574 uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b;
1588 unsigned int lower_lim_r, lower_lim_g, lower_lim_b; 1575 rgba low;
1589 unsigned int upper_lim_r, upper_lim_g, upper_lim_b; 1576 rgba high;
1590 int i; 1577 int i;
1591 int host_byte_order = byteorder.big_endian () ? MSBFirst : LSBFirst; 1578 int host_byte_order = byteorder.big_endian () ? MSBFirst : LSBFirst;
1592 1579
1593 if (visual->c_class != TrueColor || srcImage->format != ZPixmap) return; 1580 if (visual->c_class != TrueColor || srcImage->format != ZPixmap) return;
1594 1581
1659 /* prepare limits for color transformation (each channel is handled separately) */ 1646 /* prepare limits for color transformation (each channel is handled separately) */
1660 if (shade > 100) 1647 if (shade > 100)
1661 { 1648 {
1662 shade = 200 - shade; 1649 shade = 200 - shade;
1663 1650
1664 lower_lim_r = 65535-rm; 1651 high.r = (65535 - c.r) * shade / 100;
1665 lower_lim_g = 65535-gm; 1652 high.g = (65535 - c.g) * shade / 100;
1666 lower_lim_b = 65535-bm; 1653 high.b = (65535 - c.b) * shade / 100;
1667 1654
1668 lower_lim_r = 65535-(unsigned int)(((uint32_t)lower_lim_r)*((uint32_t)shade)/100); 1655 low.r = 65535 - high.r;
1669 lower_lim_g = 65535-(unsigned int)(((uint32_t)lower_lim_g)*((uint32_t)shade)/100); 1656 low.g = 65535 - high.g;
1670 lower_lim_b = 65535-(unsigned int)(((uint32_t)lower_lim_b)*((uint32_t)shade)/100); 1657 low.b = 65535 - high.b;
1671
1672 upper_lim_r = upper_lim_g = upper_lim_b = 65535;
1673 } 1658 }
1674 else 1659 else
1675 { 1660 {
1661 high.r = c.r * shade / 100;
1662 high.g = c.g * shade / 100;
1663 high.b = c.b * shade / 100;
1676 1664
1677 lower_lim_r = lower_lim_g = lower_lim_b = 0; 1665 low.r = low.g = low.b = 0;
1678
1679 upper_lim_r = (unsigned int)((((uint32_t)rm)*((uint32_t)shade))/100);
1680 upper_lim_g = (unsigned int)((((uint32_t)gm)*((uint32_t)shade))/100);
1681 upper_lim_b = (unsigned int)((((uint32_t)bm)*((uint32_t)shade))/100);
1682 } 1666 }
1683 1667
1684 /* fill our lookup tables */ 1668 /* fill our lookup tables */
1685 for (i = 0; i <= mask_r>>sh_r; i++) 1669 for (i = 0; i <= mask_r>>sh_r; i++)
1686 { 1670 {
1687 uint32_t tmp; 1671 uint32_t tmp;
1688 tmp = ((uint32_t)i)*((uint32_t)(upper_lim_r-lower_lim_r)); 1672 tmp = i * high.r;
1689 tmp += ((uint32_t)(mask_r>>sh_r))*((uint32_t)lower_lim_r); 1673 tmp += (mask_r>>sh_r) * low.r;
1690 lookup_r[i] = (tmp/65535)<<sh_r; 1674 lookup_r[i] = (tmp/65535)<<sh_r;
1691 } 1675 }
1692 for (i = 0; i <= mask_g>>sh_g; i++) 1676 for (i = 0; i <= mask_g>>sh_g; i++)
1693 { 1677 {
1694 uint32_t tmp; 1678 uint32_t tmp;
1695 tmp = ((uint32_t)i)*((uint32_t)(upper_lim_g-lower_lim_g)); 1679 tmp = i * high.g;
1696 tmp += ((uint32_t)(mask_g>>sh_g))*((uint32_t)lower_lim_g); 1680 tmp += (mask_g>>sh_g) * low.g;
1697 lookup_g[i] = (tmp/65535)<<sh_g; 1681 lookup_g[i] = (tmp/65535)<<sh_g;
1698 } 1682 }
1699 for (i = 0; i <= mask_b>>sh_b; i++) 1683 for (i = 0; i <= mask_b>>sh_b; i++)
1700 { 1684 {
1701 uint32_t tmp; 1685 uint32_t tmp;
1702 tmp = ((uint32_t)i)*((uint32_t)(upper_lim_b-lower_lim_b)); 1686 tmp = i * high.b;
1703 tmp += ((uint32_t)(mask_b>>sh_b))*((uint32_t)lower_lim_b); 1687 tmp += (mask_b>>sh_b) * low.b;
1704 lookup_b[i] = (tmp/65535)<<sh_b; 1688 lookup_b[i] = (tmp/65535)<<sh_b;
1705 } 1689 }
1706 1690
1707 /* apply table to input image (replacing colors by newly calculated ones) */ 1691 /* apply table to input image (replacing colors by newly calculated ones) */
1708 if (srcImage->bits_per_pixel == 32 1692 if (srcImage->bits_per_pixel == 32

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines