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.31 by root, Tue Nov 4 13:20:40 2008 UTC vs.
Revision 1.41 by sf-exg, Sat Aug 21 16:07:15 2010 UTC

27#define DO_TIMING_TEST 0 27#define DO_TIMING_TEST 0
28 28
29#if DO_TIMING_TEST 29#if DO_TIMING_TEST
30# include <sys/time.h> 30# include <sys/time.h>
31#define TIMING_TEST_START(id) \ 31#define TIMING_TEST_START(id) \
32 struct timeval timing_test_##id##_stv;\ 32 struct timeval timing_test_##id##_stv; \
33 gettimeofday (&timing_test_##id##_stv, NULL); 33 gettimeofday (&timing_test_##id##_stv, NULL);
34 34
35#define TIMING_TEST_PRINT_RESULT(id) \ 35#define TIMING_TEST_PRINT_RESULT(id) \
36 do{ struct timeval tv;gettimeofday (&tv, NULL); tv.tv_sec -= (timing_test_##id##_stv).tv_sec;\ 36 do { \
37 struct timeval tv; \
38 gettimeofday (&tv, NULL); \
39 tv.tv_sec -= (timing_test_##id##_stv).tv_sec; \
37 fprintf (stderr, "%s: %s: %d: elapsed %ld usec\n", #id, __FILE__, __LINE__,\ 40 fprintf (stderr, "%s: %s: %d: elapsed %ld usec\n", #id, __FILE__, __LINE__, \
38 tv.tv_sec * 1000000 + tv.tv_usec - (timing_test_##id##_stv).tv_usec);}while (0) 41 tv.tv_sec * 1000000 + tv.tv_usec - (timing_test_##id##_stv).tv_usec); \
42 } while (0)
39 43
40#else 44#else
41#define TIMING_TEST_START(id) do{}while (0) 45#define TIMING_TEST_START(id) do {} while (0)
42#define TIMING_TEST_PRINT_RESULT(id) do{}while (0) 46#define TIMING_TEST_PRINT_RESULT(id) do {} while (0)
43#endif 47#endif
44 48
45/* 49/*
46 * Pixmap geometry string interpretation : 50 * Pixmap geometry string interpretation :
47 * Each geometry string contains zero or one scale/position 51 * Each geometry string contains zero or one scale/position
48 * adjustment and may optionally be followed by a colon and one or more 52 * adjustment and may optionally be followed by a colon and one or more
49 * colon-delimited pixmap operations. 53 * colon-delimited pixmap operations.
50 * The following table shows the valid geometry strings and their 54 * The following table shows the valid geometry strings and their
51 * affects on the background image : 55 * effects on the background image :
52 * 56 *
53 * WxH+X+Y Set scaling to W% by H%, and position to X% by Y%. 57 * WxH+X+Y Set scaling to W% by H%, and position to X% by Y%.
54 * W and H are percentages of the terminal window size. 58 * W and H are percentages of the terminal window size.
55 * X and Y are also percentages; e.g., +50+50 centers 59 * X and Y are also percentages; e.g., +50+50 centers
56 * the image in the window. 60 * the image in the window.
136# endif 140# endif
137 141
138 return false; 142 return false;
139} 143}
140 144
141bool 145bool
142bgPixmap_t::window_position_sensitive () 146bgPixmap_t::window_position_sensitive ()
143{ 147{
144# ifdef ENABLE_TRANSPARENCY 148# ifdef ENABLE_TRANSPARENCY
145 if (flags & isTransparent) 149 if (flags & isTransparent)
146 return true; 150 return true;
147# endif 151# endif
259 int geom_flags = 0, changed = 0; 263 int geom_flags = 0, changed = 0;
260 int x = 0, y = 0; 264 int x = 0, y = 0;
261 unsigned int w = 0, h = 0; 265 unsigned int w = 0, h = 0;
262 unsigned int n; 266 unsigned int n;
263 unsigned long new_flags = (flags & (~geometryFlags)); 267 unsigned long new_flags = (flags & (~geometryFlags));
264 char *p; 268 const char *p;
265# define MAXLEN_GEOM 256 /* could be longer than regular geometry string */ 269# define MAXLEN_GEOM 256 /* could be longer than regular geometry string */
266 270
267 if (geom == NULL) 271 if (geom == NULL)
268 return false; 272 return false;
269 273
495 new_pmap_height = background->height; 499 new_pmap_height = background->height;
496 result = background; 500 result = background;
497 501
498 if (background_tint != TINT_LEAVE_SAME) 502 if (background_tint != TINT_LEAVE_SAME)
499 { 503 {
500 ASImage* tmp = tile_asimage (target->asv, background, 0, 0, 504 ASImage *tmp = tile_asimage (target->asv, background, 0, 0,
501 target_width, target_height, background_tint, 505 target_width, target_height, background_tint,
502 ASA_XImage, 100, ASIMAGE_QUALITY_DEFAULT); 506 ASA_XImage, 100, ASIMAGE_QUALITY_DEFAULT);
503 if (tmp) 507 if (tmp)
504 result = tmp; 508 result = tmp;
505 } 509 }
533 if (h_scale == 0 || v_scale == 0) 537 if (h_scale == 0 || v_scale == 0)
534 { 538 {
535 ASImage *tmp = tile_asimage (target->asv, result, 539 ASImage *tmp = tile_asimage (target->asv, result,
536 (h_scale > 0) ? 0 : (int)result->width - x, 540 (h_scale > 0) ? 0 : (int)result->width - x,
537 (v_scale > 0) ? 0 : (int)result->height - y, 541 (v_scale > 0) ? 0 : (int)result->height - y,
538 new_pmap_width, 542 new_pmap_width,
539 new_pmap_height, 543 new_pmap_height,
540 TINT_LEAVE_SAME, ASA_XImage, 544 TINT_LEAVE_SAME, ASA_XImage,
541 100, ASIMAGE_QUALITY_DEFAULT); 545 100, ASIMAGE_QUALITY_DEFAULT);
542 if (tmp) 546 if (tmp)
543 { 547 {
675 { 679 {
676# ifdef HAVE_AFTERIMAGE 680# ifdef HAVE_AFTERIMAGE
677 if (!target->asimman) 681 if (!target->asimman)
678 target->asimman = create_generic_imageman (target->rs[Rs_path]); 682 target->asimman = create_generic_imageman (target->rs[Rs_path]);
679 683
680 if (char *f = strchr (file, ';')) 684 if (const char *p = strchr (file, ';'))
681 { 685 {
682 size_t len = f - file; 686 size_t len = p - file;
683 f = (char *)malloc (len + 1); 687 char *f = (char *)malloc (len + 1);
684 memcpy (f, file, len); 688 memcpy (f, file, len);
685 f[len] = '\0'; 689 f[len] = '\0';
686 original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100); 690 original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100);
687 free (f); 691 free (f);
688 } 692 }
848 unsigned long result = 0; 852 unsigned long result = 0;
849 853
850 if (target == NULL) 854 if (target == NULL)
851 return 0; 855 return 0;
852 856
853 /* root dimentions may change from call to call - but Display structure should 857 /* root dimensions may change from call to call - but Display structure should
854 * be always up-to-date, so let's use it : 858 * be always up-to-date, so let's use it :
855 */ 859 */
856 Window root = target->display->root; 860 Window root = target->display->root;
857 int screen = target->display->screen; 861 int screen = target->display->screen;
858 Display *dpy = target->dpy; 862 Display *dpy = target->dpy;
947 else 951 else
948 result |= transpPmapTiled; 952 result |= transpPmapTiled;
949 } 953 }
950 else 954 else
951 { 955 {
952 /* strightforward pixmap copy */ 956 /* straightforward pixmap copy */
953 gcv.tile = root_pixmap; 957 gcv.tile = root_pixmap;
954 gcv.fill_style = FillTiled; 958 gcv.fill_style = FillTiled;
955 959
956 while (sx < 0) sx += (int)root_width; 960 while (sx < 0) sx += (int)root_width;
957 while (sy < 0) sy += (int)root_height; 961 while (sy < 0) sy += (int)root_height;
1108 return false; 1112 return false;
1109} 1113}
1110# endif /* ENABLE_TRANSPARENCY */ 1114# endif /* ENABLE_TRANSPARENCY */
1111 1115
1112# ifndef HAVE_AFTERIMAGE 1116# ifndef HAVE_AFTERIMAGE
1113static void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm); 1117static void ShadeXImage(rxvt_term *term, XImage *srcImage, int shade, int rm, int gm, int bm);
1114# endif 1118# endif
1115 1119
1116bool 1120bool
1117bgPixmap_t::render () 1121bgPixmap_t::render ()
1118{ 1122{
1119 unsigned long background_flags = 0; 1123 unsigned long background_flags = 0;
1120 1124
1121 if (target == NULL) 1125 if (target == NULL)
1122 return false; 1126 return false;
1123
1124 target->init_asv ();
1125 1127
1126 TIMING_TEST_START (tp); 1128 TIMING_TEST_START (tp);
1127 1129
1128 invalidate (); 1130 invalidate ();
1129# ifdef ENABLE_TRANSPARENCY 1131# ifdef ENABLE_TRANSPARENCY
1142 XImage *result = NULL; 1144 XImage *result = NULL;
1143# ifdef HAVE_AFTERIMAGE 1145# ifdef HAVE_AFTERIMAGE
1144 if (original_asim 1146 if (original_asim
1145 || (background_flags & transpTransformations) != (flags & transpTransformations)) 1147 || (background_flags & transpTransformations) != (flags & transpTransformations))
1146 { 1148 {
1149 target->init_asv ();
1150
1147 ASImage *background = NULL; 1151 ASImage *background = NULL;
1148 ARGB32 as_tint = TINT_LEAVE_SAME; 1152 ARGB32 as_tint = TINT_LEAVE_SAME;
1149 if (background_flags) 1153 if (background_flags)
1150 background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); 1154 background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100);
1151 1155
1165 as_tint = shading2tint32 (&as_shade); 1169 as_tint = shading2tint32 (&as_shade);
1166 } 1170 }
1167 1171
1168 if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL) 1172 if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL)
1169 { 1173 {
1170 ASImage* tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, 1174 ASImage *tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF,
1171 (original_asim == NULL || tint == TINT_LEAVE_SAME)?ASA_XImage:ASA_ASImage, 1175 (original_asim == NULL || tint == TINT_LEAVE_SAME)?ASA_XImage:ASA_ASImage,
1172 100, ASIMAGE_QUALITY_DEFAULT); 1176 100, ASIMAGE_QUALITY_DEFAULT);
1173 if (tmp) 1177 if (tmp)
1174 { 1178 {
1175 destroy_asimage (&background); 1179 destroy_asimage (&background);
1186 else if (background_flags && pmap_depth != target->depth) 1190 else if (background_flags && pmap_depth != target->depth)
1187 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); 1191 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap);
1188 1192
1189# elif !XFT /* our own client-side tinting */ 1193# elif !XFT /* our own client-side tinting */
1190 1194
1191 /* ATTENTION: We ASSUME that XFT will let us do all the tinting neccessary server-side. 1195 /* ATTENTION: We ASSUME that XFT will let us do all the tinting necessary server-side.
1192 This may need to be changed in need_client_side_rendering() logic is altered !!! */ 1196 This may need to be changed in need_client_side_rendering() logic is altered !!! */
1193 1197
1194 if (background_flags && (flags & isInvalid)) 1198 if (background_flags && (flags & isInvalid))
1195 { 1199 {
1196 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); 1200 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap);
1327 1331
1328 /* don't want Expose on the parent or vt. It is better to use 1332 /* don't want Expose on the parent or vt. It is better to use
1329 scr_touch or we get a great deal of flicker otherwise: */ 1333 scr_touch or we get a great deal of flicker otherwise: */
1330 XClearWindow (target->dpy, target->parent[0]); 1334 XClearWindow (target->dpy, target->parent[0]);
1331 1335
1332 if (target->scrollBar.win) 1336 if (target->scrollBar.state && target->scrollBar.win)
1333 { 1337 {
1334 target->scrollBar.state = STATE_IDLE; 1338 target->scrollBar.state = STATE_IDLE;
1335 target->scrollBar.show (0); 1339 target->scrollBar.show (0);
1336 } 1340 }
1337 1341
1346/* taken from aterm-0.4.2 */ 1350/* taken from aterm-0.4.2 */
1347 1351
1348typedef uint32_t RUINT32T; 1352typedef uint32_t RUINT32T;
1349 1353
1350static void 1354static void
1351ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm) 1355ShadeXImage(rxvt_term *term, XImage *srcImage, int shade, int rm, int gm, int bm)
1352{ 1356{
1353 int sh_r, sh_g, sh_b; 1357 int sh_r, sh_g, sh_b;
1354 RUINT32T mask_r, mask_g, mask_b; 1358 RUINT32T mask_r, mask_g, mask_b;
1355 RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; 1359 RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b;
1356 unsigned int lower_lim_r, lower_lim_g, lower_lim_b; 1360 unsigned int lower_lim_r, lower_lim_g, lower_lim_b;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines