Coverage Report

Created: 2026-07-24 07:44

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ghostpdl/base/gxdda.h
Line
Count
Source
1
/* Copyright (C) 2001-2026 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
/* Definitions for DDAs */
18
/* Requires gxfixed.h */
19
20
#ifndef gxdda_INCLUDED
21
#  define gxdda_INCLUDED
22
23
#include "stdpre.h"
24
#include "stdint_.h"
25
#include "gxfixed.h"
26
27
/* We use the familiar Bresenham DDA algorithm for several purposes:
28
 *      - tracking the edges when filling trapezoids;
29
 *      - tracking the current pixel corner coordinates when rasterizing
30
 *      skewed or rotated images;
31
 *      - converting curves to sequences of lines (this is a 3rd-order
32
 *      DDA, the others are 1st-order);
33
 *      - perhaps someday for drawing single-pixel lines.
34
 * In the case of trapezoids, lines, and curves, we need to use
35
 * the DDA to find the integer X values at integer+0.5 values of Y;
36
 * in the case of images, we use DDAs to compute the (fixed)
37
 * X and Y values at (integer) source pixel corners.
38
 *
39
 * The purpose of the DDA is to compute the exact values Q(i) = floor(i*D/N)
40
 * for increasing integers i, 0 <= i <= N.  D is considered to be an
41
 * integer, although it may actually be a fixed.
42
 *
43
 * In the original formulation of the algorithm, we maintained i*D/N as
44
 * Q + (N-R)/N where Q and R are integers, where 0 < R <= N, with the
45
 * following auxiliary values:
46
 *      dQ = floor(D/N)
47
 *      dR = D mod N (0 <= dR < N)
48
 *      NdR = N - dR
49
 * And at each iteration the code did:
50
 *      Q += dQ;
51
 *      if ( R > dR ) R -= dR; else ++Q, R += NdR;
52
 *
53
 * In the new formulation here, we hold i*D/N as Q + (N-1-R)/N where Q and R
54
 * are integers, 0 <= R < N.
55
 *      Q += dQ;
56
 *      R -= dR
57
 *      if ( R < 0) R += N, ++Q;
58
 * These formulas work regardless of the sign of D, and never let R go
59
 * out of range.
60
 *
61
 * Why is the new formulation better? Well, it's simpler for one thing - the
62
 * values stored in the structure are the obvious ones, without the strange
63
 * NdR one. Also, in the original we test R > dR, which takes as long as
64
 * doing R-=dR in the first place; in the new code we test R against 0, which
65
 * we get for free on most architectures.
66
 *
67
 * In architectures that use branches for alternation, the first (should)
68
 * compiles to something like (excuse the pseudo code):
69
 *
70
 *   Q += dQ
71
 *   if (R > dR)
72
 *      goto A
73
 *   R -= dR
74
 *   goto B
75
 * A:
76
 *   Q += 1
77
 *   R += NdR
78
 * B:
79
 *
80
 * So 7 'instructions', 5 on each possible route through the code, including
81
 * 1 branch regardless of the values.
82
 *
83
 * In the new form, it compiles to:
84
 *
85
 *   R -= dR
86
 *   if (R >= 0)     <- this instruction for free due to preceeding one
87
 *       goto A:
88
 *   R += N
89
 *   Q++
90
 * A:
91
 *   Q += dQ
92
 *
93
 * So 5 'instructions', 3 on the no step case, 5 on the step case, including
94
 * 1 branch on the no-step case.
95
 *
96
 * If the compiler is smart enough to use the carry flag, it becomes:
97
 *
98
 *   R -= dR
99
 *   if (R >= 0)     <- this instruction for free due to preceeding one
100
 *       goto A:
101
 *   R += N
102
 * A:
103
 *   Q += dQ + C     <- Add with carry
104
 *
105
 * 4 instructions total, 3 on the no step case, 4 on the step case, including
106
 * 1 branch on the no-step case.
107
 *
108
 * This is an even better win on architectures (like ARM) where alternation
109
 * can be done without branches; the original gives:
110
 *
111
 *   ADD   Q, Q, dQ
112
 *   CMP   R, dR
113
 *   SUBGT R, R, dR
114
 *   ADDLE Q, Q, #1
115
 *   ADDLE R, R, nDR
116
 *
117
 * (assuming all values in registers) and the new formulation becomes:
118
 *
119
 *   SUBS  R, R, dR
120
 *   ADDLT R, R, N
121
 *   ADDLT Q, Q, #1
122
 *   ADD   Q, Q, dQ
123
 *
124
 * If the compiler is smart enough to use the carry flag, we can do even
125
 * better:
126
 *
127
 *   SUBS  R, R, dR
128
 *   ADDLT R, R, N
129
 *   ADC   Q, Q, dQ
130
 *
131
 * (Actually looking at the compilation given by MSVC 2005 confirms a 1
132
 * instruction (and one branch) win for the above results. Sadly compilers
133
 * don't look to be smart enough to exploit carry flag tricks.)
134
 */
135
136
/* In the following structure definitions, ntype must be an unsigned type. */
137
#define dda_state_struct(sname, dtype, ntype)\
138
  struct sname { dtype Q; ntype R; }
139
#define dda_step_struct(sname, dtype, ntype)\
140
  struct sname { dtype dQ; ntype dR, N; }
