http://www.jwz.org/xscreensaver/xscreensaver-5.13.tar.gz
[xscreensaver] / hacks / glx / glslideshow.c
index e3108980609f7573ac3f0ab657aed18d6adee44b..be77dc1fef0a66e6af3960e2ff55beadeb1d9adf 100644 (file)
@@ -1,4 +1,4 @@
-/* glslideshow, Copyright (c) 2003-2008 Jamie Zawinski <jwz@jwz.org>
+/* glslideshow, Copyright (c) 2003-2011 Jamie Zawinski <jwz@jwz.org>
  * Loads a sequence of images and smoothly pans around them; crossfades
  * when loading new images.
  *
@@ -73,7 +73,7 @@
                   "*showFPS:         False                \n" \
                  "*fpsSolid:        True                 \n" \
                  "*useSHM:          True                 \n" \
-                 "*titleFont:       -*-times-bold-r-normal-*-180-*\n" \
+                 "*titleFont:       -*-helvetica-medium-r-normal-*-180-*\n" \
                   "*desktopGrabber:  xscreensaver-getimage -no-desktop %s\n" \
                  "*grabDesktopImages:   False \n" \
                  "*chooseRandomImages:  True  \n"
@@ -358,11 +358,17 @@ image_loaded_cb (const char *filename, XRectangle *geom,
       img->geom.height *= scale;
     }
 
-  if (img->title)   /* strip filename to part after last /. */
+# if 0 /* xscreensaver-getimage returns paths relative to the image directory
+          now, so leave the sub-directory part in.
+        */
+  if (img->title)  /* strip filename to part between last "/" and last ".". */
     {
       char *s = strrchr (img->title, '/');
       if (s) strcpy (img->title, s+1);
+      s = strrchr (img->title, '.');
+      if (s) *s = 0;
     }
+# endif /* 0 */
 
   if (debug_p)
     fprintf (stderr, "%s: loaded   img %2d: \"%s\"\n",
@@ -468,30 +474,22 @@ randomize_sprite (ModeInfo *mi, sprite *sp)
   int vp_h = MI_HEIGHT(mi);
   int img_w = sp->img->geom.width;
   int img_h = sp->img->geom.height;
-  int min_w, min_h, max_w, max_h;
+  int min_w, max_w;
   double ratio = (double) img_h / img_w;
 
   if (letterbox_p)
     {
       min_w = img_w;
-      min_h = img_h;
     }
   else
     {
       if (img_w < vp_w)
-        {
-          min_w = vp_w;
-          min_h = img_h * (float) vp_w / img_w;
-        }
+        min_w = vp_w;
       else
-        {
-          min_w = img_w * (float) vp_h / img_h;
-          min_h = vp_h;
-        }
+        min_w = img_w * (float) vp_h / img_h;
     }
 
   max_w = min_w * 100 / zoom;
-  max_h = min_h * 100 / zoom;
 
   sp->from.w = min_w + frand ((max_w - min_w) * 0.4);
   sp->to.w   = max_w - frand ((max_w - min_w) * 0.4);
@@ -531,16 +529,22 @@ randomize_sprite (ModeInfo *mi, sprite *sp)
       sp->from = swap;
     }
 
-  /* Make sure the aspect ratios are within 0.0001 of each other.
+  /* Make sure the aspect ratios are within 0.001 of each other.
    */
-  if ((int) (0.5 + (sp->from.w * 1000 / sp->from.h)) !=
-      (int) (0.5 + (sp->to.w   * 1000 / sp->to.h)))
-    {
-      fprintf (stderr, "%s: botched aspect: %f x %f vs  %f x %f: %s\n",
-               progname, sp->from.w, sp->from.h, sp->to.w, sp->to.h,
-               sp->img->title);
-      abort();
-    }
+  {
+    int r1 = 0.5 + (sp->from.w * 1000 / sp->from.h);
+    int r2 = 0.5 + (sp->to.w   * 1000 / sp->to.h);
+    if (r1 < r2-1 || r1 > r2+1)
+      {
+        fprintf (stderr,
+                 "%s: botched aspect: %f x %f (%d) vs  %f x %f (%d): %s\n",
+                 progname, 
+                 sp->from.w, sp->from.h, r1,
+                 sp->to.w, sp->to.h, r2,
+                 (sp->img->title ? sp->img->title : "[null]"));
+        abort();
+      }
+  }
 
   sp->from.x /= vp_w;
   sp->from.y /= vp_h;
@@ -810,12 +814,12 @@ draw_sprite (ModeInfo *mi, sprite *sp)
         glColor4f (0, 0, 0, sp->opacity);   /* cheap-assed dropshadow */
         print_gl_string (mi->dpy, ss->xfont, ss->font_dlist,
                          mi->xgwa.width, mi->xgwa.height, x, y,
-                         img->title);
+                         img->title, False);
         x++; y++;
         glColor4f (1, 1, 1, sp->opacity);
         print_gl_string (mi->dpy, ss->xfont, ss->font_dlist,
                          mi->xgwa.width, mi->xgwa.height, x, y,
-                         img->title);
+                         img->title, False);
       }
   }
   glPopMatrix();
@@ -1210,8 +1214,8 @@ draw_slideshow (ModeInfo *mi)
 
   draw_sprites (mi);
 
-  ss->fps = fps_1 (mi);
-  if (mi->fps_p) fps_2 (mi);
+  ss->fps = fps_compute (mi->fpst, 0);
+  if (mi->fps_p) do_fps (mi);
 
   glFinish();
   glXSwapBuffers (MI_DISPLAY (mi), MI_WINDOW(mi));