ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtimg.C
(Generate patch)

Comparing rxvt-unicode/src/rxvtimg.C (file contents):
Revision 1.32 by root, Thu Jun 7 07:53:12 2012 UTC vs.
Revision 1.33 by root, Thu Jun 7 08:12:55 2012 UTC

2#include "../config.h" 2#include "../config.h"
3#include "rxvt.h" 3#include "rxvt.h"
4 4
5#if HAVE_IMG 5#if HAVE_IMG
6 6
7rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int width, int height) 7rxvt_img::rxvt_img (rxvt_screen *screen, XRenderPictFormat *format, int x, int y, int width, int height)
8: s(screen), x(0), y(0), w(width), h(height), format(format), repeat(RepeatNormal), 8: s(screen), x(x), y(y), w(width), h(height), format(format), repeat(RepeatNormal),
9 pm(0), refcnt(0) 9 pm(0), refcnt(0)
10{ 10{
11} 11}
12 12
13rxvt_img::rxvt_img (const rxvt_img &img) 13rxvt_img::rxvt_img (const rxvt_img &img)
44 return 0; 44 return 0;
45 45
46 rxvt_img *img = new rxvt_img ( 46 rxvt_img *img = new rxvt_img (
47 s, 47 s,
48 XRenderFindVisualFormat (dpy, DefaultVisual (dpy, s->display->screen)), 48 XRenderFindVisualFormat (dpy, DefaultVisual (dpy, s->display->screen)),
49 0,
50 0,
49 root_pm_w, 51 root_pm_w,
50 root_pm_h 52 root_pm_h
51 ); 53 );
52 54
53 img->pm = root_pixmap; 55 img->pm = root_pixmap;
65 rxvt_fatal ("rxvt_img::new_from_file: %s\n", err->message); 67 rxvt_fatal ("rxvt_img::new_from_file: %s\n", err->message);
66 68
67 rxvt_img *img = new rxvt_img ( 69 rxvt_img *img = new rxvt_img (
68 s, 70 s,
69 XRenderFindStandardFormat (s->display->dpy, gdk_pixbuf_get_has_alpha (pb) ? PictStandardARGB32 : PictStandardRGB24), 71 XRenderFindStandardFormat (s->display->dpy, gdk_pixbuf_get_has_alpha (pb) ? PictStandardARGB32 : PictStandardRGB24),
72 0,
73 0,
70 gdk_pixbuf_get_width (pb), 74 gdk_pixbuf_get_width (pb),
71 gdk_pixbuf_get_height (pb) 75 gdk_pixbuf_get_height (pb)
72 ); 76 );
73 img->alloc (); 77 img->alloc ();
74 img->render_pixbuf (pb, 0, 0, img->w, img->h, 0, 0); 78 img->render_pixbuf (pb, 0, 0, img->w, img->h, 0, 0);
158 162
159 Display *dpy = s->display->dpy; 163 Display *dpy = s->display->dpy;
160 int size = max (rh, rv) * 2 + 1; 164 int size = max (rh, rv) * 2 + 1;
161 double *kernel = (double *)malloc (size * sizeof (double)); 165 double *kernel = (double *)malloc (size * sizeof (double));
162 XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); 166 XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed));
163 rxvt_img *img = new rxvt_img (s, format, w, h); 167 rxvt_img *img = new rxvt_img (s, format, x, y, w, h);
164 img->alloc (); 168 img->alloc ();
165 169
166 XRenderPictureAttributes pa; 170 XRenderPictureAttributes pa;
167 171
168 pa.repeat = RepeatPad; 172 pa.repeat = RepeatPad;
374{ 378{
375 return new rxvt_img (*this); 379 return new rxvt_img (*this);
376} 380}
377 381
378rxvt_img * 382rxvt_img *
379rxvt_img::sub_rect (int x, int y, int width, int height) 383rxvt_img::reify ()
380{ 384{
381 rxvt_img *img = new rxvt_img (s, format, width, height); 385 rxvt_img *img = new rxvt_img (s, format, 0, 0, w, h);
382 img->alloc (); 386 img->alloc ();
387
388 // todo, if x==0 and y==0 and w==real width we could clone
389 // but that involves an rtt to find pixmap width.
383 390
384 Display *dpy = s->display->dpy; 391 Display *dpy = s->display->dpy;
385 XRenderPictureAttributes pa; 392 XRenderPictureAttributes pa;
386 pa.repeat = repeat; 393 pa.repeat = repeat;
387 Picture src = XRenderCreatePicture (dpy, pm, format, CPRepeat, &pa); 394 Picture src = XRenderCreatePicture (dpy, pm, format, CPRepeat, &pa);
388 Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); 395 Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0);
389 396
390 XRenderComposite (dpy, PictOpSrc, src, None, dst, x, y, 0, 0, 0, 0, width, height); 397 XRenderComposite (dpy, PictOpSrc, src, None, dst, x, y, 0, 0, 0, 0, w, h);
391 398
392 XRenderFreePicture (dpy, src);
393 XRenderFreePicture (dpy, dst); 399 XRenderFreePicture (dpy, src);
400 XRenderFreePicture (dpy, dst);
401
402 return img;
403}
404
405rxvt_img *
406rxvt_img::sub_rect (int x, int y, int width, int height)
407{
408 rxvt_img *img = clone ();
409
410 img->x += x;
411 img->y += y;
412 img->w = width;
413 img->h = height;
394 414
395 return img; 415 return img;
396} 416}
397 417
398rxvt_img * 418rxvt_img *
399rxvt_img::transform (int new_width, int new_height, double matrix[9]) 419rxvt_img::transform (int new_width, int new_height, double matrix[9])
400{ 420{
401 rxvt_img *img = new rxvt_img (s, format, new_width, new_height); 421 rxvt_img *img = new rxvt_img (s, format, 0, 0, new_width, new_height);
402 img->alloc (); 422 img->alloc ();
403 423
404 Display *dpy = s->display->dpy; 424 Display *dpy = s->display->dpy;
405 XRenderPictureAttributes pa; 425 XRenderPictureAttributes pa;
406 pa.repeat = repeat; 426 pa.repeat = repeat;
410 XTransform xfrm; 430 XTransform xfrm;
411 431
412 for (int i = 0; i < 3; ++i) 432 for (int i = 0; i < 3; ++i)
413 for (int j = 0; j < 3; ++j) 433 for (int j = 0; j < 3; ++j)
414 xfrm.matrix [i][j] = XDoubleToFixed (matrix [i * 3 + j]); 434 xfrm.matrix [i][j] = XDoubleToFixed (matrix [i * 3 + j]);
435
436 xfrm.matrix [0][2] += XDoubleToFixed (x);//TODO
437 xfrm.matrix [0][3] += XDoubleToFixed (y);
415 438
416 XRenderSetPictureFilter (dpy, src, "good", 0, 0); 439 XRenderSetPictureFilter (dpy, src, "good", 0, 0);
417 XRenderSetPictureTransform (dpy, src, &xfrm); 440 XRenderSetPictureTransform (dpy, src, &xfrm);
418 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, new_width, new_height); 441 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, new_width, new_height);
419 442
454rxvt_img::convert_to (XRenderPictFormat *new_format, const rxvt_color &bg) 477rxvt_img::convert_to (XRenderPictFormat *new_format, const rxvt_color &bg)
455{ 478{
456 if (new_format == format) 479 if (new_format == format)
457 return clone (); 480 return clone ();
458 481
459 rxvt_img *img = new rxvt_img (s, new_format, w, h); 482 rxvt_img *img = new rxvt_img (s, new_format, x, y, w, h);
460 img->alloc (); 483 img->alloc ();
461 484
462 Display *dpy = s->display->dpy; 485 Display *dpy = s->display->dpy;
463 Picture src = XRenderCreatePicture (dpy, pm, format, 0, 0); 486 Picture src = XRenderCreatePicture (dpy, pm, format, 0, 0);
464 Picture dst = XRenderCreatePicture (dpy, img->pm, new_format, 0, 0); 487 Picture dst = XRenderCreatePicture (dpy, img->pm, new_format, 0, 0);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines