Coverage Report

Created: 2025-06-10 06:49

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