141
142
/* DDA with int Q and uint N */
143
typedef struct gx_dda_int_s {
144
    dda_state_struct(ia_, int, uint) state;
145
    dda_step_struct(ie_, int, uint) step;
146
} gx_dda_int_t;
147
148
/* DDA with fixed Q and (unsigned) integer N */
149
typedef
150
dda_state_struct(_a, fixed, uint) gx_dda_state_fixed;
151
     typedef dda_step_struct(_e, fixed, uint) gx_dda_step_fixed;
152
     typedef struct gx_dda_fixed_s {
153
         gx_dda_state_fixed state;
154
         gx_dda_step_fixed step;
155
     } gx_dda_fixed;
156
/*
157
 * Define a pair of DDAs for iterating along an arbitrary line.
158
 */
159
     typedef struct gx_dda_fixed_point_s {
160
         gx_dda_fixed x, y;
161
     } gx_dda_fixed_point;
162
/*
163
 * Initialize a DDA.  The sign test is needed only because C doesn't
164
 * provide reliable definitions of / and % for integers (!!!).
165
 */
166
#define dda_init_state(dstate, init, N_)\
167
8.36M
  (dstate).Q = (init), (dstate).R = ((N_)-1)
168
#define dda_init_step(dstep, D, N_)\
169
8.36M
  do {\
170
8.36M
    if ( (N_) == 0 )\
171
8.36M
      (dstep).dQ = 0, (dstep).dR = 0;\
172
8.36M
    else if ( (D) < 0 )\
173
8.32M
     { (dstep).dQ = -(int)((uint)-(D) / (N_));\
174
1.10M
       if ( ((dstep).dR = -(D) % (N_)) != 0 )\
175
1.10M
         --(dstep).dQ, (dstep).dR = (N_) - (dstep).dR;\
176
1.10M
     }\
177
8.32M
    else\
178
8.32M
     { (dstep).dQ = (D) / (N_); (dstep).dR = (D) % (N_); }\
179
8.36M
    (dstep).N = (N_);\
180
8.36M
  } while (0)
181
#define dda_init(dda, init, D, N)\
182
8.36M
  do {\
183
8.36M
    dda_init_state((dda).state, init, N);\
184
8.36M
    dda_init_step((dda).step, D, N);\
185
8.36M
  } while (0)
186
187
static inline
188
int dda_will_overflow(gx_dda_fixed dda)
189
7.03M
{
190
    /* Every step, R decrements by dR. If it becomes negative, we add 1 to Q, and add N to R. */
191
    /* So on average we add (N-dR)/N to Q each step. So in N steps we add (N-dR) to Q. */
192
7.03M
    int64_t delta;
193
7.03M
    int res;
194
195
    /* The values we're checking should fit in 32 bit values, hence using
196
       check_int_multiply() - the int64_t variables allow us leeway for the
197
       additions/subtractions.
198
     */
199
7.03M
    if (check_int_multiply(dda.step.dQ, dda.step.N, &res) < 0)
200
895
        return 1;
201
202
7.03M
    delta = (int64_t)res + dda.step.N - dda.step.dR;
203
204
7.03M
    if (delta > 0 && delta + dda.state.Q > max_int)
205
457
            return 1;
206
7.03M
    if (delta < 0 && delta + dda.state.Q < min_int)
207
80
            return 1;
208
7.03M
    return 0;
209
7.03M
}
Unexecuted instantiation: imain.c:dda_will_overflow
Unexecuted instantiation: gconfig.c:dda_will_overflow
Unexecuted instantiation: gximage3.c:dda_will_overflow
Unexecuted instantiation: gximage4.c:dda_will_overflow
Unexecuted instantiation: gxmclip.c:dda_will_overflow
Unexecuted instantiation: gsptype1.c:dda_will_overflow
Unexecuted instantiation: gxp1fill.c:dda_will_overflow
Unexecuted instantiation: gxpcmap.c:dda_will_overflow
Unexecuted instantiation: gxicolor.c:dda_will_overflow
Unexecuted instantiation: gsdps1.c:dda_will_overflow
Unexecuted instantiation: gsciemap.c:dda_will_overflow
Unexecuted instantiation: gstrans.c:dda_will_overflow
Unexecuted instantiation: gximag3x.c:dda_will_overflow
Unexecuted instantiation: gxblend.c:dda_will_overflow
Unexecuted instantiation: gdevp14.c:dda_will_overflow
Unexecuted instantiation: gdevdevn.c:dda_will_overflow
Unexecuted instantiation: gsequivc.c:dda_will_overflow
Unexecuted instantiation: gdevdcrd.c:dda_will_overflow
Unexecuted instantiation: gscpixel.c:dda_will_overflow
Unexecuted instantiation: gdevbbox.c:dda_will_overflow
Unexecuted instantiation: gdevprn.c:dda_will_overflow
Unexecuted instantiation: gdevppla.c:dda_will_overflow
Unexecuted instantiation: gdevflp.c:dda_will_overflow
Unexecuted instantiation: gdevoflt.c:dda_will_overflow
Unexecuted instantiation: gdevnup.c:dda_will_overflow
Unexecuted instantiation: gdevsclass.c:dda_will_overflow
Unexecuted instantiation: gxclist.c:dda_will_overflow
Unexecuted instantiation: gxclpage.c:dda_will_overflow
Unexecuted instantiation: gxclread.c:dda_will_overflow
Unexecuted instantiation: gxclrect.c:dda_will_overflow
Unexecuted instantiation: gxclutil.c:dda_will_overflow
Unexecuted instantiation: gxclimag.c:dda_will_overflow
Unexecuted instantiation: gxclpath.c:dda_will_overflow
Unexecuted instantiation: gxdhtserial.c:dda_will_overflow
Unexecuted instantiation: gxclthrd.c:dda_will_overflow
Unexecuted instantiation: gsicc.c:dda_will_overflow
Unexecuted instantiation: gsicc_manage.c:dda_will_overflow
Unexecuted instantiation: gsicc_cache.c:dda_will_overflow
Unexecuted instantiation: gsicc_lcms2mt.c:dda_will_overflow
Unexecuted instantiation: gsicc_create.c:dda_will_overflow
Unexecuted instantiation: gsicc_nocm.c:dda_will_overflow
Unexecuted instantiation: gsicc_replacecm.c:dda_will_overflow
Unexecuted instantiation: gsicc_monitorcm.c:dda_will_overflow
Unexecuted instantiation: gsicc_blacktext.c:dda_will_overflow
Unexecuted instantiation: gdevbmp.c:dda_will_overflow
Unexecuted instantiation: gdevbmpc.c:dda_will_overflow
Unexecuted instantiation: gdevpccm.c:dda_will_overflow
Unexecuted instantiation: gdevcups.c:dda_will_overflow
Unexecuted instantiation: gdevpdf.c:dda_will_overflow
Unexecuted instantiation: gdevpdfb.c:dda_will_overflow
Unexecuted instantiation: gdevpdfc.c:dda_will_overflow
Unexecuted instantiation: gdevpdfd.c:dda_will_overflow
Unexecuted instantiation: gdevpdfe.c:dda_will_overflow
Unexecuted instantiation: gdevpdfg.c:dda_will_overflow
Unexecuted instantiation: gdevpdfi.c:dda_will_overflow
Unexecuted instantiation: gdevpdfj.c:dda_will_overflow
Unexecuted instantiation: gdevpdfk.c:dda_will_overflow
Unexecuted instantiation: gdevpdfm.c:dda_will_overflow
Unexecuted instantiation: gdevpdfo.c:dda_will_overflow
Unexecuted instantiation: gdevpdfp.c:dda_will_overflow
Unexecuted instantiation: gdevpdft.c:dda_will_overflow
Unexecuted instantiation: gdevpdfr.c:dda_will_overflow
Unexecuted instantiation: gdevpdfu.c:dda_will_overflow
Unexecuted instantiation: gdevpdfv.c:dda_will_overflow
Unexecuted instantiation: gdevpsdi.c:dda_will_overflow
Unexecuted instantiation: gdevpsdp.c:dda_will_overflow
Unexecuted instantiation: gdevpsds.c:dda_will_overflow
Unexecuted instantiation: gdevpsdu.c:dda_will_overflow
Unexecuted instantiation: gdevvec.c:dda_will_overflow
Unexecuted instantiation: gdevpdt.c:dda_will_overflow
Unexecuted instantiation: gdevpdtd.c:dda_will_overflow
Unexecuted instantiation: gdevpdtf.c:dda_will_overflow
Unexecuted instantiation: gdevpdti.c:dda_will_overflow
Unexecuted instantiation: gdevpdts.c:dda_will_overflow
Unexecuted instantiation: gdevpdtt.c:dda_will_overflow
Unexecuted instantiation: gdevpdtw.c:dda_will_overflow
Unexecuted instantiation: gxfcopy.c:dda_will_overflow
Unexecuted instantiation: gdevfax.c:dda_will_overflow
Unexecuted instantiation: gdevdjet.c:dda_will_overflow
Unexecuted instantiation: gdevdljm.c:dda_will_overflow
Unexecuted instantiation: gdevpcl.c:dda_will_overflow
Unexecuted instantiation: gdevpcl3.c:dda_will_overflow
Unexecuted instantiation: pclcap.c:dda_will_overflow
Unexecuted instantiation: gdevpbm.c:dda_will_overflow
Unexecuted instantiation: gdevmpla.c:dda_will_overflow
Unexecuted instantiation: gdevpng.c:dda_will_overflow
Unexecuted instantiation: gdevpsd.c:dda_will_overflow
Unexecuted instantiation: gdevpx.c:dda_will_overflow
Unexecuted instantiation: gdevpxut.c:dda_will_overflow
Unexecuted instantiation: gdevtsep.c:dda_will_overflow
Unexecuted instantiation: gdevtifs.c:dda_will_overflow
Unexecuted instantiation: gdevupd.c:dda_will_overflow
Unexecuted instantiation: gdevxps.c:dda_will_overflow
Unexecuted instantiation: gdevkrnlsclass.c:dda_will_overflow
Unexecuted instantiation: gschar.c:dda_will_overflow
Unexecuted instantiation: gscolor.c:dda_will_overflow
Unexecuted instantiation: gscoord.c:dda_will_overflow
Unexecuted instantiation: gscspace.c:dda_will_overflow
Unexecuted instantiation: gsovrc.c:dda_will_overflow
Unexecuted instantiation: gxoprect.c:dda_will_overflow
Unexecuted instantiation: gsdevice.c:dda_will_overflow
Unexecuted instantiation: gsdparam.c:dda_will_overflow
Unexecuted instantiation: gsfont.c:dda_will_overflow
Unexecuted instantiation: gsht.c:dda_will_overflow
Unexecuted instantiation: gshtscr.c:dda_will_overflow
Unexecuted instantiation: gsimage.c:dda_will_overflow
Unexecuted instantiation: gsgstate.c:dda_will_overflow
Unexecuted instantiation: gsline.c:dda_will_overflow
Unexecuted instantiation: gspaint.c:dda_will_overflow
Unexecuted instantiation: gspath.c:dda_will_overflow
Unexecuted instantiation: gsstate.c:dda_will_overflow
Unexecuted instantiation: gstext.c:dda_will_overflow
Unexecuted instantiation: gxfapi.c:dda_will_overflow
Unexecuted instantiation: write_t2.c:dda_will_overflow
Unexecuted instantiation: gxccache.c:dda_will_overflow
Unexecuted instantiation: gxccman.c:dda_will_overflow
Unexecuted instantiation: gxchar.c:dda_will_overflow
Unexecuted instantiation: gxcht.c:dda_will_overflow
Unexecuted instantiation: gxclip.c:dda_will_overflow
Unexecuted instantiation: gxcmap.c:dda_will_overflow
Unexecuted instantiation: gxcpath.c:dda_will_overflow
Unexecuted instantiation: gxdcconv.c:dda_will_overflow
Unexecuted instantiation: gxdcolor.c:dda_will_overflow
Unexecuted instantiation: gxhldevc.c:dda_will_overflow
Unexecuted instantiation: gxfill.c:dda_will_overflow
Unexecuted instantiation: gxht.c:dda_will_overflow
Unexecuted instantiation: gxht_thresh.c:dda_will_overflow
Unexecuted instantiation: gxidata.c:dda_will_overflow
Unexecuted instantiation: gxifast.c:dda_will_overflow
Unexecuted instantiation: gximage.c:dda_will_overflow
Unexecuted instantiation: gximdecode.c:dda_will_overflow
Unexecuted instantiation: gximage1.c:dda_will_overflow
Unexecuted instantiation: gximono.c:dda_will_overflow
gxipixel.c:dda_will_overflow
Line
Count
Source
189
7.03M
{
190
    /* Every step, R decrements by dR. If it becomes negative, we add 1 to Q, and add N to R. */
191
    /* So on average we add (N-dR)/N to Q each step. So in N steps we add (N-dR) to Q. */
192
7.03M
    int64_t delta;
193
7.03M
    int res;
194
195
    /* The values we're checking should fit in 32 bit values, hence using
196
       check_int_multiply() - the int64_t variables allow us leeway for the
197
       additions/subtractions.
198
     */
199
7.03M
    if (check_int_multiply(dda.step.dQ, dda.step.N, &res) < 0)
200
895
        return 1;
201
202
7.03M
    delta = (int64_t)res + dda.step.N - dda.step.dR;
203
204
7.03M
    if (delta > 0 && delta + dda.state.Q > max_int)
205
457
            return 1;
206
7.03M
    if (delta < 0 && delta + dda.state.Q < min_int)
207
80
            return 1;
208
7.03M
    return 0;
209
7.03M
}
Unexecuted instantiation: gximask.c:dda_will_overflow
Unexecuted instantiation: gxi12bit.c:dda_will_overflow
Unexecuted instantiation: gxi16bit.c:dda_will_overflow
Unexecuted instantiation: gxiscale.c:dda_will_overflow
Unexecuted instantiation: gxpaint.c:dda_will_overflow
Unexecuted instantiation: gxpcopy.c:dda_will_overflow
Unexecuted instantiation: gxsample.c:dda_will_overflow
Unexecuted instantiation: gxstroke.c:dda_will_overflow
Unexecuted instantiation: gdevabuf.c:dda_will_overflow
Unexecuted instantiation: gdevdbit.c:dda_will_overflow
Unexecuted instantiation: gdevddrw.c:dda_will_overflow
Unexecuted instantiation: gdevdflt.c:dda_will_overflow
Unexecuted instantiation: gdevdgbr.c:dda_will_overflow
Unexecuted instantiation: gdevnfwd.c:dda_will_overflow
Unexecuted instantiation: gdevmem.c:dda_will_overflow
Unexecuted instantiation: gdevplnx.c:dda_will_overflow
Unexecuted instantiation: gdevm1.c:dda_will_overflow
Unexecuted instantiation: gdevm2.c:dda_will_overflow
Unexecuted instantiation: gdevm4.c:dda_will_overflow
Unexecuted instantiation: gdevm8.c:dda_will_overflow
Unexecuted instantiation: gdevm16.c:dda_will_overflow
Unexecuted instantiation: gdevm24.c:dda_will_overflow
Unexecuted instantiation: gdevm32.c:dda_will_overflow
Unexecuted instantiation: gdevm40.c:dda_will_overflow
Unexecuted instantiation: gdevm48.c:dda_will_overflow
Unexecuted instantiation: gdevm56.c:dda_will_overflow
Unexecuted instantiation: gdevm64.c:dda_will_overflow
Unexecuted instantiation: gdevmx.c:dda_will_overflow
Unexecuted instantiation: gdevdsha.c:dda_will_overflow
Unexecuted instantiation: gxscanc.c:dda_will_overflow
Unexecuted instantiation: siscale.c:dda_will_overflow
Unexecuted instantiation: sidscale.c:dda_will_overflow
Unexecuted instantiation: gdevdrop.c:dda_will_overflow
Unexecuted instantiation: gdevmr1.c:dda_will_overflow
Unexecuted instantiation: gdevmr2n.c:dda_will_overflow
Unexecuted instantiation: gdevmr8n.c:dda_will_overflow
Unexecuted instantiation: gdevrops.c:dda_will_overflow
Unexecuted instantiation: gsrop.c:dda_will_overflow
Unexecuted instantiation: zcolor1.c:dda_will_overflow
Unexecuted instantiation: zht1.c:dda_will_overflow
Unexecuted instantiation: zupath.c:dda_will_overflow
Unexecuted instantiation: gdevhit.c:dda_will_overflow
Unexecuted instantiation: zdps1.c:dda_will_overflow
Unexecuted instantiation: zchar1.c:dda_will_overflow
Unexecuted instantiation: zcharout.c:dda_will_overflow
Unexecuted instantiation: zfont1.c:dda_will_overflow
Unexecuted instantiation: zusparam.c:dda_will_overflow
Unexecuted instantiation: zchar42.c:dda_will_overflow
Unexecuted instantiation: zfont0.c:dda_will_overflow
Unexecuted instantiation: zfdctd.c:dda_will_overflow
Unexecuted instantiation: spdiff.c:dda_will_overflow
Unexecuted instantiation: zdevice2.c:dda_will_overflow
Unexecuted instantiation: zpcolor.c:dda_will_overflow
Unexecuted instantiation: idisp.c:dda_will_overflow
Unexecuted instantiation: psapi.c:dda_will_overflow
Unexecuted instantiation: zfileio.c:dda_will_overflow
Unexecuted instantiation: zbfont.c:dda_will_overflow
Unexecuted instantiation: zchar.c:dda_will_overflow
Unexecuted instantiation: zcolor.c:dda_will_overflow
Unexecuted instantiation: zdevice.c:dda_will_overflow
Unexecuted instantiation: zfont.c:dda_will_overflow
Unexecuted instantiation: zht.c:dda_will_overflow
Unexecuted instantiation: zimage.c:dda_will_overflow
Unexecuted instantiation: zfapi.c:dda_will_overflow
Unexecuted instantiation: zcsindex.c:dda_will_overflow
Unexecuted instantiation: zht2.c:dda_will_overflow
Unexecuted instantiation: zcssepr.c:dda_will_overflow
Unexecuted instantiation: zfunc4.c:dda_will_overflow
Unexecuted instantiation: zfimscale.c:dda_will_overflow
Unexecuted instantiation: simscale.c:dda_will_overflow
Unexecuted instantiation: zform.c:dda_will_overflow
Unexecuted instantiation: zimage3.c:dda_will_overflow
Unexecuted instantiation: zicc.c:dda_will_overflow
Unexecuted instantiation: ztrans.c:dda_will_overflow
Unexecuted instantiation: zpdfops.c:dda_will_overflow
Unexecuted instantiation: pdf_loop_detect.c:dda_will_overflow
Unexecuted instantiation: ghostpdf.c:dda_will_overflow
Unexecuted instantiation: pdf_dict.c:dda_will_overflow
Unexecuted instantiation: pdf_array.c:dda_will_overflow
Unexecuted instantiation: pdf_xref.c:dda_will_overflow
Unexecuted instantiation: pdf_int.c:dda_will_overflow
Unexecuted instantiation: pdf_file.c:dda_will_overflow
Unexecuted instantiation: pdf_path.c:dda_will_overflow
Unexecuted instantiation: pdf_colour.c:dda_will_overflow
Unexecuted instantiation: pdf_pattern.c:dda_will_overflow
Unexecuted instantiation: pdf_gstate.c:dda_will_overflow
Unexecuted instantiation: pdf_stack.c:dda_will_overflow
Unexecuted instantiation: pdf_image.c:dda_will_overflow
Unexecuted instantiation: pdf_page.c:dda_will_overflow
Unexecuted instantiation: pdf_annot.c:dda_will_overflow
Unexecuted instantiation: pdf_mark.c:dda_will_overflow
Unexecuted instantiation: pdf_font.c:dda_will_overflow
Unexecuted instantiation: pdf_font0.c:dda_will_overflow
Unexecuted instantiation: pdf_ciddec.c:dda_will_overflow
Unexecuted instantiation: pdf_font1.c:dda_will_overflow
Unexecuted instantiation: pdf_font1C.c:dda_will_overflow
Unexecuted instantiation: pdf_fontps.c:dda_will_overflow
Unexecuted instantiation: pdf_font3.c:dda_will_overflow
Unexecuted instantiation: pdf_fontTT.c:dda_will_overflow
Unexecuted instantiation: pdf_font11.c:dda_will_overflow
Unexecuted instantiation: pdf_cmap.c:dda_will_overflow
Unexecuted instantiation: pdf_fmap.c:dda_will_overflow
Unexecuted instantiation: pdf_text.c:dda_will_overflow
Unexecuted instantiation: pdf_shading.c:dda_will_overflow
Unexecuted instantiation: pdf_func.c:dda_will_overflow
Unexecuted instantiation: pdf_trans.c:dda_will_overflow
Unexecuted instantiation: pdf_device.c:dda_will_overflow
Unexecuted instantiation: pdf_misc.c:dda_will_overflow
Unexecuted instantiation: pdf_optcontent.c:dda_will_overflow
Unexecuted instantiation: pdf_check.c:dda_will_overflow
Unexecuted instantiation: pdf_sec.c:dda_will_overflow
Unexecuted instantiation: pdf_utf8.c:dda_will_overflow
Unexecuted instantiation: pdf_deref.c:dda_will_overflow
Unexecuted instantiation: pdf_repair.c:dda_will_overflow
Unexecuted instantiation: pdf_obj.c:dda_will_overflow
Unexecuted instantiation: pdf_doc.c:dda_will_overflow
Unexecuted instantiation: imainarg.c:dda_will_overflow
Unexecuted instantiation: gsclipsr.c:dda_will_overflow
Unexecuted instantiation: gscdevn.c:dda_will_overflow
Unexecuted instantiation: gxdevndi.c:dda_will_overflow
Unexecuted instantiation: gxclipm.c:dda_will_overflow
Unexecuted instantiation: gscolor3.c:dda_will_overflow
Unexecuted instantiation: gsptype2.c:dda_will_overflow
Unexecuted instantiation: gsshade.c:dda_will_overflow
Unexecuted instantiation: gxshade.c:dda_will_overflow
Unexecuted instantiation: gxshade1.c:dda_will_overflow
Unexecuted instantiation: gxshade4.c:dda_will_overflow
Unexecuted instantiation: gxshade6.c:dda_will_overflow
Unexecuted instantiation: gscolor1.c:dda_will_overflow
Unexecuted instantiation: gsht1.c:dda_will_overflow
Unexecuted instantiation: gscolor2.c:dda_will_overflow
Unexecuted instantiation: gspcolor.c:dda_will_overflow
Unexecuted instantiation: gxclip2.c:dda_will_overflow
Unexecuted instantiation: gspath1.c:dda_will_overflow
Unexecuted instantiation: gstype42.c:dda_will_overflow
Unexecuted instantiation: gxchrout.c:dda_will_overflow
Unexecuted instantiation: gxttfb.c:dda_will_overflow
Unexecuted instantiation: gzspotan.c:dda_will_overflow
Unexecuted instantiation: gscie.c:dda_will_overflow
Unexecuted instantiation: gscsepr.c:dda_will_overflow
Unexecuted instantiation: gxblend1.c:dda_will_overflow
Unexecuted instantiation: gxdownscale.c:dda_will_overflow
Unexecuted instantiation: gdevepo.c:dda_will_overflow
Unexecuted instantiation: gxclbits.c:dda_will_overflow
Unexecuted instantiation: gxclrast.c:dda_will_overflow
Unexecuted instantiation: gschar0.c:dda_will_overflow
Unexecuted instantiation: gsfont0.c:dda_will_overflow
Unexecuted instantiation: gsfcmap.c:dda_will_overflow
Unexecuted instantiation: gstype1.c:dda_will_overflow
Unexecuted instantiation: gxtype1.c:dda_will_overflow
Unexecuted instantiation: gstype2.c:dda_will_overflow
Unexecuted instantiation: gsicc_profilecache.c:dda_will_overflow
Unexecuted instantiation: gdevpdtb.c:dda_will_overflow
Unexecuted instantiation: gdevpdtc.c:dda_will_overflow
Unexecuted instantiation: gdevpdte.c:dda_will_overflow
Unexecuted instantiation: gdevpsfx.c:dda_will_overflow
Unexecuted instantiation: gstiffio.c:dda_will_overflow
Unexecuted instantiation: gdeveprn.c:dda_will_overflow
Unexecuted instantiation: eprnparm.c:dda_will_overflow
Unexecuted instantiation: eprnrend.c:dda_will_overflow
Unexecuted instantiation: eprnfs.c:dda_will_overflow
Unexecuted instantiation: gscicach.c:dda_will_overflow
Unexecuted instantiation: gsdevmem.c:dda_will_overflow
Unexecuted instantiation: gxacpath.c:dda_will_overflow
Unexecuted instantiation: gxpdash.c:dda_will_overflow
Unexecuted instantiation: pdf_fapi.c:dda_will_overflow
Unexecuted instantiation: gscscie.c:dda_will_overflow
Unexecuted instantiation: plmain.c:dda_will_overflow
Unexecuted instantiation: gpdlimpl.c:dda_will_overflow
Unexecuted instantiation: pctop.c:dda_will_overflow
Unexecuted instantiation: pxtop.c:dda_will_overflow
Unexecuted instantiation: xpstop.c:dda_will_overflow
Unexecuted instantiation: pdftop.c:dda_will_overflow
Unexecuted instantiation: pxerrors.c:dda_will_overflow
Unexecuted instantiation: pxparse.c:dda_will_overflow
Unexecuted instantiation: pxstate.c:dda_will_overflow
Unexecuted instantiation: pxptable.c:dda_will_overflow
Unexecuted instantiation: pxpthr.c:dda_will_overflow
Unexecuted instantiation: pxfont.c:dda_will_overflow
Unexecuted instantiation: pxgstate.c:dda_will_overflow
Unexecuted instantiation: pximage.c:dda_will_overflow
Unexecuted instantiation: pxink.c:dda_will_overflow
Unexecuted instantiation: pxpaint.c:dda_will_overflow
Unexecuted instantiation: pxsessio.c:dda_will_overflow
Unexecuted instantiation: pxstream.c:dda_will_overflow
Unexecuted instantiation: pccprint.c:dda_will_overflow
Unexecuted instantiation: pcjob.c:dda_will_overflow
Unexecuted instantiation: pcpage.c:dda_will_overflow
Unexecuted instantiation: pcursor.c:dda_will_overflow
Unexecuted instantiation: pcfont.c:dda_will_overflow
Unexecuted instantiation: pctext.c:dda_will_overflow
Unexecuted instantiation: pcsymbol.c:dda_will_overflow
Unexecuted instantiation: pcsfont.c:dda_will_overflow
Unexecuted instantiation: pcmacros.c:dda_will_overflow
Unexecuted instantiation: pcrect.c:dda_will_overflow
Unexecuted instantiation: pcstatus.c:dda_will_overflow
Unexecuted instantiation: pcmisc.c:dda_will_overflow
Unexecuted instantiation: pcfontpg.c:dda_will_overflow
Unexecuted instantiation: rtmisc.c:dda_will_overflow
Unexecuted instantiation: rtraster.c:dda_will_overflow
Unexecuted instantiation: pcommand.c:dda_will_overflow
Unexecuted instantiation: pcparse.c:dda_will_overflow
Unexecuted instantiation: pcdraw.c:dda_will_overflow
Unexecuted instantiation: pcbiptrn.c:dda_will_overflow
Unexecuted instantiation: pccid.c:dda_will_overflow
Unexecuted instantiation: pccolor.c:dda_will_overflow
Unexecuted instantiation: pccsbase.c:dda_will_overflow
Unexecuted instantiation: pcdither.c:dda_will_overflow
Unexecuted instantiation: pcfrgrnd.c:dda_will_overflow
Unexecuted instantiation: pcht.c:dda_will_overflow
Unexecuted instantiation: pcident.c:dda_will_overflow
Unexecuted instantiation: pcindxed.c:dda_will_overflow
Unexecuted instantiation: pclookup.c:dda_will_overflow
Unexecuted instantiation: pcpalet.c:dda_will_overflow
Unexecuted instantiation: pcpatrn.c:dda_will_overflow
Unexecuted instantiation: pcpatxfm.c:dda_will_overflow
Unexecuted instantiation: pcuptrn.c:dda_will_overflow
Unexecuted instantiation: pcwhtidx.c:dda_will_overflow
Unexecuted instantiation: rtgmode.c:dda_will_overflow
Unexecuted instantiation: rtrstcmp.c:dda_will_overflow
Unexecuted instantiation: pgcolor.c:dda_will_overflow
Unexecuted instantiation: pgdraw.c:dda_will_overflow
Unexecuted instantiation: pginit.c:dda_will_overflow
Unexecuted instantiation: pgparse.c:dda_will_overflow
Unexecuted instantiation: pgmisc.c:dda_will_overflow
Unexecuted instantiation: pgframe.c:dda_will_overflow
Unexecuted instantiation: pgconfig.c:dda_will_overflow
Unexecuted instantiation: pgvector.c:dda_will_overflow
Unexecuted instantiation: pgpoly.c:dda_will_overflow
Unexecuted instantiation: pglfill.c:dda_will_overflow
Unexecuted instantiation: pgchar.c:dda_will_overflow
Unexecuted instantiation: pglabel.c:dda_will_overflow
Unexecuted instantiation: pgfont.c:dda_will_overflow
Unexecuted instantiation: xpsmem.c:dda_will_overflow
Unexecuted instantiation: xpshash.c:dda_will_overflow
Unexecuted instantiation: xpszip.c:dda_will_overflow
Unexecuted instantiation: xpsdoc.c:dda_will_overflow
Unexecuted instantiation: xpspage.c:dda_will_overflow
Unexecuted instantiation: xpsresource.c:dda_will_overflow
Unexecuted instantiation: xpscommon.c:dda_will_overflow
Unexecuted instantiation: xpsanalyze.c:dda_will_overflow
Unexecuted instantiation: xpscolor.c:dda_will_overflow
Unexecuted instantiation: xpsopacity.c:dda_will_overflow
Unexecuted instantiation: xpspath.c:dda_will_overflow
Unexecuted instantiation: xpstile.c:dda_will_overflow
Unexecuted instantiation: xpsvisual.c:dda_will_overflow
Unexecuted instantiation: xpsimage.c:dda_will_overflow
Unexecuted instantiation: xpsgradient.c:dda_will_overflow
Unexecuted instantiation: xpsglyphs.c:dda_will_overflow
Unexecuted instantiation: xpsfont.c:dda_will_overflow
Unexecuted instantiation: xpsttf.c:dda_will_overflow
Unexecuted instantiation: xpscff.c:dda_will_overflow
Unexecuted instantiation: xpsfapi.c:dda_will_overflow
Unexecuted instantiation: pngtop.c:dda_will_overflow
Unexecuted instantiation: jp2ktop.c:dda_will_overflow
Unexecuted instantiation: jbig2top.c:dda_will_overflow
Unexecuted instantiation: tifftop.c:dda_will_overflow
Unexecuted instantiation: pwgtop.c:dda_will_overflow
Unexecuted instantiation: jpgtop.c:dda_will_overflow
Unexecuted instantiation: urftop.c:dda_will_overflow
Unexecuted instantiation: psitop.c:dda_will_overflow
Unexecuted instantiation: txttop.c:dda_will_overflow
Unexecuted instantiation: gshtx.c:dda_will_overflow
Unexecuted instantiation: gdevmplt.c:dda_will_overflow
Unexecuted instantiation: spwgd.c:dda_will_overflow
Unexecuted instantiation: plht.c:dda_will_overflow
Unexecuted instantiation: plfapi.c:dda_will_overflow
Unexecuted instantiation: plchar.c:dda_will_overflow
Unexecuted instantiation: plfont.c:dda_will_overflow
Unexecuted instantiation: pxffont.c:dda_will_overflow
Unexecuted instantiation: pcfsel.c:dda_will_overflow
Unexecuted instantiation: pgfdata.c:dda_will_overflow
Unexecuted instantiation: xpsutf.c:dda_will_overflow
Unexecuted instantiation: xpsjpeg.c:dda_will_overflow
Unexecuted instantiation: xpspng.c:dda_will_overflow
Unexecuted instantiation: xpstiff.c:dda_will_overflow
Unexecuted instantiation: xpsjxr.c:dda_will_overflow
Unexecuted instantiation: xpsxml.c:dda_will_overflow
210
211
/*
212
 * Initialise a DDA, and do a half step.
213
 */
