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.187 by sf-exg, Wed Dec 28 13:13:33 2011 UTC vs.
Revision 1.190 by sf-exg, Thu Dec 29 20:35:37 2011 UTC

33#ifndef FilterConvolution 33#ifndef FilterConvolution
34#define FilterConvolution "convolution" 34#define FilterConvolution "convolution"
35#endif 35#endif
36 36
37#ifdef HAVE_BG_PIXMAP 37#ifdef HAVE_BG_PIXMAP
38# if XRENDER
39static Picture
40create_xrender_mask (Display *dpy, Drawable drawable, Bool argb, Bool component_alpha)
41{
42 Pixmap pixmap = XCreatePixmap (dpy, drawable, 1, 1, argb ? 32 : 8);
43
44 XRenderPictFormat *format = XRenderFindStandardFormat (dpy, argb ? PictStandardARGB32 : PictStandardA8);
45 XRenderPictureAttributes pa;
46 pa.repeat = True;
47 pa.component_alpha = component_alpha;
48 Picture mask = XRenderCreatePicture (dpy, pixmap, format, CPRepeat | CPComponentAlpha, &pa);
49
50 XFreePixmap (dpy, pixmap);
51
52 return mask;
53}
54# endif
55
38void 56void
39rxvt_term::bg_destroy () 57rxvt_term::bg_destroy ()
40{ 58{
41#ifdef HAVE_AFTERIMAGE 59#ifdef HAVE_AFTERIMAGE
42 if (original_asim) 60 if (original_asim)
802 820
803#if XRENDER 821#if XRENDER
804 if (tr_flags) 822 if (tr_flags)
805 { 823 {
806 XRenderPictureAttributes pa; 824 XRenderPictureAttributes pa;
807
808 XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, visual); 825 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
826
809 Picture src = XRenderCreatePicture (dpy, root_pmap, src_format, 0, &pa); 827 Picture src = XRenderCreatePicture (dpy, root_pmap, format, 0, &pa);
810 828
811 XRenderPictFormat *dst_format = XRenderFindVisualFormat (dpy, visual);
812 Picture dst = XRenderCreatePicture (dpy, bg_pixmap, dst_format, 0, &pa); 829 Picture dst = XRenderCreatePicture (dpy, bg_pixmap, format, 0, &pa);
813 830
814 pa.repeat = True; 831 Picture mask = create_xrender_mask (dpy, vt, False, False);
815 Pixmap mask_pmap = XCreatePixmap (dpy, vt, 1, 1, 8);
816 XRenderPictFormat *mask_format = XRenderFindStandardFormat (dpy, PictStandardA8);
817 Picture mask = XRenderCreatePicture (dpy, mask_pmap, mask_format, CPRepeat, &pa);
818 XFreePixmap (dpy, mask_pmap);
819 832
820 XRenderColor mask_c; 833 XRenderColor mask_c;
821 834
822 mask_c.alpha = 0x8000; 835 mask_c.alpha = 0x8000;
823 mask_c.red = 0; 836 mask_c.red = 0;
1139 c.r = c.r * (200 - shade) / 100; 1152 c.r = c.r * (200 - shade) / 100;
1140 c.g = c.g * (200 - shade) / 100; 1153 c.g = c.g * (200 - shade) / 100;
1141 c.b = c.b * (200 - shade) / 100; 1154 c.b = c.b * (200 - shade) / 100;
1142 } 1155 }
1143 1156
1144 XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
1145 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); 1157 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
1146 XRenderPictureAttributes pa; 1158 XRenderPictureAttributes pa;
1147 1159
1148 Picture back_pic = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); 1160 Picture back_pic = XRenderCreatePicture (dpy, pixmap, format, 0, &pa);
1149 1161
1150 pa.repeat = True; 1162 Picture overlay_pic = create_xrender_mask (dpy, pixmap, True, False);
1151 1163
1152 Pixmap overlay_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); 1164 Picture mask_pic = create_xrender_mask (dpy, pixmap, True, True);
1153 Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa);
1154 XFreePixmap (dpy, overlay_pmap);
1155
1156 pa.component_alpha = True;
1157 Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32);
1158 Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat | CPComponentAlpha, &pa);
1159 XFreePixmap (dpy, mask_pmap);
1160 1165
1161 XRenderColor mask_c; 1166 XRenderColor mask_c;
1162 1167
1163 mask_c.alpha = 0xffff; 1168 mask_c.alpha = 0xffff;
1164 mask_c.red = 1169 mask_c.red =
1293 1298
1294 if (gc) 1299 if (gc)
1295 { 1300 {
1296 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height); 1301 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height);
1297 result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS); 1302 result |= BG_IS_VALID | (bg_flags & BG_EFFECTS_FLAGS);
1298 XFreeGC (dpy, gc);
1299 1303
1300 if (!(bg_flags & BG_CLIENT_RENDER)) 1304 if (!(bg_flags & BG_CLIENT_RENDER))
1301 { 1305 {
1302 if (bg_flags & BG_NEEDS_BLUR) 1306 if (bg_flags & BG_NEEDS_BLUR)
1303 { 1307 {
1307 if (bg_flags & BG_NEEDS_TINT) 1311 if (bg_flags & BG_NEEDS_TINT)
1308 { 1312 {
1309 if (tint_pixmap (bg_pixmap, visual, window_width, window_height)) 1313 if (tint_pixmap (bg_pixmap, visual, window_width, window_height))
1310 result &= ~BG_NEEDS_TINT; 1314 result &= ~BG_NEEDS_TINT;
1311 } 1315 }
1316# ifndef HAVE_AFTERIMAGE
1317 if (result & BG_NEEDS_TINT)
1318 {
1319 XImage *ximage = XGetImage (dpy, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, ZPixmap);
1320 if (ximage)
1321 {
1322 /* our own client-side tinting */
1323 tint_ximage (DefaultVisual (dpy, display->screen), ximage);
1324
1325 XPutImage (dpy, bg_pixmap, gc, ximage, 0, 0, 0, 0, ximage->width, ximage->height);
1326 XDestroyImage (ximage);
1327 }
1328 }
1329# endif
1312 } /* server side rendering completed */ 1330 } /* server side rendering completed */
1331
1332 XFreeGC (dpy, gc);
1313 } 1333 }
1314 1334
1315 if (recoded_root_pmap != root_pixmap) 1335 if (recoded_root_pmap != root_pixmap)
1316 XFreePixmap (dpy, recoded_root_pmap); 1336 XFreePixmap (dpy, recoded_root_pmap);
1317 1337
1350 if ((bg_flags & BG_IS_FROM_FILE) 1370 if ((bg_flags & BG_IS_FROM_FILE)
1351 || (tr_flags & BG_EFFECTS_FLAGS)) 1371 || (tr_flags & BG_EFFECTS_FLAGS))
1352 { 1372 {
1353 if (render_image (tr_flags)) 1373 if (render_image (tr_flags))
1354 bg_flags |= BG_IS_VALID; 1374 bg_flags |= BG_IS_VALID;
1355 }
1356# endif
1357
1358# if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE)
1359 XImage *result = NULL;
1360
1361 if (tr_flags & BG_NEEDS_TINT)
1362 {
1363 result = XGetImage (dpy, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, ZPixmap);
1364 }
1365
1366 if (result)
1367 {
1368 /* our own client-side tinting */
1369 //if (tr_flags & BG_NEEDS_TINT)
1370 if (1)
1371 tint_ximage (DefaultVisual (dpy, display->screen), result);
1372
1373 GC gc = XCreateGC (dpy, vt, 0UL, NULL);
1374
1375 if (gc)
1376 {
1377 XPutImage (dpy, bg_pixmap, gc, result, 0, 0, 0, 0, result->width, result->height);
1378
1379 XFreeGC (dpy, gc);
1380 }
1381
1382 XDestroyImage (result);
1383 } 1375 }
1384# endif 1376# endif
1385 1377
1386 if (!(bg_flags & BG_IS_VALID)) 1378 if (!(bg_flags & BG_IS_VALID))
1387 { 1379 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines