diff options
| author | Po Lu | 2022-10-14 15:52:16 +0800 |
|---|---|---|
| committer | Po Lu | 2022-10-14 15:56:15 +0800 |
| commit | 6ea69fc7340e48cf73df351a544c1d8946395b3d (patch) | |
| tree | 2046b8dad9f6385ec8b66d64d4a405b03deff871 | |
| parent | 9074103fbff70a30664b291f5ea3af443f88e4d8 (diff) | |
| download | emacs-6ea69fc7340e48cf73df351a544c1d8946395b3d.tar.gz emacs-6ea69fc7340e48cf73df351a544c1d8946395b3d.zip | |
Avoid redundant creation of XRender pictures
* src/xterm.c (x_composite_image): Take arg DESTINATION. Do not
create a picture if it is set.
(x_draw_image_foreground, x_draw_image_foreground_1): Pass
destination where appropriate.
| -rw-r--r-- | src/xterm.c | 68 |
1 files changed, 49 insertions, 19 deletions
diff --git a/src/xterm.c b/src/xterm.c index 27a66873484..0fca9788ce5 100644 --- a/src/xterm.c +++ b/src/xterm.c | |||
| @@ -9603,31 +9603,49 @@ x_draw_glyph_string_box (struct glyph_string *s) | |||
| 9603 | 9603 | ||
| 9604 | 9604 | ||
| 9605 | #ifndef USE_CAIRO | 9605 | #ifndef USE_CAIRO |
| 9606 | |||
| 9606 | static void | 9607 | static void |
| 9607 | x_composite_image (struct glyph_string *s, Pixmap dest, | 9608 | x_composite_image (struct glyph_string *s, Pixmap dest, |
| 9609 | #ifdef HAVE_XRENDER | ||
| 9610 | Picture destination, | ||
| 9611 | #endif | ||
| 9608 | int srcX, int srcY, int dstX, int dstY, | 9612 | int srcX, int srcY, int dstX, int dstY, |
| 9609 | int width, int height) | 9613 | int width, int height) |
| 9610 | { | 9614 | { |
| 9611 | Display *display = FRAME_X_DISPLAY (s->f); | 9615 | Display *display; |
| 9612 | #ifdef HAVE_XRENDER | 9616 | #ifdef HAVE_XRENDER |
| 9613 | if (s->img->picture && FRAME_X_PICTURE_FORMAT (s->f)) | 9617 | XRenderPictFormat *default_format; |
| 9614 | { | 9618 | XRenderPictureAttributes attr UNINIT; |
| 9615 | Picture destination; | 9619 | #endif |
| 9616 | XRenderPictFormat *default_format; | ||
| 9617 | XRenderPictureAttributes attr UNINIT; | ||
| 9618 | 9620 | ||
| 9619 | default_format = FRAME_X_PICTURE_FORMAT (s->f); | 9621 | display = FRAME_X_DISPLAY (s->f); |
| 9620 | destination = XRenderCreatePicture (display, dest, | ||
| 9621 | default_format, 0, &attr); | ||
| 9622 | 9622 | ||
| 9623 | XRenderComposite (display, s->img->mask_picture ? PictOpOver : PictOpSrc, | 9623 | #ifdef HAVE_XRENDER |
| 9624 | s->img->picture, s->img->mask_picture, destination, | 9624 | if (s->img->picture && FRAME_X_PICTURE_FORMAT (s->f)) |
| 9625 | srcX, srcY, | 9625 | { |
| 9626 | srcX, srcY, | 9626 | if (destination == None) |
| 9627 | dstX, dstY, | 9627 | { |
| 9628 | width, height); | 9628 | /* The destination picture was not specified. This means we |
| 9629 | have to create a picture representing the */ | ||
| 9630 | default_format = FRAME_X_PICTURE_FORMAT (s->f); | ||
| 9631 | destination = XRenderCreatePicture (display, dest, | ||
| 9632 | default_format, 0, &attr); | ||
| 9633 | |||
| 9634 | XRenderComposite (display, (s->img->mask_picture | ||
| 9635 | ? PictOpOver : PictOpSrc), | ||
| 9636 | s->img->picture, s->img->mask_picture, | ||
| 9637 | destination, srcX, srcY, srcX, srcY, | ||
| 9638 | dstX, dstY, width, height); | ||
| 9639 | |||
| 9640 | XRenderFreePicture (display, destination); | ||
| 9641 | } | ||
| 9642 | else | ||
| 9643 | XRenderComposite (display, (s->img->mask_picture | ||
| 9644 | ? PictOpOver : PictOpSrc), | ||
| 9645 | s->img->picture, s->img->mask_picture, | ||
| 9646 | destination, srcX, srcY, srcX, srcY, | ||
| 9647 | dstX, dstY, width, height); | ||
| 9629 | 9648 | ||
| 9630 | XRenderFreePicture (display, destination); | ||
| 9631 | return; | 9649 | return; |
| 9632 | } | 9650 | } |
| 9633 | #endif | 9651 | #endif |
| @@ -9637,6 +9655,7 @@ x_composite_image (struct glyph_string *s, Pixmap dest, | |||
| 9637 | srcX, srcY, | 9655 | srcX, srcY, |
| 9638 | width, height, dstX, dstY); | 9656 | width, height, dstX, dstY); |
| 9639 | } | 9657 | } |
| 9658 | |||
| 9640 | #endif /* !USE_CAIRO */ | 9659 | #endif /* !USE_CAIRO */ |
| 9641 | 9660 | ||
| 9642 | 9661 | ||
| @@ -9715,6 +9734,9 @@ x_draw_image_foreground (struct glyph_string *s) | |||
| 9715 | image_rect.height = s->slice.height; | 9734 | image_rect.height = s->slice.height; |
| 9716 | if (gui_intersect_rectangles (&clip_rect, &image_rect, &r)) | 9735 | if (gui_intersect_rectangles (&clip_rect, &image_rect, &r)) |
| 9717 | x_composite_image (s, FRAME_X_DRAWABLE (s->f), | 9736 | x_composite_image (s, FRAME_X_DRAWABLE (s->f), |
| 9737 | #ifdef HAVE_XRENDER | ||
| 9738 | FRAME_X_PICTURE (s->f), | ||
| 9739 | #endif | ||
| 9718 | s->slice.x + r.x - x, s->slice.y + r.y - y, | 9740 | s->slice.x + r.x - x, s->slice.y + r.y - y, |
| 9719 | r.x, r.y, r.width, r.height); | 9741 | r.x, r.y, r.width, r.height); |
| 9720 | } | 9742 | } |
| @@ -9728,7 +9750,12 @@ x_draw_image_foreground (struct glyph_string *s) | |||
| 9728 | image_rect.width = s->slice.width; | 9750 | image_rect.width = s->slice.width; |
| 9729 | image_rect.height = s->slice.height; | 9751 | image_rect.height = s->slice.height; |
| 9730 | if (gui_intersect_rectangles (&clip_rect, &image_rect, &r)) | 9752 | if (gui_intersect_rectangles (&clip_rect, &image_rect, &r)) |
| 9731 | x_composite_image (s, FRAME_X_DRAWABLE (s->f), s->slice.x + r.x - x, s->slice.y + r.y - y, | 9753 | x_composite_image (s, FRAME_X_DRAWABLE (s->f), |
| 9754 | #ifdef HAVE_XRENDER | ||
| 9755 | FRAME_X_PICTURE (s->f), | ||
| 9756 | #endif | ||
| 9757 | s->slice.x + r.x - x, | ||
| 9758 | s->slice.y + r.y - y, | ||
| 9732 | r.x, r.y, r.width, r.height); | 9759 | r.x, r.y, r.width, r.height); |
| 9733 | 9760 | ||
| 9734 | /* When the image has a mask, we can expect that at | 9761 | /* When the image has a mask, we can expect that at |
| @@ -9894,8 +9921,11 @@ x_draw_image_foreground_1 (struct glyph_string *s, Pixmap pixmap) | |||
| 9894 | XChangeGC (display, s->gc, mask, &xgcv); | 9921 | XChangeGC (display, s->gc, mask, &xgcv); |
| 9895 | 9922 | ||
| 9896 | x_composite_image (s, pixmap, | 9923 | x_composite_image (s, pixmap, |
| 9897 | s->slice.x, s->slice.y, | 9924 | #ifdef HAVE_XRENDER |
| 9898 | x, y, s->slice.width, s->slice.height); | 9925 | None, |
| 9926 | #endif | ||
| 9927 | s->slice.x, s->slice.y, x, y, | ||
| 9928 | s->slice.width, s->slice.height); | ||
| 9899 | XSetClipMask (display, s->gc, None); | 9929 | XSetClipMask (display, s->gc, None); |
| 9900 | } | 9930 | } |
| 9901 | else | 9931 | else |