/src/ghostpdl/psi/zpaint.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* Copyright (C) 2001-2021 Artifex Software, Inc. |
2 | | All Rights Reserved. |
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 | | Refer to licensing information at http://www.artifex.com or contact |
12 | | Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato, |
13 | | CA 94945, U.S.A., +1(415)492-9861, for further information. |
14 | | */ |
15 | | |
16 | | |
17 | | /* Painting operators */ |
18 | | #include "ghost.h" |
19 | | #include "oper.h" |
20 | | #include "gspaint.h" |
21 | | #include "igstate.h" |
22 | | #include "store.h" |
23 | | #include "estack.h" |
24 | | |
25 | | /* - fill - */ |
26 | | static int |
27 | | zfill(i_ctx_t *i_ctx_p) |
28 | 475k | { |
29 | 475k | return gs_fill(igs); |
30 | 475k | } |
31 | | |
32 | | /* - eofill - */ |
33 | | static int |
34 | | zeofill(i_ctx_t *i_ctx_p) |
35 | 12.0k | { |
36 | 12.0k | return gs_eofill(igs); |
37 | 12.0k | } |
38 | | |
39 | | /* - stroke - */ |
40 | | static int |
41 | | zstroke(i_ctx_t *i_ctx_p) |
42 | 45.6k | { |
43 | 45.6k | return gs_stroke(igs); |
44 | 45.6k | } |
45 | | |
46 | | static int |
47 | | fillstroke_cont(i_ctx_t *i_ctx_p) |
48 | 8 | { |
49 | 8 | os_ptr op = osp; |
50 | 8 | int restart, code; |
51 | | |
52 | 8 | check_type(*op, t_integer); |
53 | 8 | restart = (int)op->value.intval; |
54 | 8 | code = gs_fillstroke(igs, &restart); |
55 | 8 | if (code == gs_error_Remap_Color) { |
56 | 0 | op->value.intval = restart; |
57 | 0 | return code; |
58 | 0 | } |
59 | 8 | pop(1); |
60 | 8 | return code; |
61 | 8 | } |
62 | | |
63 | | static int |
64 | | zfillstroke(i_ctx_t *i_ctx_p) |
65 | 8 | { |
66 | 8 | os_ptr op = osp; |
67 | 8 | push(1); |
68 | 8 | make_int(op, 0); /* 0 implies we are at fill color, need to swap first */ |
69 | 8 | push_op_estack(fillstroke_cont); |
70 | 8 | return o_push_estack; |
71 | 8 | } |
72 | | |
73 | | static int |
74 | | eofillstroke_cont(i_ctx_t *i_ctx_p) |
75 | 21 | { |
76 | 21 | os_ptr op = osp; |
77 | 21 | int restart, code; |
78 | | |
79 | 21 | check_type(*op, t_integer); |
80 | 21 | restart = (int)op->value.intval; |
81 | 21 | code = gs_eofillstroke(igs, &restart); |
82 | 21 | if (code == gs_error_Remap_Color) { |
83 | 0 | op->value.intval = restart; |
84 | 0 | return code; |
85 | 0 | } |
86 | 21 | pop(1); |
87 | 21 | return code; |
88 | 21 | } |
89 | | |
90 | | static int |
91 | | zeofillstroke(i_ctx_t *i_ctx_p) |
92 | 21 | { |
93 | 21 | os_ptr op = osp; |
94 | 21 | push(1); |
95 | 21 | make_int(op, 0); |
96 | 21 | push_op_estack(eofillstroke_cont); |
97 | 21 | return o_push_estack; |
98 | 21 | } |
99 | | |
100 | | /* ------ Non-standard operators ------ */ |
101 | | |
102 | | /* - .fillpage - */ |
103 | | static int |
104 | | zfillpage(i_ctx_t *i_ctx_p) |
105 | 538k | { |
106 | 538k | return gs_fillpage(igs); |
107 | 538k | } |
108 | | |
109 | | /* <width> <height> <data> .imagepath - */ |
110 | | static int |
111 | | zimagepath(i_ctx_t *i_ctx_p) |
112 | 0 | { |
113 | 0 | os_ptr op = osp; |
114 | 0 | int code; |
115 | |
|
116 | 0 | check_type(op[-2], t_integer); |
117 | 0 | check_type(op[-1], t_integer); |
118 | 0 | check_read_type(*op, t_string); |
119 | 0 | if (r_size(op) < ((op[-2].value.intval + 7) >> 3) * op[-1].value.intval) |
120 | 0 | return_error(gs_error_rangecheck); |
121 | 0 | code = gs_imagepath(igs, |
122 | 0 | (int)op[-2].value.intval, (int)op[-1].value.intval, |
123 | 0 | op->value.const_bytes); |
124 | 0 | if (code >= 0) |
125 | 0 | pop(3); |
126 | 0 | return code; |
127 | 0 | } |
128 | | |
129 | | /* ------ Initialization procedure ------ */ |
130 | | |
131 | | const op_def zpaint_op_defs[] = |
132 | | { |
133 | | {"0eofill", zeofill}, |
134 | | {"0fill", zfill}, |
135 | | {"0stroke", zstroke}, |
136 | | /* Non-standard operators */ |
137 | | {"0.fillpage", zfillpage}, |
138 | | {"3.imagepath", zimagepath}, |
139 | | {"0.eofillstroke", zeofillstroke}, |
140 | | {"0.fillstroke", zfillstroke}, |
141 | | {"0%eofillstroke_cont", eofillstroke_cont }, |
142 | | {"0%fillstroke_cont", fillstroke_cont }, |
143 | | op_def_end(0) |
144 | | }; |