[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH] KRGB 1.0 bug fix for gs-gpl



severity 294430 grave
found 294430 8.01-5
tags 294430 patch
thanks

This bug is caused by a grave problem in the KRGB 1.0 patch gs-gpl carries.
The attached patch fixes this, and upgrades KRGB support to something that
works.

Bug severity adjusted, as it breaks printing in a large number of devices,
as it hoses IJS (and not just KRGB IJS).

I intend to NMU gs-gpl quite soon to fix this issue, probably through the
DELAYED queue.  An NMU bug will be filled before I upload, of course.

-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh
diff -ruN gs-gpl-8.15/debian/patches/06_ijs_krgb_support.dpatch gs-gpl-8.15.fixed/debian/patches/06_ijs_krgb_support.dpatch
--- gs-gpl-8.15/debian/patches/06_ijs_krgb_support.dpatch	2006-02-23 15:21:34.000000000 -0300
+++ gs-gpl-8.15.fixed/debian/patches/06_ijs_krgb_support.dpatch	2006-02-23 15:19:56.748375909 -0300
@@ -1,8 +1,9 @@
 #! /bin/sh -e
-## 06_ijs_krgb_support.dpatch by Masayuki Hatta <mhatta@debian.org>
+## 06_ijs_krgb_support.dpatch by David Suffield <linux.deskjet@hp.com>
 ##
 ## All lines beginning with \`## DP:' are a description of the patch.
 ## DP: Added KRGB colorspace support to gs IJS driver.
