-- Leo's gemini proxy
-- Connecting to git.thebackupbox.net:1965...
-- Connected
-- Sending request
-- Meta line: 20 text/gemini
repo: rxvt-unicode-sixel action: commit revision: path_from: revision_from: d82449d373c5d0219755dff728a1a15f6eca4096: path_to: revision_to:
commit d82449d373c5d0219755dff728a1a15f6eca4096 Author: Marc Lehmann <schmorp@schmorp.de> Date: Mon Jul 2 03:57:53 2012 +0000 hmm... diff --git a/src/rxvtimg.C b/src/rxvtimg.C
--- a/src/rxvtimg.C +++ b/src/rxvtimg.C @@ -172,9 +172,9 @@ namespace } ecb_noinline - void mask (bool rgb = true, int x = 1, int y = 1) + void mask (bool rgb = true, int w = 1, int h = 1) { - Pixmap pixmap = XCreatePixmap (dpy, srcimg->pm, x, y, rgb ? 32 : 8); + Pixmap pixmap = XCreatePixmap (dpy, srcimg->pm, w, h, rgb ? 32 : 8); XRenderPictFormat *format = XRenderFindStandardFormat (dpy, rgb ? PictStandardARGB32 : PictStandardA8); XRenderPictureAttributes pa; @@ -596,6 +596,64 @@ rxvt_img::blur (int rh, int rv) return img; } +rxvt_img * +rxvt_img::muladd (nv mul, nv add) +{ + // STEP 1: double the image width, fill all odd columns with white (==1) + + composer cc (this, new rxvt_img (s, format, 0, 0, w * 2, h, repeat)); + + // why the hell does XRenderSetPictureTransform want a writable matrix :( + // that keeps us from just static const'ing this matrix. + XTransform h_double = { + 32768, 0, 0, + 0, 65536, 0, + 0, 0, 65536 + }; + + XRenderSetPictureFilter (cc.dpy, cc.src, "nearest", 0, 0); + XRenderSetPictureTransform (cc.dpy, cc.src, &h_double); + XRenderComposite (cc.dpy, PictOpSrc, cc.src, None, cc.dst, 0, 0, 0, 0, 0, 0, w * 2, h); + + cc.mask (false, 2, 1); + + static const XRenderColor c0 = { 0, 0, 0, 0 }; + XRenderFillRectangle (cc.dpy, PictOpSrc, cc.msk, &c0, 0, 0, 1, 1); + static const XRenderColor c1 = { 65535, 65535, 65535, 65535 }; + XRenderFillRectangle (cc.dpy, PictOpSrc, cc.msk, &c1, 1, 0, 1, 1); + + Picture white = XRenderCreateSolidFill (cc.dpy, &c1); + + XRenderComposite (cc.dpy, PictOpOver, white, cc.msk, cc.dst, 0, 0, 0, 0, 0, 0, w * 2, h); + + XRenderFreePicture (cc.dpy, white); + + // STEP 2: convolve the image with a 3x1 filter + // a 2x1 filter would obviously suffice, but given the total lack of specification + // for xrender, I expect different xrender implementations to randomly diverge. + // we also halve the image, and hope for the best (again, for lack of specs). + composer cc2 (cc.dstimg); + + XFixed kernel [] = { + XDoubleToFixed (3), XDoubleToFixed (1), + XDoubleToFixed (0), XDoubleToFixed (mul), XDoubleToFixed (add) + }; + + XTransform h_halve = { + 131072, 0, 0, + 0, 65536, 0, + 0, 0, 65536 + }; + + XRenderSetPictureFilter (cc.dpy, cc2.src, "nearest", 0, 0); + XRenderSetPictureTransform (cc.dpy, cc2.src, &h_halve); + XRenderSetPictureFilter (cc.dpy, cc2.src, FilterConvolution, kernel, ecb_array_length (kernel)); + + XRenderComposite (cc.dpy, PictOpSrc, cc2.src, None, cc2.dst, 0, 0, 0, 0, 0, 0, w * 2, h); + + return cc2; +} + ecb_noinline static void extract (int32_t cl0, int32_t cl1, int32_t &c, unsigned short &xc) { diff --git a/src/rxvtimg.h b/src/rxvtimg.h
--- a/src/rxvtimg.h +++ b/src/rxvtimg.h @@ -94,6 +94,7 @@ struct rxvt_img //void linear_gradient (const XLinearGradient *gradient, const XFixed *stops, const XRenderColor *colors, int nstops); //void radial_gradient (const XRadialGradient *gradient, const XFixed *stops, const XRenderColor *colors, int nstops); //void conical_gradient (const XConicalGradient *gradient, const XFixed *stops, const XRenderColor *colors, int nstops); + void brightness (int32_t r, int32_t g, int32_t b, int32_t a); void contrast (int32_t r, int32_t g, int32_t b, int32_t a); @@ -130,6 +131,7 @@ struct rxvt_img rxvt_img *convert_format (XRenderPictFormat *format, const rgba &bg); rxvt_img *tint (const rgba &c); rxvt_img *filter (const char *name, int nparams = 0, nv *params = 0); + rxvt_img *muladd (nv mul, nv add); // general multiply and add, implemen ted as the biggets hack ever :/ // egregiuous helper category rxvt_img *replace (rxvt_img *&p) diff --git a/src/rxvtperl.xs b/src/rxvtperl.xs
--- a/src/rxvtperl.xs +++ b/src/rxvtperl.xs @@ -2364,6 +2364,9 @@ rxvt_img::sub_rect (int x, int y, int width, int height) rxvt_img * rxvt_img::blur (int rh, int rv) +rxvt_img * +rxvt_img::muladd (rxvt_img::nv mul, rxvt_img::nv add) + rxvt_img * rxvt_img::transform (rxvt_img::nv p11, rxvt_img::nv p12, rxvt_img::nv p13, rxvt_img::nv p21, rxvt_img::nv p22, rxvt_img::nv p23, rxvt_img::nv p31, rxvt_img::nv p32, rxvt_img::nv p33) INIT:
-----END OF PAGE-----
-- Response ended
-- Page fetched on Sun Jun 2 10:39:11 2024