X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fswirl.c;h=93f0c0a63da6721ffdeb3d0e8b4064680de2b171;hb=bc7b7a8eb122206d239ec0e693676bcce31be1aa;hp=0d0f5abf4f56472a2e32529d898aa293c84e1c7f;hpb=6bb727f03bff0389fbb1349d7df4c9d8d7532959;p=xscreensaver diff --git a/hacks/swirl.c b/hacks/swirl.c index 0d0f5abf..93f0c0a6 100644 --- a/hacks/swirl.c +++ b/hacks/swirl.c @@ -1,7 +1,7 @@ /* -*- Mode: C; tab-width: 4 -*- * swirl --- swirly color-cycling patterns. */ -#if !defined( lint ) && !defined( SABER ) +#if 0 static const char sccsid[] = "@(#)swirl.c 4.00 97/01/01 xlockmore"; #endif @@ -19,7 +19,7 @@ static const char sccsid[] = "@(#)swirl.c 4.00 97/01/01 xlockmore"; * event will the author be liable for any lost revenue or profits or * other special, indirect and consequential damages. * - * 13-May-97: jwz@netscape.com: turned into a standalone program. + * 13-May-97: jwz@jwz.org: turned into a standalone program. * 21-Apr-95: improved startup time for TrueColour displays * (limited to 16bpp to save memory) S.Early * 09-Jan-95: fixed colour maps (more colourful) and the image now spirals @@ -36,13 +36,18 @@ static const char sccsid[] = "@(#)swirl.c 4.00 97/01/01 xlockmore"; # define swirl_opts xlockmore_opts # define DEFAULTS "*count: 5 \n" \ "*delay: 10000 \n" \ - "*ncolors: 200 \n" + "*ncolors: 200 \n" \ + "*useSHM: True \n" # define SMOOTH_COLORS # define WRITABLE_COLORS # include "xlockmore.h" /* from the xscreensaver distribution */ # include +# ifdef HAVE_XSHM_EXTENSION +# include "xshm.h" +# endif /* HAVE_XSHM_EXTENSION */ #else /* !STANDALONE */ # include "xlock.h" /* from the xlockmore distribution */ +# undef HAVE_XSHM_EXTENSION #endif /* !STANDALONE */ ModeSpecOpt swirl_opts = { @@ -219,9 +224,7 @@ initialise_swirl(ModeInfo * mi, SWIRL_P swirl) #endif /* !STANDALONE */ -#ifdef STANDALONE -# define MI_COLORMAP MI_WIN_COLORMAP -#else /* !STANDALONE */ +#ifndef STANDALONE swirl->fg = MI_FG_COLOR(mi); swirl->bg = MI_BG_COLOR(mi); swirl->fgcol.pixel = swirl->fg; @@ -248,11 +251,27 @@ initialise_image(ModeInfo * mi, SWIRL_P swirl) if (swirl->ximage != NULL) XDestroyImage(swirl->ximage); - swirl->ximage = XCreateImage(dpy, swirl->visual, swirl->rdepth, ZPixmap, - 0, 0, swirl->width, swirl->height, - 8, 0); - swirl->ximage->data = swirl->image = - (unsigned char *) calloc(swirl->height, swirl->ximage->bytes_per_line); + swirl->ximage = 0; +#ifdef HAVE_XSHM_EXTENSION + if (mi->use_shm) + { + swirl->ximage = create_xshm_image(dpy, swirl->visual, swirl->rdepth, + ZPixmap, 0, &mi->shm_info, + swirl->width, swirl->height); + if (!swirl->ximage) + mi->use_shm = False; + } +#endif /* HAVE_XSHM_EXTENSION */ + + if (!swirl->ximage) + { + swirl->ximage = XCreateImage(dpy, swirl->visual, swirl->rdepth, ZPixmap, + 0, 0, swirl->width, swirl->height, + 8, 0); + swirl->image = (unsigned char *) + calloc(swirl->height, swirl->ximage->bytes_per_line); + swirl->ximage->data = (char *) swirl->image; + } } /****************************************************************/ @@ -1107,10 +1126,17 @@ draw_point(ModeInfo * mi, SWIRL_P swirl) draw_block(swirl->ximage, x, y, r, do_point(swirl, x, y)); /* update the screen */ -/* PURIFY 4.0.1 on SunOS4 and on Solaris 2 reports a 256 byte memory leak on * - the next line. */ - XPutImage(MI_DISPLAY(mi), MI_WINDOW(mi), MI_GC(mi), swirl->ximage, - x, y, x, y, r, r); + +#ifdef HAVE_XSHM_EXTENSION + if (mi->use_shm) + XShmPutImage(MI_DISPLAY(mi), MI_WINDOW(mi), MI_GC(mi), swirl->ximage, + x, y, x, y, r, r, False); + else +#endif /* !HAVE_XSHM_EXTENSION */ + /* PURIFY 4.0.1 on SunOS4 and on Solaris 2 reports a 256 byte memory + leak on the next line. */ + XPutImage(MI_DISPLAY(mi), MI_WINDOW(mi), MI_GC(mi), swirl->ximage, + x, y, x, y, r, r); } /****************************************************************/