[gs-commits] rev 10990 - in trunk/gs: base psi

robin at ghostscript.com robin at ghostscript.com
Tue Mar 30 14:46:57 UTC 2010


Author: robin
Date: 2010-03-30 14:46:56 +0000 (Tue, 30 Mar 2010)
New Revision: 10990

Modified:
   trunk/gs/base/gsht.c
   trunk/gs/base/gsstate.c
   trunk/gs/base/gxdcolor.h
   trunk/gs/base/gxistate.h
   trunk/gs/base/gzstate.h
   trunk/gs/psi/zht.c
   trunk/gs/psi/zht1.c
Log:
In the gs_2_colors branch I had made 2 copies of the color state and swapped
between them. I had included dev_ht as part of this 'split' state, which
was a significant contributor to the slowdown due to it forcing repeated
writing of the halftone data to the clist. Also, it required significant
extra work on every setscreen or setcolorscreen operation.

Discussions with Henry/Ray/Kens et al lead to the realisation this wasn't
required. This patch therefore backs out the dev_ht split, and the changes
to zsetscreen and zsetcolorscreen. Additional code is however required to
clear the 'alternative' dev_color when a halftone is installed to stop the
'swapped out' color pointing to an illegal halftone cache.

This runs through local testing with no diffs showing (though some
strangeness was observed with an earlier version of this patch in
regression testing - Marcos has captured this with bug 691223).

This seems to have helped with the largest slowdowns, but there are still
significant differences in some cases. Very preliminary investigations seem
to show more time being spent in the interpreter/gc mechanism. Continuing
to investigate.




Modified: trunk/gs/base/gsht.c
===================================================================
--- trunk/gs/base/gsht.c	2010-03-30 10:50:29 UTC (rev 10989)
+++ trunk/gs/base/gsht.c	2010-03-30 14:46:56 UTC (rev 10990)
@@ -1288,6 +1288,7 @@
     }
     pgs->halftone = new_ht;
     gx_unset_dev_color(pgs);
+    gx_unset_alt_dev_color(pgs);
     return 0;
 }
 

Modified: trunk/gs/base/gsstate.c
===================================================================
--- trunk/gs/base/gsstate.c	2010-03-30 10:50:29 UTC (rev 10989)
+++ trunk/gs/base/gsstate.c	2010-03-30 14:46:56 UTC (rev 10990)
@@ -1,6 +1,6 @@
 /* Copyright (C) 2001-2006 Artifex Software, Inc.
    All Rights Reserved.
-  
+
    This software is provided AS-IS with no warranty, either express or
    implied.
 
@@ -260,7 +260,6 @@
     gs_swapcolors_quick(pgs); /* To color 0 */
     gx_set_device_color_1(pgs); /* sets colorspace and client color */
     pgs->device = 0;		/* setting device adjusts refcts */
-    pgs->dev_ht_alt = 0;
     pgs->cie_joint_caches_alt = 0;
     pgs->pattern_cache_alt = 0;
     gs_nulldevice(pgs);
@@ -278,7 +277,7 @@
     pgs->level = 0;
     pgs->dfilter_stack = 0;
     pgs->transparency_group_stack = 0;
-    if (gs_initgraphics(pgs) >= 0) 
+    if (gs_initgraphics(pgs) >= 0)
 	return pgs;
     /* Something went very wrong. */
 fail:
