xref: /plan9/sys/src/cmd/gs/src/zrop.c (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 1995, 1996, 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: zrop.c,v 1.4 2002/02/21 22:24:54 giles Exp $ */
18 /* RasterOp control operators */
19 #include "memory_.h"
20 #include "ghost.h"
21 #include "oper.h"
22 #include "gsrop.h"
23 #include "gsutil.h"
24 #include "gxdevice.h"
25 #include "idict.h"
26 #include "idparam.h"
27 #include "igstate.h"
28 #include "store.h"
29 
30 /* <int8> .setrasterop - */
31 private int
zsetrasterop(i_ctx_t * i_ctx_p)32 zsetrasterop(i_ctx_t *i_ctx_p)
33 {
34     os_ptr op = osp;
35     int param;
36     int code = int_param(op, 0xff, &param);
37 
38     if (code < 0)
39 	return code;
40     gs_setrasterop(igs, (gs_rop3_t)param);
41     pop(1);
42     return 0;
43 }
44 
45 /* - .currentrasterop <int8> */
46 private int
zcurrentrasterop(i_ctx_t * i_ctx_p)47 zcurrentrasterop(i_ctx_t *i_ctx_p)
48 {
49     os_ptr op = osp;
50 
51     push(1);
52     make_int(op, (int)gs_currentrasterop(igs));
53     return 0;
54 }
55 
56 /* <bool> .setsourcetransparent - */
57 private int
zsetsourcetransparent(i_ctx_t * i_ctx_p)58 zsetsourcetransparent(i_ctx_t *i_ctx_p)
59 {
60     os_ptr op = osp;
61 
62     check_type(*op, t_boolean);
63     gs_setsourcetransparent(igs, op->value.boolval);
64     pop(1);
65     return 0;
66 }
67 
68 /* - .currentsourcetransparent <bool> */
69 private int
zcurrentsourcetransparent(i_ctx_t * i_ctx_p)70 zcurrentsourcetransparent(i_ctx_t *i_ctx_p)
71 {
72     os_ptr op = osp;
73 
74     push(1);
75     make_bool(op, gs_currentsourcetransparent(igs));
76     return 0;
77 }
78 
79 /* <bool> .settexturetransparent - */
80 private int
zsettexturetransparent(i_ctx_t * i_ctx_p)81 zsettexturetransparent(i_ctx_t *i_ctx_p)
82 {
83     os_ptr op = osp;
84 
85     check_type(*op, t_boolean);
86     gs_settexturetransparent(igs, op->value.boolval);
87     pop(1);
88     return 0;
89 }
90 
91 /* - .currenttexturetransparent <bool> */
92 private int
zcurrenttexturetransparent(i_ctx_t * i_ctx_p)93 zcurrenttexturetransparent(i_ctx_t *i_ctx_p)
94 {
95     os_ptr op = osp;
96 
97     push(1);
98     make_bool(op, gs_currenttexturetransparent(igs));
99     return 0;
100 }
101 
102 /* ------ Initialization procedure ------ */
103 
104 const op_def zrop_op_defs[] =
105 {
106     {"0.currentrasterop", zcurrentrasterop},
107     {"0.currentsourcetransparent", zcurrentsourcetransparent},
108     {"0.currenttexturetransparent", zcurrenttexturetransparent},
109     {"1.setrasterop", zsetrasterop},
110     {"1.setsourcetransparent", zsetsourcetransparent},
111     {"1.settexturetransparent", zsettexturetransparent},
112     op_def_end(0)
113 };
114