Coverage Report

Created: 2025-06-24 07:01

/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
2.32M
{
29
2.32M
    return gs_fill(igs);
30
2.32M
}
31
32
/* - eofill - */
33
static int
34
zeofill(i_ctx_t *i_ctx_p)
35
448k
{
36
448k
    return gs_eofill(igs);
37
448k
}
38
39
/* - stroke - */
40
static int
41
zstroke(i_ctx_t *i_ctx_p)
42
117k
{
43
117k
    return gs_stroke(igs);
44
117k
}
45
46
static int
47
fillstroke_cont(i_ctx_t *i_ctx_p)
48
12
{
49
12
    os_ptr op = osp;
50
12
    int restart, code;
51
52
12
    check_op(1);
53
12
    check_type(*op, t_integer);
54
12
    restart = (int)op->value.intval;
55
12
    code = gs_fillstroke(igs, &restart);
56
12
    if (code == gs_error_Remap_Color) {
57
0
        op->value.intval = restart;
58
0
        return code;
59
0
    }
60
12
    pop(1);
61
12
    return code;
62
12
}
63
64
static int
65
zfillstroke(i_ctx_t *i_ctx_p)
66
12
{
67
12
    os_ptr op = osp;
68
12
    push(1);
69
12
    check_estack(1);
70
12
    make_int(op, 0);    /* 0 implies we are at fill color, need to swap first */
71
12
    push_op_estack(fillstroke_cont);
72
12
    return o_push_estack;
73
12
}
74
75
static int
76
eofillstroke_cont(i_ctx_t *i_ctx_p)
77
65
{
78
65
    os_ptr op = osp;
79
65
    int restart, code;
80
81
65
    check_op(1);
82
65
    check_type(*op, t_integer);
83
65
    restart = (int)op->value.intval;
84
65
    code = gs_eofillstroke(igs, &restart);
85
65
    if (code == gs_error_Remap_Color) {
86
0
        op->value.intval = restart;
87
0
        return code;
88
0
    }
89
65
    pop(1);
90
65
    return code;
91
65
}
92
93
static int
94
zeofillstroke(i_ctx_t *i_ctx_p)
95
65
{
96
65
    os_ptr op = osp;
97
65
    push(1);
98
65
    make_int(op, 0);
99
65
    push_op_estack(eofillstroke_cont);
100
65
    return o_push_estack;
101
65
}
102
103
/* ------ Non-standard operators ------ */
104
105
/* - .fillpage - */
106
static int
107
zfillpage(i_ctx_t *i_ctx_p)
108
1.16M
{
109
1.16M
    return gs_fillpage(igs);
110
1.16M
}
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
};