Coverage Report

Created: 2025-06-24 07:01

/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
15.7M
{
28
15.7M
    return pgs->in_cachedevice > 1 &&
29
15.7M
            pgs->font != NULL &&
30
15.7M
            pgs->font->FontType != ft_user_defined &&
31
15.7M
            pgs->font->FontType != ft_PDF_user_defined &&
32
15.7M
            pgs->font->FontType != ft_PCL_user_defined &&
33
15.7M
            pgs->font->FontType != ft_GL2_stick_user_defined &&
34
15.7M
            pgs->font->FontType != ft_CID_user_defined;
35
15.7M
}
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
11.8M
{
42
11.8M
    gx_device *dev = gs_currentdevice_inline(pgs);
43
11.8M
    gx_clip_path *pcpath;
44
11.8M
    int code = gx_effective_clip_path(pgs, &pcpath);
45
11.8M
    gx_fill_params params;
46
47
11.8M
    if (code < 0)
48
0
        return code;
49
11.8M
    params.rule = rule;
50
11.8M
    params.adjust.x = adjust_x;
51
11.8M
    params.adjust.y = adjust_y;
52
11.8M
    params.flatness = (caching_an_outline_font(pgs) ? 0.0 : pgs->flatness);
53
11.8M
    return (*dev_proc(dev, fill_path))
54
11.8M
        (dev, (const gs_gstate *)pgs, ppath, &params, pdevc, pcpath);
55
11.8M
}
56
57
/* Stroke a path for drawing or saving. */
58
int
59
gx_stroke_fill(gx_path * ppath, gs_gstate * pgs)
60
3.74M
{
61
3.74M
    gx_device *dev = gs_currentdevice_inline(pgs);
62
3.74M
    gx_clip_path *pcpath;
63
3.74M
    int code = gx_effective_clip_path(pgs, &pcpath);
64
3.74M
    gx_stroke_params params;
65
66
3.74M
    if (code < 0)
67
0
        return code;
68
3.74M
    params.flatness = (caching_an_outline_font(pgs) ? 0.0 : pgs->flatness);
69
3.74M
    params.traditional = false;
70
71
3.74M
    code = (*dev_proc(dev, stroke_path))
72
3.74M
        (dev, (const gs_gstate *)pgs, ppath, &params,
73
3.74M
         gs_currentdevicecolor_inline(pgs), pcpath);
74
75
3.74M
    if (pgs->black_textvec_state) {
76
0
        gsicc_restore_blacktextvec(pgs, true);
77
0
    }
78
79
3.74M
    return code;
80
3.74M
}
81
82
int
83
gx_fill_stroke_path(gs_gstate * pgs, int rule)
84
69.3k
{
85
69.3k
    gx_device *dev = gs_currentdevice_inline(pgs);
86
69.3k
    gx_clip_path *pcpath;
87
69.3k
    int code = gx_effective_clip_path(pgs, &pcpath);
88
69.3k
    gx_stroke_params stroke_params;
89
69.3k
    gx_fill_params fill_params;
90
91
69.3k
    if (code < 0)
92
0
        return code;
93
69.3k
    fill_params.rule = rule;
94
69.3k
    fill_params.adjust.x = pgs->fill_adjust.x;
95
69.3k
    fill_params.adjust.y = pgs->fill_adjust.y;
96
69.3k
    fill_params.flatness = (caching_an_outline_font(pgs) ? 0.0 : pgs->flatness);
97
69.3k
    stroke_params.flatness = (caching_an_outline_font(pgs) ? 0.0 : pgs->flatness);
98
69.3k
    stroke_params.traditional = false;
99
100
69.3k
    code = (*dev_proc(dev, fill_stroke_path))
101
69.3k
        (dev, (const gs_gstate *)pgs, pgs->path,
102
69.3k
         &fill_params, gs_currentdevicecolor_inline(pgs),
103
69.3k
         &stroke_params, gs_swappeddevicecolor_inline(pgs),
104
69.3k
         pcpath);
105
106
69.3k
    if (pgs->black_textvec_state) {
107
0
        gsicc_restore_blacktextvec(pgs, true);
108
0
    }
109
110
69.3k
    return code;
111
69.3k
}
112
113
int
114
gx_stroke_add(gx_path * ppath, gx_path * to_path,
115
              const gs_gstate * pgs, bool traditional)
116
1.87k
{
117
1.87k
    gx_stroke_params params;
118
119
1.87k
    params.flatness = (caching_an_outline_font(pgs) ? 0.0 : pgs->flatness);
120
1.87k
    params.traditional = traditional;
121
1.87k
    return gx_stroke_path_only(ppath, to_path, pgs->device,
122
1.87k
                               (const gs_gstate *)pgs,
123
1.87k
                               &params, NULL, NULL);
124
1.87k
}
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
}