… | |
… | |
409 | img->alloc (); |
409 | img->alloc (); |
410 | |
410 | |
411 | Picture src = src_picture (); |
411 | Picture src = src_picture (); |
412 | Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); |
412 | Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); |
413 | |
413 | |
|
|
414 | if (alpha) |
|
|
415 | { |
|
|
416 | XRenderColor rc = { 0, 0, 0, 0 }; |
|
|
417 | XRenderFillRectangle (dpy, PictOpSrc, dst, &rc, 0, 0, w, h);//TODO: split into four fillrectangles |
|
|
418 | XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, -x, -y, ref->w, ref->h); |
|
|
419 | } |
|
|
420 | else |
414 | XRenderComposite (dpy, PictOpSrc, src, None, dst, x, y, 0, 0, 0, 0, w, h); |
421 | XRenderComposite (dpy, PictOpSrc, src, None, dst, x, y, 0, 0, 0, 0, w, h); |
415 | |
422 | |
416 | XRenderFreePicture (dpy, src); |
423 | XRenderFreePicture (dpy, src); |
417 | XRenderFreePicture (dpy, dst); |
424 | XRenderFreePicture (dpy, dst); |
418 | |
425 | |
419 | return img; |
426 | return img; |
420 | } |
427 | } |
… | |
… | |
454 | |
461 | |
455 | for (int i = 0; i < 3; ++i) |
462 | for (int i = 0; i < 3; ++i) |
456 | for (int j = 0; j < 3; ++j) |
463 | for (int j = 0; j < 3; ++j) |
457 | xfrm.matrix [i][j] = XDoubleToFixed (matrix [i * 3 + j]); |
464 | xfrm.matrix [i][j] = XDoubleToFixed (matrix [i * 3 + j]); |
458 | |
465 | |
|
|
466 | #if 0 |
459 | xfrm.matrix [0][2] += XDoubleToFixed (x);//TODO |
467 | xfrm.matrix [0][2] -= XDoubleToFixed (x);//TODO |
460 | xfrm.matrix [0][3] += XDoubleToFixed (y); |
468 | xfrm.matrix [1][2] -= XDoubleToFixed (y); |
|
|
469 | #endif |
461 | |
470 | |
462 | XRenderSetPictureFilter (dpy, src, "good", 0, 0); |
471 | XRenderSetPictureFilter (dpy, src, "good", 0, 0); |
463 | XRenderSetPictureTransform (dpy, src, &xfrm); |
472 | XRenderSetPictureTransform (dpy, src, &xfrm); |
464 | XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, new_width, new_height); |
473 | XRenderComposite (dpy, PictOpSrc, src, None, dst, 0, 0, 0, 0, 0, 0, new_width, new_height); |
465 | |
474 | |
… | |
… | |
470 | } |
479 | } |
471 | |
480 | |
472 | rxvt_img * |
481 | rxvt_img * |
473 | rxvt_img::scale (int new_width, int new_height) |
482 | rxvt_img::scale (int new_width, int new_height) |
474 | { |
483 | { |
|
|
484 | if (w == new_width && h == new_height) |
|
|
485 | return clone (); |
|
|
486 | |
475 | double matrix[9] = { |
487 | double matrix[9] = { |
476 | w / (double)new_width, 0, 0, |
488 | w / (double)new_width, 0, 0, |
477 | 0, h / (double)new_height, 0, |
489 | 0, h / (double)new_height, 0, |
478 | 0, 0, 1 |
490 | 0, 0, 1 |
479 | }; |
491 | }; |
480 | |
492 | |
|
|
493 | int old_repeat_mode = repeat; |
|
|
494 | repeat = RepeatPad; // not right, but xrender can't proeprly scale it seems |
|
|
495 | |
481 | return transform (new_width, new_height, matrix); |
496 | rxvt_img *img = transform (new_width, new_height, matrix); |
|
|
497 | |
|
|
498 | repeat = old_repeat_mode; |
|
|
499 | img->repeat = repeat; |
|
|
500 | |
|
|
501 | return img; |
482 | } |
502 | } |
483 | |
503 | |
484 | rxvt_img * |
504 | rxvt_img * |
485 | rxvt_img::rotate (int new_width, int new_height, int x, int y, double phi) |
505 | rxvt_img::rotate (int new_width, int new_height, int x, int y, double phi) |
486 | { |
506 | { |