http://ftp.ksu.edu.tw/FTP/FreeBSD/distfiles/xscreensaver-4.20.tar.gz
[xscreensaver] / hacks / distort.c
index ffaaa53e6b186539bfac5a44d77f4a5c8f76bda1..919aa4bd83219f88daab240017cfc0ea85c3f207 100644 (file)
@@ -1,6 +1,5 @@
 /* -*- mode: C; tab-width: 4 -*-
- * xscreensaver, Copyright (c) 1992, 1993, 1994, 1996, 1997, 1998
- * Jamie Zawinski <jwz@jwz.org>
+ * xscreensaver, Copyright (c) 1992-2005 Jamie Zawinski <jwz@jwz.org>
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
  * documentation for any purpose is hereby granted without fee, provided that
@@ -208,6 +207,18 @@ static void init_distort(Display *dpy, Window window)
           radius = xgwa.width/8;
        }
 
+    /* never allow the radius to be too close to the min window dimension
+     */
+    if (radius >= xgwa.width  * 0.45) radius = xgwa.width  * 0.45;
+    if (radius >= xgwa.height * 0.45) radius = xgwa.height * 0.45;
+
+
+    /* -swamp mode consumes vast amounts of memory, proportional to radius --
+       so throttle radius to a small-ish value (60 => ~30MB.)
+     */
+    if (effect == &swamp_thing && radius > 60)
+      radius = 60;
+
        if (delay < 0)
                delay = 0;
        if (radius <= 0)
@@ -236,7 +247,7 @@ static void init_distort(Display *dpy, Window window)
                gcflags |= GCSubwindowMode;
        gc = XCreateGC (dpy, window, gcflags, &gcv);
 
-       grab_screen_image (xgwa.screen, window);
+    load_random_image (xgwa.screen, window, window, NULL, NULL);
 
        buffer_map = 0;
        orig_map = XGetImage(dpy, window, 0, 0, xgwa.width, xgwa.height,
@@ -568,6 +579,7 @@ static void reflect_draw(int k)
                ly = i - cy;
                lysq = ly * ly;
                ny = xy_coo[k].y + i;
+               if (ny >= orig_map->height) ny = orig_map->height-1;
                for(j = 0 ; j < 2*radius+speed+2 ; j++) {
                        lx = j - cx;
                        dist = lx * lx + lysq;
@@ -696,7 +708,7 @@ char *defaults [] = {
        "*visualID:                     Best",
 #endif
 
-       "*delay:                        1000",
+       "*delay:                        20000",
        "*radius:                       0",
        "*speed:                        0",
        "*number:                       0",