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.85 by root, Thu Jun 14 18:59:39 2012 UTC vs.
Revision 1.90 by root, Thu Jun 14 19:44:45 2012 UTC

530 XRenderComposite (dpy, op, src, mask_p, dst, x - img->x, y - img->y, 0, 0, 0, 0, w, h); 530 XRenderComposite (dpy, op, src, mask_p, dst, x - img->x, y - img->y, 0, 0, 0, 0, w, h);
531 531
532 XRenderFreePicture (dpy, src); 532 XRenderFreePicture (dpy, src);
533 XRenderFreePicture (dpy, dst); 533 XRenderFreePicture (dpy, dst);
534 534
535 if (mask) 535 if (mask_p)
536 XRenderFreePicture (dpy, mask_p); 536 XRenderFreePicture (dpy, mask_p);
537} 537}
538 538
539rxvt_img * 539rxvt_img *
540rxvt_img::clone () 540rxvt_img::clone ()
563 563
564 if (alpha) 564 if (alpha)
565 { 565 {
566 XRenderColor rc = { 0, 0, 0, 0 }; 566 XRenderColor rc = { 0, 0, 0, 0 };
567 XRenderFillRectangle (dpy, PictOpSrc, dst, &rc, 0, 0, w, h);//TODO: split into four fillrectangles 567 XRenderFillRectangle (dpy, PictOpSrc, dst, &rc, 0, 0, w, h);//TODO: split into four fillrectangles
568 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, -x, -y, ref->w, ref->h); 568 XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, x, y, ref->w, ref->h);
569 } 569 }
570 else 570 else
571 XRenderComposite (dpy, PictOpSrc, src, None, dst, x, y, 0, 0, 0, 0, w, h); 571 XRenderComposite (dpy, PictOpSrc, src, None, dst, -x, -y, 0, 0, 0, 0, w, h);
572 572
573 XRenderFreePicture (dpy, src); 573 XRenderFreePicture (dpy, src);
574 XRenderFreePicture (dpy, dst); 574 XRenderFreePicture (dpy, dst);
575 575
576 return img; 576 return img;
579rxvt_img * 579rxvt_img *
580rxvt_img::sub_rect (int x, int y, int width, int height) 580rxvt_img::sub_rect (int x, int y, int width, int height)
581{ 581{
582 rxvt_img *img = clone (); 582 rxvt_img *img = clone ();
583 583
584 img->x += x; 584 img->x -= x;
585 img->y += y; 585 img->y -= y;
586 586
587 if (w != width || h != height) 587 if (w != width || h != height)
588 { 588 {
589 img->w = width; 589 img->w = width;
590 img->h = height; 590 img->h = height;
629} 629}
630 630
631rxvt_img * 631rxvt_img *
632rxvt_img::transform (nv matrix[3][3]) 632rxvt_img::transform (nv matrix[3][3])
633{ 633{
634 // find new offset
635 int ox = mat_apply (matrix, 0, x, y);
636 int oy = mat_apply (matrix, 1, x, y);
637
638 // calculate new pixel bounding box coordinates 634 // calculate new pixel bounding box coordinates
639 nv d [2], rmin[2], rmax[2]; 635 nv rmin[2], rmax[2];
640 636
641 for (int i = 0; i < 2; ++i) 637 for (int i = 0; i < 2; ++i)
642 { 638 {
643 nv v; 639 nv v;
640
644 v = mat_apply (matrix, i, 0, 0); rmin [i] = rmax [i] = v; d [i] = v; 641 v = mat_apply (matrix, i, 0+x, 0+y); rmin [i] = rmax [i] = v;
645 v = mat_apply (matrix, i, w, 0); min_it (rmin [i], v); max_it (rmax [i], v); 642 v = mat_apply (matrix, i, w+x, 0+y); min_it (rmin [i], v); max_it (rmax [i], v);
646 v = mat_apply (matrix, i, 0, h); min_it (rmin [i], v); max_it (rmax [i], v); 643 v = mat_apply (matrix, i, 0+x, h+y); min_it (rmin [i], v); max_it (rmax [i], v);
647 v = mat_apply (matrix, i, w, h); min_it (rmin [i], v); max_it (rmax [i], v); 644 v = mat_apply (matrix, i, w+x, h+y); min_it (rmin [i], v); max_it (rmax [i], v);
648 } 645 }
649 646
647 // TODO: adjust matrix for subpixel accuracy
650 int dx = floor (rmin [0]); 648 int dx = floor (rmin [0]);
651 int dy = floor (rmin [1]); 649 int dy = floor (rmin [1]);
652 650
653 int new_width = ceil (rmax [0] - dx); 651 int new_width = ceil (rmax [0] - dx);
654 int new_height = ceil (rmax [1] - dy); 652 int new_height = ceil (rmax [1] - dy);
655 653
656 nv inv[3][3]; 654 nv inv[3][3];
657 mat_invert (matrix, inv); 655 mat_invert (matrix, inv);
658 656
659 rxvt_img *img = new rxvt_img (s, format, ox - dx - d [0], oy - dy - d [1], new_width, new_height, repeat); 657 rxvt_img *img = new rxvt_img (s, format, dx, dy, new_width, new_height, repeat);
660 img->alloc (); 658 img->alloc ();
661 659
662 Display *dpy = s->display->dpy; 660 Display *dpy = s->display->dpy;
663 Picture src = picture (); 661 Picture src = picture ();
664 Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); 662 Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0);
707{ 705{
708 nv s = sin (phi); 706 nv s = sin (phi);
709 nv c = cos (phi); 707 nv c = cos (phi);
710 708
711 nv matrix[3][3] = { 709 nv matrix[3][3] = {
712 { c, -s, cx - c * cx + s * cy }, 710 { c, -s, cx - c * cx + s * cy + 200 },
713 { s, c, cy - s * cx - c * cy }, 711 { s, c, cy - s * cx - c * cy },
714 { 0, 0, 1 } 712 { 0, 0, 1 }
715 //{ c, -s, 0 }, 713 //{ c, -s, 0 },
716 //{ s, c, 0 }, 714 //{ s, c, 0 },
717 //{ 0, 0, 1 } 715 //{ 0, 0, 1 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines