Coverage Report

Created: 2025-06-24 07:01

/src/ghostpdl/base/gxdda.h
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
/* Definitions for DDAs */
18
/* Requires gxfixed.h */
19
20
#ifndef gxdda_INCLUDED
21
#  define gxdda_INCLUDED
22
23
#include "stdpre.h"
24
#include "gxfixed.h"
25
26
/* We use the familiar Bresenham DDA algorithm for several purposes:
27
 *      - tracking the edges when filling trapezoids;
28
 *      - tracking the current pixel corner coordinates when rasterizing
29
 *      skewed or rotated images;
30
 *      - converting curves to sequences of lines (this is a 3rd-order
31
 *      DDA, the others are 1st-order);
32
 *      - perhaps someday for drawing single-pixel lines.
33
 * In the case of trapezoids, lines, and curves, we need to use
34
 * the DDA to find the integer X values at integer+0.5 values of Y;
35
 * in the case of images, we use DDAs to compute the (fixed)
36
 * X and Y values at (integer) source pixel corners.
37
 *
38
 * The purpose of the DDA is to compute the exact values Q(i) = floor(i*D/N)
39
 * for increasing integers i, 0 <= i <= N.  D is considered to be an
40
 * integer, although it may actually be a fixed.
41
 *
42
 * In the original formulation of the algorithm, we maintained i*D/N as
43
 * Q + (N-R)/N where Q and R are integers, where 0 < R <= N, with the
44
 * following auxiliary values:
45
 *      dQ = floor(D/N)
46
 *      dR = D mod N (0 <= dR < N)
47
 *      NdR = N - dR
48
 * And at each iteration the code did:
49
 *      Q += dQ;
50
 *      if ( R > dR ) R -= dR; else ++Q, R += NdR;
51
 *
52
 * In the new formulation here, we hold i*D/N as Q + (N-1-R)/N where Q and R
53
 * are integers, 0 <= R < N.
54
 *      Q += dQ;
55
 *      R -= dR
56
 *      if ( R < 0) R += N, ++Q;
57
 * These formulas work regardless of the sign of D, and never let R go
58
 * out of range.
59
 *
60
 * Why is the new formulation better? Well, it's simpler for one thing - the
61
 * values stored in the structure are the obvious ones, without the strange
62
 * NdR one. Also, in the original we test R > dR, which takes as long as
63
 * doing R-=dR in the first place; in the new code we test R against 0, which
64
 * we get for free on most architectures.
65
 *
66
 * In architectures that use branches for alternation, the first (should)
67
 * compiles to something like (excuse the pseudo code):
68
 *
69
 *   Q += dQ
70
 *   if (R > dR)
71
 *      goto A
72
 *   R -= dR
73
 *   goto B
74
 * A:
75
 *   Q += 1
76
 *   R += NdR
77
 * B:
78
 *
79
 * So 7 'instructions', 5 on each possible route through the code, including
80
 * 1 branch regardless of the values.
81
 *
82
 * In the new form, it compiles to:
83
 *
84
 *   R -= dR
85
 *   if (R >= 0)     <- this instruction for free due to preceeding one
86
 *       goto A:
87
 *   R += N
88
 *   Q++
89
 * A:
90
 *   Q += dQ
91
 *
92
 * So 5 'instructions', 3 on the no step case, 5 on the step case, including
93
 * 1 branch on the no-step case.
94
 *
95
 * If the compiler is smart enough to use the carry flag, it becomes:
96
 *
97
 *   R -= dR
98
 *   if (R >= 0)     <- this instruction for free due to preceeding one
99
 *       goto A:
100
 *   R += N
101
 * A:
102
 *   Q += dQ + C     <- Add with carry
103
 *
104
 * 4 instructions total, 3 on the no step case, 4 on the step case, including
105
 * 1 branch on the no-step case.
106
 *
107
 * This is an even better win on architectures (like ARM) where alternation
108
 * can be done without branches; the original gives:
109
 *
110
 *   ADD   Q, Q, dQ
111
 *   CMP   R, dR
112
 *   SUBGT R, R, dR
113
 *   ADDLE Q, Q, #1
114
 *   ADDLE R, R, nDR
115
 *
116
 * (assuming all values in registers) and the new formulation becomes:
117
 *
118
 *   SUBS  R, R, dR
119
 *   ADDLT R, R, N
120
 *   ADDLT Q, Q, #1
121
 *   ADD   Q, Q, dQ
122
 *
123
 * If the compiler is smart enough to use the carry flag, we can do even
124
 * better:
125
 *
126
 *   SUBS  R, R, dR
127
 *   ADDLT R, R, N
128
 *   ADC   Q, Q, dQ
129
 *
130
 * (Actually looking at the compilation given by MSVC 2005 confirms a 1
131
 * instruction (and one branch) win for the above results. Sadly compilers
132
 * don't look to be smart enough to exploit carry flag tricks.)
133
 */
134
135
/* In the following structure definitions, ntype must be an unsigned type. */
136
#define dda_state_struct(sname, dtype, ntype)\
137
  struct sname { dtype Q; ntype R; }
138
#define dda_step_struct(sname, dtype, ntype)\
139
  struct sname { dtype dQ; ntype dR, N; }
140
141
/* DDA with int Q and uint N */
142
typedef struct gx_dda_int_s {
143
    dda_state_struct(ia_, int, uint) state;
144
    dda_step_struct(ie_, int, uint) step;
145
} gx_dda_int_t;
146
147
/* DDA with fixed Q and (unsigned) integer N */
148
typedef
149
dda_state_struct(_a, fixed, uint) gx_dda_state_fixed;
150
     typedef dda_step_struct(_e, fixed, uint) gx_dda_step_fixed;
151
     typedef struct gx_dda_fixed_s {
152
         gx_dda_state_fixed state;
153
         gx_dda_step_fixed step;
154
     } gx_dda_fixed;
155
/*
156
 * Define a pair of DDAs for iterating along an arbitrary line.
157
 */
158
     typedef struct gx_dda_fixed_point_s {
159
         gx_dda_fixed x, y;
160
     } gx_dda_fixed_point;
161
/*
162
 * Initialize a DDA.  The sign test is needed only because C doesn't
163
 * provide reliable definitions of / and % for integers (!!!).
164
 */
165
#define dda_init_state(dstate, init, N_)\
166
10.6M
  (dstate).Q = (init), (dstate).R = ((N_)-1)
167
#define dda_init_step(dstep, D, N_)\
168
10.6M
  do {\
169
10.6M
    if ( (N_) == 0 )\
170
10.6M
      (dstep).dQ = 0, (dstep).dR = 0;\
171
10.6M
    else if ( (D) < 0 )\
172
10.5M
     { (dstep).dQ = -(int)((uint)-(D) / (N_));\
173
1.32M
       if ( ((dstep).dR = -(D) % (N_)) != 0 )\
174
1.32M
         --(dstep).dQ, (dstep).dR = (N_) - (dstep).dR;\
175
1.32M
     }\
176
10.5M
    else\
177
10.5M
     { (dstep).dQ = (D) / (N_); (dstep).dR = (D) % (N_); }\
178
10.6M
    (dstep).N = (N_);\
179
10.6M
  } while (0)
180
#define dda_init(dda, init, D, N)\
181
10.6M
  do {\
182
10.6M
    dda_init_state((dda).state, init, N);\
183
10.6M
    dda_init_step((dda).step, D, N);\
184
10.6M
  } while (0)
185
186
static inline
187
int dda_will_overflow(gx_dda_fixed dda)
188
9.12M
{
189
    /* Every step, R decrements by dR. If it becomes negative, we add 1 to Q, and add N to R. */
190
    /* So on average we add (N-dR)/N to Q each step. So in N steps we add (N-dR) to Q. */
191
9.12M
    uint N = dda.step.N;
192
9.12M
    fixed delta = dda.step.dQ * N + N - dda.step.dR;
193
194
9.12M
    if (delta > 0 && delta + dda.state.Q < dda.state.Q)
195
0
            return 1;
196
9.12M
    if (delta < 0 && delta + dda.state.Q > dda.state.Q)
197
0
            return 1;
198
9.12M
    return 0;
199
9.12M
}
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
188
9.12M
{
189
    /* Every step, R decrements by dR. If it becomes negative, we add 1 to Q, and add N to R. */
190
    /* So on average we add (N-dR)/N to Q each step. So in N steps we add (N-dR) to Q. */
191
9.12M
    uint N = dda.step.N;
192
9.12M
    fixed delta = dda.step.dQ * N + N - dda.step.dR;
193
194
9.12M
    if (delta > 0 && delta + dda.state.Q < dda.state.Q)
195
0
            return 1;
196
9.12M
    if (delta < 0 && delta + dda.state.Q > dda.state.Q)
197
0
            return 1;
198
9.12M
    return 0;
199
9.12M
}
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: 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: 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
200
201
/*
202
 * Initialise a DDA, and do a half step.
203
 */
204
#define dda_init_state_half(dstate, dstep, init, N_)\
205
  (dstate).Q = (init) + ((dstep).dQ>>1);\
206
  (dstate).R = ((N_)-1) - (((dstep).dR + ((dstep).dQ & 1 ? (dstep).N : 0))>>1);\
207
  if ((signed)(dstate).R < 0) {\
208
    (dstate).Q++;\
209
    (dstate).R += (dstep).N;\
210
  }
211
#define dda_init_half(dda, init, D, N)\
212
  do {\
213
    dda_init_step((dda).step, D, N);\
214
    dda_init_state_half((dda).state, (dda).step, init, N);\
215
  } while (0)
216
217
/*
218
 * Compute the sum of two DDA steps with the same D and N.
219
 * Note that since dR + NdR = N, this quantity must be the same in both
220
 * fromstep and tostep.
221
 */
222
#define dda_step_add(tostep, fromstep)\
223
22.2M
    BEGIN\
224
22.2M
        (tostep).dR += (fromstep).dR;\
225
22.2M
        if ((tostep).dR >= (tostep).N) {\
226
7.18M
            (tostep).dQ ++;\
227
7.18M
            (tostep).dR -= (tostep).N;\
228
7.18M
        }\
229
22.2M
        (tostep).dQ += (fromstep).dQ;\
230
22.2M
    END
231
/*
232
 * Return the current value in a DDA.
233
 */
234
7.96G
#define dda_state_current(dstate) (dstate).Q
235
7.96G
#define dda_current(dda) dda_state_current((dda).state)
236
#define dda_current_fixed2int(dda)\
237
176M
  fixed2int_var(dda_state_current((dda).state))
238
/*
239
 * Increment a DDA to the next point.
240
 * Returns the updated current value.
241
 */
242
#define dda_state_next(dstate, dstep)\
243
10.9G
    do {\
244
10.9G
        (dstate).R -= (dstep).dR;\
245
10.9G
        if ((signed)(dstate).R < 0) {\
246
1.39G
            (dstate).Q++;\
247
1.39G
            (dstate).R += (dstep).N;\
248
1.39G
        };\
249
10.9G
        (dstate).Q += (dstep).dQ;\
250
10.9G
    } while (0)
251
10.5G
#define dda_next(dda) dda_state_next((dda).state, (dda).step)
252
0
#define dda_next_assign(dda,v) BEGIN dda_next(dda);(v)=(dda).state.Q; END
253
254
/*
255
 * Back up a DDA to the previous point.
256
 * Returns the updated current value.
257
 */
258
#define dda_state_previous(dstate, dstep)\
259
0
    BEGIN\
260
0
        (dstate).R += (dstep).dR;\
261
0
        if ((dstate).R >= (dstep).N) {\
262
0
            (dstate).Q--;\
263
0
            (dstate).R -= (dstep).N;\
264
0
        }\
265
0
        (dstate).Q -= (dstep).dQ;\
266
0
    END
267
0
#define dda_previous(dda) dda_state_previous((dda).state, (dda).step)
268
0
#define dda_previous_assign(dda,v) BEGIN dda_previous(dda);(v)=(dda).state.Q;END
269
/*
270
 * Advance a DDA by an arbitrary number of steps.
271
 * This implementation is very inefficient; we'll improve it if needed.
272
 */
273
#define dda_state_advance(dstate, dstep, nsteps)\
274
6.50M
  BEGIN\
275
6.50M
      uint n_ = (nsteps);\
276
6.50M
      (dstate).Q += (dstep).dQ * (nsteps);\
277
2.81G
      while ( n_-- ) {\
278
2.81G
          (dstate).R -= (dstep).dR;\
279
2.81G
          if ((signed int)(dstate).R < 0) {\
280
321M
              (dstate).Q ++;\
281
321M
              (dstate).R += (dstep).N;\
282
321M
          }\
283
2.81G
      }\
284
6.50M
  END
285
#define dda_advance(dda, nsteps)\
286
6.50M
  dda_state_advance((dda).state, (dda).step, nsteps)
287
/*
288
 * Translate the position of a DDA by a given amount.
289
 */
290
#define dda_state_translate(dstate, delta)\
291
128M
  ((dstate).Q += (delta))
292
#define dda_translate(dda, delta)\
293
128M
  dda_state_translate((dda).state, delta)
294
295
#endif /* gxdda_INCLUDED */