214
#define dda_init_state_half(dstate, dstep, init, N_)\
215
  (dstate).Q = (init) + ((dstep).dQ>>1);\
216
  (dstate).R = ((N_)-1) - (((dstep).dR + ((dstep).dQ & 1 ? (dstep).N : 0))>>1);\
217
  if ((signed)(dstate).R < 0) {\
218
    (dstate).Q++;\
219
    (dstate).R += (dstep).N;\
220
  }
221
#define dda_init_half(dda, init, D, N)\
222
  do {\
223
    dda_init_step((dda).step, D, N);\
224
    dda_init_state_half((dda).state, (dda).step, init, N);\
225
  } while (0)
226
227
/*
228
 * Compute the sum of two DDA steps with the same D and N.
229
 * Note that since dR + NdR = N, this quantity must be the same in both
230
 * fromstep and tostep.
231
 */
232
#define dda_step_add(tostep, fromstep)\
233
23.4M
    BEGIN\
234
23.4M
        (tostep).dR += (fromstep).dR;\
235
23.4M
        if ((tostep).dR >= (tostep).N) {\
236
4.02M
            (tostep).dQ ++;\
237
4.02M
            (tostep).dR -= (tostep).N;\
238
4.02M
        }\
239
23.4M
        (tostep).dQ += (fromstep).dQ;\
