This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository legacy-imlib2.
View the commit online.
commit eae5c3bdbfcb8d5217cc4558d872adc5562818f5
Author: Kim Woelders <[email protected]>
AuthorDate: Sun Mar 5 16:18:16 2023 +0100
x11_grab: Eliminate some overhead in scaled grabbing
Avoid call to XGetWindowAttributes(), X-error, call to XGetGeometry().
---
src/lib/api_x11.c | 6 ++--
src/lib/x11_grab.c | 87 ++++++++++++++++++++++++++++++++----------------------
src/lib/x11_grab.h | 3 +-
src/lib/x11_rend.c | 4 +--
4 files changed, 58 insertions(+), 42 deletions(-)
diff --git a/src/lib/api_x11.c b/src/lib/api_x11.c
index 1ceda39..2a9b76b 100644
--- a/src/lib/api_x11.c
+++ b/src/lib/api_x11.c
@@ -307,7 +307,7 @@ imlib_create_image_from_drawable(Pixmap mask, int x, int y, int width,
err = __imlib_GrabDrawableToRGBA(&ctx->x11, im->data, 0, 0, width, height,
ctx->drawable, mask,
x, y, width, height,
- &domask, need_to_grab_x, true);
+ &domask, need_to_grab_x, true, NULL);
if (err)
{
__imlib_FreeImage(im);
@@ -359,7 +359,7 @@ imlib_create_scaled_image_from_drawable(Pixmap mask, int src_x, int src_y,
0, 0, dst_width, dst_height,
ctx->drawable, mask,
src_x, src_y, src_width, src_height,
- &domask, need_to_grab_x, true);
+ &domask, need_to_grab_x, true, NULL);
else
err = __imlib_GrabDrawableScaledToRGBA(&ctx->x11, im->data,
0, 0, dst_width, dst_height,
@@ -405,7 +405,7 @@ imlib_copy_drawable_to_image(Pixmap mask, int src_x, int src_y, int src_width,
dst_x, dst_y, im->w, im->h,
ctx->drawable, mask,
src_x, src_y, src_width, src_height,
- &domask, need_to_grab_x, false);
+ &domask, need_to_grab_x, false, NULL);
}
EAPI void
diff --git a/src/lib/x11_grab.c b/src/lib/x11_grab.c
index 747e55f..43ff825 100644
--- a/src/lib/x11_grab.c
+++ b/src/lib/x11_grab.c
@@ -604,7 +604,8 @@ __imlib_GrabDrawableToRGBA(const ImlibContextX11 * x11, uint32_t * data,
int w_dst, int h_dst,
Drawable draw, Pixmap mask_,
int x_src, int y_src, int w_src, int h_src,
- char *pdomask, int grab, bool clear)
+ char *pdomask, int grab, bool clear,
+ const XWindowAttributes * attr)
{
XWindowAttributes xatt;
bool is_pixmap, is_shm, is_mshm;
@@ -624,49 +625,61 @@ __imlib_GrabDrawableToRGBA(const ImlibContextX11 * x11, uint32_t * data,
width = w_src;
height = h_src;
- is_pixmap = _DrawableCheck(x11->dpy, draw, &xatt);
-
- if (is_pixmap)
+ if (attr)
{
- Window rret;
- unsigned int bw;
-
- XGetGeometry(x11->dpy, draw, &rret, &xatt.x, &xatt.y,
- (unsigned int *)&xatt.width, (unsigned int *)&xatt.height,
- &bw, (unsigned int *)&xatt.depth);
+ is_pixmap = true;
+ xatt.width = attr->width;
+ xatt.height = attr->height;
+ xatt.depth = attr->depth;
}
else
{
- XWindowAttributes ratt;
- Window cret;
+ is_pixmap = _DrawableCheck(x11->dpy, draw, &xatt);
- if ((xatt.map_state != IsViewable) && (xatt.backing_store == NotUseful))
- goto bail;
-
- /* Clip source to screen */
- XGetWindowAttributes(x11->dpy, xatt.root, &ratt);
- XTranslateCoordinates(x11->dpy, draw, xatt.root,
- 0, 0, &xatt.x, &xatt.y, &cret);
-
- if (xatt.x + x_src < 0)
+ if (is_pixmap)
{
- width += xatt.x + x_src;
- x_src = -xatt.x;
- }
- if (xatt.x + x_src + width > ratt.width)
- width = ratt.width - (xatt.x + x_src);
+ Window rret;
+ unsigned int bw;
- if (xatt.y + y_src < 0)
- {
- height += xatt.y + y_src;
- y_src = -xatt.y;
+ XGetGeometry(x11->dpy, draw, &rret, &xatt.x, &xatt.y,
+ (unsigned int *)&xatt.width,
+ (unsigned int *)&xatt.height,
+ &bw, (unsigned int *)&xatt.depth);
}
- if (xatt.y + y_src + height > ratt.height)
- height = ratt.height - (xatt.y + y_src);
+ else
+ {
+ XWindowAttributes ratt;
+ Window cret;
+
+ if (xatt.map_state != IsViewable &&
+ xatt.backing_store == NotUseful)
+ goto bail;
+
+ /* Clip source to screen */
+ XGetWindowAttributes(x11->dpy, xatt.root, &ratt);
+ XTranslateCoordinates(x11->dpy, draw, xatt.root,
+ 0, 0, &xatt.x, &xatt.y, &cret);
+
+ if (xatt.x + x_src < 0)
+ {
+ width += xatt.x + x_src;
+ x_src = -xatt.x;
+ }
+ if (xatt.x + x_src + width > ratt.width)
+ width = ratt.width - (xatt.x + x_src);
- /* Is this ever relevant? */
- if (xatt.colormap == None)
- xatt.colormap = ratt.colormap;
+ if (xatt.y + y_src < 0)
+ {
+ height += xatt.y + y_src;
+ y_src = -xatt.y;
+ }
+ if (xatt.y + y_src + height > ratt.height)
+ height = ratt.height - (xatt.y + y_src);
+
+ /* Is this ever relevant? */
+ if (xatt.colormap == None)
+ xatt.colormap = ratt.colormap;
+ }
}
/* Clip source to drawable */
@@ -993,9 +1006,11 @@ __imlib_GrabDrawableScaledToRGBA(const ImlibContextX11 * x11, uint32_t * data,
height -= xx;
}
+ xatt.width = w_dst; /* Not the actual pixmap size but the scaled size */
+ xatt.height = h_dst;
rc = __imlib_GrabDrawableToRGBA(x11, data, x_dst_, y_dst_, w_dst, h_dst,
psc, msc, x_src_, y_src_, width, height,
- pdomask, grab, clear);
+ pdomask, grab, clear, &xatt);
if (mgc)
XFreeGC(x11->dpy, mgc);
diff --git a/src/lib/x11_grab.h b/src/lib/x11_grab.h
index 3999274..d09ca36 100644
--- a/src/lib/x11_grab.h
+++ b/src/lib/x11_grab.h
@@ -12,7 +12,8 @@ int __imlib_GrabDrawableToRGBA(const ImlibContextX11 * x11,
int x_src, int y_src,
int w_src, int h_src,
char *domask, int grab,
- bool clear);
+ bool clear,
+ const XWindowAttributes * attr);
int __imlib_GrabDrawableScaledToRGBA(const ImlibContextX11 *
x11, uint32_t * data,
diff --git a/src/lib/x11_rend.c b/src/lib/x11_rend.c
index 4fd73ec..2c56951 100644
--- a/src/lib/x11_rend.c
+++ b/src/lib/x11_rend.c
@@ -319,7 +319,7 @@ __imlib_RenderImage(const ImlibContextX11 * x11, ImlibImage * im,
{
back = malloc(dw * dh * sizeof(uint32_t));
if (__imlib_GrabDrawableToRGBA(x11, back, 0, 0, dw, dh,
- w, 0, dx, dy, dw, dh, 0, 1, false))
+ w, 0, dx, dy, dw, dh, 0, 1, false, NULL))
{
free(back);
back = NULL;
@@ -568,7 +568,7 @@ __imlib_RenderImageSkewed(const ImlibContextX11 * x11, ImlibImage * im,
__imlib_GetContext(x11);
__imlib_GrabDrawableToRGBA(x11, back->data, 0, 0, dw, dh,
- w, 0, dx1, dy1, dw, dh, 0, 1, false);
+ w, 0, dx1, dy1, dw, dh, 0, 1, false, NULL);
__imlib_BlendImageToImageSkewed(im, back, antialias, 1, 0, sx, sy, sw, sh,
dx - dx1, dy - dy1, hsx, hsy, vsx, vsy,
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.