xref: /plan9/sys/src/cmd/gs/src/gzstate.h (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 1989, 1995, 1996, 1997, 1998, 1999 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: gzstate.h,v 1.10 2004/03/13 18:28:52 igor Exp $ */
18 /* Private graphics state definition for Ghostscript library */
19 
20 #ifndef gzstate_INCLUDED
21 #  define gzstate_INCLUDED
22 
23 #include "gscpm.h"
24 #include "gscspace.h"
25 #include "gsrefct.h"
26 #include "gxdcolor.h"
27 #include "gxistate.h"
28 #include "gsstate.h"
29 #include "gxstate.h"
30 
31 /* Opaque types referenced by the graphics state. */
32 #ifndef gx_path_DEFINED
33 #  define gx_path_DEFINED
34 typedef struct gx_path_s gx_path;
35 #endif
36 #ifndef gx_clip_path_DEFINED
37 #  define gx_clip_path_DEFINED
38 typedef struct gx_clip_path_s gx_clip_path;
39 #endif
40 #ifndef gx_clip_stack_DEFINED
41 #  define gx_clip_stack_DEFINED
42 typedef struct gx_clip_stack_s gx_clip_stack_t;
43 #endif
44 #ifndef gs_color_space_DEFINED
45 #  define gs_color_space_DEFINED
46 typedef struct gs_color_space_s gs_color_space;
47 #endif
48 #ifndef gs_client_color_DEFINED
49 #  define gs_client_color_DEFINED
50 typedef struct gs_client_color_s gs_client_color;
51 #endif
52 #ifndef gs_font_DEFINED
53 #  define gs_font_DEFINED
54 typedef struct gs_font_s gs_font;
55 #endif
56 #ifndef gs_transparency_group_DEFINED
57 #  define gs_transparency_group_DEFINED
58 typedef struct gs_transparency_group_s gs_transparency_group_t;
59 #endif
60 #ifndef gs_device_filter_stack_DEFINED
61 #  define gs_device_filter_stack_DEFINED
62 typedef struct gs_device_filter_stack_s gs_device_filter_stack_t;
63 #endif
64 
65 /* Device filter stack structure is defined here so that gstate
66    lifecycle operations can access reference count; implementation is
67    in gsdfilt.c.
68  */
69 
70 #ifndef gs_device_filter_DEFINED
71 #  define gs_device_filter_DEFINED
72 typedef struct gs_device_filter_s gs_device_filter_t;
73 #endif
74 
75 /* This is the base structure from which device filters are derived. */
76 struct gs_device_filter_stack_s {
77     gs_device_filter_stack_t *next;
78     gs_device_filter_t *df;
79     gx_device *next_device;
80     rc_header rc;
81 };
82 
83 /* Graphics state structure. */
84 
85 struct gs_state_s {
86     gs_imager_state_common;	/* imager state, must be first */
87     gs_state *saved;		/* previous state from gsave */
88 
89     /* Transformation: */
90 
91     gs_matrix ctm_inverse;
92     bool ctm_inverse_valid;	/* true if ctm_inverse = ctm^-1 */
93     gs_matrix ctm_default;
94     bool ctm_default_set;	/* if true, use ctm_default; */
95 				/* if false, ask device */
96     /* Paths: */
97 
98     gx_path *path;
99     gx_clip_path *clip_path;
100     gx_clip_stack_t *clip_stack;  /* (LanguageLevel 3 only) */
101     gx_clip_path *view_clip;	/* (may be 0, or have rule = 0) */
102 
103     /* Effective clip path cache */
104     gs_id effective_clip_id;	/* (key) clip path id */
105     gs_id effective_view_clip_id;	/* (key) view clip path id */
106     gx_clip_path *effective_clip_path;	/* (value) effective clip path, */
107 				/* possibly = clip_path or view_clip */
108     bool effective_clip_shared;	/* true iff e.c.p. = c.p. or v.c. */
109 
110     /* Color (device-independent): */
111 
112     gs_color_space *color_space; /* after substitution */
113     gs_client_color *ccolor;
114 
115     /* Color caches: */
116 
117     gx_device_color *dev_color;
118 
119     /* Font: */
120 
121     gs_font *font;
122     gs_font *root_font;
123     gs_matrix_fixed char_tm;	/* font matrix * ctm */
124 #define char_tm_only(pgs) *(gs_matrix *)&(pgs)->char_tm
125     bool char_tm_valid;		/* true if char_tm is valid */
126     gs_in_cache_device_t in_cachedevice;    /* (see gscpm.h) */
127     gs_char_path_mode in_charpath;	/* (see gscpm.h) */
128     gs_state *show_gstate;	/* gstate when show was invoked */
129 				/* (so charpath can append to path) */
130 
131     /* Other stuff: */
132 
133     int level;			/* incremented by 1 per gsave */
134     gx_device *device;
135 #undef gs_currentdevice_inline
136 #define gs_currentdevice_inline(pgs) ((pgs)->device)
137     gs_device_filter_stack_t *dfilter_stack;
138 
139     gs_transparency_group_t *transparency_group_stack; /* (PDF 1.4 only) */
140 
141     /* Client data: */
142 
143     /*void *client_data;*/	/* in imager state */
144 #define gs_state_client_data(pgs) ((pgs)->client_data)
145     gs_state_client_procs client_procs;
146 };
147 
148 #define public_st_gs_state()	/* in gsstate.c */\
149   gs_public_st_composite(st_gs_state, gs_state, "gs_state",\
150     gs_state_enum_ptrs, gs_state_reloc_ptrs)
151 
152 /*
153  * Enumerate the pointers in a graphics state, other than the ones in the
154  * imager state, and device, which must be handled specially.
155  */
156 #define gs_state_do_ptrs(m)\
157   m(0,saved) m(1,path) m(2,clip_path) m(3,clip_stack)\
158   m(4,view_clip) m(5,effective_clip_path)\
159   m(6,color_space) m(7,ccolor) m(8,dev_color)\
160   m(9,font) m(10,root_font) m(11,show_gstate) /*m(---,device)*/\
161   m(12,transparency_group_stack)
162 #define gs_state_num_ptrs 13
163 
164 /* The following macro is used for development purpose for designating places
165    where current point is changed. Clients must not use it. */
166 #define gx_setcurrentpoint(pgs, xx, yy)\
167     (pgs)->current_point.x = xx;\
168     (pgs)->current_point.y = yy;
169 
170 #endif /* gzstate_INCLUDED */
171