/src/ghostpdl/base/gsropt.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 | | /* RasterOp / transparency type definitions */ |
18 | | |
19 | | #ifndef gsropt_INCLUDED |
20 | | # define gsropt_INCLUDED |
21 | | |
22 | | #include "stdpre.h" |
23 | | #ifdef HAVE_SSE2 |
24 | | #include <emmintrin.h> |
25 | | #endif |
26 | | |
27 | | /* |
28 | | * This file defines the types for some library extensions that are |
29 | | * motivated by PCL5 and also made available for PostScript: |
30 | | * RasterOp, source and pattern white-pixel transparency, and |
31 | | * per-pixel "render algorithm" information. |
32 | | */ |
33 | | |
34 | | /* Raster ops are explained in Chapter 5 of "The PCL 5 Color Technical |
35 | | * Reference Manual", but essentially, they provide a way of mixing |
36 | | * various bitmaps together. The most general form is where a texture |
37 | | * bitmap, a source bitmap, and a destination bitmap are added together to |
38 | | * give a new destination bitmap value. |
39 | | * |
40 | | * Each bitmap value is either 0 or 1, so essentially each raster op is |
41 | | * a function of the form f(D,S,T). (Confusingly, the HP documentation uses |
42 | | * the name 'pattern' in the english descriptive text in an inconsistent way |
43 | | * to sometimes mean 'texture' and sometimes mean something that is used to |
44 | | * help generate the texture. We will use texture exclusively here.) |
45 | | * |
46 | | * There are therefore 8 possible values on input to such functions, and 2 |
47 | | * possible output values for each input. Hence 2^8 = 256 possible raster |
48 | | * op functions. |
49 | | * |
50 | | * For any given function, f(D,S,T), we can form an 8 bit number as follows: |
51 | | * Bit 0 = f(0,0,0) |
52 | | * Bit 1 = f(1,0,0) |
53 | | * Bit 2 = f(0,1,0) |
54 | | * Bit 3 = f(1,1,0) |
55 | | * Bit 4 = f(0,0,1) |
56 | | * Bit 5 = f(1,0,1) |
57 | | * Bit 6 = f(0,1,1) |
58 | | * Bit 7 = f(1,1,1) |
59 | | * Running this in reverse for each number from 0 to 255 we have an |
60 | | * enumeratation of the possible 3 input raster op functions. |
61 | | * |
62 | | * We could therefore define F(op,D,S,T) to be a 'master' function that |
63 | | * encapsulates all these raster op functions as follows: |
64 | | * F(op,D,S,T) = !!(op & ((D?0xAA:0x55) & (S?0xCC:0x33) & (T?0xF0:0xF))) |
65 | | * We don't actually use that technique here (as it only works for 1bpp |
66 | | * inputs, and we actually use the rasterops for doing multiple bits at |
67 | | * once - it is mentioned for interests sake only. |
68 | | */ |
69 | | |
70 | | /* |
71 | | * By the magic of Boolean algebra, we can operate on the rop codes using |
72 | | * Boolean operators and get the right result. E.g., the value of |
73 | | * (rop3_S & rop3_D) is the rop3 code for S & D. We just have to remember |
74 | | * to mask results with rop2_1 or rop3_1 if necessary. |
75 | | */ |
76 | | |
77 | | /* 2-input RasterOp */ |
78 | | typedef enum { |
79 | | rop2_0 = 0, |
80 | | rop2_S = 0xc, /* source */ |
81 | | #define rop2_S_shift 2 |
82 | | rop2_D = 0xa, /* destination */ |
83 | | #define rop2_D_shift 1 |
84 | | rop2_1 = 0xf, |
85 | | #define rop2_operand(shift, d, s)\ |
86 | | ((shift) == 2 ? (s) : (d)) |
87 | | rop2_default = rop2_S |
88 | | } gs_rop2_t; |
89 | | |
90 | | /* |
91 | | * For the 3-input case, we follow H-P's inconsistent terminology: |
92 | | * the transparency mode is called pattern transparency, but the third |
93 | | * RasterOp operand is called texture, not pattern. |
94 | | */ |
95 | | |
96 | | /* We have to define rop3_{T,S,D} as enum values to shut compilers |
97 | | * up that do switch checking. We also have to #define them to allow |
98 | | * the preprocessor templating to work. */ |
99 | | |
100 | | /* 3-input RasterOp */ |
101 | | typedef enum { |
102 | | rop3_0 = 0, |
103 | | rop3_T = 0xf0, /* texture */ |
104 | 1.58G | #define rop3_T 0xf0 |
105 | 0 | #define rop3_T_shift 4 |
106 | | rop3_S = 0xcc, /* source */ |
107 | 2.84G | #define rop3_S 0xcc |
108 | 0 | #define rop3_S_shift 2 |
109 | | rop3_D = 0xaa, /* destination */ |
110 | 279M | #define rop3_D 0xaa |
111 | 278M | #define rop3_D_shift 1 |
112 | | rop3_1 = 0xff, |
113 | | rop3_default = rop3_T | rop3_S |
114 | | } gs_rop3_t; |
115 | | |
116 | | /* All the transformations on rop3s are designed so that */ |
117 | | /* they can also be used on lops. The only place this costs anything */ |
118 | | /* is in rop3_invert. */ |
119 | | |
120 | | /* |
121 | | * Invert an operand. |
122 | | */ |
123 | | #define rop3_invert_(op, mask, shift)\ |
124 | 0 | ( (((op) & mask) >> shift) | (((op) & (rop3_1 - mask)) << shift) |\ |
125 | 0 | ((op) & ~rop3_1) ) |
126 | | #define rop3_invert_D(op) rop3_invert_(op, rop3_D, rop3_D_shift) |
127 | 0 | #define rop3_invert_S(op) rop3_invert_(op, rop3_S, rop3_S_shift) |
128 | 0 | #define rop3_invert_T(op) rop3_invert_(op, rop3_T, rop3_T_shift) |
129 | | /* |
130 | | * Pin an operand to 0. |
131 | | */ |
132 | | #define rop3_know_0_(op, mask, shift)\ |
133 | 120M | ( (((op) & (rop3_1 - mask)) << shift) | ((op) & ~mask) ) |
134 | | #define rop3_know_D_0(op) rop3_know_0_(op, rop3_D, rop3_D_shift) |
135 | 54.2M | #define rop3_know_S_0(op) rop3_know_0_(op, rop3_S, rop3_S_shift) |
136 | 66.0M | #define rop3_know_T_0(op) rop3_know_0_(op, rop3_T, rop3_T_shift) |
137 | | /* |
138 | | * Pin an operand to 1. |
139 | | */ |
140 | | #define rop3_know_1_(op, mask, shift)\ |
141 | 46.5M | ( (((op) & mask) >> shift) | ((op) & ~(rop3_1 - mask)) ) |
142 | | #define rop3_know_D_1(op) rop3_know_1_(op, rop3_D, rop3_D_shift) |
143 | 41.6M | #define rop3_know_S_1(op) rop3_know_1_(op, rop3_S, rop3_S_shift) |
144 | 4.96M | #define rop3_know_T_1(op) rop3_know_1_(op, rop3_T, rop3_T_shift) |
145 | | /* |
146 | | * Swap S and T. |
147 | | */ |
148 | | #define rop3_swap_S_T(op)\ |
149 | 0 | ( (((op) & rop3_S & ~rop3_T) << (rop3_T_shift - rop3_S_shift)) |\ |
150 | 0 | (((op) & ~rop3_S & rop3_T) >> (rop3_T_shift - rop3_S_shift)) |\ |
151 | 0 | ((op) & ~(rop3_S ^ rop3_T)) ) |
152 | | |
153 | | #define lop_swap_S_T(op)\ |
154 | 0 | ( ((rop3_swap_S_T(op)) & ~(lop_S_transparent | lop_T_transparent)) |\ |
155 | 0 | (((op) & lop_S_transparent) ? lop_T_transparent : 0) |\ |
156 | 0 | (((op) & lop_T_transparent) ? lop_S_transparent : 0) ) |
157 | | |
158 | | /* |
159 | | * Account for transparency. |
160 | | */ |
161 | | #define rop3_use_D_when_0_(op, mask)\ |
162 | 0 | (((op) & ~(rop3_1 - mask)) | (rop3_D & ~mask)) |
163 | | #define rop3_use_D_when_1_(op, mask)\ |
164 | 0 | (((op) & ~mask) | (rop3_D & mask)) |
165 | 0 | #define rop3_use_D_when_S_0(op) rop3_use_D_when_0_(op, rop3_S) |
166 | 0 | #define rop3_use_D_when_S_1(op) rop3_use_D_when_1_(op, rop3_S) |
167 | 0 | #define rop3_use_D_when_T_0(op) rop3_use_D_when_0_(op, rop3_T) |
168 | 0 | #define rop3_use_D_when_T_1(op) rop3_use_D_when_1_(op, rop3_T) |
169 | | /* |
170 | | * Invert the result. |
171 | | */ |
172 | 274 | #define rop3_not(op) ((op) ^ rop3_1) |
173 | | /* |
174 | | * Test whether an operand is used. |
175 | | */ |
176 | | #define rop3_uses_(op, mask, shift)\ |
177 | 67.5M | ( ((((op) << shift) ^ (op)) & mask) != 0 ) |
178 | 0 | #define rop3_uses_D(op) rop3_uses_(op, rop3_D, rop3_D_shift) |
179 | 32.8M | #define rop3_uses_S(op) rop3_uses_(op, rop3_S, rop3_S_shift) |
180 | 32.8M | #define rop3_uses_T(op) rop3_uses_(op, rop3_T, rop3_T_shift) |
181 | | /* |
182 | | * Test whether an operation is idempotent, i.e., whether |
183 | | * f(D, S, T) = f(f(D, S, T), S, T) (for all D,S,T) |
184 | | * f has a range of 0 or 1, so this is equivalent to the condition that: |
185 | | * There exists no s,t, s.t. (f(0,s,t) == 1 && f(1,s,t) == 0) |
186 | | * or equivalently: |
187 | | * For all s, t, ~(f(0,s,t) == 1 && f(1,s,t) == 0 ) |
188 | | * or For all s, t, ~(f(0,s,t) == 1 && ~(f(1,s,t) == 1)) |
189 | | * or For all s, t, ~((f(0,s,t) & ~f(1,s,t)) == 1) |
190 | | * or For all s, t, ((f(0,s,t) & ~f(1,s,t)) == 0) |
191 | | * |
192 | | * We can code this as a logical operation by observing that: |
193 | | * ((~op) & rop3_D) gives us a bitfield of ~f(1,s,t) |
194 | | * (((op)<<rop_3_D_shift) & rop3_D) gives us a bitfield of f(0,s,t) |
195 | | * So |
196 | | * ((~op) & rop3_D) & ((op<<rop3_D_shift) & rop3_D) == 0 iff idempotent |
197 | | * === ((~op) & (op<<rop3_D_shift) & rop3_D) == 0 iff idempotent |
198 | | */ |
199 | | #define rop3_is_idempotent(op)\ |
200 | 556M | !( (~op) & ((op) << rop3_D_shift) & rop3_D ) |
201 | | |
202 | | /* Transparency */ |
203 | 423M | #define source_transparent_default false |
204 | 423M | #define pattern_transparent_default false |
205 | | |
206 | | /* |
207 | | * We define a logical operation as a RasterOp, transparency flags, |
208 | | * and render algorithm all packed into a single integer. |
209 | | * In principle, we should use a structure, but most C implementations |
210 | | * implement structure values very inefficiently. |
211 | | * |
212 | | * In addition, we define a "pdf14" flag which indicates that PDF |
213 | | * transparency is in effect. This doesn't change rendering in any way, |
214 | | * but does force the lop to be considered non-idempotent. The lop_pdf14 |
215 | | * bit is used for fill/stroke ops but even if this is clear, we still |
216 | | * may be painting in a transparency buffer in an idempotent mode. |
217 | | */ |
218 | 96.7M | #define lop_rop(lop) ((gs_rop3_t)((lop) & 0xff)) /* must be low-order bits */ |
219 | 172M | #define lop_S_transparent 0x100 |
220 | 1.64G | #define lop_T_transparent 0x200 |
221 | 314M | #define lop_pdf14 0x400 |
222 | | |
223 | | static inline int |
224 | | lop_sanitize(int lop) |
225 | 35.1M | { |
226 | 35.1M | int olop = lop; |
227 | | |
228 | | /* Nobble transparency using ROP conversion */ |
229 | | /* The T transparency flag only has an effect if |
230 | | * we aren't on the leading diagonal. */ |
231 | 35.1M | if (olop & lop_T_transparent && |
232 | 35.1M | ((lop & 0xF0)>>4) != (lop & 0x0F)) |
233 | 0 | lop = (lop & 0xCF) | 0x20; |
234 | 35.1M | if (olop & lop_S_transparent) |
235 | 0 | lop = (lop & 0x33) | 0x88; |
236 | | /* Preserve the PDF14 bit */ |
237 | 35.1M | lop |= (olop & lop_pdf14); |
238 | | |
239 | 35.1M | return lop; |
240 | 35.1M | } Unexecuted instantiation: imain.c:lop_sanitize Unexecuted instantiation: gconfig.c:lop_sanitize Unexecuted instantiation: gximage3.c:lop_sanitize Unexecuted instantiation: gximage4.c:lop_sanitize Unexecuted instantiation: gxmclip.c:lop_sanitize Unexecuted instantiation: gsptype1.c:lop_sanitize Unexecuted instantiation: gxp1fill.c:lop_sanitize Unexecuted instantiation: gxpcmap.c:lop_sanitize Unexecuted instantiation: gxicolor.c:lop_sanitize Unexecuted instantiation: gsdps1.c:lop_sanitize Unexecuted instantiation: gsciemap.c:lop_sanitize Unexecuted instantiation: gstrans.c:lop_sanitize Unexecuted instantiation: gximag3x.c:lop_sanitize Unexecuted instantiation: gxblend.c:lop_sanitize Unexecuted instantiation: gdevp14.c:lop_sanitize Unexecuted instantiation: gdevdevn.c:lop_sanitize Unexecuted instantiation: gsequivc.c:lop_sanitize Unexecuted instantiation: gdevdcrd.c:lop_sanitize Unexecuted instantiation: gscpixel.c:lop_sanitize Unexecuted instantiation: gdevbbox.c:lop_sanitize Unexecuted instantiation: gdevprn.c:lop_sanitize Unexecuted instantiation: gdevppla.c:lop_sanitize Unexecuted instantiation: gdevflp.c:lop_sanitize Unexecuted instantiation: gdevoflt.c:lop_sanitize Unexecuted instantiation: gdevnup.c:lop_sanitize Unexecuted instantiation: gdevsclass.c:lop_sanitize Unexecuted instantiation: gxclist.c:lop_sanitize Unexecuted instantiation: gxclpage.c:lop_sanitize Unexecuted instantiation: gxclread.c:lop_sanitize Unexecuted instantiation: gxclrect.c:lop_sanitize Unexecuted instantiation: gxclutil.c:lop_sanitize Unexecuted instantiation: gsroptab.c:lop_sanitize Unexecuted instantiation: gxclimag.c:lop_sanitize Unexecuted instantiation: gxclpath.c:lop_sanitize Unexecuted instantiation: gxdhtserial.c:lop_sanitize Unexecuted instantiation: gxclthrd.c:lop_sanitize Unexecuted instantiation: gsicc.c:lop_sanitize Unexecuted instantiation: gsicc_manage.c:lop_sanitize Unexecuted instantiation: gsicc_cache.c:lop_sanitize Unexecuted instantiation: gsicc_lcms2mt.c:lop_sanitize Unexecuted instantiation: gsicc_create.c:lop_sanitize Unexecuted instantiation: gsicc_nocm.c:lop_sanitize Unexecuted instantiation: gsicc_replacecm.c:lop_sanitize Unexecuted instantiation: gsicc_monitorcm.c:lop_sanitize Unexecuted instantiation: gsicc_blacktext.c:lop_sanitize Unexecuted instantiation: gdevbmp.c:lop_sanitize Unexecuted instantiation: gdevbmpc.c:lop_sanitize Unexecuted instantiation: gdevpccm.c:lop_sanitize Unexecuted instantiation: gdevcups.c:lop_sanitize Unexecuted instantiation: gdevpdf.c:lop_sanitize Unexecuted instantiation: gdevpdfb.c:lop_sanitize Unexecuted instantiation: gdevpdfc.c:lop_sanitize Unexecuted instantiation: gdevpdfd.c:lop_sanitize Unexecuted instantiation: gdevpdfe.c:lop_sanitize Unexecuted instantiation: gdevpdfg.c:lop_sanitize Unexecuted instantiation: gdevpdfi.c:lop_sanitize Unexecuted instantiation: gdevpdfj.c:lop_sanitize Unexecuted instantiation: gdevpdfk.c:lop_sanitize Unexecuted instantiation: gdevpdfm.c:lop_sanitize Unexecuted instantiation: gdevpdfo.c:lop_sanitize Unexecuted instantiation: gdevpdfp.c:lop_sanitize Unexecuted instantiation: gdevpdft.c:lop_sanitize Unexecuted instantiation: gdevpdfr.c:lop_sanitize Unexecuted instantiation: gdevpdfu.c:lop_sanitize Unexecuted instantiation: gdevpdfv.c:lop_sanitize Unexecuted instantiation: gdevpsdi.c:lop_sanitize Unexecuted instantiation: gdevpsdp.c:lop_sanitize Unexecuted instantiation: gdevpsds.c:lop_sanitize Unexecuted instantiation: gdevpsdu.c:lop_sanitize Unexecuted instantiation: gdevvec.c:lop_sanitize Unexecuted instantiation: gdevpdt.c:lop_sanitize Unexecuted instantiation: gdevpdtd.c:lop_sanitize Unexecuted instantiation: gdevpdtf.c:lop_sanitize Unexecuted instantiation: gdevpdti.c:lop_sanitize Unexecuted instantiation: gdevpdts.c:lop_sanitize Unexecuted instantiation: gdevpdtt.c:lop_sanitize Unexecuted instantiation: gdevpdtw.c:lop_sanitize Unexecuted instantiation: gxfcopy.c:lop_sanitize Unexecuted instantiation: gdevfax.c:lop_sanitize Unexecuted instantiation: gdevdjet.c:lop_sanitize Unexecuted instantiation: gdevdljm.c:lop_sanitize Unexecuted instantiation: gdevpcl.c:lop_sanitize Unexecuted instantiation: gdevpcl3.c:lop_sanitize Unexecuted instantiation: pclcap.c:lop_sanitize Unexecuted instantiation: gdevpbm.c:lop_sanitize Unexecuted instantiation: gdevmpla.c:lop_sanitize Unexecuted instantiation: gdevpng.c:lop_sanitize Unexecuted instantiation: gdevpsd.c:lop_sanitize Unexecuted instantiation: gdevpx.c:lop_sanitize Unexecuted instantiation: gdevpxut.c:lop_sanitize Unexecuted instantiation: gdevtsep.c:lop_sanitize Unexecuted instantiation: gdevtifs.c:lop_sanitize Unexecuted instantiation: gdevupd.c:lop_sanitize Unexecuted instantiation: gdevxps.c:lop_sanitize Unexecuted instantiation: gdevkrnlsclass.c:lop_sanitize Unexecuted instantiation: gschar.c:lop_sanitize Unexecuted instantiation: gscolor.c:lop_sanitize Unexecuted instantiation: gscoord.c:lop_sanitize Unexecuted instantiation: gscspace.c:lop_sanitize Unexecuted instantiation: gsovrc.c:lop_sanitize Unexecuted instantiation: gxoprect.c:lop_sanitize Unexecuted instantiation: gsdevice.c:lop_sanitize Unexecuted instantiation: gsdparam.c:lop_sanitize Unexecuted instantiation: gsfont.c:lop_sanitize Unexecuted instantiation: gsht.c:lop_sanitize Unexecuted instantiation: gshtscr.c:lop_sanitize Unexecuted instantiation: gsimage.c:lop_sanitize Unexecuted instantiation: gsgstate.c:lop_sanitize Unexecuted instantiation: gsline.c:lop_sanitize Unexecuted instantiation: gspaint.c:lop_sanitize Unexecuted instantiation: gspath.c:lop_sanitize Unexecuted instantiation: gsstate.c:lop_sanitize Unexecuted instantiation: gstext.c:lop_sanitize Unexecuted instantiation: gxfapi.c:lop_sanitize Unexecuted instantiation: write_t2.c:lop_sanitize Unexecuted instantiation: gxccache.c:lop_sanitize Unexecuted instantiation: gxccman.c:lop_sanitize Unexecuted instantiation: gxchar.c:lop_sanitize Unexecuted instantiation: gxcht.c:lop_sanitize Unexecuted instantiation: gxclip.c:lop_sanitize Unexecuted instantiation: gxcmap.c:lop_sanitize Unexecuted instantiation: gxcpath.c:lop_sanitize Unexecuted instantiation: gxdcconv.c:lop_sanitize Unexecuted instantiation: gxdcolor.c:lop_sanitize Unexecuted instantiation: gxhldevc.c:lop_sanitize Unexecuted instantiation: gxfill.c:lop_sanitize Unexecuted instantiation: gxht.c:lop_sanitize Unexecuted instantiation: gxht_thresh.c:lop_sanitize Unexecuted instantiation: gxidata.c:lop_sanitize Unexecuted instantiation: gxifast.c:lop_sanitize Unexecuted instantiation: gximage.c:lop_sanitize Unexecuted instantiation: gximdecode.c:lop_sanitize Unexecuted instantiation: gximage1.c:lop_sanitize Unexecuted instantiation: gximono.c:lop_sanitize Line | Count | Source | 225 | 2.28M | { | 226 | 2.28M | int olop = lop; | 227 | | | 228 | | /* Nobble transparency using ROP conversion */ | 229 | | /* The T transparency flag only has an effect if | 230 | | * we aren't on the leading diagonal. */ | 231 | 2.28M | if (olop & lop_T_transparent && | 232 | 2.28M | ((lop & 0xF0)>>4) != (lop & 0x0F)) | 233 | 0 | lop = (lop & 0xCF) | 0x20; | 234 | 2.28M | if (olop & lop_S_transparent) | 235 | 0 | lop = (lop & 0x33) | 0x88; | 236 | | /* Preserve the PDF14 bit */ | 237 | 2.28M | lop |= (olop & lop_pdf14); | 238 | | | 239 | 2.28M | return lop; | 240 | 2.28M | } |
Unexecuted instantiation: gximask.c:lop_sanitize Unexecuted instantiation: gxi12bit.c:lop_sanitize Unexecuted instantiation: gxi16bit.c:lop_sanitize Unexecuted instantiation: gxiscale.c:lop_sanitize Unexecuted instantiation: gxpaint.c:lop_sanitize Unexecuted instantiation: gxpcopy.c:lop_sanitize Unexecuted instantiation: gxsample.c:lop_sanitize Unexecuted instantiation: gxstroke.c:lop_sanitize Unexecuted instantiation: gdevabuf.c:lop_sanitize Unexecuted instantiation: gdevdbit.c:lop_sanitize Unexecuted instantiation: gdevddrw.c:lop_sanitize Unexecuted instantiation: gdevdflt.c:lop_sanitize Unexecuted instantiation: gdevdgbr.c:lop_sanitize Unexecuted instantiation: gdevnfwd.c:lop_sanitize Unexecuted instantiation: gdevmem.c:lop_sanitize Unexecuted instantiation: gdevplnx.c:lop_sanitize Unexecuted instantiation: gdevm1.c:lop_sanitize Unexecuted instantiation: gdevm2.c:lop_sanitize Unexecuted instantiation: gdevm4.c:lop_sanitize Unexecuted instantiation: gdevm8.c:lop_sanitize Unexecuted instantiation: gdevm16.c:lop_sanitize Unexecuted instantiation: gdevm24.c:lop_sanitize Unexecuted instantiation: gdevm32.c:lop_sanitize Unexecuted instantiation: gdevm40.c:lop_sanitize Unexecuted instantiation: gdevm48.c:lop_sanitize Unexecuted instantiation: gdevm56.c:lop_sanitize Unexecuted instantiation: gdevm64.c:lop_sanitize Unexecuted instantiation: gdevmx.c:lop_sanitize Unexecuted instantiation: gdevdsha.c:lop_sanitize Unexecuted instantiation: gxscanc.c:lop_sanitize Unexecuted instantiation: gdevdrop.c:lop_sanitize Unexecuted instantiation: gdevmr1.c:lop_sanitize Unexecuted instantiation: gdevmr2n.c:lop_sanitize Unexecuted instantiation: gdevmr8n.c:lop_sanitize Unexecuted instantiation: gdevrops.c:lop_sanitize Unexecuted instantiation: gsrop.c:lop_sanitize Unexecuted instantiation: zcolor1.c:lop_sanitize Unexecuted instantiation: zht1.c:lop_sanitize Unexecuted instantiation: zupath.c:lop_sanitize Unexecuted instantiation: gdevhit.c:lop_sanitize Unexecuted instantiation: zdps1.c:lop_sanitize Unexecuted instantiation: zchar1.c:lop_sanitize Unexecuted instantiation: zcharout.c:lop_sanitize Unexecuted instantiation: zfont1.c:lop_sanitize Unexecuted instantiation: zusparam.c:lop_sanitize Unexecuted instantiation: zchar42.c:lop_sanitize Unexecuted instantiation: zfont0.c:lop_sanitize Unexecuted instantiation: zfdctd.c:lop_sanitize Unexecuted instantiation: zdevice2.c:lop_sanitize Unexecuted instantiation: zpcolor.c:lop_sanitize Unexecuted instantiation: idisp.c:lop_sanitize Unexecuted instantiation: psapi.c:lop_sanitize Unexecuted instantiation: zfileio.c:lop_sanitize Unexecuted instantiation: zbfont.c:lop_sanitize Unexecuted instantiation: zchar.c:lop_sanitize Unexecuted instantiation: zcolor.c:lop_sanitize Unexecuted instantiation: zdevice.c:lop_sanitize Unexecuted instantiation: zfont.c:lop_sanitize Unexecuted instantiation: zht.c:lop_sanitize Unexecuted instantiation: zimage.c:lop_sanitize Unexecuted instantiation: zfapi.c:lop_sanitize Unexecuted instantiation: zcsindex.c:lop_sanitize Unexecuted instantiation: zht2.c:lop_sanitize Unexecuted instantiation: zcssepr.c:lop_sanitize Unexecuted instantiation: zfunc4.c:lop_sanitize Unexecuted instantiation: zform.c:lop_sanitize Unexecuted instantiation: zimage3.c:lop_sanitize Unexecuted instantiation: zicc.c:lop_sanitize Unexecuted instantiation: ztrans.c:lop_sanitize Unexecuted instantiation: zpdfops.c:lop_sanitize Unexecuted instantiation: pdf_loop_detect.c:lop_sanitize Unexecuted instantiation: ghostpdf.c:lop_sanitize Unexecuted instantiation: pdf_dict.c:lop_sanitize Unexecuted instantiation: pdf_array.c:lop_sanitize Unexecuted instantiation: pdf_xref.c:lop_sanitize Unexecuted instantiation: pdf_int.c:lop_sanitize Unexecuted instantiation: pdf_file.c:lop_sanitize Unexecuted instantiation: pdf_path.c:lop_sanitize Unexecuted instantiation: pdf_colour.c:lop_sanitize Unexecuted instantiation: pdf_pattern.c:lop_sanitize Unexecuted instantiation: pdf_gstate.c:lop_sanitize Unexecuted instantiation: pdf_stack.c:lop_sanitize Unexecuted instantiation: pdf_image.c:lop_sanitize Unexecuted instantiation: pdf_page.c:lop_sanitize Unexecuted instantiation: pdf_annot.c:lop_sanitize Unexecuted instantiation: pdf_mark.c:lop_sanitize Unexecuted instantiation: pdf_font.c:lop_sanitize Unexecuted instantiation: pdf_font0.c:lop_sanitize Unexecuted instantiation: pdf_ciddec.c:lop_sanitize Unexecuted instantiation: pdf_font1.c:lop_sanitize Unexecuted instantiation: pdf_font1C.c:lop_sanitize Unexecuted instantiation: pdf_fontps.c:lop_sanitize Unexecuted instantiation: pdf_font3.c:lop_sanitize Unexecuted instantiation: pdf_fontTT.c:lop_sanitize Unexecuted instantiation: pdf_font11.c:lop_sanitize Unexecuted instantiation: pdf_cmap.c:lop_sanitize Unexecuted instantiation: pdf_fmap.c:lop_sanitize Unexecuted instantiation: pdf_text.c:lop_sanitize Unexecuted instantiation: pdf_shading.c:lop_sanitize Unexecuted instantiation: pdf_func.c:lop_sanitize Unexecuted instantiation: pdf_trans.c:lop_sanitize Unexecuted instantiation: pdf_device.c:lop_sanitize Unexecuted instantiation: pdf_misc.c:lop_sanitize Unexecuted instantiation: pdf_optcontent.c:lop_sanitize Unexecuted instantiation: pdf_check.c:lop_sanitize Unexecuted instantiation: pdf_sec.c:lop_sanitize Unexecuted instantiation: pdf_utf8.c:lop_sanitize Unexecuted instantiation: pdf_deref.c:lop_sanitize Unexecuted instantiation: pdf_repair.c:lop_sanitize Unexecuted instantiation: pdf_obj.c:lop_sanitize Unexecuted instantiation: pdf_doc.c:lop_sanitize Unexecuted instantiation: imainarg.c:lop_sanitize Unexecuted instantiation: gsclipsr.c:lop_sanitize Unexecuted instantiation: gscdevn.c:lop_sanitize Unexecuted instantiation: gxdevndi.c:lop_sanitize Unexecuted instantiation: gxclipm.c:lop_sanitize Unexecuted instantiation: gscolor3.c:lop_sanitize Unexecuted instantiation: gsptype2.c:lop_sanitize Unexecuted instantiation: gsshade.c:lop_sanitize Unexecuted instantiation: gxshade.c:lop_sanitize Unexecuted instantiation: gxshade1.c:lop_sanitize Unexecuted instantiation: gxshade4.c:lop_sanitize Unexecuted instantiation: gxshade6.c:lop_sanitize Unexecuted instantiation: gscolor1.c:lop_sanitize Unexecuted instantiation: gsht1.c:lop_sanitize Unexecuted instantiation: gscolor2.c:lop_sanitize Unexecuted instantiation: gspcolor.c:lop_sanitize Unexecuted instantiation: gxclip2.c:lop_sanitize Unexecuted instantiation: gspath1.c:lop_sanitize Unexecuted instantiation: gstype42.c:lop_sanitize Unexecuted instantiation: gxchrout.c:lop_sanitize Unexecuted instantiation: gxttfb.c:lop_sanitize Unexecuted instantiation: gzspotan.c:lop_sanitize Unexecuted instantiation: gscie.c:lop_sanitize Unexecuted instantiation: gscsepr.c:lop_sanitize Unexecuted instantiation: gxblend1.c:lop_sanitize Unexecuted instantiation: gxdownscale.c:lop_sanitize Unexecuted instantiation: gdevepo.c:lop_sanitize Unexecuted instantiation: gxclbits.c:lop_sanitize Unexecuted instantiation: gxclrast.c:lop_sanitize Line | Count | Source | 225 | 32.8M | { | 226 | 32.8M | int olop = lop; | 227 | | | 228 | | /* Nobble transparency using ROP conversion */ | 229 | | /* The T transparency flag only has an effect if | 230 | | * we aren't on the leading diagonal. */ | 231 | 32.8M | if (olop & lop_T_transparent && | 232 | 32.8M | ((lop & 0xF0)>>4) != (lop & 0x0F)) | 233 | 0 | lop = (lop & 0xCF) | 0x20; | 234 | 32.8M | if (olop & lop_S_transparent) | 235 | 0 | lop = (lop & 0x33) | 0x88; | 236 | | /* Preserve the PDF14 bit */ | 237 | 32.8M | lop |= (olop & lop_pdf14); | 238 | | | 239 | 32.8M | return lop; | 240 | 32.8M | } |
Unexecuted instantiation: gschar0.c:lop_sanitize Unexecuted instantiation: gsfont0.c:lop_sanitize Unexecuted instantiation: gstype1.c:lop_sanitize Unexecuted instantiation: gxtype1.c:lop_sanitize Unexecuted instantiation: gstype2.c:lop_sanitize Unexecuted instantiation: gsicc_profilecache.c:lop_sanitize Unexecuted instantiation: gdevpdtb.c:lop_sanitize Unexecuted instantiation: gdevpdtc.c:lop_sanitize Unexecuted instantiation: gdevpdte.c:lop_sanitize Unexecuted instantiation: gdevpsfx.c:lop_sanitize Unexecuted instantiation: gstiffio.c:lop_sanitize Unexecuted instantiation: gdeveprn.c:lop_sanitize Unexecuted instantiation: eprnparm.c:lop_sanitize Unexecuted instantiation: eprnrend.c:lop_sanitize Unexecuted instantiation: eprnfs.c:lop_sanitize Unexecuted instantiation: gscicach.c:lop_sanitize Unexecuted instantiation: gsdevmem.c:lop_sanitize Unexecuted instantiation: gxacpath.c:lop_sanitize Unexecuted instantiation: gxpdash.c:lop_sanitize Unexecuted instantiation: pdf_fapi.c:lop_sanitize Unexecuted instantiation: gscscie.c:lop_sanitize |
241 | | |
242 | | typedef uint gs_logical_operation_t; |
243 | | |
244 | | #define lop_default\ |
245 | 457M | (rop3_default |\ |
246 | 457M | (source_transparent_default ? lop_S_transparent : 0) |\ |
247 | 457M | (pattern_transparent_default ? lop_T_transparent : 0)) |
248 | | |
249 | | /* Test whether a logical operation uses S or T. */ |
250 | | #define lop_uses_S(lop)\ |
251 | 0 | (rop3_uses_S(lop) || ((lop) & (lop_S_transparent | lop_T_transparent))) |
252 | | #define lop_uses_T(lop)\ |
253 | 0 | (rop3_uses_T(lop) || ((lop) & lop_T_transparent)) |
254 | | /* Test whether a logical operation just sets D = x if y = 0. */ |
255 | | #define lop_no_T_is_S(lop)\ |
256 | | (((lop) & (lop_S_transparent | (rop3_1 - rop3_T))) == (rop3_S & ~rop3_T)) |
257 | | #define lop_no_S_is_T(lop)\ |
258 | 1.50G | (((lop) & (lop_T_transparent | (rop3_1 - rop3_S))) == (rop3_T & ~rop3_S)) |
259 | | /* Test whether a logical operation is idempotent. */ |
260 | 278M | #define lop_is_idempotent(lop) (rop3_is_idempotent(lop) && !(lop & lop_pdf14)) |
261 | | |
262 | | /* |
263 | | * Define the logical operation versions of some RasterOp transformations. |
264 | | * Note that these also affect the transparency flags. |
265 | | */ |
266 | | #define lop_know_S_0(lop)\ |
267 | 53.7M | (rop3_know_S_0(lop) & ~lop_S_transparent) |
268 | | #define lop_know_T_0(lop)\ |
269 | 0 | (rop3_know_T_0(lop) & ~lop_T_transparent) |
270 | | #define lop_know_S_1(lop)\ |
271 | 41.6M | (lop & lop_S_transparent ? rop3_D : rop3_know_S_1(lop)) |
272 | | #define lop_know_T_1(lop)\ |
273 | 0 | (lop & lop_T_transparent ? rop3_D : rop3_know_T_1(lop)) |
274 | | |
275 | | /* Define the interface to the table of 256 RasterOp procedures. */ |
276 | | typedef unsigned long rop_operand; |
277 | | typedef rop_operand (*rop_proc)(rop_operand D, rop_operand S, rop_operand T); |
278 | | |
279 | | /* Define the table of operand usage by the 256 RasterOp operations. */ |
280 | | typedef enum { |
281 | | rop_usage_none = 0, |
282 | | rop_usage_D = 1, |
283 | | rop_usage_S = 2, |
284 | | rop_usage_DS = 3, |
285 | | rop_usage_T = 4, |
286 | | rop_usage_DT = 5, |
287 | | rop_usage_ST = 6, |
288 | | rop_usage_DST = 7 |
289 | | } rop_usage_t; |
290 | | |
291 | | /* Define the table of RasterOp implementation procedures. */ |
292 | | extern const rop_proc rop_proc_table[256]; |
293 | | |
294 | | /* Define the table of RasterOp operand usage. */ |
295 | | extern const byte /*rop_usage_t*/ rop_usage_table[256]; |
296 | | |
297 | | /* Rather than just doing one raster operation at a time (which costs us |
298 | | * a significant amount of time due to function call overheads), we attempt |
299 | | * to ameliorate this by doing runs of raster operations at a time. |
300 | | */ |
301 | | |
302 | | /* The raster op run operator type */ |
303 | | typedef struct rop_run_op_s rop_run_op; |
304 | | |
305 | | /* The contents of these structs should really be private, but we define them |
306 | | * in the open here to allow us to easily allocate the space on the stack |
307 | | * and thus avoid costly malloc/free overheads. */ |
308 | | typedef union rop_source_s { |
309 | | struct { |
310 | | const byte *ptr; |
311 | | int pos; |
312 | | } b; |
313 | | rop_operand c; |
314 | | } rop_source; |
315 | | |
316 | | /* |
317 | | scolors and tcolors in the following structure should really be |
318 | | gx_color_index *, but to do that would require gxcindex.h being |
319 | | included everywhere this header is, and it's not. Including it |
320 | | at the top of this header runs other things into problems, so |
321 | | living with void *'s until we can get the header inclusion |
322 | | sorted. |
323 | | */ |
324 | | struct rop_run_op_s { |
325 | | void (*run)(rop_run_op *, byte *dest, int len); |
326 | | void (*runswap)(rop_run_op *, byte *dest, int len); |
327 | | rop_source s; |
328 | | rop_source t; |
329 | | int rop; |
330 | | byte depth; |
331 | | byte flags; |
332 | | byte mul; |
333 | | byte dpos; |
334 | | const void *scolors; |
335 | | const void *tcolors; |
336 | | void (*release)(rop_run_op *); |
337 | | void *opaque; |
338 | | }; |
339 | | |
340 | | /* Flags for passing into rop_get_run_op */ |
341 | | enum { |
342 | | rop_s_constant = 1, |
343 | | rop_t_constant = 2, |
344 | | rop_s_1bit = 4, |
345 | | rop_t_1bit = 8 |
346 | | }; |
347 | | |
348 | | /* To use a rop_run_op, allocate it on the stack, then (if T or S are constant) |
349 | | * call one of: |
350 | | */ |
351 | | void rop_set_s_constant(rop_run_op *op, int s); |
352 | | void rop_set_t_constant(rop_run_op *op, int t); |
353 | | |
354 | | /* Then call rop_get_run_op with a pointer to it to fill it in with details |
355 | | * of an implementer. If you're lucky (doing a popular rop) you'll get an |
356 | | * optimised implementation. If you're not, you'll get a general purpose |
357 | | * slow rop. You will always get an implementation of some kind though. |
358 | | * |
359 | | * You should logical or together the flags - this tells the routine whether |
360 | | * s and t are constant, or will be varying across the run. |
361 | | * |
362 | | * If this function returns non zero, the ROP has been optimised out. |
363 | | */ |
364 | | int rop_get_run_op(rop_run_op *op, int rop, int depth, int flags); |
365 | | |
366 | | /* Next, (for non-constant S or T) you should set the values of S and T. |
367 | | * (Constant values were handled earlier, remember?) Each of these can |
368 | | * either be a constant value, or a pointer to a run of bytes. It is the |
369 | | * callers responsibility to set these in the correct way (corresponding |
370 | | * to the flags passed into the call to rop_get_run_op. |
371 | | * |
372 | | * For cases where depth < 8, and a bitmap is used, we have to specify the |
373 | | * start bit position within the byte. (All data in rop bitmaps is considered |
374 | | * to be bigendian). */ |
375 | | void rop_set_s_constant(rop_run_op *op, int s); |
376 | | void rop_set_s_bitmap(rop_run_op *op, const byte *s); |
377 | | void rop_set_s_bitmap_subbyte(rop_run_op *op, const byte *s, int startbitpos); |
378 | | void rop_set_s_colors(rop_run_op *op, const byte *scolors); |
379 | | void rop_set_t_bitmap(rop_run_op *op, const byte *t); |
380 | | void rop_set_t_bitmap_subbyte(rop_run_op *op, const byte *s, int startbitpos); |
381 | | void rop_set_t_colors(rop_run_op *op, const byte *scolors); |
382 | | |
383 | | /* At last we call the rop_run function itself. (This can happen multiple |
384 | | * times, perhaps once per scanline, with any required calls to the |
385 | | * rop_set_{s,t} functions.) The length field is given in terms of 'number |
386 | | * of depth bits'. |
387 | | * |
388 | | * This version is for the depth >= 8 case. */ |
389 | | void rop_run(rop_run_op *op, byte *d, int len); |
390 | | |
391 | | /* This version tells us how many bits to skip over in the first byte, and |
392 | | * is therefore only useful in the depth < 8 case. */ |
393 | | void rop_run_subbyte(rop_run_op *op, byte *d, int startbitpos, int len); |
394 | | |
395 | | /* And finally we release our rop (in case any allocation was done). */ |
396 | | void rop_release_run_op(rop_run_op *op); |
397 | | |
398 | | /* We offer some of these functions implemented as macros for speed */ |
399 | 0 | #define rop_set_s_constant(OP,S) ((OP)->s.c = (S)) |
400 | 0 | #define rop_set_s_bitmap(OP,S) ((OP)->s.b.ptr = (S)) |
401 | 62.8M | #define rop_set_s_bitmap_subbyte(OP,S,B) (((OP)->s.b.ptr = (S)),((OP)->s.b.pos = (B))) |
402 | 0 | #define rop_set_s_colors(OP,S) ((OP)->scolors = (const byte *)(S)) |
403 | 0 | #define rop_set_t_constant(OP,T) ((OP)->t.c = (T)) |
404 | 0 | #define rop_set_t_bitmap(OP,T) ((OP)->t.b.ptr = (T)) |
405 | 0 | #define rop_set_t_bitmap_subbyte(OP,T,B) (((OP)->t.b.ptr = (T)),((OP)->t.b.pos = (B))) |
406 | 0 | #define rop_set_t_colors(OP,T) ((OP)->tcolors = (const byte *)(T)) |
407 | 0 | #define rop_run(OP,D,LEN) (((OP)->run)(OP,D,LEN)) |
408 | 62.8M | #define rop_run_subbyte(OP,D,S,L) (((OP)->dpos=(byte)S),((OP)->run)(OP,D,L)) |
409 | 32.8M | #define rop_release_run_op(OP) do { rop_run_op *OP2 = (OP); \ |
410 | 32.8M | if (OP2->release) OP2->release(OP2); \ |
411 | 32.8M | } while (0==1) |
412 | | |
413 | | #ifdef _MSC_VER /* Are we using MSVC? */ |
414 | | # if defined(_M_IX86) || defined(_M_AMD64) /* Are we on an x86? */ |
415 | | # if MSC_VER >= 1400 /* old versions have _byteswap_ulong() in stdlib.h */ |
416 | | # include "intrin.h" |
417 | | # endif |
418 | | # define ENDIAN_SWAP_INT _byteswap_ulong |
419 | | #endif |
420 | | |
421 | | #elif defined(HAVE_BSWAP32) |
422 | | |
423 | 806M | #define ENDIAN_SWAP_INT __builtin_bswap32 |
424 | | |
425 | | #elif defined(HAVE_BYTESWAP_H) |
426 | | |
427 | | #include <byteswap.h> |
428 | | #define ENDIAN_SWAP_INT bswap_32 |
429 | | |
430 | | #endif |
431 | | |
432 | | #endif /* gsropt_INCLUDED */ |