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.30 by ayin, Tue Feb 19 10:47:03 2008 UTC vs.
Revision 1.31 by root, Tue Nov 4 13:20:40 2008 UTC

1/*----------------------------------------------------------------------* 1/*----------------------------------------------------------------------*
2 * File: background.C - former xpm.C 2 * File: background.C - former xpm.C
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * 4 *
5 * All portions of code are copyright by their respective author/s. 5 * All portions of code are copyright by their respective author/s.
6 * Copyright (c) 2005-2006 Marc Lehmann <pcg@goof.com> 6 * Copyright (c) 2005-2008 Marc Lehmann <pcg@goof.com>
7 * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net> 7 * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net>
8 * 8 *
9 * This program is free software; you can redistribute it and/or modify 9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by 10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or 11 * the Free Software Foundation; either version 2 of the License, or
449bgPixmap_t::render_asim (ASImage *background, ARGB32 background_tint) 449bgPixmap_t::render_asim (ASImage *background, ARGB32 background_tint)
450{ 450{
451 if (target == NULL) 451 if (target == NULL)
452 return false; 452 return false;
453 453
454 target->init_asv ();
455
456 ASImage *result = 0;
457
454 int target_width = (int)target->szHint.width; 458 int target_width = target->szHint.width;
455 int target_height = (int)target->szHint.height; 459 int target_height = target->szHint.height;
456 int new_pmap_width = target_width, new_pmap_height = target_height; 460 int new_pmap_width = target_width;
457 ASImage *result = NULL; 461 int new_pmap_height = target_height;
458 462
459 int x = 0; 463 int x = 0;
460 int y = 0; 464 int y = 0;
461 int w = h_scale * target_width / 100; 465 int w = h_scale * target_width / 100;
462 int h = v_scale * target_height / 100; 466 int h = v_scale * target_height / 100;
663# endif /* HAVE_AFTERIMAGE */ 667# endif /* HAVE_AFTERIMAGE */
664 668
665bool 669bool
666bgPixmap_t::set_file (const char *file) 670bgPixmap_t::set_file (const char *file)
667{ 671{
668 char *f;
669
670 assert (file); 672 assert (file);
671 673
672 if (*file) 674 if (*file)
673 { 675 {
674# ifdef HAVE_AFTERIMAGE 676# ifdef HAVE_AFTERIMAGE
675 if (target->asimman == NULL) 677 if (!target->asimman)
676 target->asimman = create_generic_imageman (target->rs[Rs_path]); 678 target->asimman = create_generic_imageman (target->rs[Rs_path]);
677 679
678 if ((f = strchr (file, ';')) == NULL) 680 if (char *f = strchr (file, ';'))
679 original_asim = get_asimage (target->asimman, file, 0xFFFFFFFF, 100);
680 else
681 { 681 {
682 size_t len = f - file; 682 size_t len = f - file;
683 f = (char *)malloc (len + 1); 683 f = (char *)malloc (len + 1);
684 memcpy (f, file, len); 684 memcpy (f, file, len);
685 f[len] = '\0'; 685 f[len] = '\0';
686 original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100); 686 original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100);
687 free (f); 687 free (f);
688 } 688 }
689 else
690 original_asim = get_asimage (target->asimman, file, 0xFFFFFFFF, 100);
689 691
690 return original_asim; 692 return original_asim;
691# endif 693# endif
692 } 694 }
693 695
1117 unsigned long background_flags = 0; 1119 unsigned long background_flags = 0;
1118 1120
1119 if (target == NULL) 1121 if (target == NULL)
1120 return false; 1122 return false;
1121 1123
1124 target->init_asv ();
1125
1122 TIMING_TEST_START (tp); 1126 TIMING_TEST_START (tp);
1123 1127
1124 invalidate(); 1128 invalidate ();
1125# ifdef ENABLE_TRANSPARENCY 1129# ifdef ENABLE_TRANSPARENCY
1126 if (flags & isTransparent) 1130 if (flags & isTransparent)
1127 { 1131 {
1128 /* we need to re-generate transparency pixmap in that case ! */ 1132 /* we need to re-generate transparency pixmap in that case ! */
1129 background_flags = make_transparency_pixmap (); 1133 background_flags = make_transparency_pixmap ();
1141 || (background_flags & transpTransformations) != (flags & transpTransformations)) 1145 || (background_flags & transpTransformations) != (flags & transpTransformations))
1142 { 1146 {
1143 ASImage *background = NULL; 1147 ASImage *background = NULL;
1144 ARGB32 as_tint = TINT_LEAVE_SAME; 1148 ARGB32 as_tint = TINT_LEAVE_SAME;
1145 if (background_flags) 1149 if (background_flags)
1146 background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); 1150 background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100);
1147 1151
1148# ifdef ENABLE_TRANSPARENCY 1152# ifdef ENABLE_TRANSPARENCY
1149 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) 1153 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded))
1150 { 1154 {
1151 ShadingInfo as_shade; 1155 ShadingInfo as_shade;
1158 as_shade.tintColor.green = c.g; 1162 as_shade.tintColor.green = c.g;
1159 as_shade.tintColor.blue = c.b; 1163 as_shade.tintColor.blue = c.b;
1160 1164
1161 as_tint = shading2tint32 (&as_shade); 1165 as_tint = shading2tint32 (&as_shade);
1162 } 1166 }
1167
1163 if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL) 1168 if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL)
1164 { 1169 {
1165 ASImage* tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, 1170 ASImage* tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF,
1166 (original_asim == NULL || tint == TINT_LEAVE_SAME)?ASA_XImage:ASA_ASImage, 1171 (original_asim == NULL || tint == TINT_LEAVE_SAME)?ASA_XImage:ASA_ASImage,
1167 100, ASIMAGE_QUALITY_DEFAULT); 1172 100, ASIMAGE_QUALITY_DEFAULT);
1174# endif 1179# endif
1175 1180
1176 if (render_asim (background, as_tint)) 1181 if (render_asim (background, as_tint))
1177 flags = flags & ~isInvalid; 1182 flags = flags & ~isInvalid;
1178 if (background) 1183 if (background)
1179 destroy_asimage (&background); 1184 destroy_asimage (&background);
1180 } 1185 }
1181 else if (background_flags && pmap_depth != target->depth) 1186 else if (background_flags && pmap_depth != target->depth)
1182 {
1183 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); 1187 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap);
1184 }
1185 1188
1186# elif !XFT /* our own client-side tinting */ 1189# elif !XFT /* our own client-side tinting */
1187 1190
1188 /* ATTENTION: We ASSUME that XFT will let us do all the tinting neccessary server-side. 1191 /* ATTENTION: We ASSUME that XFT will let us do all the tinting neccessary server-side.
1189 This may need to be changed in need_client_side_rendering() logic is altered !!! */ 1192 This may need to be changed in need_client_side_rendering() logic is altered !!! */
1190 1193
1191 if (background_flags && (flags & isInvalid)) 1194 if (background_flags && (flags & isInvalid))
1192 { 1195 {
1193 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); 1196 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap);
1197
1194 if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded)) 1198 if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded))
1195 { 1199 {
1196 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 1200 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
1197 if (flags & tintSet) 1201 if (flags & tintSet)
1198 tint.get (c); 1202 tint.get (c);
1273# ifdef ENABLE_TRANSPARENCY 1277# ifdef ENABLE_TRANSPARENCY
1274 root_depth = DefaultDepthOfScreen (ScreenOfDisplay (target->dpy, target->display->screen)); 1278 root_depth = DefaultDepthOfScreen (ScreenOfDisplay (target->dpy, target->display->screen));
1275# endif 1279# endif
1276 return true; 1280 return true;
1277 } 1281 }
1282
1278 return false; 1283 return false;
1279} 1284}
1280 1285
1281void 1286void
1282bgPixmap_t::apply () 1287bgPixmap_t::apply ()

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines