kwo pushed a commit to branch master.

http://git.enlightenment.org/legacy/imlib2.git/commit/?id=8232c9213b04e64e71a2d7e5cc449438f874d43e

commit 8232c9213b04e64e71a2d7e5cc449438f874d43e
Author: Kim Woelders <k...@woelders.dk>
Date:   Sat Dec 23 19:33:14 2017 +0100

    imlib_create_scaled_image_from_drawable(): Drop shape handling if unshaped
---
 src/lib/api.c | 43 +++++++++++++++++++++++++++----------------
 1 file changed, 27 insertions(+), 16 deletions(-)

diff --git a/src/lib/api.c b/src/lib/api.c
index 82c2c33..2231bbc 100644
--- a/src/lib/api.c
+++ b/src/lib/api.c
@@ -2187,25 +2187,36 @@ imlib_create_scaled_image_from_drawable(Pixmap mask, 
int source_x,
         XRectangle         *rect;
         int                 rect_num, rect_ord;
 
-        tmpmask = 1;
-        mask =
-           XCreatePixmap(ctx->display, ctx->drawable, source_width,
-                         source_height, 1);
-        mgc = XCreateGC(ctx->display, mask,
-                        GCForeground | GCGraphicsExposures, &gcv);
-        rect =
-           XShapeGetRectangles(ctx->display, ctx->drawable, ShapeBounding,
-                               &rect_num, &rect_ord);
-        XFillRectangle(ctx->display, mask, mgc, 0, 0, source_width,
-                       source_height);
-        if (rect)
+        rect = XShapeGetRectangles(ctx->display, ctx->drawable, ShapeBounding,
+                                   &rect_num, &rect_ord);
+
+        if (rect && (rect_num == 1 &&
+                     rect[0].x == 0 && rect[0].y == 0 &&
+                     rect[0].width == source_width &&
+                     rect[0].height == source_height))
           {
-             XSetForeground(ctx->display, mgc, 1);
-             for (x = 0; x < rect_num; x++)
-                XFillRectangle(ctx->display, mask, mgc, rect[x].x,
-                               rect[x].y, rect[x].width, rect[x].height);
+             domask = 0;
              XFree(rect);
           }
+        else
+          {
+             tmpmask = 1;
+             mask =
+                XCreatePixmap(ctx->display, ctx->drawable, source_width,
+                              source_height, 1);
+             mgc = XCreateGC(ctx->display, mask,
+                             GCForeground | GCGraphicsExposures, &gcv);
+             XFillRectangle(ctx->display, mask, mgc, 0, 0, source_width,
+                            source_height);
+             if (rect)
+               {
+                  XSetForeground(ctx->display, mgc, 1);
+                  for (x = 0; x < rect_num; x++)
+                     XFillRectangle(ctx->display, mask, mgc, rect[x].x,
+                                    rect[x].y, rect[x].width, rect[x].height);
+                  XFree(rect);
+               }
+          }
      }
 
    if ((destination_width == source_width) &&

-- 


Reply via email to