--- rxvt-unicode/src/rxvtimg.C 2012/06/07 10:19:23 1.39 +++ rxvt-unicode/src/rxvtimg.C 2012/06/07 13:02:50 1.43 @@ -4,8 +4,8 @@ #if HAVE_IMG -rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int x, int y, int width, int height) -: s(screen), x(x), y(y), w(width), h(height), format(format), repeat(RepeatNormal), +rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int x, int y, int width, int height, int repeat) +: s(screen), x(x), y(y), w(width), h(height), format(format), repeat(repeat), pm(0), ref(0) { } @@ -178,7 +178,7 @@ int size = max (rh, rv) * 2 + 1; double *kernel = (double *)malloc (size * sizeof (double)); XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); - rxvt_img *img = new rxvt_img (s, format, x, y, w, h); + rxvt_img *img = new rxvt_img (s, format, x, y, w, h, repeat); img->alloc (); Picture src = src_picture (); @@ -399,16 +399,27 @@ if (x == 0 && y == 0 && w == ref->w && h == ref->h) return clone (); - rxvt_img *img = new rxvt_img (s, format, 0, 0, w, h); - img->alloc (); - Display *dpy = s->display->dpy; + bool alpha = !format->direct.alphaMask + && (x || y) + && repeat == RepeatNone; + + rxvt_img *img = new rxvt_img (s, alpha ? XRenderFindStandardFormat (dpy, PictStandardARGB32) : format, 0, 0, w, h, repeat); + img->alloc (); + Picture src = src_picture (); Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); - XRenderComposite (dpy, PictOpSrc, src, None, dst, x, y, 0, 0, 0, 0, w, h); - + if (alpha) + { + XRenderColor rc = { 0, 0, 0, 0 }; + XRenderFillRectangle (dpy, PictOpSrc, dst, &rc, 0, 0, w, h); + XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, -x, -y, ref->w, ref->h); + } + else + XRenderComposite (dpy, PictOpSrc, src, None, dst, x, y, 0, 0, 0, 0, w, h); + XRenderFreePicture (dpy, src); XRenderFreePicture (dpy, dst); @@ -439,7 +450,7 @@ rxvt_img * rxvt_img::transform (int new_width, int new_height, double matrix[9]) { - rxvt_img *img = new rxvt_img (s, format, 0, 0, new_width, new_height); + rxvt_img *img = new rxvt_img (s, format, 0, 0, new_width, new_height, repeat); img->alloc (); Display *dpy = s->display->dpy; @@ -468,13 +479,24 @@ rxvt_img * rxvt_img::scale (int new_width, int new_height) { + if (w == new_width && h == new_height) + return clone (); + double matrix[9] = { w / (double)new_width, 0, 0, 0, h / (double)new_height, 0, 0, 0, 1 }; - return transform (new_width, new_height, matrix); + int old_repeat_mode = repeat; + repeat = RepeatPad; // not right, but xrender can't proeprly scale it seems + + rxvt_img *img = transform (new_width, new_height, matrix); + + repeat = old_repeat_mode; + img->repeat = repeat; + + return img; } rxvt_img * @@ -498,9 +520,11 @@ if (new_format == format) return clone (); - rxvt_img *img = new rxvt_img (s, new_format, 0, 0, w, h); + rxvt_img *img = new rxvt_img (s, new_format, 0, 0, w, h, repeat); img->alloc (); + printf ("convert %d to %d\n", format->direct.alphaMask, new_format->direct.alphaMask);//D + Display *dpy = s->display->dpy; Picture src = src_picture (); Picture dst = XRenderCreatePicture (dpy, img->pm, new_format, 0, 0);