240
23.4M
    END
241
/*
242
 * Return the current value in a DDA.
243
 */
244
4.12G
#define dda_state_current(dstate) (dstate).Q
245
4.12G
#define dda_current(dda) dda_state_current((dda).state)
246
#define dda_current_fixed2int(dda)\
247
99.8M
  fixed2int_var(dda_state_current((dda).state))
248
/*
249
 * Increment a DDA to the next point.
250
 * Returns the updated current value.
251
 */
252
#define dda_state_next(dstate, dstep)\
253
5.57G
    do {\
254
5.57G
        (dstate).R -= (dstep).dR;\
255
5.57G
        if ((signed)(dstate).R < 0) {\
256
739M
            (dstate).Q++;\
257
739M
            (dstate).R += (dstep).N;\
258
739M
        };\
259
5.57G
        (dstate).Q += (dstep).dQ;\
260
5.57G
    } while (0)
261
5.40G
#define dda_next(dda) dda_state_next((dda).state, (dda).step)
262
0
#define dda_next_assign(dda,v) BEGIN dda_next(dda);(v)=(dda).state.Q; END
263
264
/*
265
 * Back up a DDA to the previous point.
266
 * Returns the updated current value.
267
 */
268
#define dda_state_previous(dstate, dstep)\
269
0
    BEGIN\
