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.44 by sf-exg, Sun Aug 29 15:12:41 2010 UTC vs.
Revision 1.48 by sf-exg, Tue Aug 31 14:12:20 2010 UTC

441 { 441 {
442 flags = new_flags; 442 flags = new_flags;
443 changed++; 443 changed++;
444 } 444 }
445 445
446//fprintf (stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n", 446 //fprintf (stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n",
447// flags, h_scale, v_scale, h_align, v_align); 447 // flags, h_scale, v_scale, h_align, v_align);
448 return (changed > 0); 448 return (changed > 0);
449} 449}
450 450
451# ifdef HAVE_AFTERIMAGE 451# ifdef HAVE_AFTERIMAGE
452bool 452bool
453bgPixmap_t::render_asim (ASImage *background, ARGB32 background_tint) 453bgPixmap_t::render_asim (unsigned long background_flags)
454{ 454{
455 if (target == NULL) 455 if (target == NULL)
456 return false; 456 return false;
457 457
458 target->init_asv (); 458 target->init_asv ();
459
460 ASImage *background = NULL;
461 ARGB32 background_tint = TINT_LEAVE_SAME;
462
463# ifdef ENABLE_TRANSPARENCY
464 if (background_flags)
465 background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100);
466
467 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded))
468 {
469 ShadingInfo as_shade;
470 as_shade.shading = (shade == 0) ? 100 : shade;
471
472 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
473 if (flags & tintSet)
474 tint.get (c);
475 as_shade.tintColor.red = c.r;
476 as_shade.tintColor.green = c.g;
477 as_shade.tintColor.blue = c.b;
478
479 background_tint = shading2tint32 (&as_shade);
480 }
481
482 if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL)
483 {
484 ASImage *tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF,
485 (original_asim == NULL || tint == TINT_LEAVE_SAME) ? ASA_XImage : ASA_ASImage,
486 100, ASIMAGE_QUALITY_DEFAULT);
487 if (tmp)
488 {
489 destroy_asimage (&background);
490 background = tmp;
491 }
492 }
493# endif
459 494
460 ASImage *result = 0; 495 ASImage *result = 0;
461 496
462 int target_width = target->szHint.width; 497 int target_width = target->szHint.width;
463 int target_height = target->szHint.height; 498 int target_height = target->szHint.height;
473 508
474 if (original_asim) 509 if (original_asim)
475 { 510 {
476 if (h_align == rootAlign || v_align == rootAlign) 511 if (h_align == rootAlign || v_align == rootAlign)
477 { 512 {
478 target->get_window_origin(x, y); 513 target->get_window_origin (x, y);
479 x = -x; 514 x = -x;
480 y = -y; 515 y = -y;
481 } 516 }
482 517
483 if (h_align != rootAlign) 518 if (h_align != rootAlign)
635 pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth); 670 pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth);
636 pmap_width = new_pmap_width; 671 pmap_width = new_pmap_width;
637 pmap_height = new_pmap_height; 672 pmap_height = new_pmap_height;
638 pmap_depth = target->depth; 673 pmap_depth = target->depth;
639 } 674 }
640 /* fill with background color ( if result's not completely overlapping it)*/ 675 /* fill with background color (if result's not completely overlapping it) */
641 gcv.foreground = target->pix_colors[Color_bg]; 676 gcv.foreground = target->pix_colors[Color_bg];
642 gc = XCreateGC (target->dpy, target->vt, GCForeground, &gcv); 677 gc = XCreateGC (target->dpy, target->vt, GCForeground, &gcv);
643 678
644 int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0; 679 int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0;
645 int dst_width = result->width, dst_height = result->height; 680 int dst_width = result->width, dst_height = result->height;
662 destroy_asimage (&result); 697 destroy_asimage (&result);
663 698
664 XFreeGC (target->dpy, gc); 699 XFreeGC (target->dpy, gc);
665 TIMING_TEST_PRINT_RESULT (asim); 700 TIMING_TEST_PRINT_RESULT (asim);
666 } 701 }
702
703 if (background)
704 destroy_asimage (&background);
667 705
668 return true; 706 return true;
669} 707}
670# endif /* HAVE_AFTERIMAGE */ 708# endif /* HAVE_AFTERIMAGE */
671 709
766 flags |= bgPixmap_t::tintNeeded; 804 flags |= bgPixmap_t::tintNeeded;
767 else if (tint) 805 else if (tint)
768 { 806 {
769 if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700) 807 if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700)
770 && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) 808 && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700))
771 { 809 {
772 flags |= bgPixmap_t::tintNeeded; 810 flags |= bgPixmap_t::tintNeeded;
773 } 811 }
774 } 812 }
775 813
776 if (flags & bgPixmap_t::tintNeeded) 814 if (flags & bgPixmap_t::tintNeeded)
777 { 815 {
778 if (flags & bgPixmap_t::tintWholesome) 816 if (flags & bgPixmap_t::tintWholesome)
807{ 845{
808 unsigned long new_flags = compute_tint_shade_flags (NULL, shade); 846 unsigned long new_flags = compute_tint_shade_flags (NULL, shade);
809 847
810 if (new_flags != (flags & tintFlags)) 848 if (new_flags != (flags & tintFlags))
811 { 849 {
812 flags = (flags&~tintFlags)|new_flags; 850 flags = (flags&~tintFlags)|new_flags;
813 return true; 851 return true;
814 } 852 }
815 853
816 return false; 854 return false;
817} 855}
818 856
903 941
904 attr.background_pixmap = ParentRelative; 942 attr.background_pixmap = ParentRelative;
905 attr.backing_store = Always; 943 attr.backing_store = Always;
906 attr.event_mask = ExposureMask; 944 attr.event_mask = ExposureMask;
907 attr.override_redirect = True; 945 attr.override_redirect = True;
908 src = XCreateWindow (dpy, root, sx, sy, window_width, window_height, 0, 946 src = XCreateWindow (dpy, root, sx, sy, window_width, window_height, 0,
909 CopyFromParent, CopyFromParent, CopyFromParent, 947 CopyFromParent, CopyFromParent, CopyFromParent,
910 CWBackPixmap|CWBackingStore|CWOverrideRedirect|CWEventMask, 948 CWBackPixmap|CWBackingStore|CWOverrideRedirect|CWEventMask,
911 &attr); 949 &attr);
912 950
913 if (src != None) 951 if (src != None)
937 XDestroyWindow (dpy, src); 975 XDestroyWindow (dpy, src);
938 XUngrabServer (dpy); 976 XUngrabServer (dpy);
939 //fprintf (stderr, "%s:%d: ev_count = %d\n", __FUNCTION__, __LINE__, ev_count); 977 //fprintf (stderr, "%s:%d: ev_count = %d\n", __FUNCTION__, __LINE__, ev_count);
940 } 978 }
941 979
942 if (!success) 980 if (!success)
943 { 981 {
944 XFreePixmap (dpy, tiled_root_pmap); 982 XFreePixmap (dpy, tiled_root_pmap);
945 tiled_root_pmap = None; 983 tiled_root_pmap = None;
946 } 984 }
947 else 985 else
948 result |= transpPmapTiled; 986 result |= transpPmapTiled;
949 } 987 }
950 else 988 else
951 { 989 {
952 /* straightforward pixmap copy */ 990 /* straightforward pixmap copy */
953 gcv.tile = root_pixmap; 991 gcv.tile = root_pixmap;
1070# if DO_TIMING_TEST 1108# if DO_TIMING_TEST
1071 XSync (dpy, False); 1109 XSync (dpy, False);
1072# endif 1110# endif
1073# endif 1111# endif
1074 } 1112 }
1075 } 1113 }
1076 } /* server side rendering completed */ 1114 } /* server side rendering completed */
1077 1115
1078 if (pixmap) 1116 if (pixmap)
1079 XFreePixmap (dpy, pixmap); 1117 XFreePixmap (dpy, pixmap);
1080 1118
1130 /* we need to re-generate transparency pixmap in that case ! */ 1168 /* we need to re-generate transparency pixmap in that case ! */
1131 background_flags = make_transparency_pixmap (); 1169 background_flags = make_transparency_pixmap ();
1132 if (background_flags == 0) 1170 if (background_flags == 0)
1133 return false; 1171 return false;
1134 else if ((background_flags & transpTransformations) == (flags & transpTransformations) 1172 else if ((background_flags & transpTransformations) == (flags & transpTransformations)
1135 && pmap_depth == target->depth) 1173 && pmap_depth == target->depth)
1136 flags = flags & ~isInvalid; 1174 flags = flags & ~isInvalid;
1137 } 1175 }
1138# endif 1176# endif
1139 1177
1140 XImage *result = NULL;
1141# ifdef HAVE_AFTERIMAGE 1178# ifdef HAVE_AFTERIMAGE
1142 if (original_asim 1179 if (original_asim
1143 || (background_flags & transpTransformations) != (flags & transpTransformations)) 1180 || (background_flags & transpTransformations) != (flags & transpTransformations))
1144 { 1181 {
1145 target->init_asv ();
1146
1147 ASImage *background = NULL;
1148 ARGB32 as_tint = TINT_LEAVE_SAME;
1149 if (background_flags)
1150 background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100);
1151
1152# ifdef ENABLE_TRANSPARENCY
1153 if (!(background_flags & transpPmapTinted) && (flags & tintNeeded))
1154 {
1155 ShadingInfo as_shade;
1156 as_shade.shading = (shade == 0) ? 100 : shade;
1157
1158 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
1159 if (flags & tintSet)
1160 tint.get (c);
1161 as_shade.tintColor.red = c.r;
1162 as_shade.tintColor.green = c.g;
1163 as_shade.tintColor.blue = c.b;
1164
1165 as_tint = shading2tint32 (&as_shade);
1166 }
1167
1168 if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL)
1169 {
1170 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,
1172 100, ASIMAGE_QUALITY_DEFAULT);
1173 if (tmp)
1174 {
1175 destroy_asimage (&background);
1176 background = tmp;
1177 }
1178 }
1179# endif
1180
1181 if (render_asim (background, as_tint)) 1182 if (render_asim (background_flags))
1182 flags = flags & ~isInvalid; 1183 flags = flags & ~isInvalid;
1183 if (background)
1184 destroy_asimage (&background);
1185 } 1184 }
1186 else if (background_flags && pmap_depth != target->depth) 1185# endif
1187 result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap);
1188 1186
1189# elif !XFT /* our own client-side tinting */ 1187 XImage *result = NULL;
1190
1191 /* 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 !!! */
1193 1188
1194 if (background_flags && (flags & isInvalid)) 1189 if (background_flags && (flags & isInvalid))
1195 { 1190 {
1196 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);
1197 1192
1193# if !defined(HAVE_AFTERIMAGE) && !XFT
1194 /* our own client-side tinting */
1195 /* ATTENTION: We ASSUME that XFT will let us do all the tinting necessary server-side.
1196 This may need to be changed in need_client_side_rendering() logic is altered !!! */
1198 if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded)) 1197 if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded))
1199 { 1198 {
1200 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 1199 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
1201 if (flags & tintSet) 1200 if (flags & tintSet)
1202 tint.get (c); 1201 tint.get (c);
1203 ShadeXImage (target, result, shade, c.r, c.g, c.b); 1202 ShadeXImage (target, result, shade, c.r, c.g, c.b);
1204 } 1203 }
1204# endif
1205 } 1205 }
1206# endif /* HAVE_AFTERIMAGE */
1207 1206
1208 if (result) 1207 if (result)
1209 { 1208 {
1210 GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); 1209 GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL);
1211 1210
1243 1242
1244 XFreeGC (target->dpy, gc); 1243 XFreeGC (target->dpy, gc);
1245 flags = flags & ~isInvalid; 1244 flags = flags & ~isInvalid;
1246 } 1245 }
1247 1246
1248 XDestroyImage (result); 1247 XDestroyImage (result);
1249 } 1248 }
1250 1249
1251 if (flags & isInvalid) 1250 if (flags & isInvalid)
1252 { 1251 {
1253 if (pixmap != None) 1252 if (pixmap != None)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines