xref: /plan9/sys/src/cmd/gs/src/gsdfilt.h (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /*
2   Copyright (C) 2001 artofcode LLC.
3 
4   This software is provided AS-IS with no warranty, either express or
5   implied.
6 
7   This software is distributed under license and may not be copied,
8   modified or distributed except as expressly authorized under the terms
9   of the license contained in the file LICENSE in this distribution.
10 
11   For more information about licensing, please refer to
12   http://www.ghostscript.com/licensing/. For information on
13   commercial licensing, go to http://www.artifex.com/licensing/ or
14   contact Artifex Software, Inc., 101 Lucas Valley Road #110,
15   San Rafael, CA  94903, U.S.A., +1(415)492-9861.
16 
17   Author: Raph Levien <raph@artofcode.com>
18 */
19 /* $Id: gsdfilt.h,v 1.9 2003/08/15 22:32:02 raph Exp $ */
20 
21 #ifndef gsdfilt_INCLUDED
22 #  define gsdfilt_INCLUDED
23 
24 /* The device filter stack lives in the gs_state structure. It represents
25    a chained sequence of devices that filter device requests, each forwarding
26    to its target. The last such target is the physical device as set by
27    setpagedevice.
28 
29    There is a "shadow" gs_device_filter_stack_s object for each device in
30    the chain. The stack management uses these objects to keep track of the
31    chain.
32 */
33 
34 #ifndef gs_device_filter_stack_DEFINED
35 #  define gs_device_filter_stack_DEFINED
36 typedef struct gs_device_filter_stack_s gs_device_filter_stack_t;
37 #endif
38 
39 #ifndef gs_device_filter_DEFINED
40 #  define gs_device_filter_DEFINED
41 typedef struct gs_device_filter_s gs_device_filter_t;
42 #endif
43 
44 struct gs_device_filter_s {
45     int (*push)(gs_device_filter_t *self, gs_memory_t *mem, gs_state *pgs,
46 		gx_device **pdev, gx_device *target);
47     int (*prepop)(gs_device_filter_t *self, gs_memory_t *mem, gs_state *pgs,
48 		  gx_device *dev);
49     int (*postpop)(gs_device_filter_t *self, gs_memory_t *mem, gs_state *pgs,
50 		   gx_device *dev);
51 };
52 
53 extern_st(st_gs_device_filter);
54 
55 /**
56  * gs_push_device_filter: Push a device filter.
57  * @mem: Memory for creating device filter.
58  * @pgs: Graphics state.
59  * @df: The device filter.
60  *
61  * Pushes a device filter, thereby becoming the first in the chain.
62  *
63  * Return value: 0 on success, or error code.
64  **/
65 int gs_push_device_filter(gs_memory_t *mem, gs_state *pgs, gs_device_filter_t *df);
66 
67 /**
68  * gs_pop_device_filter: Pop a device filter.
69  * @mem: Memory in which device filter was created, for freeing.
70  * @pgs: Graphics state.
71  *
72  * Removes the topmost device filter (ie, first filter in the chain)
73  * from the graphics state's device filter stack.
74  *
75  * Return value: 0 on success, or error code.
76  **/
77 int gs_pop_device_filter(gs_memory_t *mem, gs_state *pgs);
78 
79 /**
80  * gs_clear_device_filters: Clear device filters from a graphics state.
81  * @mem: Memory in which device filters were created, for freeing.
82  * @pgs: Graphics state.
83  *
84  * Clears all device filters from the given graphics state.
85  *
86  * Return value: 0 on success, or error code.
87  **/
88 int gs_clear_device_filters(gs_memory_t *mem, gs_state *pgs);
89 
90 
91 #endif /* gsdfilt_INCLUDED */
92