Coverage Report

Created: 2025-06-10 07:24

/src/ghostpdl/base/gxpaint.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
/* Graphics-state-aware fill and stroke procedures */
18
#include "gx.h"
19
#include "gzstate.h"
20
#include "gxdevice.h"
21
#include "gxhttile.h"
22
#include "gxpaint.h"
23
#include "gxpath.h"
24
#include "gxfont.h"
25
26
static bool caching_an_outline_font(const gs_gstate * pgs)
27
477k
{
28
477k
    return pgs->in_cachedevice > 1 &&
29
477k
            pgs->font != NULL &&
30
477k
            pgs->font->FontType != ft_user_defined &&
31
477k
            pgs->font->FontType != ft_PDF_user_defined &&
32
477k
            pgs->font->FontType != ft_PCL_user_defined &&
33
477k
            pgs->font->FontType != ft_GL2_stick_user_defined &&
34
477k
            pgs->font->FontType != ft_CID_user_defined;
35
477k
}
36
37
/* Fill a path. */
38
int
39
gx_fill_path(gx_path * ppath, gx_device_color * pdevc, gs_gstate * pgs,
40
             int rule, fixed adjust_x, fixed adjust_y)
41
200k
{
42
200k
    gx_device *dev = gs_currentdevice_inline(pgs);
43
200k
    gx_clip_path *pcpath;
44
200k
    int code = gx_effective_clip_path(pgs, &pcpath);
45
200k
    gx_fill_params params;
46
47
200k
    if (code < 0)
48
0
        return code;
49
200k
    params.rule = rule;
50
200k
    params.adjust.x = adjust_x;
51
200k
    params.adjust.y = adjust_y;
52
200k
    params.flatness = (caching_an_outline_font(pgs) ? 0.0 : pgs->flatness);
53
200k
    return (*dev_proc(dev, fill_path))
54
200k
        (dev, (const gs_gstate *)pgs, ppath, &params, pdevc, pcpath);
55
200k
}
56
57
/* Stroke a path for drawing or saving. */
58
int
59
gx_stroke_fill(gx_path * ppath, gs_gstate * pgs)
60
268k
{
61
268k
    gx_device *dev = gs_currentdevice_inline(pgs);
62
268k
    gx_clip_path *pcpath;
63
268k
    int code = gx_effective_clip_path(pgs, &pcpath);
64
268k
    gx_stroke_params params;
65
66
268k
    if (code < 0)
67
0
        return code;
68
268k
    params.flatness = (caching_an_outline_font(pgs) ? 0.0 : pgs->flatness);
69
268k
    params.traditional = false;
70
71
268k
    code = (*dev_proc(dev, stroke_path))
72
268k
        (dev, (const gs_gstate *)pgs, ppath, &params,
73
268k
         gs_currentdevicecolor_inline(pgs), pcpath);
74
75
268k
    if (pgs->black_textvec_state) {
76
0
        gsicc_restore_blacktextvec(pgs, true);
77
0
    }
78
79
268k
    return code;
80
268k
}
81
82
int
83
gx_fill_stroke_path(gs_gstate * pgs, int rule)
84
4.26k
{
85
4.26k
    gx_device *dev = gs_currentdevice_inline(pgs);
86
4.26k
    gx_clip_path *pcpath;
87
4.26k
    int code = gx_effective_clip_path(pgs, &pcpath);
88
4.26k
    gx_stroke_params stroke_params;
89
4.26k
    gx_fill_params fill_params;
90
91
4.26k
    if (code < 0)
92
0
        return code;
93
4.26k
    fill_params.rule = rule;
94
4.26k
    fill_params.adjust.x = pgs->fill_adjust.x;
95
4.26k
    fill_params.adjust.y = pgs->fill_adjust.y;
96
4.26k
    fill_params.flatness = (caching_an_outline_font(pgs) ? 0.0 : pgs->flatness);
97
4.26k
    stroke_params.flatness = (caching_an_outline_font(pgs) ? 0.0 : pgs->flatness);
98
4.26k
    stroke_params.traditional = false;
99
100
4.26k
    code = (*dev_proc(dev, fill_stroke_path))
101
4.26k
        (dev, (const gs_gstate *)pgs, pgs->path,
102
4.26k
         &fill_params, gs_currentdevicecolor_inline(pgs),
103
4.26k
         &stroke_params, gs_swappeddevicecolor_inline(pgs),
104
4.26k
         pcpath);
105
106
4.26k
    if (pgs->black_textvec_state) {
107
0
        gsicc_restore_blacktextvec(pgs, true);
108
0
    }
109
110
4.26k
    return code;
111
4.26k
}
112
113
int
114
gx_stroke_add(gx_path * ppath, gx_path * to_path,
115
              const gs_gstate * pgs, bool traditional)
116
226
{
117
226
    gx_stroke_params params;
118
119
226
    params.flatness = (caching_an_outline_font(pgs) ? 0.0 : pgs->flatness);
120
226
    params.traditional = traditional;
121
226
    return gx_stroke_path_only(ppath, to_path, pgs->device,
122
226
                               (const gs_gstate *)pgs,
123
226
                               &params, NULL, NULL);
124
226
}
125
126
int
127
gx_gstate_stroke_add(gx_path *ppath, gx_path *to_path,
128
                     gx_device *dev, const gs_gstate *pgs)
129
0
{
130
0
    gx_stroke_params params;
131
132
0
    params.flatness = pgs->flatness;
133
0
    params.traditional = false;
134
0
    return gx_stroke_path_only(ppath, to_path, dev, pgs,
135
0
                               &params, NULL, NULL);
136
0
}