Speedup in imlib_create_scaled_image_from_drawable()

Avoid intermediate pixmap copy when scaling 1:1 with no offset.
This commit is contained in:
Kim Woelders 2021-11-20 21:09:08 +01:00
parent b2d7af466e
commit 5627edbb76
1 changed files with 13 additions and 3 deletions

View File

@ -880,7 +880,6 @@ __imlib_GrabDrawableScaledToRGBA(DATA32 * data, int nu_x_dst, int nu_y_dst,
Pixmap psc, msc;
h_tmp = h_dst > h_src ? h_dst : h_src;
psc = XCreatePixmap(d, p, w_dst, h_tmp, depth);
gcv.foreground = 0;
gcv.subwindow_mode = IncludeInferiors;
@ -896,11 +895,21 @@ __imlib_GrabDrawableScaledToRGBA(DATA32 * data, int nu_x_dst, int nu_y_dst,
if (w_dst == w_src && h_dst == h_src)
{
XCopyArea(d, p, psc, gc, x_src, y_src, w_src, h_src, 0, 0);
if (x_src == 0 && y_src == 0)
{
psc = p;
}
else
{
psc = XCreatePixmap(d, p, w_src, h_tmp, depth);
XCopyArea(d, p, psc, gc, x_src, y_src, w_src, h_src, 0, 0);
}
msc = m;
}
else
{
psc = XCreatePixmap(d, p, w_dst, h_tmp, depth);
if (*pdomask)
{
msc = XCreatePixmap(d, p, w_dst, h_tmp, 1);
@ -953,7 +962,8 @@ __imlib_GrabDrawableScaledToRGBA(DATA32 * data, int nu_x_dst, int nu_y_dst,
if (m != None && m != m_)
XFreePixmap(d, m);
XFreeGC(d, gc);
XFreePixmap(d, psc);
if (psc != p)
XFreePixmap(d, psc);
return rc;
}