+## DP: Patch from HPLIP upstream, distributed in the hpijs package
 
 if [ $# -ne 1 ]; then
     echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
@@ -19,10 +20,10 @@
 
 exit 0
 
-diff -urN gs-gpl-8.01.orig/src/gdevijs.c gs-gpl-8.01/src/gdevijs.c
---- gs-gpl-8.01.orig/src/gdevijs.c	2004-08-15 13:13:02.000000000 +0900
-+++ gs-gpl-8.01/src/gdevijs.c	2004-08-15 13:13:20.000000000 +0900
-@@ -27,15 +27,25 @@
+diff -uNr old/src/gdevijs.c new/src/gdevijs.c
+--- old/src/gdevijs.c	2005-02-20 15:43:15.284386019 -0800
++++ new/src/gdevijs.c	2005-02-20 15:43:36.682297237 -0800
+@@ -27,15 +27,29 @@
   * which is a security risk, since any program can be run.
   * You should use -dSAFER which sets .LockSafetyParams to true 
   * before opening this device.
@@ -33,6 +34,10 @@
 + * 1. Removed hpijs 1.0-1.0.2 workarounds, use hpijs 1.0.3 or higher.
 + * 2. Added krgb support.
 + *
++ * 02/21/05 David Suffield
++ * 1. Fixed segfault issue with 1-bit color space.
++ * 2. Fixed z-order issue with colored text on black rectangle.
++ *
   */
  
  #include "unistd_.h"	/* for dup() */
@@ -48,7 +53,7 @@
  /* This should go into gdevprn.h, or, better yet, gdevprn should
     acquire an API for changing resolution. */
  int gdev_prn_maybe_realloc_memory(gx_device_printer *pdev,
-@@ -51,6 +61,14 @@
+@@ -51,6 +65,14 @@
  private dev_proc_get_params(gsijs_get_params);
  private dev_proc_put_params(gsijs_put_params);
  
@@ -63,7 +68,7 @@
  private const gx_device_procs gsijs_procs =
  prn_color_params_procs(gsijs_open, gsijs_output_page, gsijs_close,
  		   gx_default_rgb_map_rgb_color, gx_default_rgb_map_color_rgb,
-@@ -83,6 +101,14 @@
+@@ -83,6 +105,14 @@
  
      IjsClientCtx *ctx;
      int ijs_version;
@@ -78,7 +83,7 @@
  };
  
  #define DEFAULT_DPI 74   /* See gsijs_set_resolution() below. */
-@@ -110,7 +136,12 @@
+@@ -110,7 +140,12 @@
      FALSE,	/* Tumble_set */
  
      NULL,	/* IjsClient *ctx */
@@ -92,7 +97,7 @@
  };
  
  
-@@ -126,12 +157,234 @@
+@@ -126,12 +161,254 @@
  
  /**************************************************************************/
  
@@ -161,11 +166,12 @@
 +
 +private int gsijs_copy_mono(gx_device * dev, const byte * data,
 +      int dx, int draster, gx_bitmap_id id,
-+      int x, int y, int w, int h, gx_color_index zero, gx_color_index one)
++      int x, int y, int w, int height, gx_color_index zero, gx_color_index one)
 +{
 +   gx_device_ijs *ijsdev = (gx_device_ijs *)((gx_device_forward *)dev)->target;
 +
-+   if (ijsdev->krgb_mode && ijsdev->k_path && one==0x0) 
++   //   if (ijsdev->krgb_mode && ijsdev->k_path && one==0x0) 
++   if (ijsdev->krgb_mode && ijsdev->k_path) 
 +   {
 +      /* Store in k plane band instead of regular band. */
 +      int raster = (ijsdev->k_width+7) >> 3;       /* raster width in bytes, byte aligned */
@@ -173,25 +179,43 @@
 +      register const unsigned char *scan=data+(dx >> 3);
 +      int dest_start_bit = x & 7;
 +      int scan_start_bit = dx & 7;
-+      int i;
++      int i, h=height;
 +      
 +      if (h <= 0 || w <= 0)
 +         return 0;
 +
-+      while (h-- > 0)
++      if (one==0x0)
 +      {
-+         for (i=0; i<w; i++)
++         /* Color is black, store in k plane band instead of regular band. */
++         while (h-- > 0)
 +         {
-+            if (scan[(scan_start_bit+i)>>3] & xmask[(scan_start_bit+i)&7])
-+               dest[(dest_start_bit+i)>>3] |= xmask[(dest_start_bit+i)&7];
++            for (i=0; i<w; i++)
++            {
++               if (scan[(scan_start_bit+i)>>3] & xmask[(scan_start_bit+i)&7])
++                  dest[(dest_start_bit+i)>>3] |= xmask[(dest_start_bit+i)&7];
++            }
++            scan+=draster;
++            dest+=raster;
 +         }
-+         scan+=draster;
-+         dest+=raster;
++         return 0;
 +      }
-+      return 0;   
++      else
++      {
++         /* Color is not black, remove any k plane bits for z-order dependencies, store in regular band. */
++         while (h-- > 0)
++         {
++            for (i=0; i<w; i++)
++            {
++               if (scan[(scan_start_bit+i)>>3] & xmask[(scan_start_bit+i)&7])
++                  dest[(dest_start_bit+i)>>3] &= ~xmask[(dest_start_bit+i)&7];
++            }
++            scan+=draster;
++            dest+=raster;
++         }
++      }   
 +   }
 +
-+   return (*ijsdev->prn_procs.copy_mono)(dev, data, dx, draster, id, x, y, w, h, zero, one);
++   return (*ijsdev->prn_procs.copy_mono)(dev, data, dx, draster, id, x, y, w, height, zero, one);
 +}
 +
 +/* ---------------- High-level graphic procedures ---------------- */
@@ -290,8 +314,9 @@
 +            const gx_render_plane_t *render_plane, gs_memory_t *mem, bool for_band)
 +{
 +   gx_device_ijs *ijsdev = (gx_device_ijs *)target;
++   int n_chan = ijsdev->color_info.num_components;
 +   int code = gx_default_create_buf_device(pbdev, target, render_plane, mem, for_band);
-+   if (code < 0)
++   if (code < 0 || n_chan != 3)
 +      return code;
 +
 +   /* Save buffer (vector) procedures so that we can hook them during banding playback. */
@@ -332,7 +357,7 @@
  
  private int
  gsijs_parse_wxh (const char *val, int size, double *pw, double *ph)
-@@ -169,34 +422,6 @@
+@@ -169,34 +446,6 @@
  }
  
  /**
@@ -367,7 +392,7 @@
   * gsijs_set_generic_params: Set generic IJS parameters.
   **/
  private int
