--- rxvt-unicode/src/rxvtperl.xs 2012/06/14 17:06:57 1.194 +++ rxvt-unicode/src/rxvtperl.xs 2012/12/28 21:19:21 1.207 @@ -59,7 +59,9 @@ #if HAVE_PIXBUF typedef GdkPixbuf * urxvt__pixbuf; #endif +#if HAVE_IMG typedef rxvt_img * urxvt__img; +typedef rxvt_img::nv rxvt_img__nv; ///////////////////////////////////////////////////////////////////////////// @@ -68,8 +70,10 @@ { rgba c; - if (AV *av = (AV *)SvRV (sv)) + if (SvROK (sv)) { + AV *av = (AV *)SvRV (sv); + if (SvTYPE ((SV *)av) != SVt_PVAV) croak ("colour must be either a colour string, or an array,"); @@ -97,11 +101,14 @@ rc.set (s, SvPVbyte_nolen (sv)); rc.get (c); } + else + croak ("unable to parse colour,"); return c; } ///////////////////////////////////////////////////////////////////////////// +#endif static wchar_t * sv2wcs (SV *sv) @@ -908,6 +915,62 @@ const_iv (RepeatNormal), const_iv (RepeatPad), const_iv (RepeatReflect), + // all versions + const_iv (PictOpClear), + const_iv (PictOpSrc), + const_iv (PictOpDst), + const_iv (PictOpOver), + const_iv (PictOpOverReverse), + const_iv (PictOpIn), + const_iv (PictOpInReverse), + const_iv (PictOpOut), + const_iv (PictOpOutReverse), + const_iv (PictOpAtop), + const_iv (PictOpAtopReverse), + const_iv (PictOpXor), + const_iv (PictOpAdd), + const_iv (PictOpSaturate), + // 0.2+ + const_iv (PictOpDisjointClear), + const_iv (PictOpDisjointSrc), + const_iv (PictOpDisjointDst), + const_iv (PictOpDisjointOver), + const_iv (PictOpDisjointOverReverse), + const_iv (PictOpDisjointIn), + const_iv (PictOpDisjointInReverse), + const_iv (PictOpDisjointOut), + const_iv (PictOpDisjointOutReverse), + const_iv (PictOpDisjointAtop), + const_iv (PictOpDisjointAtopReverse), + const_iv (PictOpDisjointXor), + const_iv (PictOpConjointClear), + const_iv (PictOpConjointSrc), + const_iv (PictOpConjointDst), + const_iv (PictOpConjointOver), + const_iv (PictOpConjointOverReverse), + const_iv (PictOpConjointIn), + const_iv (PictOpConjointInReverse), + const_iv (PictOpConjointOut), + const_iv (PictOpConjointOutReverse), + const_iv (PictOpConjointAtop), + const_iv (PictOpConjointAtopReverse), + const_iv (PictOpConjointXor), + // 0.11+ + const_iv (PictOpMultiply), + const_iv (PictOpScreen), + const_iv (PictOpOverlay), + const_iv (PictOpDarken), + const_iv (PictOpLighten), + const_iv (PictOpColorDodge), + const_iv (PictOpColorBurn), + const_iv (PictOpHardLight), + const_iv (PictOpSoftLight), + const_iv (PictOpDifference), + const_iv (PictOpExclusion), + const_iv (PictOpHSLHue), + const_iv (PictOpHSLSaturation), + const_iv (PictOpHSLColor), + const_iv (PictOpHSLLuminosity), #endif # if 0 const_iv (XIMForwardChar), @@ -1395,6 +1458,13 @@ OUTPUT: RETVAL +Window +rxvt_term::vt () + CODE: + RETVAL = THIS->vt; + OUTPUT: + RETVAL + void rxvt_term::vt_emask_add (U32 emask) CODE: @@ -2096,12 +2166,12 @@ #if HAVE_IMG rxvt_img * -rxvt_term::new_img (SV *format, int width = 1, int height = 1) +rxvt_term::new_img (SV *format = &PL_sv_undef, int x = 0, int y = 0, int width = 1, int height = 1) CODE: XRenderPictFormat *f = SvOK (format) ? XRenderFindStandardFormat (THIS->dpy, SvIV (format)) : XRenderFindVisualFormat (THIS->dpy, THIS->visual); - RETVAL = new rxvt_img (THIS, f, 0, 0, width, height); + RETVAL = new rxvt_img (THIS, f, x, y, width, height); RETVAL->alloc (); OUTPUT: RETVAL @@ -2148,10 +2218,10 @@ img = img->clone (); // own the img if (img->repeat != RepeatNormal) // X11 only supports RepeatNormal as bg pixmap - img->sub_rect (0, 0, - border ? THIS->vt_width : THIS->szHint.width, - border ? THIS->vt_height : THIS->szHint.height) - ->replace (img); + img->sub_rect (0, 0, + border ? THIS->vt_width : THIS->szHint.width, + border ? THIS->vt_height : THIS->szHint.height) + ->replace (img); // just in case, should usually be a nop img->reify () @@ -2201,7 +2271,7 @@ void DESTROY (urxvt::pixbuf self) CODE: - gdk_pixbuf_unref (self); + g_object_unref (self); #endif @@ -2212,17 +2282,30 @@ # rxvt_img *new (rxvt_screen *screen, XRenderPictFormat *format, int width, int height) # rxvt_img *rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height, Pixmap pixmap); -int -rxvt_img::w () - CODE: - RETVAL = THIS->w; - OUTPUT: - RETVAL +void +rxvt_img::geometry () + PPCODE: + EXTEND (SP, 4); + PUSHs (sv_2mortal (newSViv (THIS->x))); + PUSHs (sv_2mortal (newSViv (THIS->y))); + PUSHs (sv_2mortal (newSViv (THIS->w))); + PUSHs (sv_2mortal (newSViv (THIS->h))); int -rxvt_img::h () +rxvt_img::x () + ALIAS: + x = 0 + y = 1 + w = 2 + h = 3 CODE: - RETVAL = THIS->h; + switch (ix) + { + case 0: RETVAL = THIS->x; break; + case 1: RETVAL = THIS->y; break; + case 2: RETVAL = THIS->w; break; + case 3: RETVAL = THIS->h; break; + } OUTPUT: RETVAL @@ -2234,10 +2317,11 @@ RETVAL void -rxvt_img::fill (SV *c) +rxvt_img::fill (SV *c, int x = 0, int y = 0, int w = THIS->w, int h = THIS->h) + PROTOTYPE: $;$$$$ INIT: rgba cc = parse_rgba (c, THIS->s); - C_ARGS: cc + C_ARGS: cc, x, y, w, h void rxvt_img::DESTROY () @@ -2245,11 +2329,14 @@ delete THIS; void +rxvt_img::add_alpha () + +void rxvt_img::unshare () -int +void rxvt_img::repeat_mode (render_repeat_mode repeat = 0) - CODE: + PPCODE: if (items >= 2) THIS->repeat_mode (repeat); if (GIMME_V != G_VOID) @@ -2259,10 +2346,13 @@ rxvt_img::move (int dx, int dy) void -rxvt_img::brightness (NV r, NV g, NV b, NV a = 1.) +rxvt_img::brightness (rxvt_img::nv r, rxvt_img::nv g, rxvt_img::nv b, rxvt_img::nv a = 1.) void -rxvt_img::contrast (NV r, NV g, NV b, NV a = 1.) +rxvt_img::contrast (rxvt_img::nv r, rxvt_img::nv g, rxvt_img::nv b, rxvt_img::nv a = 1.) + +void +rxvt_img::draw (rxvt_img *img, int op = PictOpOver, rxvt_img::nv mask = 1.); rxvt_img * rxvt_img::clone () @@ -2277,9 +2367,12 @@ rxvt_img::blur (int rh, int rv) rxvt_img * -rxvt_img::transform (NV p11, NV p12, NV p13, NV p21, NV p22, NV p23, NV p31, NV p32, NV p33) +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: - double matrix[3][3] = { + rxvt_img::nv matrix[3][3] = { { p11, p12, p13 }, { p21, p22, p23 }, { p31, p32, p33 } @@ -2290,7 +2383,38 @@ rxvt_img::scale (int new_width, int new_height) rxvt_img * -rxvt_img::rotate (int x, int y, NV phi) +rxvt_img::rotate (int x, int y, rxvt_img::nv phi) + +rxvt_img * +rxvt_img::tint (SV *c) + INIT: + rgba cc = parse_rgba (c, THIS->s); + C_ARGS: cc + +rxvt_img * +rxvt_img::filter (octet_string name, SV *params = &PL_sv_undef) + CODE: + rxvt_img::nv *vparams = 0; + int nparams = 0; + + if (SvOK (params)) + { + // we overlay rxvt_temp_buf, what a hack + assert (sizeof (rxvt_img::nv) >= sizeof (int)); + + if (!SvROK (params) || SvTYPE (SvRV (params)) != SVt_PVAV) + croak ("rxvt_img::filter: params must be an array reference with parameter values"); + + nparams = av_len ((AV *)SvRV (params)) + 1; + vparams = rxvt_temp_buf (nparams); + + for (int i = 0; i < nparams; ++i) + vparams [i] = SvNV (*av_fetch ((AV *)SvRV (params), i, 1)); + } + + RETVAL = THIS->filter (name, nparams, vparams); + OUTPUT: + RETVAL #endif