kwo pushed a commit to branch master. http://git.enlightenment.org/legacy/imlib2.git/commit/?id=6f62c70bacba2d2d8a08cf07b2c7ae173445f0b3
commit 6f62c70bacba2d2d8a08cf07b2c7ae173445f0b3 Author: Alexander Volkov <[email protected]> Date: Tue Feb 6 16:04:12 2018 +0100 put a check for shared memory inside __imlib_ShmGetXImage() Summary: This check actually refers to the internal implementation and should not be done outside this function. Reviewers: kwo Reviewed By: kwo Differential Revision: https://phab.enlightenment.org/D5783 --- src/lib/grab.c | 10 ++-------- src/lib/ximage.c | 25 +++++++++++-------------- src/lib/ximage.h | 3 --- 3 files changed, 13 insertions(+), 25 deletions(-) diff --git a/src/lib/grab.c b/src/lib/grab.c index f3fdef8..c4239f4 100644 --- a/src/lib/grab.c +++ b/src/lib/grab.c @@ -659,15 +659,9 @@ __imlib_GrabDrawableToRGBA(DATA32 * data, int ox, int oy, int ow, int oh, } /* Create an Ximage (shared or not) */ - if (x_does_shm < 0) - __imlib_ShmCheck(d); + xim = __imlib_ShmGetXImage(d, v, p, xatt.depth, x, y, w, h, &shminfo); + is_shm = ! !xim; - xim = NULL; - if (x_does_shm) - { - xim = __imlib_ShmGetXImage(d, v, p, xatt.depth, x, y, w, h, &shminfo); - is_shm = ! !xim; - } if (!xim) xim = XGetImage(d, p, x, y, w, h, 0xffffffff, ZPixmap); if (!xim) diff --git a/src/lib/ximage.c b/src/lib/ximage.c index 750761f..c94f725 100644 --- a/src/lib/ximage.c +++ b/src/lib/ximage.c @@ -9,7 +9,7 @@ #include "ximage.h" /* global flags */ -signed char x_does_shm = -1; +static signed char x_does_shm = -1; /* static private variables */ static int list_num = 0; @@ -32,8 +32,8 @@ TmpXError(Display * d, XErrorEvent * ev) return 0; } -void -__imlib_ShmCheck(Display * d) +static void +ShmCheck(Display * d) { /* if its there set x_does_shm flag */ if (XShmQueryExtension(d)) @@ -49,6 +49,12 @@ __imlib_ShmGetXImage(Display * d, Visual * v, Drawable draw, int depth, { XImage *xim; + if (x_does_shm < 0) + ShmCheck(d); + + if (!x_does_shm) + return NULL; + /* try create an shm image */ xim = XShmCreateImage(d, v, depth, ZPixmap, NULL, si, w, h); if (!xim) @@ -258,10 +264,6 @@ __imlib_ProduceXImage(Display * d, Visual * v, int depth, int w, int h, XImage *xim; int i, err; - /* if we havent check the shm extension before - see if its there */ - if (x_does_shm < 0) - __imlib_ShmCheck(d); - /* find a cached XImage (to avoid server to & fro) that is big enough */ /* for our needs and the right depth */ *shared = 0; @@ -312,13 +314,8 @@ __imlib_ProduceXImage(Display * d, Visual * v, int depth, int w, int h, } /* work on making a shared image */ - xim = NULL; - /* if the server does shm */ - if (x_does_shm) - { - xim = __imlib_ShmGetXImage(d, v, None, depth, 0, 0, w, h, - list_si[list_num - 1]); - } + xim = __imlib_ShmGetXImage(d, v, None, depth, 0, 0, w, h, + list_si[list_num - 1]); /* ok if xim == NULL it all failed - fall back to XImages */ if (xim) { diff --git a/src/lib/ximage.h b/src/lib/ximage.h index 01dc951..2a7006e 100644 --- a/src/lib/ximage.h +++ b/src/lib/ximage.h @@ -6,8 +6,6 @@ #include "common.h" -extern signed char x_does_shm; - void __imlib_SetMaxXImageCount(Display * d, int num); int __imlib_GetMaxXImageCount(Display * d); void __imlib_SetMaxXImageTotalSize(Display * d, int num); @@ -16,7 +14,6 @@ void __imlib_FlushXImage(Display * d); void __imlib_ConsumeXImage(Display * d, XImage * xim); XImage *__imlib_ProduceXImage(Display * d, Visual * v, int depth, int w, int h, char *shared); -void __imlib_ShmCheck(Display * d); XImage *__imlib_ShmGetXImage(Display * d, Visual * v, Drawable draw, int depth, int x, int y, int w, int h, XShmSegmentInfo * si); --
