From 062f6dd59d0c63bd316c727214d0841f020b6953 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sun, 17 Nov 2013 18:51:19 +0100 Subject: [PATCH] Code refactoring: replaced macro 'XSHM' by 'USE_XSHM' for consistency The usual way to define a macro in is to name macro with 'USE_xxx' when they are used to enable a feature 'xxx'. Signed-off-by: Christophe CURIS --- configure.ac | 2 +- wrlib/context.c | 2 +- wrlib/convert.c | 10 +++++----- wrlib/wraster.h | 4 ++-- wrlib/xutil.c | 30 +++++++++++++++--------------- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/configure.ac b/configure.ac index e463eced..72597747 100644 --- a/configure.ac +++ b/configure.ac @@ -604,7 +604,7 @@ if test "$shm" = yes; then if test "$added_xext" = no; then XLIBS="-lXext $XLIBS" fi - AC_DEFINE(XSHM, 1, [define if X's shared memory extension is available (set by configure)]) + AC_DEFINE(USE_XSHM, 1, [define if X's shared memory extension is available (set by configure)]) fi fi diff --git a/wrlib/context.c b/wrlib/context.c index 3fdaafe4..da9dbe68 100644 --- a/wrlib/context.c +++ b/wrlib/context.c @@ -664,7 +664,7 @@ RContext *RCreateContext(Display * dpy, int screen_number, const RContextAttribu } /* check avaiability of MIT-SHM */ -#ifdef XSHM +#ifdef USE_XSHM if (!(context->attribs->flags & RC_UseSharedMemory)) { context->attribs->flags |= RC_UseSharedMemory; context->attribs->use_shared_memory = True; diff --git a/wrlib/convert.c b/wrlib/convert.c index f690e1f7..f3c9a49d 100644 --- a/wrlib/convert.c +++ b/wrlib/convert.c @@ -35,7 +35,7 @@ #include "wraster.h" -#ifdef XSHM +#ifdef USE_XSHM extern Pixmap R_CreateXImageMappedPixmap(RContext * context, RXImage * ximage); #endif @@ -819,7 +819,7 @@ static RXImage *image2Bitmap(RContext * ctx, RImage * image, int threshold) int RConvertImage(RContext * context, RImage * image, Pixmap * pixmap) { RXImage *ximg = NULL; -#ifdef XSHM +#ifdef USE_XSHM Pixmap tmp; #endif @@ -852,7 +852,7 @@ int RConvertImage(RContext * context, RImage * image, Pixmap * pixmap) *pixmap = XCreatePixmap(context->dpy, context->drawable, image->width, image->height, context->depth); -#ifdef XSHM +#ifdef USE_XSHM if (context->flags.use_shared_pixmap && ximg->is_shared) tmp = R_CreateXImageMappedPixmap(context, ximg); else @@ -873,9 +873,9 @@ int RConvertImage(RContext * context, RImage * image, Pixmap * pixmap) } else { RPutXImage(context, *pixmap, context->copy_gc, ximg, 0, 0, 0, 0, image->width, image->height); } -#else /* !XSHM */ +#else /* !USE_XSHM */ RPutXImage(context, *pixmap, context->copy_gc, ximg, 0, 0, 0, 0, image->width, image->height); -#endif /* !XSHM */ +#endif /* !USE_XSHM */ RDestroyXImage(context, ximg); diff --git a/wrlib/wraster.h b/wrlib/wraster.h index ff2b2c31..25e39e79 100644 --- a/wrlib/wraster.h +++ b/wrlib/wraster.h @@ -47,7 +47,7 @@ #include #include -#ifdef XSHM +#ifdef USE_XSHM #include #endif @@ -204,7 +204,7 @@ typedef struct RXImage { XImage *image; /* Private data. Do not access */ -#ifdef XSHM +#ifdef USE_XSHM XShmSegmentInfo info; char is_shared; #endif diff --git a/wrlib/xutil.c b/wrlib/xutil.c index 6d0b242d..82122d4b 100644 --- a/wrlib/xutil.c +++ b/wrlib/xutil.c @@ -30,14 +30,14 @@ #include -#ifdef XSHM +#ifdef USE_XSHM #include #include -#endif /* XSHM */ +#endif /* USE_XSHM */ #include "wraster.h" -#ifdef XSHM +#ifdef USE_XSHM static int shmError; @@ -64,7 +64,7 @@ RXImage *RCreateXImage(RContext * context, int depth, unsigned width, unsigned h RErrorCode = RERR_NOMEMORY; return NULL; } -#ifndef XSHM +#ifndef USE_XSHM rximg->image = XCreateImage(context->dpy, visual, depth, ZPixmap, 0, NULL, width, height, 8, 0); if (!rximg->image) { free(rximg); @@ -78,7 +78,7 @@ RXImage *RCreateXImage(RContext * context, int depth, unsigned width, unsigned h RErrorCode = RERR_NOMEMORY; return NULL; } -#else /* XSHM */ +#else /* USE_XSHM */ if (!context->attribs->use_shared_memory) { retry_without_shm: @@ -145,16 +145,16 @@ RXImage *RCreateXImage(RContext * context, int depth, unsigned width, unsigned h goto retry_without_shm; } } -#endif /* XSHM */ +#endif /* USE_XSHM */ return rximg; } void RDestroyXImage(RContext * context, RXImage * rximage) { -#ifndef XSHM +#ifndef USE_XSHM XDestroyImage(rximage->image); -#else /* XSHM */ +#else /* USE_XSHM */ if (rximage->is_shared) { XSync(context->dpy, False); XShmDetach(context->dpy, &rximage->info); @@ -186,7 +186,7 @@ RXImage *RGetXImage(RContext * context, Drawable d, int x, int y, unsigned width { RXImage *ximg = NULL; -#ifdef XSHM +#ifdef USE_XSHM if (context->attribs->use_shared_memory && 0) { ximg = RCreateXImage(context, getDepth(context->dpy, d), width, height); @@ -208,7 +208,7 @@ RXImage *RGetXImage(RContext * context, Drawable d, int x, int y, unsigned width ximg->image = XGetImage(context->dpy, d, x, y, width, height, AllPlanes, ZPixmap); } return ximg; -#else /* !XSHM */ +#else /* !USE_XSHM */ ximg = malloc(sizeof(RXImage)); if (!ximg) { RErrorCode = RERR_NOMEMORY; @@ -218,14 +218,14 @@ RXImage *RGetXImage(RContext * context, Drawable d, int x, int y, unsigned width ximg->image = XGetImage(context->dpy, d, x, y, width, height, AllPlanes, ZPixmap); return ximg; -#endif /* !XSHM */ +#endif /* !USE_XSHM */ } void RPutXImage(RContext * context, Drawable d, GC gc, RXImage * ximage, int src_x, int src_y, int dest_x, int dest_y, unsigned int width, unsigned int height) { -#ifndef XSHM +#ifndef USE_XSHM XPutImage(context->dpy, d, gc, ximage->image, src_x, src_y, dest_x, dest_y, width, height); #else if (ximage->is_shared) { @@ -235,10 +235,10 @@ RPutXImage(RContext * context, Drawable d, GC gc, RXImage * ximage, int src_x, XPutImage(context->dpy, d, gc, ximage->image, src_x, src_y, dest_x, dest_y, width, height); } XFlush(context->dpy); -#endif /* XSHM */ +#endif /* USE_XSHM */ } -#ifdef XSHM +#ifdef USE_XSHM Pixmap R_CreateXImageMappedPixmap(RContext * context, RXImage * rximage) { Pixmap pix; @@ -250,4 +250,4 @@ Pixmap R_CreateXImageMappedPixmap(RContext * context, RXImage * rximage) return pix; } -#endif /* XSHM */ +#endif /* USE_XSHM */ -- 2.11.4.GIT