Coverage Report

Created: 2025-06-10 07:19

/src/ghostpdl/psi/zpaint.c
Line
Count
Source (jump to first uncovered line)
1
/* Copyright (C) 2001-2023 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.,  39 Mesa Street, Suite 108A, San Francisco,
13
   CA 94129, USA, 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
299k
{
29
299k
    return gs_fill(igs);
30
299k
}
31
32
/* - eofill - */
33
static int
34
zeofill(i_ctx_t *i_ctx_p)
35
52.0k
{
36
52.0k
    return gs_eofill(igs);
37
52.0k
}
38
39
/* - stroke - */
40
static int
41
zstroke(i_ctx_t *i_ctx_p)
42
13.7k
{
43
13.7k
    return gs_stroke(igs);
44
13.7k
}
45
46
static int
47
fillstroke_cont(i_ctx_t *i_ctx_p)
48
1
{
49
1
    os_ptr op = osp;
50
1
    int restart, code;
51
52
1
    check_op(1);
53
1
    check_type(*op, t_integer);
54
1
    restart = (int)op->value.intval;
55
1
    code = gs_fillstroke(igs, &restart);
56
1
    if (code == gs_error_Remap_Color) {
57
0
        op->value.intval = restart;
58
0
        return code;
59
0
    }
60
1
    pop(1);
61
1
    return code;
62
1
}
63
64
static int
65
zfillstroke(i_ctx_t *i_ctx_p)
66
1
{
67
1
    os_ptr op = osp;
68
1
    push(1);
69
1
    check_estack(1);
70
1
    make_int(op, 0);    /* 0 implies we are at fill color, need to swap first */
71
1
    push_op_estack(fillstroke_cont);
72
1
    return o_push_estack;
73
1
}
74
75
static int
76
eofillstroke_cont(i_ctx_t *i_ctx_p)
77
2
{
78
2
    os_ptr op = osp;
79
2
    int restart, code;
80
81
2
    check_op(1);
82
2
    check_type(*op, t_integer);
83
2
    restart = (int)op->value.intval;
84
2
    code = gs_eofillstroke(igs, &restart);
85
2
    if (code == gs_error_Remap_Color) {
86
0
        op->value.intval = restart;
87
0
        return code;
88
0
    }
89
2
    pop(1);
90
2
    return code;
91
2
}
92
93
static int
94
zeofillstroke(i_ctx_t *i_ctx_p)
95
2
{
96
2
    os_ptr op = osp;
97
2
    push(1);
98
2
    make_int(op, 0);
99
2
    push_op_estack(eofillstroke_cont);
100
2
    return o_push_estack;
101
2
}
102
103
/* ------ Non-standard operators ------ */
104
105
/* - .fillpage - */
106
static int
107
zfillpage(i_ctx_t *i_ctx_p)
108
67.5k
{
109
67.5k
    return gs_fillpage(igs);
110
67.5k
}
111
112
/* <width> <height> <data> .imagepath - */
113
static int
114
zimagepath(i_ctx_t *i_ctx_p)
115
0
{
116
0
    os_ptr op = osp;
117
0
    int code;
118
119
0
    check_op(3);
120
0
    check_type(op[-2], t_integer);
121
0
    check_type(op[-1], t_integer);
122
0
    check_read_type(*op, t_string);
123
0
    if (r_size(op) < ((op[-2].value.intval + 7) >> 3) * op[-1].value.intval)
124
0
        return_error(gs_error_rangecheck);
125
0
    code = gs_imagepath(igs,
126
0
                        (int)op[-2].value.intval, (int)op[-1].value.intval,
127
0
                        op->value.const_bytes);
128
0
    if (code >= 0)
129
0
        pop(3);
130
0
    return code;
131
0
}
132
133
/* ------ Initialization procedure ------ */
134
135
const op_def zpaint_op_defs[] =
136
{
137
    {"0eofill", zeofill},
138
    {"0fill", zfill},
139
    {"0stroke", zstroke},
140
                /* Non-standard operators */
141
    {"0.fillpage", zfillpage},
142
    {"3.imagepath", zimagepath},
143
    {"0.eofillstroke", zeofillstroke},
144
    {"0.fillstroke", zfillstroke},
145
    {"0%eofillstroke_cont", eofillstroke_cont },
146
    {"0%fillstroke_cont", fillstroke_cont },
147
    op_def_end(0)
148
};