… | |
… | |
50 | |
50 | |
51 | return img; |
51 | return img; |
52 | } |
52 | } |
53 | |
53 | |
54 | # if HAVE_PIXBUF |
54 | # if HAVE_PIXBUF |
|
|
55 | |
55 | rxvt_img * |
56 | rxvt_img * |
56 | rxvt_img::new_from_pixbuf (rxvt_screen *s, GdkPixbuf *pb) |
57 | rxvt_img::new_from_pixbuf (rxvt_screen *s, GdkPixbuf *pb) |
57 | { |
58 | { |
58 | Display *dpy = s->display->dpy; |
59 | Display *dpy = s->display->dpy; |
59 | |
60 | |
… | |
… | |
166 | |
167 | |
167 | g_object_unref (pb); |
168 | g_object_unref (pb); |
168 | |
169 | |
169 | return img; |
170 | return img; |
170 | } |
171 | } |
|
|
172 | |
171 | # endif |
173 | # endif |
172 | |
174 | |
173 | void |
175 | void |
174 | rxvt_img::destroy () |
176 | rxvt_img::destroy () |
175 | { |
177 | { |
… | |
… | |
224 | } |
226 | } |
225 | |
227 | |
226 | void |
228 | void |
227 | rxvt_img::fill (const rxvt_color &c) |
229 | rxvt_img::fill (const rxvt_color &c) |
228 | { |
230 | { |
229 | XGCValues gcv; |
231 | rgba cc; |
230 | gcv.foreground = c; |
232 | c.get (cc); |
231 | GC gc = XCreateGC (s->display->dpy, pm, GCForeground, &gcv); |
233 | XRenderColor rc = { cc.r, cc.g, cc.b, cc.a }; |
232 | XFillRectangle (s->display->dpy, pm, gc, 0, 0, w, h); |
234 | |
233 | XFreeGC (s->display->dpy, gc); |
235 | Display *dpy = s->display->dpy; |
|
|
236 | Picture src = src_picture (); |
|
|
237 | XRenderFillRectangle (dpy, PictOpSrc, src, &rc, 0, 0, w, h); |
|
|
238 | XRenderFreePicture (dpy, src); |
234 | } |
239 | } |
235 | |
240 | |
236 | static void |
241 | static void |
237 | get_gaussian_kernel (int radius, int width, double *kernel, XFixed *params) |
242 | get_gaussian_kernel (int radius, int width, double *kernel, XFixed *params) |
238 | { |
243 | { |
… | |
… | |
308 | w, h); |
313 | w, h); |
309 | } |
314 | } |
310 | |
315 | |
311 | free (kernel); |
316 | free (kernel); |
312 | free (params); |
317 | free (params); |
|
|
318 | |
313 | XRenderFreePicture (dpy, src); |
319 | XRenderFreePicture (dpy, src); |
314 | XRenderFreePicture (dpy, dst); |
320 | XRenderFreePicture (dpy, dst); |
315 | XRenderFreePicture (dpy, tmp); |
321 | XRenderFreePicture (dpy, tmp); |
316 | |
322 | |
317 | return img; |
323 | return img; |
… | |
… | |
514 | |
520 | |
515 | return img; |
521 | return img; |
516 | } |
522 | } |
517 | |
523 | |
518 | rxvt_img * |
524 | rxvt_img * |
519 | rxvt_img::transform (int new_width, int new_height, double matrix[9]) |
525 | rxvt_img::transform (double matrix[9], int new_width, int new_height) |
520 | { |
526 | { |
521 | rxvt_img *img = new rxvt_img (s, format, 0, 0, new_width, new_height, repeat); |
527 | rxvt_img *img = new rxvt_img (s, format, 0, 0, new_width, new_height, repeat); |
522 | img->alloc (); |
528 | img->alloc (); |
523 | |
529 | |
524 | Display *dpy = s->display->dpy; |
530 | Display *dpy = s->display->dpy; |
… | |
… | |
555 | 0, h / (double)new_height, 0, |
561 | 0, h / (double)new_height, 0, |
556 | 0, 0, 1 |
562 | 0, 0, 1 |
557 | }; |
563 | }; |
558 | |
564 | |
559 | int old_repeat_mode = repeat; |
565 | int old_repeat_mode = repeat; |
560 | repeat = RepeatPad; // not right, but xrender can't proeprly scale it seems |
566 | repeat = RepeatPad; // not right, but xrender can't properly scale it seems |
561 | |
567 | |
562 | rxvt_img *img = transform (new_width, new_height, matrix); |
568 | rxvt_img *img = transform (matrix, new_width, new_height); |
563 | |
569 | |
564 | repeat = old_repeat_mode; |
570 | repeat = old_repeat_mode; |
565 | img->repeat = repeat; |
571 | img->repeat = repeat; |
566 | |
572 | |
567 | return img; |
573 | return img; |
568 | } |
574 | } |
569 | |
575 | |
570 | rxvt_img * |
576 | rxvt_img * |
571 | rxvt_img::rotate (int new_width, int new_height, int x, int y, double phi) |
577 | rxvt_img::rotate (int x, int y, double phi, int new_width, int new_height) |
572 | { |
578 | { |
573 | double s = sin (phi); |
579 | double s = sin (phi); |
574 | double c = cos (phi); |
580 | double c = cos (phi); |
575 | |
581 | |
576 | double matrix[9] = { |
582 | double matrix[9] = { |
577 | c, -s, -c * x + s * y + x, |
583 | c, -s, -c * x + s * y + x, |
578 | s, c, -s * x - c * y + y, |
584 | s, c, -s * x - c * y + y, |
579 | 0, 0, 1 |
585 | 0, 0, 1 |
580 | }; |
586 | }; |
581 | |
587 | |
582 | return transform (new_width, new_height, matrix); |
588 | return transform (matrix, new_width, new_height); |
583 | } |
589 | } |
584 | |
590 | |
585 | rxvt_img * |
591 | rxvt_img * |
586 | rxvt_img::convert_format (XRenderPictFormat *new_format, const rxvt_color &bg) |
592 | rxvt_img::convert_format (XRenderPictFormat *new_format, const rxvt_color &bg) |
587 | { |
593 | { |