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.80 by root, Tue Jun 12 18:25:57 2012 UTC vs.
Revision 1.82 by root, Thu Jun 14 17:06:57 2012 UTC

224 pm = pm2; 224 pm = pm2;
225 ref = new pixref (ref->w, ref->h); 225 ref = new pixref (ref->w, ref->h);
226} 226}
227 227
228void 228void
229rxvt_img::fill (const rxvt_color &c) 229rxvt_img::fill (const rgba &c)
230{ 230{
231 rgba cc;
232 c.get (cc);
233 XRenderColor rc = { cc.r, cc.g, cc.b, cc.a }; 231 XRenderColor rc = { c.r, c.g, c.b, c.a };
234 232
235 Display *dpy = s->display->dpy; 233 Display *dpy = s->display->dpy;
236 Picture src = src_picture (); 234 Picture src = src_picture ();
237 XRenderFillRectangle (dpy, PictOpSrc, src, &rc, 0, 0, w, h); 235 XRenderFillRectangle (dpy, PictOpSrc, src, &rc, 0, 0, w, h);
238 XRenderFreePicture (dpy, src); 236 XRenderFreePicture (dpy, src);
397 if (r < 0 || g < 0 || b < 0 || a < 0) 395 if (r < 0 || g < 0 || b < 0 || a < 0)
398 rxvt_fatal ("rxvt_img::contrast does not support negative values.\n"); 396 rxvt_fatal ("rxvt_img::contrast does not support negative values.\n");
399 397
400 rxvt_img *img = new rxvt_img (s, format, x, y, w, h, repeat); 398 rxvt_img *img = new rxvt_img (s, format, x, y, w, h, repeat);
401 img->alloc (); 399 img->alloc ();
402 400 img->fill (rgba (0, 0, 0, 0));
403 {
404 rxvt_color empty;
405 empty.set (s, rgba (0, 0, 0, 0));
406 img->fill (empty);
407 }
408 401
409 // premultiply (yeah, these are not exact, sue me or fix it) 402 // premultiply (yeah, these are not exact, sue me or fix it)
410 r = (r * (a >> 8)) >> 8; 403 r = (r * (a >> 8)) >> 8;
411 g = (g * (a >> 8)) >> 8; 404 g = (g * (a >> 8)) >> 8;
412 b = (b * (a >> 8)) >> 8; 405 b = (b * (a >> 8)) >> 8;
558 // find new offset 551 // find new offset
559 int ox = mat_apply (matrix, 0, x, y); 552 int ox = mat_apply (matrix, 0, x, y);
560 int oy = mat_apply (matrix, 1, x, y); 553 int oy = mat_apply (matrix, 1, x, y);
561 554
562 // calculate new pixel bounding box coordinates 555 // calculate new pixel bounding box coordinates
563 double rmin[2], rmax[2]; 556 double d [2], rmin[2], rmax[2];
564 557
565 for (int i = 0; i < 2; ++i) 558 for (int i = 0; i < 2; ++i)
566 { 559 {
567 double v; 560 double v;
568 v = mat_apply (matrix, i, 0, 0); rmin [i] = rmax [i] = v; 561 v = mat_apply (matrix, i, 0, 0); rmin [i] = rmax [i] = v; d [i] = v;
569 v = mat_apply (matrix, i, w, 0); min_it (rmin [i], v); max_it (rmax [i], v); 562 v = mat_apply (matrix, i, w, 0); min_it (rmin [i], v); max_it (rmax [i], v);
570 v = mat_apply (matrix, i, 0, h); min_it (rmin [i], v); max_it (rmax [i], v); 563 v = mat_apply (matrix, i, 0, h); min_it (rmin [i], v); max_it (rmax [i], v);
571 v = mat_apply (matrix, i, w, h); min_it (rmin [i], v); max_it (rmax [i], v); 564 v = mat_apply (matrix, i, w, h); min_it (rmin [i], v); max_it (rmax [i], v);
572 } 565 }
573 566
578 int new_height = ceil (rmax [1] - dy); 571 int new_height = ceil (rmax [1] - dy);
579 572
580 double inv[3][3]; 573 double inv[3][3];
581 mat_invert (matrix, inv); 574 mat_invert (matrix, inv);
582 575
583 rxvt_img *img = new rxvt_img (s, format, ox - dx, oy - dy, new_width, new_height, repeat); 576 rxvt_img *img = new rxvt_img (s, format, ox - dx - d [0], oy - dy - d [1], new_width, new_height, repeat);
584 img->alloc (); 577 img->alloc ();
585 578
586 Display *dpy = s->display->dpy; 579 Display *dpy = s->display->dpy;
587 Picture src = src_picture (); 580 Picture src = src_picture ();
588 Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); 581 Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0);
631{ 624{
632 double s = sin (phi); 625 double s = sin (phi);
633 double c = cos (phi); 626 double c = cos (phi);
634 627
635 double matrix[3][3] = { 628 double matrix[3][3] = {
636 //{ c, -s, cx - c * cx + s * cy }, 629 { c, -s, cx - c * cx + s * cy },
637 //{ s, c, cy - s * cx - c * cy }, 630 { s, c, cy - s * cx - c * cy },
638 //{ 0, 0, 1 } 631 { 0, 0, 1 }
639 { c, -s, 0 }, 632 //{ c, -s, 0 },
640 { s, c, 0 }, 633 //{ s, c, 0 },
641 { 0, 0, 1 } 634 //{ 0, 0, 1 }
642 }; 635 };
643 636
644 move (-cx, -cy); 637 //move (-cx, -cy);
645 rxvt_img *img = transform (matrix); 638 rxvt_img *img = transform (matrix);
646 move ( cx, cy); 639 //move ( cx, cy);
647 img->move (cx, cy); 640 //img->move (cx, cy);
648 641
649 return img; 642 return img;
650} 643}
651 644
652rxvt_img * 645rxvt_img *
653rxvt_img::convert_format (XRenderPictFormat *new_format, const rxvt_color &bg) 646rxvt_img::convert_format (XRenderPictFormat *new_format, const rgba &bg)
654{ 647{
655 if (new_format == format) 648 if (new_format == format)
656 return clone (); 649 return clone ();
657 650
658 rxvt_img *img = new rxvt_img (s, new_format, x, y, w, h, repeat); 651 rxvt_img *img = new rxvt_img (s, new_format, x, y, w, h, repeat);
664 int op = PictOpSrc; 657 int op = PictOpSrc;
665 658
666 if (format->direct.alphaMask && !new_format->direct.alphaMask) 659 if (format->direct.alphaMask && !new_format->direct.alphaMask)
667 { 660 {
668 // does it have to be that complicated 661 // does it have to be that complicated
669 rgba c;
670 bg.get (c);
671
672 XRenderColor rc = { c.r, c.g, c.b, 0xffff }; 662 XRenderColor rc = { bg.r, bg.g, bg.b, bg.a };
673 XRenderFillRectangle (dpy, PictOpSrc, dst, &rc, 0, 0, w, h); 663 XRenderFillRectangle (dpy, PictOpSrc, dst, &rc, 0, 0, w, h);
674 664
675 op = PictOpOver; 665 op = PictOpOver;
676 } 666 }
677 667

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines