[gs-cvs] rev 8459 - trunk/gs/src

giles at ghostscript.com giles at ghostscript.com
Fri Dec 21 16:10:06 PST 2007


Author: giles
Date: 2007-12-21 16:10:05 -0800 (Fri, 21 Dec 2007)
New Revision: 8459

Removed:
   trunk/gs/src/gdevcmap.c
   trunk/gs/src/gdevcmap.h
Modified:
   trunk/gs/src/gslib.c
   trunk/gs/src/lib.mak
   trunk/gs/src/ugcclib.mak
Log:
Remove the unused cmap device.


Deleted: trunk/gs/src/gdevcmap.c
===================================================================
--- trunk/gs/src/gdevcmap.c	2007-12-21 19:58:19 UTC (rev 8458)
+++ trunk/gs/src/gdevcmap.c	2007-12-22 00:10:05 UTC (rev 8459)
@@ -1,321 +0,0 @@
-/* Copyright (C) 2001-2006 Artifex Software, Inc.
-   All Rights Reserved.
-  
-   This software is provided AS-IS with no warranty, either express or
-   implied.
-
-   This software is distributed under license and may not be copied, modified
-   or distributed except as expressly authorized under the terms of that
-   license.  Refer to licensing information at http://www.artifex.com/
-   or contact Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134,
-   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
-*/
-/* $Id$ */
-/* Special color mapping device */
-#include "gx.h"
-#include "gserrors.h"
-#include "gxdevice.h"
-#include "gxlum.h"
-#include "gxfrac.h"
-#include "gxdcconv.h"
-#include "gdevcmap.h"
-
-/*
- * The devices in this file exist only to implement the PCL5 special
- * color mapping algorithms.  They are not useful for PostScript.
- */
-
-/* GC descriptor */
-public_st_device_cmap();
-
-/* Device procedures */
-static dev_proc_get_params(cmap_get_params);
-static dev_proc_put_params(cmap_put_params);
-static dev_proc_begin_typed_image(cmap_begin_typed_image);
-static dev_proc_get_color_mapping_procs(cmap_get_color_mapping_procs);
-
-/*
- * NB: all of the device color model information will be replaced by
- * the target's color model information. Only the
- * get_color_mapping_procs method is modified (aside from
- * get_params/put_params).
- *
- * The begin_typed_image method is used only to force use of the default
- * image rendering routines if a special mapping_method (anything other
- * than device_cmap_identity) is requested.
- */
-
-static const gx_device_cmap gs_cmap_device = {
-    std_device_dci_body(gx_device_cmap, 0, "special color mapper",
-                        0, 0, 1, 1,
-                        3, 24, 255, 255, 256, 256),
-    {
-        0, 0, 0, 0, 0, 0, 0,
-        gx_forward_fill_rectangle,
-        gx_forward_tile_rectangle,
-        gx_forward_copy_mono,
-        gx_forward_copy_color,
-        0, 0,
-        cmap_get_params,
-        cmap_put_params,
-        0, 0, 0, 0,
-        0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0, 0, 0,
-        gx_default_begin_image,
-        0, 0, 0, 0, 0,
-        cmap_begin_typed_image,
-        0, 0, 0, 0, 0, 0,
-        0, 0, 0, 0, 0,
-        cmap_get_color_mapping_procs,
-        0, 0, 0
-    },
-    0,                          /* target */
-    device_cmap_identity
-};
-
-/* Set the color mapping method. */
-static int
-gdev_cmap_set_method(gx_device_cmap * cmdev,
-		     gx_device_color_mapping_method_t method)
-{
-    gx_device *target = cmdev->target;
-
-    /*
-     * If we're transforming the color, we may need to fool the graphics
-     * core into not halftoning.
-     */
-    set_dev_proc(cmdev, map_cmyk_color, gx_default_map_cmyk_color);
-    set_dev_proc(cmdev, map_color_rgb, gx_forward_map_color_rgb);
-
-    switch (method) {
-
-	case device_cmap_identity:
-	    /*
-	     * In this case, and only this case, we can allow the target's
-	     * color model to propagate here.
-	     */
-	    set_dev_proc(cmdev, map_cmyk_color, gx_forward_map_cmyk_color);
-	    cmdev->color_info.max_gray = target->color_info.max_gray;
-	    cmdev->color_info.max_color = target->color_info.max_color;
-	    cmdev->color_info.max_components =
-	        target->color_info.max_components;
-	    cmdev->color_info.num_components =
-		target->color_info.num_components;
-	    cmdev->color_info.polarity = target->color_info.polarity;
-	    cmdev->color_info.gray_index = target->color_info.gray_index;
-	    cmdev->color_info.cm_name = target->color_info.cm_name;
-	    gx_device_copy_color_procs((gx_device *)cmdev, target);
-	    break;
-
-	case device_cmap_monochrome:
-	    cmdev->color_info.max_gray = target->color_info.max_gray;
-	    cmdev->color_info.max_color = target->color_info.max_color;
-	    cmdev->color_info.max_components = 
-	        cmdev->color_info.num_components = 1;
-	    cmdev->color_info.cm_name = "DeviceGray";
-	    break;
-
-	case device_cmap_snap_to_primaries:
-	case device_cmap_color_to_black_over_white:
-	    cmdev->color_info.max_gray = cmdev->color_info.max_color = 4095;
-	    /*
-	     * We have to be an RGB device, otherwise "primaries" doesn't
-	     * have the proper meaning.
-	     */
-	    cmdev->color_info.max_components = 
-	        cmdev->color_info.num_components = 3;
-	    cmdev->color_info.cm_name = "DeviceRGB";
-	    break;
-
-	default:
-	    return_error(gs_error_rangecheck);
-    }
-    cmdev->mapping_method = method;
-    return 0;
-}
-
-/* Initialize the device. */
-int
-gdev_cmap_init(gx_device_cmap * dev, gx_device * target,
-	       gx_device_color_mapping_method_t method)
-{
-    int code;
-
-    gx_device_init((gx_device *) dev, (const gx_device *)&gs_cmap_device,
-		   target->memory, true);
-    gx_device_set_target((gx_device_forward *)dev, target);
-    gx_device_copy_params((gx_device *)dev, target);
-    check_device_separable((gx_device *)dev);
-    gx_device_forward_fill_in_procs((gx_device_forward *) dev);
-    code = gdev_cmap_set_method(dev, method);
-    if (code < 0)
-	return code;
-    return 0;
-}
-
-/* Get parameters. */
-static int
-cmap_get_params(gx_device * dev, gs_param_list * plist)
-{
-    int code = gx_forward_get_params(dev, plist);
-    int ecode = code;
-    gx_device_cmap * const cmdev = (gx_device_cmap *)dev;
-    int cmm = cmdev->mapping_method;
-
-    if ((code = param_write_int(plist, "ColorMappingMethod", &cmm)) < 0)
-	ecode = code;
-    return ecode;
-}
-
-/* Update parameters; copy the device information back afterwards. */
-static int
-cmap_put_params(gx_device * dev, gs_param_list * plist)
-{
-    int code = gx_forward_put_params(dev, plist);
-    int ecode = code;
-    gx_device_cmap * const cmdev = (gx_device_cmap *)dev;
-    int cmm = cmdev->mapping_method;
-    const char *param_name;
-
-    switch (code = param_read_int(plist, param_name = "ColorMappingMethod",
-				  &cmm)) {
-    case 0:
-	if (cmm < 0 || cmm > device_cmap_max_method) {
-	    code = gs_note_error(gs_error_rangecheck);
-	} else
-	    break;
-    default:
-	ecode = code;
-	param_signal_error(plist, param_name, ecode);
-	break;
-    case 1:
-	break;
-    }
-    if (code >= 0) {
-	gx_device_copy_params(dev, cmdev->target);
-	gdev_cmap_set_method(cmdev, cmm);
-    }
-    return ecode;
-}
-
-/*
- * Handle high-level images.  The only reason we do this, rather than simply
- * pass the operation to the target, is that the image still has to call the
- * cmap device to do its color mapping.  As presently implemented, this
- * disables any high-level implementation that the target may provide.
- */
-static int
-cmap_begin_typed_image(gx_device * dev,
-		       const gs_imager_state * pis, const gs_matrix * pmat,
-		   const gs_image_common_t * pic, const gs_int_rect * prect,
-		       const gx_drawing_color * pdcolor,
-		       const gx_clip_path * pcpath,
-		       gs_memory_t * memory, gx_image_enum_common_t ** pinfo)
-{
-    const gx_device_cmap *const cmdev = (const gx_device_cmap *)dev;
-    gx_device *target = cmdev->target;
-
-    if (cmdev->mapping_method == device_cmap_identity)
-	return (*dev_proc(target, begin_typed_image))
-	    (target, pis, pmat, pic, prect, pdcolor, pcpath, memory, pinfo);
-    return gx_default_begin_typed_image(dev, pis, pmat, pic, prect,
-					pdcolor, pcpath, memory, pinfo);
-}
-
-static void
-cmap_gray_cs_to_cm(gx_device * dev, frac gray, frac out[])
-{
-    gx_device_cmap *    cmdev = (gx_device_cmap *)dev;
-    frac gx_max_color_frac   = cv2frac(gx_max_color_value);
-    switch (cmdev->mapping_method) {
-    case device_cmap_snap_to_primaries:
-        gray = (gray <= gx_max_color_frac / 2 ? 0 : gx_max_color_frac);
-        break;
-
-    case device_cmap_color_to_black_over_white:
-        gray = (gray == 0 ? gx_max_color_frac : 0);
-        break;
-    }
-    {
-        gx_device *target = cmdev->target ? cmdev->target : dev;
-        gx_cm_color_map_procs *cm_procs =  (dev_proc( target, get_color_mapping_procs)(target));
-        cm_procs->map_gray(target, gray, out );
-    }
-}
-
-static void
-cmap_rgb_cs_to_cm(gx_device * dev, const gs_imager_state * pis, frac r, frac g, frac b, frac out[])
-{
-    
-    gx_device_cmap *    cmdev = (gx_device_cmap *)dev;
-    frac gx_max_color_frac   = cv2frac(gx_max_color_value);
-    switch (cmdev->mapping_method) {
-        
-    case device_cmap_snap_to_primaries:
-        r = (r <= gx_max_color_frac / 2 ? 0 : gx_max_color_frac);
-        g = (g <= gx_max_color_frac / 2 ? 0 : gx_max_color_frac);
-        b = (b <= gx_max_color_frac / 2 ? 0 : gx_max_color_frac);
-        break;
-
-    case device_cmap_color_to_black_over_white:
-        if (r == 0 && g == 0 && b == 0)
-            r = g = b = gx_max_color_frac;
-        else
-            r = g = b = 0;
-        break;
-
-    case device_cmap_monochrome:
-        r = g = b = color_rgb_to_gray(r, g, b, NULL);
-        break;
-    }
-    {
-        gx_device *target = cmdev->target ? cmdev->target : dev;
-        gx_cm_color_map_procs *cm_procs =  (dev_proc( target, get_color_mapping_procs)(target));
-        cm_procs->map_rgb(target, pis, r, g, b, out );
-    }
-}
-
-static void
-cmap_cmyk_cs_to_cm(gx_device * dev, frac c, frac m, frac y, frac k, frac out[])
-{
-    gx_device_cmap *    cmdev = (gx_device_cmap *)dev;
-    frac gx_max_color_frac   = cv2frac(gx_max_color_value);
-    /* We aren't sure what to do with k so we leave it alone.  NB this
-       routine is untested and does not appear to be called.  More
-       testing needed. */
-    switch (cmdev->mapping_method) {
-    case device_cmap_snap_to_primaries:
-        c = (c > gx_max_color_frac / 2 ? 0 : gx_max_color_frac);
-        m = (m > gx_max_color_frac / 2 ? 0 : gx_max_color_frac);
-        y = (y > gx_max_color_frac / 2 ? 0 : gx_max_color_frac);
-        break;
-
-    case device_cmap_color_to_black_over_white:
-        if (c == gx_max_color_frac && m == gx_max_color_frac && y == gx_max_color_frac)
-            c = m = y = 0;
-        else
-            c = m = y = gx_max_color_frac;
-        break;
-
-    case device_cmap_monochrome:
-        c = m = y = color_cmyk_to_gray(c, m, y, k, NULL);
-        break;
-    }
-    {
-        gx_device *target = cmdev->target ? cmdev->target : dev;
-        gx_cm_color_map_procs *cm_procs =  (dev_proc( target, get_color_mapping_procs)(target));
-        cm_procs->map_cmyk(target, c, m, y, k, out );
-    }
-}
-
-static const gx_cm_color_map_procs cmap_cm_procs = {
-    cmap_gray_cs_to_cm, cmap_rgb_cs_to_cm, cmap_cmyk_cs_to_cm
-};
-
-
-static const gx_cm_color_map_procs *
-cmap_get_color_mapping_procs(const gx_device * dev)
-{
-    return &cmap_cm_procs;
-}
-

Deleted: trunk/gs/src/gdevcmap.h
===================================================================
--- trunk/gs/src/gdevcmap.h	2007-12-21 19:58:19 UTC (rev 8458)
+++ trunk/gs/src/gdevcmap.h	2007-12-22 00:10:05 UTC (rev 8459)
@@ -1,65 +0,0 @@
-/* Copyright (C) 2001-2006 Artifex Software, Inc.
-   All Rights Reserved.
-  
-   This software is provided AS-IS with no warranty, either express or
-   implied.
-
-   This software is distributed under license and may not be copied, modified
-   or distributed except as expressly authorized under the terms of that
-   license.  Refer to licensing information at http://www.artifex.com/
-   or contact Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134,
-   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
-*/
-/* $Id$ */
-/* Interface to special color mapping device */
-
-#ifndef gdevcmap_INCLUDED
-#  define gdevcmap_INCLUDED
-
-/* Define the color mapping algorithms. */
-typedef enum {
-
-    /* Don't change the color. */
-
-    device_cmap_identity = 0,
-
-    /* Snap each RGB primary component to 0 or 1 individually. */
-
-    device_cmap_snap_to_primaries,
-
-    /* Snap black to white, other colors to black. */
-
-    device_cmap_color_to_black_over_white,
-
-    /* Convert to a gray shade of the correct brightness. */
-
-    device_cmap_monochrome
-
-} gx_device_color_mapping_method_t;
-
-#define device_cmap_max_method device_cmap_monochrome
-
-/* Define the color mapping forwarding device. */
-typedef struct gx_device_cmap_s {
-    gx_device_forward_common;
-    gx_device_color_mapping_method_t mapping_method;
-} gx_device_cmap;
-
-extern_st(st_device_cmap);
-#define public_st_device_cmap()	/* in gdevcmap.c */\
-  gs_public_st_suffix_add0_final(st_device_cmap, gx_device_cmap,\
-    "gx_device_cmap", device_cmap_enum_ptrs, device_cmap_reloc_ptrs,\
-    gx_device_finalize, st_device_forward)
-
-/* Initialize a color mapping device.  Do this just once after allocation. */
-int gdev_cmap_init(gx_device_cmap * dev, gx_device * target,
-		   gx_device_color_mapping_method_t mapping_method);
-
-/*
- * Clients can change the color mapping method at any time by setting
- * the ColorMappingMethod device parameter, but they must then call
- *	gs_setdevice_no_init(pgs, dev);
- * for each graphics state that may reference the device.
- */
-
-#endif /* gdevcmap_INCLUDED */

Modified: trunk/gs/src/gslib.c
===================================================================
--- trunk/gs/src/gslib.c	2007-12-21 19:58:19 UTC (rev 8458)
+++ trunk/gs/src/gslib.c	2007-12-22 00:10:05 UTC (rev 8459)
@@ -44,7 +44,6 @@
 #include "gxdevice.h"
 #include "gxht.h"		/* for gs_halftone */
 #include "gdevbbox.h"
-#include "gdevcmap.h"
 #include "gshtx.h"
 
 /* Define whether we are processing captured data. */
@@ -744,21 +743,6 @@
     return v / 2;
 }
 static int
-set_cmap_method(gx_device_cmap *cmdev, gx_device_color_mapping_method_t method,
-		gs_state *pgs, gs_memory_t *mem)
-{
-    gs_c_param_list list;
-    int cmm = method;
-
-    gs_c_param_list_write(&list, mem);
-    param_write_int((gs_param_list *)&list, "ColorMappingMethod", &cmm);
-    gs_c_param_list_read(&list);
-    gs_putdeviceparams((gx_device *)cmdev, (gs_param_list *)&list);
-    gs_c_param_list_release(&list);
-    gs_setdevice_no_init(pgs, (gx_device *)cmdev);
-    return 0;
-}
-static int
 test6(gs_state * pgs, gs_memory_t * mem)
 {
     gs_color_space *pcs;
@@ -770,7 +754,6 @@
     {
 	{render_abc, render_abc, render_abc}
     };
-    gx_device_cmap *cmdev;
     int code;
     gs_color_space *rgb_cs;
 
@@ -799,22 +782,6 @@
     /* End of initializing the color space. */
     gs_setcolorspace(pgs, pcs);
     spectrum(pgs, 5);
-    /* Now test color snapping. */
-    cmdev =
-	gs_alloc_struct_immovable(mem, gx_device_cmap, &st_device_cmap,
-				  "cmap device");
-    gdev_cmap_init(cmdev, gs_currentdevice(pgs),
-		   device_cmap_snap_to_primaries);
-    gs_setdevice_no_init(pgs, (gx_device *) cmdev);
-    gs_setrgbcolor(pgs, 0.0, 0.0, 0.0);		/* back to DeviceRGB space */
-    gs_translate(pgs, -1.2, 1.2);
-    spectrum(pgs, 5);
-    gs_translate(pgs, 1.2, 0.0);
-    set_cmap_method(cmdev, device_cmap_monochrome, pgs, mem);
-    spectrum(pgs, 5);
-    gs_translate(pgs, -1.2, 1.2);
-    set_cmap_method(cmdev, device_cmap_color_to_black_over_white, pgs, mem);
-    spectrum(pgs, 5);
     gs_free_object(mem, rgb_cs, "test6 rgb_cs");
     return 0;
 }

Modified: trunk/gs/src/lib.mak
===================================================================
--- trunk/gs/src/lib.mak	2007-12-21 19:58:19 UTC (rev 8458)
+++ trunk/gs/src/lib.mak	2007-12-22 00:10:05 UTC (rev 8459)
@@ -1004,18 +1004,6 @@
   $(gserror_h) $(gserrors_h) $(gsmemory_h) $(gstypes_h) $(gxdevice_h)
 	$(GLCC) $(GLO_)gdevhit.$(OBJ) $(C_) $(GLSRC)gdevhit.c
 
-# Define a device that implements the PCL 5 special color mapping
-# algorithms.  This is not included in any PostScript or PDF system.
-
-$(GLD)devcmap.dev : $(LIB_MAK) $(ECHOGS_XE) $(GLOBJ)gdevcmap.$(OBJ)
-	$(SETMOD) $(GLD)devcmap $(GLOBJ)gdevcmap.$(OBJ)
-
-gdevcmap_h=$(GLSRC)gdevcmap.h
-
-$(GLOBJ)gdevcmap.$(OBJ) : $(GLSRC)gdevcmap.c $(GXERR)\
- $(gxdcconv_h) $(gxdevice_h) $(gxfrac_h) $(gxlum_h) $(gdevcmap_h)
-	$(GLCC) $(GLO_)gdevcmap.$(OBJ) $(C_) $(GLSRC)gdevcmap.c
-
 # A device that stores its data using run-length encoding.
 
 $(GLOBJ)gdevmrun.$(OBJ) : $(GLSRC)gdevmrun.c $(GXERR) $(memory__h)\
