--- rxvt-unicode/src/rxvtimg.C 2012/07/14 08:26:56 1.103 +++ rxvt-unicode/src/rxvtimg.C 2014/05/22 18:54:33 1.107 @@ -8,7 +8,7 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, @@ -535,7 +535,7 @@ Display *dpy = s->dpy; int size = max (rh, rv) * 2 + 1; nv *kernel = (nv *)malloc (size * sizeof (nv)); - XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); + XFixed *params = rxvt_temp_buf (size + 2); rxvt_img *img = new_empty (); XRenderPictureAttributes pa; @@ -580,7 +580,6 @@ } free (kernel); - free (params); XRenderFreePicture (dpy, src); XRenderFreePicture (dpy, dst); @@ -599,9 +598,9 @@ // why the hell does XRenderSetPictureTransform want a writable matrix :( // that keeps us from just static const'ing this matrix. XTransform h_double = { - 0x8000, 0, 0, - 0, 0x1000, 0, - 0, 0, 0x1000 + 0x08000, 0, 0, + 0, 0x10000, 0, + 0, 0, 0x10000 }; XRenderSetPictureFilter (cc.dpy, cc.src, "nearest", 0, 0); @@ -633,9 +632,9 @@ }; XTransform h_halve = { - 0x2000, 0, 0, - 0, 0x1000, 0, - 0, 0, 0x1000 + 0x20000, 0, 0, + 0, 0x10000, 0, + 0, 0, 0x10000 }; XRenderSetPictureFilter (cc.dpy, cc2.src, "nearest", 0, 0); @@ -917,6 +916,40 @@ } rxvt_img * +rxvt_img::shade (nv factor, rgba c) +{ + clamp_it (factor, -1., 1.); + factor++; + + if (factor > 1) + { + c.r = c.r * (2 - factor); + c.g = c.g * (2 - factor); + c.b = c.b * (2 - factor); + } + else + { + c.r = c.r * factor; + c.g = c.g * factor; + c.b = c.b * factor; + } + + rxvt_img *img = this->tint (c); + + if (factor > 1) + { + c.a = 0xffff; + c.r = + c.g = + c.b = 0xffff * (factor - 1); + + img->brightness (c.r, c.g, c.b, c.a); + } + + return img; +} + +rxvt_img * rxvt_img::filter (const char *name, int nparams, nv *params) { composer cc (this);