@@ -309,7 +308,7 @@
 int
 gs_state_free_chain(gs_state * pgs)
 {
-   gs_state *saved = pgs, *tmp; 
+   gs_state *saved = pgs, *tmp;
 
    while(saved != 0) {
        tmp = saved->saved;
@@ -949,7 +948,6 @@
 	    goto fail;
     }
     gs_imager_state_copied((gs_imager_state *)pgs);
-    rc_increment(pgs->dev_ht_alt);
     rc_increment(pgs->cie_joint_caches_alt);
     /* Don't do anything to clip_stack. */
     rc_increment(pgs->device);
@@ -986,11 +984,11 @@
 static void
 clip_stack_rc_adjust(gx_clip_stack_t *cs, int delta, client_name_t cname)
 {
-    gx_clip_stack_t *p = cs;  
+    gx_clip_stack_t *p = cs;
 
     while(p) {
         gx_clip_stack_t *q = p;
-        p = p->next;  
+        p = p->next;
         rc_adjust(q, delta, cname);
     }
 }
@@ -1003,7 +1001,6 @@
     gs_memory_t *mem = pgs->memory;
     const char *const cname = "gstate_free_contents";
     int current_col;
-    gx_device_halftone *pdhta = pgs->dev_ht_alt;
 
     rc_decrement(pgs->device, cname);
     clip_stack_rc_adjust(pgs->clip_stack, -1, cname);
@@ -1017,14 +1014,6 @@
     gs_free_object(mem, pgs->line_params.dash.pattern, cname);
     gstate_free_parts(pgs, mem, cname);
     gs_imager_state_release((gs_imager_state *)pgs);
-    /*
-     * If we're going to free the device halftone, make sure we free the
-     * dependent structures as well.
-     */
-    if (pdhta != 0 && pdhta->rc.ref_count == 1) {
-	gx_device_halftone_release(pdhta, pdhta->rc.memory);
-    }
-    rc_decrement(pgs->dev_ht_alt, "gstate_free_contents");
     rc_decrement(pgs->cie_joint_caches_alt, "gstate_free_contents");
 }
 
@@ -1090,7 +1079,6 @@
 
 	gs_imager_state_pre_assign((gs_imager_state *)pto,
 				   (const gs_imager_state *)pfrom);
-	rc_pre_assign(pto->dev_ht_alt, pfrom->dev_ht_alt, "gstate_copy");
 	rc_pre_assign(pto->cie_joint_caches_alt, pfrom->cie_joint_caches_alt, "gstate_copy");
 	*pto = *pfrom;
 	pto->client_data = pdata;
@@ -1131,7 +1119,7 @@
     int                           tmp;
     gx_device_color              *tmp_dc;
     gs_color_space               *tmp_cs;
-    
+
     tmp_cc               = pgs->color[0].ccolor;
     pgs->color[0].ccolor = pgs->color[1].ccolor;
     pgs->color[1].ccolor = tmp_cc;
@@ -1145,14 +1133,10 @@
     pgs->color[1].color_space = tmp_cs;
 
     /* Swap the bits of the imager state that depend on the current color */
-    tmp_ht          = pgs->dev_ht;
-    pgs->dev_ht     = pgs->dev_ht_alt;
-    pgs->dev_ht_alt = tmp_ht;
-    
     tmp_cie                   = pgs->cie_joint_caches;
     pgs->cie_joint_caches     = pgs->cie_joint_caches_alt;
     pgs->cie_joint_caches_alt = tmp_cie;
-    
+
     tmp_ccm                      = pgs->color_component_map;
     pgs->color_component_map     = pgs->color_component_map_alt;
     pgs->color_component_map_alt = tmp_ccm;
@@ -1160,7 +1144,7 @@
     tmp_pc                 = pgs->pattern_cache;
     pgs->pattern_cache     = pgs->pattern_cache_alt;
     pgs->pattern_cache_alt = tmp_pc;
-    
+
     tmp                = pgs->overprint;
     pgs->overprint     = pgs->overprint_alt;
     pgs->overprint_alt = tmp;
@@ -1172,7 +1156,7 @@
     tmp                               = pgs->effective_overprint_mode;
     pgs->effective_overprint_mode     = pgs->effective_overprint_mode_alt;
     pgs->effective_overprint_mode_alt = tmp;
-    
+
 }
 
 int gs_swapcolors(gs_state *pgs)

Modified: trunk/gs/base/gxdcolor.h
===================================================================
--- trunk/gs/base/gxdcolor.h	2010-03-30 10:50:29 UTC (rev 10989)
+++ trunk/gs/base/gxdcolor.h	2010-03-30 14:46:56 UTC (rev 10990)
@@ -309,6 +309,8 @@
 /* Indicate that the device color needs remapping. */
 #define gx_unset_dev_color(pgs)\
   color_unset(gs_currentdevicecolor_inline(pgs))
