Coverage Report

Created: 2025-11-16 07:40

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