270
0
        (dstate).R += (dstep).dR;\
271
0
        if ((dstate).R >= (dstep).N) {\
272
0
            (dstate).Q--;\
273
0
            (dstate).R -= (dstep).N;\
274
0
        }\
275
0
        (dstate).Q -= (dstep).dQ;\
276
0
    END
277
0
#define dda_previous(dda) dda_state_previous((dda).state, (dda).step)
278
0
#define dda_previous_assign(dda,v) BEGIN dda_previous(dda);(v)=(dda).state.Q;END
279
/*
280
 * Advance a DDA by an arbitrary number of steps.
281
 * This implementation is very inefficient; we'll improve it if needed.
282
 */
283
#define dda_state_advance(dstate, dstep, nsteps)\
284
4.84M
  BEGIN\
285
4.84M
      uint n_ = (nsteps);\
286
4.84M
      (dstate).Q += (dstep).dQ * (nsteps);\
287
2.30G
      while ( n_-- ) {\
288
2.30G
          (dstate).R -= (dstep).dR;\
289
2.30G
          if ((signed int)(dstate).R < 0) {\
290
247M
              (dstate).Q ++;\
291
247M
              (dstate).R += (dstep).N;\
292
247M
          }\
293
2.30G
      }\
294
4.84M
  END
295
#define dda_advance(dda, nsteps)\
296
4.84M
  dda_state_advance((dda).state, (dda).step, nsteps)
297
/*
298
 * Translate the position of a DDA by a given amount.
299
 */
300
#define dda_state_translate(dstate, delta)\
301
82.2M
  ((dstate).Q += (delta))
302
#define dda_translate(dda, delta)\
303
82.2M
  dda_state_translate((dda).state, delta)
304
305
#endif /* gxdda_INCLUDED */