+#define gx_unset_alt_dev_color(pgs)\
+  color_unset(gs_altdevicecolor_inline(pgs))
 
 /* Load the halftone cache in preparation for drawing. */
 #define gx_color_load_select(pdevc, pis, dev, select)\

Modified: trunk/gs/base/gxistate.h
===================================================================
--- trunk/gs/base/gxistate.h	2010-03-30 10:50:29 UTC (rev 10989)
+++ trunk/gs/base/gxistate.h	2010-03-30 14:46:56 UTC (rev 10990)
@@ -1,6 +1,6 @@
 /* Copyright (C) 2001-2006 Artifex Software, Inc.
    All Rights Reserved.
-  
+
    This software is provided AS-IS with no warranty, either express or
    implied.
 
@@ -168,8 +168,7 @@
 	/* color isn't in force at the moment */\
 	struct gx_cie_joint_caches_s *cie_joint_caches_alt;\
 	gs_devicen_color_map          color_component_map_alt;\
-	struct gx_pattern_cache_s    *pattern_cache_alt;\
-	gx_device_halftone           *dev_ht_alt
+	struct gx_pattern_cache_s    *pattern_cache_alt
 
 /*
  * Enumerate the reference-counted pointers in a c.r. state.  Note that
@@ -184,7 +183,7 @@
   m(set_transfer.blue) m(set_transfer.gray)\
   m(cie_joint_caches)\
   m(devicergb_cs) m(devicecmyk_cs)\
-  m(dev_ht_alt) m(cie_joint_caches)
+  m(cie_joint_caches_alt)
 
 /* Enumerate the pointers in a c.r. state. */
 #define gs_cr_state_do_ptrs(m)\
@@ -194,8 +193,7 @@
   m(7,set_transfer.blue) m(8,set_transfer.gray)\
   m(9,cie_joint_caches) m(10,pattern_cache)\
   m(11,devicergb_cs) m(12,devicecmyk_cs)\
-  m(13,cie_joint_caches_alt) m(14,pattern_cache_alt)\
-  m(15,dev_ht_alt)
+  m(13,cie_joint_caches_alt) m(14,pattern_cache_alt)
   /*
    * We handle effective_transfer specially in gsistate.c since its pointers
    * are not enumerated for garbage collection but they are are relocated.
@@ -204,20 +202,20 @@
  * This count does not include the effective_transfer pointers since they
  * are not enumerated for GC.
  */
-#define st_cr_state_num_ptrs 16
+#define st_cr_state_num_ptrs 15
 
 
 typedef struct gs_devicen_color_map_s {
     bool use_alt_cspace;
     separation_type sep_type;
     uint num_components;	/* Input - Duplicate of value in gs_device_n_params */
-    uint num_colorants;		/* Number of colorants - output */ 
+    uint num_colorants;		/* Number of colorants - output */
     gs_id cspace_id;		/* Used to verify color space and map match */
     int color_map[GS_CLIENT_COLOR_MAX_COMPONENTS];
 } gs_devicen_color_map;
 
 
-/* These flags are used to keep track of qQ 
+/* These flags are used to keep track of qQ
    combinations surrounding a graphic state
    change that includes a softmask setting.
    The transparency compositor must be notified

Modified: trunk/gs/base/gzstate.h
===================================================================
--- trunk/gs/base/gzstate.h	2010-03-30 10:50:29 UTC (rev 10989)
+++ trunk/gs/base/gzstate.h	2010-03-30 14:46:56 UTC (rev 10990)
@@ -110,6 +110,8 @@
     ((pgs)->color[0].ccolor)
 #define gs_currentcolorspace_inline(pgs) \
     ((pgs)->color[0].color_space)
+#define gs_altdevicecolor_inline(pgs) \
+    ((pgs)->color[1].dev_color)
 
     /* Current colors (non-stroking, and stroking) */
     struct {

Modified: trunk/gs/psi/zht.c
===================================================================
--- trunk/gs/psi/zht.c	2010-03-30 10:50:29 UTC (rev 10989)
+++ trunk/gs/psi/zht.c	2010-03-30 14:46:56 UTC (rev 10990)
@@ -1,6 +1,6 @@
 /* Copyright (C) 2001-2006 Artifex Software, Inc.
    All Rights Reserved.
-  
+
    This software is provided AS-IS with no warranty, either express or
    implied.
 
@@ -55,7 +55,7 @@
 	    push(13);
 	    {
 		os_ptr opc = op - 12;
-		gs_screen_halftone *pht = 
+		gs_screen_halftone *pht =
 		    &ht.params.colorscreen.screens.colored.red;
 
 		make_real(opc, pht->frequency);
@@ -121,7 +121,7 @@
 
 /* <frequency> <angle> <proc> setscreen - */
 static int
-zsetscreen_aux(i_ctx_t *i_ctx_p)
+zsetscreen(i_ctx_t *i_ctx_p)
 {
     os_ptr op = osp;
     gs_screen_halftone screen;
@@ -145,23 +145,6 @@
 			     setscreen_finish, space_index);
 }
 
