xref: /plan9/sys/src/cmd/gs/src/gxstate.h (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 1996 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: gxstate.h,v 1.11 2004/08/31 13:23:16 igor Exp $ */
18 /* Internal graphics state API */
19 
20 #ifndef gxstate_INCLUDED
21 #  define gxstate_INCLUDED
22 
23 /* Opaque type for a graphics state */
24 #ifndef gs_state_DEFINED
25 #  define gs_state_DEFINED
26 typedef struct gs_state_s gs_state;
27 
28 #endif
29 #include "gscspace.h"
30 
31 
32 /*
33  * The interfaces in this file are for internal use only, primarily by the
34  * interpreter.  They are not guaranteed to remain stable from one release
35  * to another.
36  */
37 
38 /* Memory and save/restore management */
39 gs_memory_t *gs_state_memory(const gs_state *);
40 gs_state *gs_state_saved(const gs_state *);
41 gs_state *gs_state_swap_saved(gs_state *, gs_state *);
42 gs_memory_t *gs_state_swap_memory(gs_state *, gs_memory_t *);
43 
44 /*
45  * "Client data" interface for graphics states.
46  *
47  * As of release 4.36, the copy procedure is superseded by copy_for
48  * (although it will still be called if there is no copy_for procedure).
49  */
50 typedef void *(*gs_state_alloc_proc_t) (gs_memory_t * mem);
51 typedef int (*gs_state_copy_proc_t) (void *to, const void *from);
52 typedef void (*gs_state_free_proc_t) (void *old, gs_memory_t * mem);
53 
54 typedef enum {
55     copy_for_gsave,		/* from = current, to = new(saved) */
56     copy_for_grestore,		/* from = saved, to = current */
57     copy_for_gstate,		/* from = current, to = new(copy) */
58     copy_for_setgstate,		/* from = stored, to = current */
59     copy_for_copygstate,	/* from & to are specified explicitly */
60     copy_for_currentgstate	/* from = current, to = stored */
61 } gs_state_copy_reason_t;
62 
63 /* Note that the 'from' argument of copy_for is not const. */
64 /* This is deliberate -- some clients need this. */
65 typedef int (*gs_state_copy_for_proc_t) (void *to, void *from,
66 					 gs_state_copy_reason_t reason);
67 typedef struct gs_state_client_procs_s {
68     gs_state_alloc_proc_t alloc;
69     gs_state_copy_proc_t copy;
70     gs_state_free_proc_t free;
71     gs_state_copy_for_proc_t copy_for;
72 } gs_state_client_procs;
73 void gs_state_set_client(gs_state *, void *, const gs_state_client_procs *,
74 			    bool client_has_pattern_streams);
75 
76 /* gzstate.h redefines the following: */
77 #ifndef gs_state_client_data
78 void *gs_state_client_data(const gs_state *);
79 #endif
80 
81 /* Accessories. */
82 gs_id gx_get_clip_path_id(gs_state *);
83 
84 #endif /* gxstate_INCLUDED */
85