1 /* Copyright (C) 1989, 2000 Aladdin Enterprises. All rights reserved. 2 3 This software is provided AS-IS with no warranty, either express or 4 implied. 5 6 This software is distributed under license and may not be copied, 7 modified or distributed except as expressly authorized under the terms 8 of the license contained in the file LICENSE in this distribution. 9 10 For more information about licensing, please refer to 11 http://www.ghostscript.com/licensing/. For information on 12 commercial licensing, go to http://www.artifex.com/licensing/ or 13 contact Artifex Software, Inc., 101 Lucas Valley Road #110, 14 San Rafael, CA 94903, U.S.A., +1(415)492-9861. 15 */ 16 17 /* $Id: igstate.h,v 1.8 2003/09/03 03:22:59 giles Exp $ */ 18 /* Interpreter graphics state definition */ 19 20 #ifndef igstate_INCLUDED 21 # define igstate_INCLUDED 22 23 #include "gsstate.h" 24 #include "gxstate.h" /* for 'client data' access */ 25 #include "imemory.h" 26 #include "istruct.h" /* for gstate obj definition */ 27 #include "gxcindex.h" 28 29 /* 30 * From the interpreter's point of view, the graphics state is largely opaque, 31 * i.e., the interpreter is just another client of the library. 32 * The interpreter does require additional items in the graphics state; 33 * these are "client data" from the library's point of view. 34 * Most of the complexity in this added state comes from 35 * the parameters associated with the various Level 2 color spaces. 36 * Note that the added information consists entirely of refs. 37 */ 38 39 /* 40 * The interpreter represents graphics state objects in a slightly 41 * unnatural way, namely, by a t_astruct ref that points to an object 42 * of type st_igstate_obj, which is essentially a t_struct ref that in turn 43 * points to a real graphics state (object of type st_gs_state). 44 * We do this so that save and restore can manipulate the intermediate 45 * object and not have to worry about copying entire gs_states. 46 * 47 * Because a number of different operators must test whether an object 48 * is a gstate, we make an exception to our convention of declaring 49 * structure descriptors only in the place where the structure itself 50 * is defined (see gsstruct.h for more information on this). 51 */ 52 typedef struct igstate_obj_s { 53 ref gstate; /* t_struct / st_gs_state */ 54 } igstate_obj; 55 56 extern_st(st_igstate_obj); 57 #define public_st_igstate_obj() /* in zdps1.c */\ 58 gs_public_st_ref_struct(st_igstate_obj, igstate_obj, "gstatetype") 59 #define igstate_ptr(rp) r_ptr(&r_ptr(rp, igstate_obj)->gstate, gs_state) 60 61 /* DeviceN names and tint transform */ 62 typedef struct ref_device_n_params_s { 63 ref layer_names, tint_transform; 64 } ref_device_n_params; 65 66 /* CIE transformation procedures */ 67 typedef struct ref_cie_procs_s { 68 union { 69 ref DEFG; 70 ref DEF; 71 } PreDecode; 72 union { 73 ref ABC; 74 ref A; 75 } Decode; 76 ref DecodeLMN; 77 } ref_cie_procs; 78 79 /* CIE rendering transformation procedures */ 80 typedef struct ref_cie_render_procs_s { 81 ref TransformPQR, EncodeLMN, EncodeABC, RenderTableT; 82 } ref_cie_render_procs; 83 84 /* Separation name and tint transform */ 85 typedef struct ref_separation_params_s { 86 ref layer_name, tint_transform; 87 } ref_separation_params; 88 89 /* All color space parameters. */ 90 /* All of these are optional. */ 91 /* Note that they may actually be the parameters for an underlying or */ 92 /* alternate space for a special space. */ 93 typedef struct ref_color_procs_s { 94 ref_cie_procs cie; 95 union { 96 ref_device_n_params device_n; 97 ref_separation_params separation; 98 ref index_proc; 99 } special; 100 } ref_color_procs; 101 typedef struct ref_colorspace_s { 102 ref array; /* color space (array), only relevant if */ 103 /* the current color space has parameters */ 104 /* associated with it. */ 105 ref_color_procs procs; /* associated procedures/parameters, */ 106 /* only relevant for DeviceN, CIE, */ 107 /* Separation, Indexed/CIE, */ 108 /* Indexed with procedure, or a Pattern */ 109 /* with one of these. */ 110 } ref_colorspace; 111 112 #ifndef int_remap_color_info_DEFINED 113 # define int_remap_color_info_DEFINED 114 typedef struct int_remap_color_info_s int_remap_color_info_t; 115 #endif 116 117 typedef struct int_gstate_s { 118 ref dash_pattern; /* (array) */ 119 /* Screen_procs are only relevant if setscreen was */ 120 /* executed more recently than sethalftone */ 121 /* (for this graphics context). */ 122 struct { 123 ref red, green, blue, gray; 124 } screen_procs, /* halftone screen procedures */ 125 transfer_procs; /* transfer procedures */ 126 ref black_generation; /* (procedure) */ 127 ref undercolor_removal; /* (procedure) */ 128 ref_colorspace colorspace; 129 /* 130 * Pattern is relevant only if the current color space 131 * is a pattern space. 132 */ 133 ref pattern; /* pattern (dictionary) */ 134 struct { 135 ref dict; /* CIE color rendering dictionary */ 136 ref_cie_render_procs procs; /* (see above) */ 137 } colorrendering; 138 /* 139 * Use_cie_color tracks the UseCIEColor parameter of the page 140 * device. This parameter may, during initialization, be read 141 * through the .getuseciecolor operator, and set (in Level 3) 142 * via the .setuseciecolor operator. 143 * 144 * Previously, the UseCIEColor color space substitution feature 145 * was implemented in the graphic library. It is now implemented 146 * strictly in the interpreter. 147 */ 148 ref use_cie_color; 149 /* 150 * Halftone is relevant only if sethalftone was executed 151 * more recently than setscreen for this graphics context. 152 * setscreen sets it to null. 153 */ 154 ref halftone; /* halftone (dictionary) */ 155 /* 156 * Pagedevice is only relevant if setpagedevice was executed more 157 * recently than nulldevice, setcachedevice, or setdevice with a 158 * non-page device (for this graphics context). If the current device 159 * is not a page device, pagedevice is null. 160 */ 161 ref pagedevice; /* page device (dictionary|null) */ 162 /* 163 * Remap_color_info is used temporarily to communicate the need for 164 * Pattern or DeviceNcolor remapping to the interpreter. See 165 * e_RemapColor in ierrors.h. The extra level of indirection through a 166 * structure is needed because the gstate passed to the PaintProc is 167 * different from the current gstate in the graphics state, and because 168 * the DeviceN color being remapped is not necessarily the current color 169 * in the graphics state (for shading or images): the structure is 170 * shared, so that the interpreter can get its hands on the remapping 171 * procedure. 172 */ 173 ref remap_color_info; /* t_struct (int_remap_color_info_t) */ 174 /* 175 * The opacity and shape masks are a PDF 1.4 transparency feature, 176 * not standard PostScript. 177 */ 178 ref opacity_mask, shape_mask; /* dictionary|null */ 179 } int_gstate; 180 181 #define clear_pagedevice(pigs) make_null(&(pigs)->pagedevice) 182 /* 183 * Even though the interpreter's part of the graphics state actually 184 * consists of refs, allocating it as refs tends to create sandbars; 185 * since it is always allocated and freed as a unit, we can treat it 186 * as an ordinary structure. 187 */ 188 #define private_st_int_gstate() /* in zgstate.c */\ 189 gs_private_st_ref_struct(st_int_gstate, int_gstate, "int_gstate") 190 191 /* Enumerate the refs in an int_gstate. */ 192 /* Since all the elements of an int_gstate are refs, this is simple. */ 193 #define int_gstate_map_refs(p,m)\ 194 { register ref *rp_ = (ref *)(p);\ 195 register int i = sizeof(int_gstate) / sizeof(ref);\ 196 do { m(rp_); ++rp_; } while ( --i );\ 197 } 198 199 /* Create the gstate for a new context. */ 200 /* We export this so that fork can use it. */ 201 gs_state *int_gstate_alloc(const gs_dual_memory_t * dmem); 202 203 /* Get the int_gstate from a gs_state. */ 204 #define gs_int_gstate(pgs) ((int_gstate *)gs_state_client_data(pgs)) 205 206 /* The current instances for operators. */ 207 #define igs (i_ctx_p->pgs) 208 #define istate gs_int_gstate(igs) 209 210 #endif /* igstate_INCLUDED */ 211