File xscreensaver-higher-res.diff of Package xscreensaver

# Subject: [1/4] Use higher res textures to increase zoom image quality
# From: garloff@suse.de
# When zooming into pictures, better have textures that have at least the
# resolution of our final zoom state.
Index: xscreensaver-5.22/hacks/glx/grab-ximage.c
===================================================================
--- xscreensaver-5.22.orig/hacks/glx/grab-ximage.c
+++ xscreensaver-5.22/hacks/glx/grab-ximage.c
@@ -691,11 +691,11 @@ load_texture_async (Screen *screen, Wind
   data->pix_width  = xgwa.width;
   data->pix_height = xgwa.height;
   data->pix_depth  = xgwa.depth;
 
-  if (desired_width  && desired_width  < xgwa.width)
+  if (desired_width /* && desired_width  < xgwa.width */)
     data->pix_width  = desired_width;
-  if (desired_height && desired_height < xgwa.height)
+  if (desired_height /*&& desired_height < xgwa.height */)
     data->pix_height = desired_height;
 
   data->pixmap = XCreatePixmap (dpy, window, data->pix_width, data->pix_height,
                                 data->pix_depth);
Index: xscreensaver-5.22/hacks/glx/glslideshow.c
===================================================================
--- xscreensaver-5.22.orig/hacks/glx/glslideshow.c
+++ xscreensaver-5.22/hacks/glx/glslideshow.c
@@ -84,8 +84,15 @@
 
 #undef countof
 #define countof(x) (sizeof((x))/sizeof((*x)))
 
+/* glslideshow uses textures that are large enough for the chosen zoom
+ * factor. You can use even larger textures by setting MAGNIF to values
+ * > 100, though the return in terms of resulting increase in image
+ * gets smaller and smaller.
+ */
+#define MAGNIF 120
+
 #ifdef USE_GL
 
 
 # define DEF_FADE_DURATION  "2"
@@ -279,8 +286,13 @@ alloc_image (ModeInfo *mi)
 {
   slideshow_state *ss = &sss[MI_SCREEN(mi)];
   int wire = MI_IS_WIREFRAME(mi);
   image *img = (image *) calloc (1, sizeof (*img));
+  /* Load image with higher resolution to accommodate zoom */
+  int desx, desy;
+  desx = mi->xgwa.width*MAGNIF/zoom; desx -= desx%4;
+  /* desy = mi->xgwa.height*MAGNIF/zoom; desy -= desy%2; */
+  desy = desx * (float)mi->xgwa.height/mi->xgwa.width + 0.5;
 
   img->id = ++ss->image_id;
   img->loaded_p = False;
   img->used_p = False;
@@ -294,9 +306,9 @@ alloc_image (ModeInfo *mi)
   if (wire)
     image_loaded_cb (0, 0, 0, 0, 0, 0, img);
   else
     load_texture_async (mi->xgwa.screen, mi->window, *ss->glx_context,
-                        0, 0, mipmap_p, img->texid, image_loaded_cb, img);
+                        desx, desy, mipmap_p, img->texid, image_loaded_cb, img);
 
   ss->images[ss->nimages++] = img;
   if (ss->nimages >= countof(ss->images)) abort();
 
@@ -348,9 +360,9 @@ image_loaded_cb (const char *filename, X
      then the image must have been scaled down (due to insufficient
      texture memory.)  Scale up the coordinates to stretch the image
      to fill the window.
    */
-  if (img->w != MI_WIDTH(mi))
+  if (img->w < MI_WIDTH(mi))
     {
       double scale = (double) MI_WIDTH(mi) / img->w;
       img->w  *= scale;
       img->h  *= scale;
@@ -475,10 +487,10 @@ static void
 randomize_sprite (ModeInfo *mi, sprite *sp)
 {
   int vp_w = MI_WIDTH(mi);
   int vp_h = MI_HEIGHT(mi);
-  int img_w = sp->img->geom.width;
-  int img_h = sp->img->geom.height;
+  int img_w = sp->img->geom.width * zoom/MAGNIF;
+  int img_h = sp->img->geom.height * zoom/MAGNIF;
   int min_w, max_w;
   double ratio = (double) img_h / img_w;
 
   if (letterbox_p)
@@ -934,9 +946,9 @@ reshape_slideshow (ModeInfo *mi, int wid
   glLoadIdentity();
   glMatrixMode (GL_MODELVIEW);
   glLoadIdentity();
 
-  s = 2;
+  s = 2 /*/ (MAGNIF/100)*/;
 
   if (debug_p)
     {
       s *= (zoom / 100.0) * 0.75;
openSUSE Build Service is sponsored by