repo: rxvt-unicode-sixel action: commit revision: path_from: revision_from: f978a897bdfd954a2e45a693eade22896cf63e76: path_to: revision_to:
commit f978a897bdfd954a2e45a693eade22896cf63e76 Author: Marc LehmannDate: Tue Jun 5 13:39:26 2012 +0000 *** empty log message *** diff --git a/src/perl/background b/src/perl/background
--- a/src/perl/background
+++ b/src/perl/background
@@ -1,6 +1,7 @@
#! perl
-our $EXPR = 'move load "/root/pix/das_fette_schwein.jpg", left, top';
+our $EXPR = 'move load "/root/pix/das_fette_schwein.jpg", repeat_wrap, X, Y';
+$EXPR = 'rotate load "/root/pix/das_fette_schwein.jpg", W, H, 50, 50, counter 1/60, repeat_mirror';
#$EXPR = 'blur root, 10, 10'
#$EXPR = 'blur move (root, -x, -y), 5, 5'
#resize load "/root/pix/das_fette_schwein.jpg", w, h
@@ -28,35 +29,53 @@ our ($l, $t, $w, $h);
die "root op not supported, exg, we need you";
}
+# sub clone($) {
+# $_[0]->clone
+# }
+
+ sub subrect($$$$$;$) {
+ $_[0]->sub_rect ($_[1], $_[2], $_[3], $_[4], $_[5])
+ }
+
sub resize($$$) {
$_[0]->scale ($_[1], $_[2])
}
- sub move($$$) {
+ sub move($$$;$) {
# TODO: must be simpler
- $_[0]->transform ($_[0]->w, $_[0]->h, $_[1],
- 1, 0, -$_[2],
- 0, 1, -$_[3],
- 0, 0, 1,
+ $_[0]->transform ($_[0]->w, $_[0]->h,
+ 1, 0, $_[1],
+ 0, 1, $_[2],
+ 0, 0, 1,
+ $_[3],
)
}
- sub rotate($$$$) {
- $_[0]->rotate ($_[0], $_[1], $_[2], $_[3] * (3.14159265 / 180))
+ sub rotate($$$$$$;$) {
+ $_[0]->rotate (
+ $_[1],
+ $_[2],
+ $_[3] * $_[0]->w * .01,
+ $_[4] * $_[0]->h * .01,
+ $_[5] * (3.14159265 / 180),
+ $_[6],
+ )
}
sub blur($$$) {
my ($img, $rh, $rv) = @_;
$img = $img->clone;
- $img->clone->blur ($rh, $rv);
+ $img->blur ($rh, $rv);
$img
}
sub contrast($$;$$;$) {
my ($img, $r, $g, $b, $a) = @_;
+
($g, $b) = ($r, $r) if @_ < 4;
$a = 1 if @_ < 5;
+
$img = $img->clone;
$img->contrast ($r, $g, $b, $a);
$img
@@ -64,17 +83,19 @@ our ($l, $t, $w, $h);
sub brightness($$;$$;$) {
my ($img, $r, $g, $b, $a) = @_;
+
($g, $b) = ($r, $r) if @_ < 4;
$a = 1 if @_ < 5;
+
$img = $img->clone;
$img->brightness ($r, $g, $b, $a);
$img
}
- sub left () { $new->{position_sensitive} = 1; $l }
- sub top () { $new->{position_sensitive} = 1; $t }
- sub width () { $new->{size_sensitive} = 1; $w }
- sub height() { $new->{size_sensitive} = 1; $h }
+ sub X() { $new->{position_sensitive} = 1; $l }
+ sub Y() { $new->{position_sensitive} = 1; $t }
+ sub W() { $new->{size_sensitive} = 1; $w }
+ sub H() { $new->{size_sensitive} = 1; $h }
sub now() { urxvt::NOW }
@@ -98,7 +119,6 @@ sub parse_expr {
sub set_expr {
my ($self, $expr) = @_;
- local $Data::Dumper::Deparse=1; use Data::Dumper; warn Dumper $expr;#d#
$self->{expr} = $expr;
$self->recalculate;
}
@@ -115,8 +135,6 @@ sub recalculate {
($l, $t, $w, $h) =
$self->get_geometry;
- warn "$l, $t";#d#
-
my $img = eval { $self->{expr}->() };
warn $@ if $@;#d#
@@ -141,9 +159,9 @@ sub recalculate {
$self->disable ("size_change");
}
- # TODO: install handlers for geometry changes &c
+ $img = $img->sub_rect (0, 0, $w, $h)
+ if $img->w != $w || $img->h != $h;
- warn $img;
$self->set_background ($img);
$self->scr_recolour (0);
$self->want_refresh;
diff --git a/src/rxvtimg.C b/src/rxvtimg.C
--- a/src/rxvtimg.C
+++ b/src/rxvtimg.C
@@ -312,15 +312,34 @@ rxvt_img::render_pixbuf (GdkPixbuf *pixbuf, int src_x, int src_y, int width, int
rxvt_img *
rxvt_img::clone ()
{
+ rxvt_img *img = new rxvt_img (s, format, w, h);
+
GC gc = XCreateGC (s->display->dpy, pm, 0, 0);
- Pixmap pm2 = XCreatePixmap (s->display->dpy, pm, w, h, format->depth);
- XCopyArea (s->display->dpy, pm, pm2, gc, 0, 0, w, h, 0, 0);
+ XCopyArea (s->display->dpy, pm, img->pm, gc, 0, 0, w, h, 0, 0);
XFreeGC (s->display->dpy, gc);
- return new rxvt_img (s, format, w, h, pm2);
}
rxvt_img *
-rxvt_img::transform (int new_width, int new_height, int repeat, double matrix[9])
+rxvt_img::sub_rect (int x, int y, int width, int height, int repeat)
+{
+ rxvt_img *img = new rxvt_img (s, format, width, height);
+
+ Display *dpy = s->display->dpy;
+ XRenderPictureAttributes pa;
+ pa.repeat = repeat;
+ Picture src = XRenderCreatePicture (dpy, pm, format, CPRepeat, &pa);
+ Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0);
+
+ XRenderComposite (dpy, PictOpSrc, src, None, dst, x, y, 0, 0, 0, 0, width, height);
+
+ XRenderFreePicture (dpy, src);
+ XRenderFreePicture (dpy, dst);
+
+ return img;
+}
+
+rxvt_img *
+rxvt_img::transform (int new_width, int new_height, double matrix[9], int repeat)
{
rxvt_img *img = new rxvt_img (s, format, new_width, new_height);
@@ -355,11 +374,11 @@ rxvt_img::scale (int new_width, int new_height)
0, 0, 1
};
- return transform (new_width, new_height, RepeatNormal, matrix);
+ return transform (new_width, new_height, matrix);
}
rxvt_img *
-rxvt_img::rotate (int new_width, int new_height, int repeat, int x, int y, double phi)
+rxvt_img::rotate (int new_width, int new_height, int x, int y, double phi, int repeat)
{
double s = sin (phi);
double c = cos (phi);
@@ -370,7 +389,7 @@ rxvt_img::rotate (int new_width, int new_height, int repeat, int x, int y, doubl
0, 0, 1
};
- return transform (new_width, new_height, repeat, matrix);
+ return transform (new_width, new_height, matrix, repeat);
}
rxvt_img *
diff --git a/src/rxvtimg.h b/src/rxvtimg.h
--- a/src/rxvtimg.h +++ b/src/rxvtimg.h @@ -40,9 +40,10 @@ struct rxvt_img // copy rxvt_img *clone (); - rxvt_img *transform (int new_width, int new_height, int repeat, double matrix[9]); + 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); rxvt_img *scale (int new_width, int new_height); - rxvt_img *rotate (int new_width, int new_height, int repeat, int x, int y, double phi); + rxvt_img *rotate (int new_width, int new_height, int x, int y, double phi, int repeat = RepeatNormal); rxvt_img *convert_to (XRenderPictFormat *format); }; diff --git a/src/rxvtperl.xs b/src/rxvtperl.xs
--- a/src/rxvtperl.xs
+++ b/src/rxvtperl.xs
@@ -54,6 +54,8 @@
typedef char * octet_string;
typedef char * utf8_string;
+typedef int render_repeat_mode;
+
typedef GdkPixbuf * urxvt__pixbuf;
typedef rxvt_img * urxvt__img;
@@ -847,6 +849,22 @@ fatal (const char *msg)
void
_exit (int status)
+void
+catch_fatal (SV *block)
+ PROTOTYPE: &
+ CODE:
+ try
+ {
+ PUSHMARK (SP);
+ PUTBACK;
+ call_sv (block, G_VOID | G_DISCARD);
+ SPAGAIN;
+ }
+ catch (const rxvt_failure_exception &e)
+ {
+ croak ("rxvt_fatal exception caught, trying to continue.");
+ }
+
NV
NOW ()
CODE:
@@ -2128,20 +2146,23 @@ rxvt_img *
rxvt_img::clone ()
rxvt_img *
-rxvt_img::transform (int new_width, int new_height, int repeat, NV p11, NV p12, NV p13, NV p21, NV p22, NV p23, NV p31, NV p32, NV p33)
+rxvt_img::sub_rect (int x, int y, int width, int height, render_repeat_mode repeat = RepeatNormal)
+
+rxvt_img *
+rxvt_img::transform (int new_width, int new_height, NV p11, NV p12, NV p13, NV p21, NV p22, NV p23, NV p31, NV p32, NV p33, render_repeat_mode repeat = RepeatNormal)
INIT:
double matrix[9] = {
p11, p12, p13,
p21, p22, p23,
p31, p32, p33
};
- C_ARGS: new_width, new_height, repeat, matrix
+ C_ARGS: new_width, new_height, matrix, repeat
rxvt_img *
rxvt_img::scale (int new_width, int new_height)
rxvt_img *
-rxvt_img::rotate (int new_width, int new_height, int repeat, int x, int y, NV phi)
+rxvt_img::rotate (int new_width, int new_height, int x, int y, NV phi, render_repeat_mode repeat = RepeatNormal)
#endif
diff --git a/src/rxvttoolkit.C b/src/rxvttoolkit.C
--- a/src/rxvttoolkit.C
+++ b/src/rxvttoolkit.C
@@ -475,6 +475,9 @@ bool rxvt_display::ref_init ()
{
flags |= DISPLAY_HAS_RENDER;
+ if (major > 0 || (major == 0 && minor >= 10))
+ flags |= DISPLAY_HAS_RENDER_10;
+
if (major > 0 || (major == 0 && minor >= 11))
flags |= DISPLAY_HAS_RENDER_MUL;
diff --git a/src/rxvttoolkit.h b/src/rxvttoolkit.h
--- a/src/rxvttoolkit.h
+++ b/src/rxvttoolkit.h
@@ -220,8 +220,9 @@ struct rxvt_screen
enum {
DISPLAY_HAS_RENDER = 1 << 0,
- DISPLAY_HAS_RENDER_MUL = 1 << 1,
- DISPLAY_HAS_RENDER_CONV = 1 << 2,
+ DISPLAY_HAS_RENDER_10 = 1 << 1,
+ DISPLAY_HAS_RENDER_MUL = 1 << 2,
+ DISPLAY_HAS_RENDER_CONV = 1 << 3,
};
struct rxvt_display : refcounted
diff --git a/src/typemap b/src/typemap
--- a/src/typemap
+++ b/src/typemap
@@ -15,6 +15,8 @@ rxvt_img * IMG
GError ** T_UV
+render_repeat_mode RENDER_REPEAT_MODE
+
INPUT
TERM
@@ -34,6 +36,16 @@ IMG
else
croak (\"%s is not of type urxvt::img\", \"$var\")
+RENDER_REPEAT_MODE
+ if (SvOK ($arg))
+ {
+ $var = SvIV ($arg);
+ if ($var != RepeatNone && $var != RepeatNormal && $var != RepeatPad && $var != RepeatReflect)
+ croak (\"invalid repeat mode specified (%d)\\n\", $var);
+ }
+ else
+ $var = RepeatNormal;
+
OUTPUT
TERM
-----END OF PAGE-----