-@@ -207,9 +432,6 @@
+@@ -207,9 +456,6 @@
      int i, j;
      char *value;
  
@@ -377,7 +402,7 @@
      /* Split IjsParams into separate parameters and send to ijs server */
      value = NULL;
      for (i=0, j=0; (j < ijsdev->IjsParams_size) && (i < sizeof(buf)-1); j++) {
-@@ -250,68 +472,6 @@
+@@ -250,68 +496,6 @@
  }
  
  /**
@@ -446,7 +471,7 @@
   * gsijs_set_margin_params: Do margin negotiation with IJS server.
   **/
  private int
-@@ -322,9 +482,6 @@
+@@ -322,9 +506,6 @@
      int i, j;
      char *value;
  
@@ -456,7 +481,7 @@
      /* Split IjsParams into separate parameters and send to ijs server */
      value = NULL;
      for (i=0, j=0; (j < ijsdev->IjsParams_size) && (i < sizeof(buf)-1); j++) {
-@@ -491,12 +648,18 @@
+@@ -491,12 +672,18 @@
      char buf[256];
      bool use_outputfd;
      int fd = -1;
@@ -475,7 +500,7 @@
      /* Decide whether to use OutputFile or OutputFD. Note: how to
         determine this is a tricky question, so we just allow the
         user to set it.
-@@ -511,6 +674,8 @@
+@@ -511,6 +698,8 @@
      if (code < 0)
  	return code;
  
@@ -484,7 +509,7 @@
      if (use_outputfd) {
  	/* Note: dup() may not be portable to all interesting IJS
  	   platforms. In that case, this branch should be #ifdef'ed out.
-@@ -570,6 +735,9 @@
+@@ -570,6 +759,9 @@
      if (code >= 0)
  	code = gsijs_set_margin_params(ijsdev);
  
@@ -494,7 +519,7 @@
      return code;
  }
  
-@@ -629,21 +797,6 @@
+@@ -629,21 +821,6 @@
      return min(width, end);
  }
  
@@ -516,7 +541,7 @@
  /* Print a page.  Don't use normal printer gdev_prn_output_page 
   * because it opens the output file.
   */
-@@ -654,8 +807,9 @@
+@@ -654,8 +831,9 @@
      gx_device_printer *pdev = (gx_device_printer *)dev;
      int raster = gdev_prn_raster(pdev);
      int ijs_width, ijs_height;
@@ -527,7 +552,7 @@
      unsigned char *data;
      char buf[256];
      double xres = pdev->HWResolution[0];
-@@ -671,13 +825,23 @@
+@@ -671,13 +849,23 @@
  
      /* Determine bitmap width and height */
      ijs_height = gdev_prn_print_scan_lines(dev);
@@ -555,7 +580,7 @@
      /* Required page parameters */
      sprintf(buf, "%d", n_chan);
      gsijs_client_set_param(ijsdev, "NumChan", buf);
-@@ -686,44 +850,71 @@
+@@ -686,44 +874,71 @@
  
      /* This needs to become more sophisticated for DeviceN. */
      strcpy(buf, (n_chan == 4) ? "DeviceCMYK" : 
@@ -647,7 +672,7 @@
      gs_free_object(pdev->memory, data, "gsijs_output_page");
  
      endcode = (pdev->buffer_space && !pdev->is_async_renderer ?
-@@ -1027,7 +1218,6 @@
+@@ -1027,7 +1242,6 @@
  	dprintf2("ijs: Can't set parameter %s=%s\n", key, value);
      return code;
  }

Reply to: