[gs-cvs] rev 7011 - trunk/gs/src
giles at ghostscript.com
giles at ghostscript.com
Tue Aug 29 17:24:59 PDT 2006
Author: giles
Date: 2006-08-29 17:24:55 -0700 (Tue, 29 Aug 2006)
New Revision: 7011
Modified:
trunk/gs/src/devs.mak
trunk/gs/src/gdevbit.c
trunk/gs/src/gspaint.c
trunk/gs/src/gstext.c
trunk/gs/src/gsutil.c
trunk/gs/src/lib.mak
Log:
Port Stefan Kemper's object tagging work from the gs853merge branch of
the ghostpcl tree. This implements a simple and somewhat ad hoc method
of generating tag bits (as for RGBK generation) marking text and vector
vs image pixels.
DETAILS:
This conflicts with Dan Coby's fix for bug 688638 in r6702. Dan will
resolve the conflict as part on new work he's doing on the code.
Modified: trunk/gs/src/devs.mak
===================================================================
--- trunk/gs/src/devs.mak 2006-08-29 15:38:38 UTC (rev 7010)
+++ trunk/gs/src/devs.mak 2006-08-30 00:24:55 UTC (rev 7011)
@@ -1096,7 +1096,8 @@
$(ADDMOD) $(DD)bitrgbtags -include $(GLD)cielib
$(GLOBJ)gdevbit.$(OBJ) : $(GLSRC)gdevbit.c $(PDEVH) $(math__h)\
- $(gdevdcrd_h) $(gscrd_h) $(gscrdp_h) $(gsparam_h) $(gxlum_h)
+ $(gsparam_h) $(gdevdcrd_h) $(gscrd_h) $(gscrdp_h) $(gxlum_h)\
+ $(gsutil_h)
$(GLCC) $(GLO_)gdevbit.$(OBJ) $(C_) $(GLSRC)gdevbit.c
### ------------------------- .BMP file formats ------------------------- ###
Modified: trunk/gs/src/gdevbit.c
===================================================================
--- trunk/gs/src/gdevbit.c 2006-08-29 15:38:38 UTC (rev 7010)
+++ trunk/gs/src/gdevbit.c 2006-08-30 00:24:55 UTC (rev 7011)
@@ -10,8 +10,10 @@
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$ */
/* "Plain bits" devices to measure rendering time. */
+
#include "math_.h"
#include "gdevprn.h"
#include "gsparam.h"
@@ -19,6 +21,7 @@
#include "gscrdp.h"
#include "gxlum.h"
#include "gdevdcrd.h"
+#include "gsutil.h" /* for bittags hack */
/* Define the device parameters. */
#ifndef X_DPI
@@ -29,13 +32,17 @@
#endif
/* The device descriptor */
+private dev_proc_get_color_mapping_procs(bittag_get_color_mapping_procs);
+private dev_proc_map_rgb_color(bittag_rgb_map_rgb_color);
+private dev_proc_map_color_rgb(bittag_map_color_rgb);
+private dev_proc_put_params(bittag_put_params);
private dev_proc_map_rgb_color(bit_mono_map_color);
+private dev_proc_map_rgb_color(bit_forcemono_map_rgb_color);
private dev_proc_map_color_rgb(bit_map_color_rgb);
private dev_proc_map_cmyk_color(bit_map_cmyk_color);
private dev_proc_get_params(bit_get_params);
private dev_proc_put_params(bit_put_params);
private dev_proc_print_page(bit_print_page);
-private dev_proc_decode_color(bit_decode_color);
#define bit_procs(encode_color)\
{ gdev_prn_open,\
@@ -90,7 +97,7 @@
NULL, /* get_color_mapping_procs */\
NULL, /* get_color_comp_index */\
encode_color, /* encode_color */\
- bit_decode_color /* decode_color */\
+ bit_map_color_rgb /* decode_color */\
}
/*
@@ -134,6 +141,232 @@
4, 4, 1, 1, 2, 2, bit_print_page)
};
+static const gx_device_procs bitrgbtags_procs =
+ {
+ gdev_prn_open, /* open_device */
+ gx_default_get_initial_matrix, /* initial_matrix */
+ ((void *)0), /* sync_output */
+ gdev_prn_output_page, /* output page */
+ gdev_prn_close, /* close_device */
+ bittag_rgb_map_rgb_color, /* map rgb color */
+ bittag_map_color_rgb, /* map color rgb */
+ ((void *)0), /* fill_rectangle */
+ ((void *)0), /* tile rectangle */
+ ((void *)0), /* copy mono */
+ ((void *)0), /* copy color */
+ ((void *)0), /* obsolete draw line */
+ ((void *)0), /* get_bits */
+ gdev_prn_get_params, /* get params */
+ bittag_put_params, /* put params */
+ bittag_rgb_map_rgb_color, /* map_cmyk_color */
+ ((void *)0), /* get_xfonts */
+ ((void *)0), /* get_xfont_device */
+ ((void *)0), /* map_rgb_alpha_color */
+ gx_page_device_get_page_device, /* get_page_device */
+ ((void *)0), /* get_alpha_bits */
+ ((void *)0), /* copy_alpha */
+ ((void *)0), /* get_band */
+ ((void *)0), /* copy_rop */
+ ((void *)0), /* fill_path */
+ ((void *)0), /* stroke_path */
+ ((void *)0), /* fill_mask */
+ ((void *)0), /* fill_trapezoid */
+ ((void *)0), /* fill_parallelogram */
+ ((void *)0), /* fill_triangle */
+ ((void *)0), /* draw_thin_line */
+ ((void *)0), /* begin_image */
+ ((void *)0), /* image_data */
+ ((void *)0), /* end_image */
+ ((void *)0), /* strip_tile_rectangle */
+ ((void *)0), /* strip_copy_rop */
+ ((void *)0), /* get_clipping_box */
+ ((void *)0), /* begin_typed_image */
+ ((void *)0), /* get_bits_rectangle */
+ ((void *)0), /* map_color_rgb_alpha */
+ ((void *)0), /* create_compositor */
+ ((void *)0), /* get_hardware_params */
+ ((void *)0), /* text_begin */
+ ((void *)0), /* finish_copydevice */
+ ((void *)0), /* begin_transparency_group */
+ ((void *)0), /* end_transparency_group */
+ ((void *)0), /* begin_transparency_mask */
+ ((void *)0), /* end_transparency_mask */
+ ((void *)0), /* discard_transparency_layer */
+ bittag_get_color_mapping_procs, /* get_color_mapping_procs */
+ ((void *)0), /* get_color_comp_index */
+ bittag_rgb_map_rgb_color, /* encode_color */
+ bittag_map_color_rgb /* decode_color */
+ };
+
+const gx_device_printer gs_bitrgbtags_device =
+ {
+ sizeof(gx_device_printer),
+ &bitrgbtags_procs,
+ "bitrgbtags",
+ 0 , /* memory */
+ &st_device_printer,
+ 0 , /* stype_is_dynamic */
+ 0 , /* finalize */
+ { 0 } , /* rc header */
+ 0 , /* retained */
+ 0 , /* is open */
+ 0, /* max_fill_band */
+ { /* color infor */
+ 4, /* max_components */
+ 4, /* num_components */
+ GX_CINFO_POLARITY_ADDITIVE, /* polarity */
+ 32, /* depth */
+ GX_CINFO_COMP_NO_INDEX, /* gray index */
+ 255 , /* max_gray */
+ 255 , /* max_colors */
+ 256 , /* dither grays */
+ 256 , /* dither colors */
+ { 1, 1 } , /* antialiasing */
+ GX_CINFO_UNKNOWN_SEP_LIN, /* sep and linear */
+ { 0 } , /* comp shift */
+ { 0 } , /* comp bits */
+ { 0 } , /* comp mask */
+ ( "DeviceRGB" ), /* color model name */
+ GX_CINFO_OPMODE_UNKNOWN , /* overprint mode */
+ 0 /* process comps */
+ },
+ {
+ ((gx_color_index)(~0)),
+ ((gx_color_index)(~0))
+ },
+ (int)((float)(85) * (X_DPI) / 10 + 0.5),
+ (int)((float)(110) * (Y_DPI) / 10 + 0.5),
+ 0,
+ {
+ (float)(((((int)((float)(85) * (X_DPI) / 10 + 0.5)) * 72.0 + 0.5) - 0.5) / (X_DPI)) ,
+ (float)(((((int)((float)(110) * (Y_DPI) / 10 + 0.5)) * 72.0 + 0.5) - 0.5) / (Y_DPI)) },
+ {
+ 0,
+ 0,
+ 0,
+ 0
+ } ,
+ 0 ,
+ { X_DPI, Y_DPI } ,
+ { X_DPI, Y_DPI },
+ {(float)(-(0) * (X_DPI)),
+ (float)(-(0) * (Y_DPI))},
+ {(float)((0) * 72.0),
+ (float)((0) * 72.0),
+ (float)((0) * 72.0),
+ (float)((0) * 72.0)},
+ 0 ,
+ 0 ,
+ 1 ,
+ 0 ,
+ 0 ,
+ 0 ,
+ 0 ,
+ {
+ gx_default_install,
+ gx_default_begin_page,
+ gx_default_end_page
+ },
+ { 0 },
+ { 0 },
+ { bit_print_page,
+ gx_default_print_page_copies,
+ { gx_default_create_buf_device,
+ gx_default_size_buf_device,
+ gx_default_setup_buf_device,
+ gx_default_destroy_buf_device },
+ gx_default_get_space_params,
+ gx_default_start_render_thread,
+ gx_default_open_render_device,
+ gx_default_close_render_device,
+ gx_default_buffer_page },
+ {
+ PRN_MAX_BITMAP,
+ PRN_BUFFER_SPACE,
+ { 0, 0, 0 },
+ 0 ,
+ BandingAlways },
+ { 0 },
+ 0 ,
+ 0 ,
+ 0 ,
+ -1,
+ 0 ,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0 ,
+ 0,
+ 0,
+ { 0 }
+ };
+
+static void
+cmyk_cs_to_rgb_cm(gx_device * dev, frac c, frac m, frac y, frac k, frac out[])
+{
+ color_cmyk_to_rgb(c, m, y, k, NULL, out);
+};
+
+static void
+static_rgb_cs_to_rgb_cm(gx_device * dev, const gs_imager_state *pis,
+ frac r, frac g, frac b, frac out[])
+{
+ out[0] = r;
+ out[1] = g;
+ out[2] = b;
+}
+
+static void
+gray_cs_to_rgb_cm(gx_device * dev, frac gray, frac out[])
+{
+ out[0] = out[1] = out[2] = gray;
+}
+
+
+static const gx_cm_color_map_procs bittag_DeviceRGB_procs = {
+ gray_cs_to_rgb_cm, static_rgb_cs_to_rgb_cm, cmyk_cs_to_rgb_cm
+};
+
+private const gx_cm_color_map_procs *
+bittag_get_color_mapping_procs(const gx_device *dev)
+{
+ return &bittag_DeviceRGB_procs;
+}
+
+private gx_color_index
+bittag_rgb_map_rgb_color(gx_device * dev, const gx_color_value cv[])
+{
+ return
+ ((cv[2]) >> ((sizeof(gx_color_value) * 8) - 8)) +
+ ((uint) ((cv[1]) >> ((sizeof(gx_color_value) * 8) - 8)) << 8) +
+ ((ulong) ((cv[0]) >> ((sizeof(gx_color_value) * 8) - 8)) << 16) +
+ ((ulong)gs_current_object_tag() << 24);
+}
+
+private int
+bittag_map_color_rgb(gx_device * dev, gx_color_index color, gx_color_value cv[4])
+{
+ int depth = 24;
+ int ncomp = 3;
+ int bpc = depth / ncomp;
+ uint mask = (1 << bpc) - 1;
+
+#define cvalue(c) ((gx_color_value)((ulong)(c) * gx_max_color_value / mask))
+
+ gx_color_index cshift = color;
+ cv[2] = cvalue(cshift & mask);
+ cshift >>= bpc;
+ cv[1] = cvalue(cshift & mask);
+ cshift >>= bpc;
+ cv[0] = cvalue(cshift & mask);
+ return 0;
+#undef cvalue
+}
+
/* Map gray to color. */
/* Note that 1-bit monochrome is a special case. */
private gx_color_index
@@ -146,6 +379,28 @@
return (bpc == 1 ? gx_max_color_value - gray : gray) >> drop;
}
+/* Map RGB to gray shade. */
+/* Only used in CMYK mode when put_params has set ForceMono=1 */
+private gx_color_index
+bit_forcemono_map_rgb_color(gx_device * dev, const gx_color_value cv[])
+{
+ gx_color_value color;
+ int bpc = dev->color_info.depth / 4; /* This function is used in CMYK mode */
+ int drop = sizeof(gx_color_value) * 8 - bpc;
+ gx_color_value gray, red, green, blue;
+ red = cv[0]; green = cv[1]; blue = cv[2];
+ gray = red;
+ if ((red != green) || (green != blue))
+ gray = (red * (unsigned long)lum_red_weight +
+ green * (unsigned long)lum_green_weight +
+ blue * (unsigned long)lum_blue_weight +
+ (lum_all_weights / 2))
+ / lum_all_weights;
+
+ color = (gx_max_color_value - gray) >> drop; /* color is in K channel */
+ return color;
+}
+
/* Map color to RGB. This has 3 separate cases, but since it is rarely */
/* used, we do a case test rather than providing 3 separate routines. */
private int
@@ -194,51 +449,6 @@
break;
}
return 0;
-}
-
-/*
- * Decode a gx_color_index back to the original color values. This has 3
- * separate cases, but since it is rarely used, we do a case test rather
- * than providing 3 separate routines.
- */
-private int
-bit_decode_color(gx_device * dev, gx_color_index color, gx_color_value * cv)
-{
- int depth = dev->color_info.depth;
- int ncomp = REAL_NUM_COMPONENTS(dev);
- int bpc = depth / ncomp;
- uint mask = (1 << bpc) - 1;
-
- switch (ncomp) {
- case 1: /* gray */
- cv[0] =
- (depth == 1 ? (color ? 0 : gx_max_color_value) :
- cvalue(color));
- break;
- case 3: /* RGB */
- {
- gx_color_index cshift = color;
-
- cv[2] = cvalue(cshift & mask);
- cshift >>= bpc;
- cv[1] = cvalue(cshift & mask);
- cv[0] = cvalue(cshift >> bpc);
- }
- break;
- case 4: /* CMYK */
- {
- gx_color_index cshift = color;
-
- cv[3] = cvalue(cshift & mask);
- cshift >>= bpc;
- cv[2] = cvalue(cshift & mask);
- cshift >>= bpc;
- cv[1] = cvalue(cshift & mask);
- cv[0] = cvalue(cshift >> bpc);
- }
- break;
- }
- return 0;
#undef cvalue
}
@@ -257,6 +467,12 @@
return (color == gx_no_color_index ? color ^ 1 : color);
}
+private int
+bittag_put_params(gx_device * pdev, gs_param_list * plist)
+{
+ gs_enable_object_tagging();
+ return gdev_prn_put_params(pdev, plist);
+}
/* Get parameters. We provide a default CRD. */
private int
bit_get_params(gx_device * pdev, gs_param_list * plist)
@@ -278,7 +494,7 @@
ecode = gdev_prn_get_params(pdev, plist);
code = sample_device_crd_get_params(pdev, plist, "CRDDefault");
- if (code < 0)
+ if (code < 0)
ecode = code;
if ((code = param_write_int(plist, "ForceMono", &forcemono)) < 0) {
ecode = code;
Modified: trunk/gs/src/gspaint.c
===================================================================
--- trunk/gs/src/gspaint.c 2006-08-29 15:38:38 UTC (rev 7010)
+++ trunk/gs/src/gspaint.c 2006-08-30 00:24:55 UTC (rev 7011)
@@ -29,6 +29,7 @@
#include "gxdevmem.h"
#include "gzcpath.h"
#include "gxhldevc.h"
+#include "gsutil.h"
/* Define the nominal size for alpha buffers. */
#define abuf_nominal_SMALL 500
@@ -268,7 +269,18 @@
code = 0;
} else {
int abits, acode, rcode = 0;
+ /* to distinguish text from vectors we hackly look at the
+ target device 1 bit per component is a cache and this is
+ text else it is a path */
+ if (gx_device_has_color(gs_currentdevice(pgs))) {
+ gx_unset_dev_color(pgs);
+ gs_set_object_tag(pgs, GS_PATH_TAG);
+ }
+ else {
+ gx_unset_dev_color(pgs);
+ gs_set_object_tag(pgs, GS_TEXT_TAG);
+ }
gx_set_dev_color(pgs);
code = gs_state_color_load(pgs);
if (code < 0)
@@ -328,13 +340,21 @@
}
code = gx_path_add_char_path(pgs->show_gstate->path, pgs->path,
pgs->in_charpath);
- } else if (gs_is_null_device(pgs->device)) {
+ } if (gs_is_null_device(pgs->device)) {
/* Handle separately to prevent gs_state_color_load. */
gs_newpath(pgs);
code = 0;
} else {
int abits, acode, rcode = 0;
+ /* to distinguish text from vectors we hackly look at the
+ target device 1 bit per component is a cache and this is
+ text else it is a path */
+ if (gx_device_has_color(gs_currentdevice(pgs)))
+ gs_set_object_tag(pgs, GS_PATH_TAG);
+ else
+ gs_set_object_tag(pgs, GS_TEXT_TAG);
+
gx_set_dev_color(pgs);
code = gs_state_color_load(pgs);
if (code < 0)
@@ -411,6 +431,8 @@
code = gx_path_assign_free(pgs->path, &spath);
if (code < 0)
return code;
+ /* NB: needs testing with PCL */
gx_setcurrentpoint(pgs, fixed2float(spath.position.x), fixed2float(spath.position.y));
return 0;
+
}
Modified: trunk/gs/src/gstext.c
===================================================================
--- trunk/gs/src/gstext.c 2006-08-29 15:38:38 UTC (rev 7010)
+++ trunk/gs/src/gstext.c 2006-08-30 00:24:55 UTC (rev 7011)
@@ -11,8 +11,9 @@
San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
*/
-/*$Id$ */
+/* $Id$ */
/* Driver text interface support */
+
#include "memory_.h"
#include "gstypes.h"
#include "gdebug.h"
@@ -28,6 +29,7 @@
#include "gxpath.h"
#include "gxtext.h"
#include "gzstate.h"
+#include "gsutil.h"
/* GC descriptors */
public_st_gs_text_params();
@@ -228,6 +230,7 @@
if (text->operation & TEXT_DO_DRAW) {
code = gx_effective_clip_path(pgs, &pcpath);
+ gs_set_object_tag(pgs, GS_TEXT_TAG);
if (code < 0)
return code;
}
Modified: trunk/gs/src/gsutil.c
===================================================================
--- trunk/gs/src/gsutil.c 2006-08-29 15:38:38 UTC (rev 7010)
+++ trunk/gs/src/gsutil.c 2006-08-30 00:24:55 UTC (rev 7011)
@@ -13,6 +13,7 @@
/* $Id$ */
/* Utilities for Ghostscript library */
+
#include "string_.h"
#include "memory_.h"
#include "gstypes.h"
@@ -23,7 +24,11 @@
#include "gsrect.h" /* for prototypes */
#include "gsuid.h"
#include "gsutil.h" /* for prototypes */
+#include "gzstate.h"
+#include "gxdcolor.h"
+
+
/* ------ Unique IDs ------ */
ulong
@@ -281,3 +286,38 @@
}
return count;
}
+
+/* tag stuff */
+static gs_object_tag_type_t BITTAG = GS_DEVICE_DOESNT_SUPPORT_TAGS;
+
+void
+gs_enable_object_tagging()
+{
+ if (BITTAG == GS_DEVICE_DOESNT_SUPPORT_TAGS)
+ BITTAG = GS_UNKNOWN_TAG;
+}
+
+
+void
+gs_set_object_tag(gs_state * pgs, const gs_object_tag_type_t tag)
+{
+ if (BITTAG != GS_DEVICE_DOESNT_SUPPORT_TAGS) {
+ if ( BITTAG != tag ) {
+ /* mkromfs breaks this dependance
+ NB: needs to be fixed.
+ gx_unset_dev_color(pgs);
+ **/
+ BITTAG = tag;
+ /* the assumption is made that the caller will:
+ * gx_set_dev_color(pgs);
+ */
+ }
+ }
+}
+
+gs_object_tag_type_t
+gs_current_object_tag()
+{
+ return BITTAG;
+}
+
Modified: trunk/gs/src/lib.mak
===================================================================
--- trunk/gs/src/lib.mak 2006-08-29 15:38:38 UTC (rev 7010)
+++ trunk/gs/src/lib.mak 2006-08-30 00:24:55 UTC (rev 7011)
@@ -268,9 +268,8 @@
$(GLCC) $(GLO_)gsserial.$(OBJ) $(C_) $(GLSRC)gsserial.c
$(GLOBJ)gsutil.$(OBJ) : $(GLSRC)gsutil.c $(AK) $(memory__h) $(string__h)\
- $(gconfigv_h)\
- $(gserror_h) $(gserrors_h) $(gsmemory_h) $(gsrect_h) $(gstypes_h)\
- $(gsuid_h) $(gsutil_h)
+ $(gstypes_h) $(gconfigv_h) $(gserror_h) $(gserrors_h) $(gsmemory_h)\
+ $(gsrect_h) $(gsuid_h) $(gsutil_h) $(gzstate_h) $(gxdcolor_h)
$(GLCC) $(GLO_)gsutil.$(OBJ) $(C_) $(GLSRC)gsutil.c
# MD5 digest
@@ -847,9 +846,9 @@
$(GLCC) $(GLO_)gsmatrix.$(OBJ) $(C_) $(GLSRC)gsmatrix.c
$(GLOBJ)gspaint.$(OBJ) : $(GLSRC)gspaint.c $(GXERR) $(math__h) $(gpcheck_h)\
- $(gspaint_h) $(gspath_h) $(gsropt_h)\
- $(gxdevmem_h) $(gxdevice_h) $(gxfixed_h) $(gxmatrix_h) $(gxpaint_h) $(gxhldevc_h)\
- $(gzcpath_h) $(gzpath_h) $(gzstate_h)
+ $(gsropt_h) $(gsfixed_h) $(gxmatrix_h) $(gspaint_h) $(gspath_h)\
+ $(gzpath_h) $(gxpaint_h) $(gzstate_h) $(gxdevice_h) $(gxdevmem_h)\
+ $(gzcpath_h) $(gxhldevc_h) $(gsutil_h)
$(GLCC) $(GLO_)gspaint.$(OBJ) $(C_) $(GLSRC)gspaint.c
$(GLOBJ)gsparam.$(OBJ) : $(GLSRC)gsparam.c $(GXERR) $(memory__h) $(string__h)\
@@ -886,8 +885,9 @@
$(GLCC) $(GLO_)gsstate.$(OBJ) $(C_) $(GLSRC)gsstate.c
$(GLOBJ)gstext.$(OBJ) : $(GLSRC)gstext.c $(memory__h) $(gdebug_h)\
- $(gserror_h) $(gserrors_h) $(gsmemory_h) $(gsstruct_h) $(gstypes_h) $(gxfcache_h)\
- $(gxdcolor_h) $(gxdevcli_h) $(gxfont_h) $(gxpath_h) $(gxtext_h) $(gzstate_h)
+ $(gserror_h) $(gserrors_h) $(gsmemory_h) $(gsstruct_h) $(gstypes_h)\
+ $(gxfcache_h) $(gxdevcli_h) $(gxdcolor_h) $(gxfont_h) $(gxpath_h)\
+ $(gxtext_h) $(gzstate_h) $(gsutil_h)
$(GLCC) $(GLO_)gstext.$(OBJ) $(C_) $(GLSRC)gstext.c
# We make gsiodevs a separate module so the PS interpreter can replace it.
More information about the gs-cvs
mailing list