@@ -2846,6 +2834,5 @@
  $(gscdefs_h) $(gscie_h) $(gscolor2_h) $(gscoord_h) $(gscrd_h)\
  $(gshtx_h) $(gsiparm3_h) $(gsiparm4_h) $(gslib_h) $(gsparam_h)\
  $(gspaint_h) $(gspath_h) $(gspath2_h) $(gsstruct_h) $(gsutil_h)\
- $(gxalloc_h) $(gxdcolor_h) $(gxdevice_h) $(gxht_h)\
- $(gdevbbox_h) $(gdevcmap_h)
+ $(gxalloc_h) $(gxdcolor_h) $(gxdevice_h) $(gxht_h) $(gdevbbox_h)
 	$(GLCC) $(GLO_)gslib.$(OBJ) $(C_) $(GLSRC)gslib.c

Modified: trunk/gs/src/ugcclib.mak
===================================================================
--- trunk/gs/src/ugcclib.mak	2007-12-21 19:58:19 UTC (rev 8458)
+++ trunk/gs/src/ugcclib.mak	2007-12-22 00:10:05 UTC (rev 8459)
@@ -106,7 +106,7 @@
 FEATURE_DEVS=$(GLD)dps2lib.dev $(GLD)psl2cs.dev $(GLD)cielib.dev\
  $(GLD)psl3lib.dev $(GLD)path1lib.dev $(GLD)patlib.dev $(GLD)htxlib.dev\
  $(GLD)cidlib.dev $(GLD)psf0lib.dev $(GLD)psf1lib.dev\
- $(GLD)roplib.dev $(GLD)devcmap.dev
+ $(GLD)roplib.dev
 
 COMPILE_INITS?=0
 BAND_LIST_STORAGE=file



More information about the gs-cvs mailing list