repo: rxvt-unicode-sixel action: commit revision: path_from: revision_from: 853c74f08650c122568fcb3ddfc9df278fbeafa6: path_to: revision_to:
commit 853c74f08650c122568fcb3ddfc9df278fbeafa6 Author: Emanuele GiaquintaDate: Tue Jun 5 15:18:24 2012 +0000 Make rxvt_img::blur non-inplace. diff --git a/src/perl/background b/src/perl/background
--- a/src/perl/background
+++ b/src/perl/background
@@ -75,9 +75,7 @@ our $MIN_INTERVAL = 1/100;
sub blur($$$) {
my ($rh, $rv, $img) = @_;
- $img = $img->clone;
$img->blur ($rh, $rv);
- $img
}
sub contrast($$;$$;$) {
diff --git a/src/rxvtimg.C b/src/rxvtimg.C
--- a/src/rxvtimg.C
+++ b/src/rxvtimg.C
@@ -121,24 +121,27 @@ get_gaussian_kernel (int radius, int width, double *kernel, XFixed *params)
params[i+2] = XDoubleToFixed (kernel[i] / sum);
}
-void
+rxvt_img *
rxvt_img::blur (int rh, int rv)
{
if (!(s->display->flags & DISPLAY_HAS_RENDER_CONV))
- return;
+ return clone ();
Display *dpy = s->display->dpy;
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, w, h);
XRenderPictureAttributes pa;
pa.repeat = RepeatPad;
- Picture src = XRenderCreatePicture (dpy, pm , format, CPRepeat, &pa);
- Pixmap tmp = XCreatePixmap (dpy, pm, w, h, format->depth);
- Picture dst = XRenderCreatePicture (dpy, tmp, format, CPRepeat, &pa);
- XFreePixmap (dpy, tmp);
+ Picture src = XRenderCreatePicture (dpy, pm , format, CPRepeat, &pa);
+ Picture dst = XRenderCreatePicture (dpy, img->pm, format, CPRepeat, &pa);
+
+ Pixmap tmp_pm = XCreatePixmap (dpy, pm, w, h, format->depth);
+ Picture tmp = XRenderCreatePicture (dpy, tmp_pm , format, CPRepeat, &pa);
+ XFreePixmap (dpy, tmp_pm);
if (kernel && params)
{
@@ -150,14 +153,12 @@ rxvt_img::blur (int rh, int rv)
PictOpSrc,
src,
None,
- dst,
+ tmp,
0, 0,
0, 0,
0, 0,
w, h);
- ::swap (src, dst);
-
size = rv * 2 + 1;
get_gaussian_kernel (rv, size, kernel, params);
::swap (params[0], params[1]);
@@ -165,7 +166,7 @@ rxvt_img::blur (int rh, int rv)
XRenderSetPictureFilter (dpy, src, FilterConvolution, params, size+2);
XRenderComposite (dpy,
PictOpSrc,
- src,
+ tmp,
None,
dst,
0, 0,
@@ -178,6 +179,9 @@ rxvt_img::blur (int rh, int rv)
free (params);
XRenderFreePicture (dpy, src);
XRenderFreePicture (dpy, dst);
+ XRenderFreePicture (dpy, tmp);
+
+ return img;
}
static Picture
diff --git a/src/rxvtimg.h b/src/rxvtimg.h
--- a/src/rxvtimg.h +++ b/src/rxvtimg.h @@ -33,12 +33,12 @@ struct rxvt_img // inplace void unshare (); // create a copy of the pixmap if !shared void fill (const rxvt_color &c); - void blur (int rh, int rv); void brightness (double r, double g, double b, double a = 1.); void contrast (double r, double g, double b, double a = 1.); bool render_pixbuf (GdkPixbuf *pixbuf, int src_x, int src_y, int width, int height, int dst_x, int dst_y); // copy + rxvt_img *blur (int rh, int rv); rxvt_img *clone (); rxvt_img *sub_rect (int x, int y, int width, int height, int repeat = RepeatNormal); rxvt_img *transform (int new_width, int new_height, double matrix[9], int repeat = RepeatNormal); diff --git a/src/rxvtperl.xs b/src/rxvtperl.xs
--- a/src/rxvtperl.xs
+++ b/src/rxvtperl.xs
@@ -2130,7 +2130,7 @@ rxvt_img::DESTROY ()
CODE:
delete THIS;
-void
+rxvt_img *
rxvt_img::blur (int rh, int rv)
void
-----END OF PAGE-----