-extern int zswapcolors(i_ctx_t *i_ctx_p);
-
-static int
-zsetscreen(i_ctx_t *i_ctx_p)
-{
-    check_ostack(3);
-    osp++; *osp = osp[-3];
-    osp++; *osp = osp[-3];
-    osp++; *osp = osp[-3];
-    check_estack(4);
-    esp += 4;
-    make_op_estack(esp-3, zsetscreen_aux);
-    make_op_estack(esp-2, zswapcolors);
-    make_op_estack(esp-1, zsetscreen_aux);
-    make_op_estack(esp,   zswapcolors);
-    return o_push_estack;
-}
 /* We break out the body of this operator so it can be shared with */
 /* the code for Type 1 halftones in sethalftone. */
 int
@@ -170,7 +153,7 @@
 		  int (*finish_proc)(i_ctx_t *), int space_index)
 {
     gs_screen_enum *penum;
-    gs_memory_t * mem = (gs_memory_t *)idmemory->spaces_indexed[space_index]; 
+    gs_memory_t * mem = (gs_memory_t *)idmemory->spaces_indexed[space_index];
     int code;
 
     check_estack(snumpush + 1);

Modified: trunk/gs/psi/zht1.c
===================================================================
--- trunk/gs/psi/zht1.c	2010-03-30 10:50:29 UTC (rev 10989)
+++ trunk/gs/psi/zht1.c	2010-03-30 14:46:56 UTC (rev 10990)
@@ -1,6 +1,6 @@
 /* Copyright (C) 2001-2006 Artifex Software, Inc.
    All Rights Reserved.
-  
+
    This software is provided AS-IS with no warranty, either express or
    implied.
 
@@ -39,7 +39,7 @@
 static int setcolorscreen_finish(i_ctx_t *);
 static int setcolorscreen_cleanup(i_ctx_t *);
 static int
-zsetcolorscreen_aux(i_ctx_t *i_ctx_p)
+zsetcolorscreen(i_ctx_t *i_ctx_p)
 {
     os_ptr op = osp;
     gs_colorscreen_halftone cscreen;
@@ -138,33 +138,6 @@
     return 0;
 }
 
-extern int zswapcolors(i_ctx_t *i_ctx_p);
-
-static int
-zsetcolorscreen(i_ctx_t *i_ctx_p)
-{
-    check_ostack(12);
-    osp++; *osp = osp[-12];
-    osp++; *osp = osp[-12];
-    osp++; *osp = osp[-12];
-    osp++; *osp = osp[-12];
-    osp++; *osp = osp[-12];
-    osp++; *osp = osp[-12];
-    osp++; *osp = osp[-12];
-    osp++; *osp = osp[-12];
-    osp++; *osp = osp[-12];
-    osp++; *osp = osp[-12];
-    osp++; *osp = osp[-12];
-    osp++; *osp = osp[-12];
-    check_estack(4);
-    esp += 4;
-    make_op_estack(esp-3, zsetcolorscreen_aux);
-    make_op_estack(esp-2, zswapcolors);
-    make_op_estack(esp-1, zsetcolorscreen_aux);
-    make_op_estack(esp,   zswapcolors);
-    return o_push_estack;
-}
-
 /* ------ Initialization procedure ------ */
 
 const op_def zht1_op_defs[] =



More information about the gs-commits mailing list