comparison mupdf-source/source/fitz/draw-affine.c @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 // Copyright (C) 2004-2025 Artifex Software, Inc.
2 //
3 // This file is part of MuPDF.
4 //
5 // MuPDF is free software: you can redistribute it and/or modify it under the
6 // terms of the GNU Affero General Public License as published by the Free
7 // Software Foundation, either version 3 of the License, or (at your option)
8 // any later version.
9 //
10 // MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY
11 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Affero General Public License
16 // along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html>
17 //
18 // Alternative licensing terms are available from the licensor.
19 // For commercial licensing, see <https://www.artifex.com/> or contact
20 // Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
21 // CA 94129, USA, for further information.
22
23 #include "mupdf/fitz.h"
24 #include "draw-imp.h"
25
26 #include <math.h>
27 #include <float.h>
28 #include <assert.h>
29
30 typedef int64_t affint;
31
32 /* Number of fraction bits for fixed point math */
33 #define PREC 14
34 #define ONE (((affint)1)<<PREC)
35 #define MASK (ONE-1)
36 #define HALF (((affint)1)<<(PREC-1))
37 #define LIMIT (((affint)1)<<((sizeof(affint)*8-1)-PREC))
38
39 typedef unsigned char byte;
40
41 typedef void (paintfn_t)(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop);
42
43 static fz_forceinline int lerp(int a, int b, int f)
44 {
45 return a + (((b - a) * f) >> PREC);
46 }
47
48 static fz_forceinline int bilerp(int a, int b, int c, int d, int uf, int vf)
49 {
50 return lerp(lerp(a, b, uf), lerp(c, d, uf), vf);
51 }
52
53 static fz_forceinline const byte *sample_nearest(const byte *s, affint w, affint h, ptrdiff_t str, int n, affint u, affint v)
54 {
55 if (u < 0) u = 0;
56 if (v < 0) v = 0;
57 if (u >= (w>>PREC)) u = (w>>PREC) - 1;
58 if (v >= (h>>PREC)) v = (h>>PREC) - 1;
59 return s + v * str + u * n;
60 }
61
62 /* Blend premultiplied source image in constant alpha over destination */
63
64 static fz_forceinline void
65 template_affine_alpha_N_lerp(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
66 {
67 int k;
68
69 do
70 {
71 if (u + HALF >= 0 && u + ONE < sw && v + HALF >= 0 && v + ONE < sh)
72 {
73 affint ui = u >> PREC;
74 affint vi = v >> PREC;
75 int uf = u & MASK;
76 int vf = v & MASK;
77 const byte *a = sample_nearest(sp, sw, sh, ss, sn1+sa, ui, vi);
78 const byte *b = sample_nearest(sp, sw, sh, ss, sn1+sa, ui+1, vi);
79 const byte *c = sample_nearest(sp, sw, sh, ss, sn1+sa, ui, vi+1);
80 const byte *d = sample_nearest(sp, sw, sh, ss, sn1+sa, ui+1, vi+1);
81 int x = sa ? bilerp(a[sn1], b[sn1], c[sn1], d[sn1], uf, vf) : 255;
82 int xa = sa ? fz_mul255(x, alpha) : alpha;
83 if (xa != 0)
84 {
85 int t = 255 - xa;
86 for (k = 0; k < sn1; k++)
87 {
88 int z = bilerp(a[k], b[k], c[k], d[k], uf, vf);
89 dp[k] = fz_mul255(z, alpha) + fz_mul255(dp[k], t);
90 }
91 for (; k < dn1; k++)
92 dp[k] = 0;
93 if (da)
94 dp[dn1] = xa + fz_mul255(dp[dn1], t);
95 if (hp)
96 hp[0] = x + fz_mul255(hp[0], 255 - x);
97 if (gp)
98 gp[0] = xa + fz_mul255(gp[0], t);
99 }
100 }
101 dp += dn1+da;
102 if (hp)
103 hp++;
104 if (gp)
105 gp++;
106 u += fa;
107 v += fb;
108 }
109 while (--w);
110 }
111
112 static fz_forceinline void
113 template_affine_alpha_N_lerp_op(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
114 {
115 int k;
116
117 do
118 {
119 if (u + HALF >= 0 && u + ONE < sw && v + HALF >= 0 && v + ONE < sh)
120 {
121 affint ui = u >> PREC;
122 affint vi = v >> PREC;
123 int uf = u & MASK;
124 int vf = v & MASK;
125 const byte *a = sample_nearest(sp, sw, sh, ss, sn1+sa, ui, vi);
126 const byte *b = sample_nearest(sp, sw, sh, ss, sn1+sa, ui+1, vi);
127 const byte *c = sample_nearest(sp, sw, sh, ss, sn1+sa, ui, vi+1);
128 const byte *d = sample_nearest(sp, sw, sh, ss, sn1+sa, ui+1, vi+1);
129 int x = sa ? bilerp(a[sn1], b[sn1], c[sn1], d[sn1], uf, vf) : 255;
130 int xa = sa ? fz_mul255(x, alpha) : alpha;
131 if (xa != 0)
132 {
133 int t = 255 - xa;
134 for (k = 0; k < sn1; k++)
135 {
136 if (fz_overprint_component(eop, k))
137 {
138 int z = bilerp(a[k], b[k], c[k], d[k], uf, vf);
139 dp[k] = fz_mul255(z, alpha) + fz_mul255(dp[k], t);
140 }
141 }
142 for (; k < dn1; k++)
143 if (fz_overprint_component(eop, k))
144 dp[k] = 0;
145 if (da)
146 dp[dn1] = xa + fz_mul255(dp[dn1], t);
147 if (hp)
148 hp[0] = x + fz_mul255(hp[0], 255-x);
149 if (gp)
150 gp[0] = xa + fz_mul255(gp[0], t);
151 }
152 }
153 dp += dn1+da;
154 if (hp)
155 hp++;
156 if (gp)
157 gp++;
158 u += fa;
159 v += fb;
160 }
161 while (--w);
162 }
163
164 /* Special case code for gray -> rgb */
165 static fz_forceinline void
166 template_affine_alpha_g2rgb_lerp(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int alpha, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
167 {
168 do
169 {
170 if (u + HALF >= 0 && u + ONE < sw && v + HALF >= 0 && v + ONE < sh)
171 {
172 affint ui = u >> PREC;
173 affint vi = v >> PREC;
174 int uf = u & MASK;
175 int vf = v & MASK;
176 const byte *a = sample_nearest(sp, sw, sh, ss, 1+sa, ui, vi);
177 const byte *b = sample_nearest(sp, sw, sh, ss, 1+sa, ui+1, vi);
178 const byte *c = sample_nearest(sp, sw, sh, ss, 1+sa, ui, vi+1);
179 const byte *d = sample_nearest(sp, sw, sh, ss, 1+sa, ui+1, vi+1);
180 int y = sa ? bilerp(a[1], b[1], c[1], d[1], uf, vf) : 255;
181 int ya = (sa ? fz_mul255(y, alpha) : alpha);
182 if (ya != 0)
183 {
184 int x = bilerp(a[0], b[0], c[0], d[0], uf, vf);
185 int t = 255 - ya;
186 x = fz_mul255(x, alpha);
187 dp[0] = x + fz_mul255(dp[0], t);
188 dp[1] = x + fz_mul255(dp[1], t);
189 dp[2] = x + fz_mul255(dp[2], t);
190 if (da)
191 dp[3] = ya + fz_mul255(dp[3], t);
192 if (hp)
193 hp[0] = y + fz_mul255(hp[0], 255 - y);
194 if (gp)
195 gp[0] = ya + fz_mul255(gp[0], t);
196 }
197 }
198 dp += 3+da;
199 if (hp)
200 hp++;
201 if (gp)
202 gp++;
203 u += fa;
204 v += fb;
205 }
206 while (--w);
207 }
208
209 static fz_forceinline void
210 template_affine_alpha_N_near_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
211 {
212 int k;
213 affint ui = u >> PREC;
214 TRACK_FN();
215 if (ui < 0 || ui >= sw)
216 return;
217 sp += ui * (sn1+sa);
218 do
219 {
220 affint vi = v >> PREC;
221 if (vi >= 0 && vi < sh)
222 {
223 const byte *sample = sp + (vi * ss);
224 int a = sa ? sample[sn1] : 255;
225 int aa = (sa ? fz_mul255(a, alpha) : alpha);
226 if (aa != 0)
227 {
228 int t = 255 - aa;
229 for (k = 0; k < sn1; k++)
230 dp[k] = fz_mul255(sample[k], alpha) + fz_mul255(dp[k], t);
231 for (; k < dn1; k++)
232 dp[k] = 0;
233 if (da)
234 dp[dn1] = aa + fz_mul255(dp[dn1], t);
235 if (hp)
236 hp[0] = a + fz_mul255(hp[0], 255 - a);
237 if (gp)
238 gp[0] = aa + fz_mul255(gp[0], t);
239 }
240 }
241 dp += dn1+da;
242 if (hp)
243 hp++;
244 if (gp)
245 gp++;
246 v += fb;
247 }
248 while (--w);
249 }
250
251 static fz_forceinline void
252 template_affine_alpha_N_near_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
253 {
254 int k;
255 affint vi = v >> PREC;
256 if (vi < 0 || vi >= sh)
257 return;
258 sp += vi * ss;
259 do
260 {
261 affint ui = u >> PREC;
262 if (ui >= 0 && ui < sw)
263 {
264 const byte *sample = sp + (ui * (sn1+sa));
265 int a = sa ? sample[sn1] : 255;
266 int aa = (sa ? fz_mul255(a, alpha) : alpha);
267 if (aa != 0)
268 {
269 int t = 255 - aa;
270 for (k = 0; k < sn1; k++)
271 dp[k] = fz_mul255(sample[k], alpha) + fz_mul255(dp[k], t);
272 for (; k < dn1; k++)
273 dp[k] = 0;
274 if (da)
275 dp[dn1] = aa + fz_mul255(dp[dn1], t);
276 if (hp)
277 hp[0] = a + fz_mul255(hp[0], 255 - a);
278 if (gp)
279 gp[0] = aa + fz_mul255(gp[0], t);
280 }
281 }
282 dp += dn1+da;
283 if (hp)
284 hp++;
285 if (gp)
286 gp++;
287 u += fa;
288 }
289 while (--w);
290 }
291
292 static fz_forceinline void
293 template_affine_alpha_N_near(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
294 {
295 int k;
296
297 do
298 {
299 affint ui = u >> PREC;
300 affint vi = v >> PREC;
301 if (ui >= 0 && ui < sw && vi >= 0 && vi < sh)
302 {
303 const byte *sample = sp + (vi * ss) + (ui * (sn1+sa));
304 int a = sa ? sample[sn1] : 255;
305 int aa = (sa ? fz_mul255(a, alpha) : alpha);
306 if (aa != 0)
307 {
308 int t = 255 - aa;
309 for (k = 0; k < sn1; k++)
310 dp[k] = fz_mul255(sample[k], alpha) + fz_mul255(dp[k], t);
311 for (; k < dn1; k++)
312 dp[k] = 0;
313 if (da)
314 dp[dn1] = aa + fz_mul255(dp[dn1], t);
315 if (hp)
316 hp[0] = a + fz_mul255(hp[0], 255 - a);
317 if (gp)
318 gp[0] = aa + fz_mul255(gp[0], t);
319 }
320 }
321 dp += dn1+da;
322 if (hp)
323 hp++;
324 if (gp)
325 gp++;
326 u += fa;
327 v += fb;
328 }
329 while (--w);
330 }
331
332 static fz_forceinline void
333 template_affine_alpha_N_near_op(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
334 {
335 int k;
336
337 do
338 {
339 affint ui = u >> PREC;
340 affint vi = v >> PREC;
341 if (ui >= 0 && ui < sw && vi >= 0 && vi < sh)
342 {
343 const byte *sample = sp + (vi * ss) + (ui * (sn1+sa));
344 int a = sa ? sample[sn1] : 255;
345 int aa = (sa ? fz_mul255(a, alpha) : alpha);
346 if (aa != 0)
347 {
348 int t = 255 - aa;
349 for (k = 0; k < sn1; k++)
350 if (fz_overprint_component(eop, k))
351 dp[k] = fz_mul255(sample[k], alpha) + fz_mul255(dp[k], t);
352 for (; k < dn1; k++)
353 if (fz_overprint_component(eop, k))
354 dp[k] = 0;
355 if (da)
356 dp[dn1] = aa + fz_mul255(dp[dn1], t);
357 if (hp)
358 hp[0] = a + fz_mul255(hp[0], 255 - a);
359 if (gp)
360 gp[0] = aa + fz_mul255(gp[0], t);
361 }
362 }
363 dp += dn1+da;
364 if (hp)
365 hp++;
366 if (gp)
367 gp++;
368 u += fa;
369 v += fb;
370 }
371 while (--w);
372 }
373
374 static fz_forceinline void
375 template_affine_alpha_g2rgb_near_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int alpha, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
376 {
377 affint ui = u >> PREC;
378 if (ui < 0 || ui >= sw)
379 return;
380 sp += ui * (1+sa);
381 do
382 {
383 affint vi = v >> PREC;
384 if (vi >= 0 && vi < sh)
385 {
386 const byte *sample = sp + (vi * ss);
387 int x = fz_mul255(sample[0], alpha);
388 int a = sa ? sample[1] : 255;
389 int aa = (sa ? fz_mul255(a, alpha) : alpha);
390 if (aa != 0)
391 {
392 int t = 255 - aa;
393 dp[0] = x + fz_mul255(dp[0], t);
394 dp[1] = x + fz_mul255(dp[1], t);
395 dp[2] = x + fz_mul255(dp[2], t);
396 if (da)
397 dp[3] = aa + fz_mul255(dp[3], t);
398 if (hp)
399 hp[0] = a + fz_mul255(hp[0], 255 - a);
400 if (gp)
401 gp[0] = aa + fz_mul255(gp[0], t);
402 }
403 }
404 dp += 3 + da;
405 if (hp)
406 hp++;
407 if (gp)
408 gp++;
409 v += fb;
410 }
411 while (--w);
412 }
413
414 static fz_forceinline void
415 template_affine_alpha_g2rgb_near_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int alpha, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
416 {
417 affint vi = v >> PREC;
418 if (vi < 0 || vi >= sh)
419 return;
420 sp += vi * ss;
421 do
422 {
423 affint ui = u >> PREC;
424 if (ui >= 0 && ui < sw)
425 {
426 const byte *sample = sp + (ui * (1+sa));
427 int x = fz_mul255(sample[0], alpha);
428 int a = sa ? sample[1] : 255;
429 int aa = (sa ? fz_mul255(a, alpha) : alpha);
430 if (aa != 0)
431 {
432 int t = 255 - aa;
433 dp[0] = x + fz_mul255(dp[0], t);
434 dp[1] = x + fz_mul255(dp[1], t);
435 dp[2] = x + fz_mul255(dp[2], t);
436 if (da)
437 dp[3] = aa + fz_mul255(dp[3], t);
438 if (hp)
439 hp[0] = a + fz_mul255(hp[0], 255 - a);
440 if (gp)
441 gp[0] = aa + fz_mul255(gp[0], t);
442 }
443 }
444 dp += 3 + da;
445 if (hp)
446 hp++;
447 if (gp)
448 gp++;
449 u += fa;
450 }
451 while (--w);
452 }
453
454 static fz_forceinline void
455 template_affine_alpha_g2rgb_near(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int alpha, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
456 {
457 do
458 {
459 affint ui = u >> PREC;
460 affint vi = v >> PREC;
461 if (ui >= 0 && ui < sw && vi >= 0 && vi < sh)
462 {
463 const byte *sample = sp + (vi * ss) + (ui * (1+sa));
464 int x = fz_mul255(sample[0], alpha);
465 int a = sa ? sample[1] : 255;
466 int aa = (sa ? fz_mul255(a, alpha): alpha);
467 if (aa != 0)
468 {
469 int t = 255 - aa;
470 dp[0] = x + fz_mul255(dp[0], t);
471 dp[1] = x + fz_mul255(dp[1], t);
472 dp[2] = x + fz_mul255(dp[2], t);
473 if (da)
474 dp[3] = aa + fz_mul255(dp[3], t);
475 if (hp)
476 hp[0] = a + fz_mul255(hp[0], 255 - a);
477 if (gp)
478 gp[0] = aa + fz_mul255(gp[0], t);
479 }
480 }
481 dp += 3 + da;
482 if (hp)
483 hp++;
484 if (gp)
485 gp++;
486 u += fa;
487 v += fb;
488 }
489 while (--w);
490 }
491
492 /* Blend premultiplied source image over destination */
493 static fz_forceinline void
494 template_affine_N_lerp(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
495 {
496 int k;
497
498 do
499 {
500 if (u + HALF >= 0 && u + ONE < sw && v + HALF >= 0 && v + ONE < sh)
501 {
502 affint ui = u >> PREC;
503 affint vi = v >> PREC;
504 int uf = u & MASK;
505 int vf = v & MASK;
506 const byte *a = sample_nearest(sp, sw, sh, ss, sn1+sa, ui, vi);
507 const byte *b = sample_nearest(sp, sw, sh, ss, sn1+sa, ui+1, vi);
508 const byte *c = sample_nearest(sp, sw, sh, ss, sn1+sa, ui, vi+1);
509 const byte *d = sample_nearest(sp, sw, sh, ss, sn1+sa, ui+1, vi+1);
510 int y = sa ? bilerp(a[sn1], b[sn1], c[sn1], d[sn1], uf, vf) : 255;
511 if (y != 0)
512 {
513 int t = 255 - y;
514 for (k = 0; k < sn1; k++)
515 {
516 int x = bilerp(a[k], b[k], c[k], d[k], uf, vf);
517 dp[k] = x + fz_mul255(dp[k], t);
518 }
519 for (; k < dn1; k++)
520 dp[k] = 0;
521 if (da)
522 dp[dn1] = y + fz_mul255(dp[dn1], t);
523 if (hp)
524 hp[0] = y + fz_mul255(hp[0], t);
525 if (gp)
526 gp[0] = y + fz_mul255(gp[0], t);
527 }
528 }
529 dp += dn1 + da;
530 if (hp)
531 hp++;
532 if (gp)
533 gp++;
534 u += fa;
535 v += fb;
536 }
537 while (--w);
538 }
539
540 static fz_forceinline void
541 template_affine_N_lerp_op(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
542 {
543 int k;
544
545 do
546 {
547 if (u + HALF >= 0 && u + ONE < sw && v + HALF >= 0 && v + ONE < sh)
548 {
549 affint ui = u >> PREC;
550 affint vi = v >> PREC;
551 int uf = u & MASK;
552 int vf = v & MASK;
553 const byte *a = sample_nearest(sp, sw, sh, ss, sn1+sa, ui, vi);
554 const byte *b = sample_nearest(sp, sw, sh, ss, sn1+sa, ui+1, vi);
555 const byte *c = sample_nearest(sp, sw, sh, ss, sn1+sa, ui, vi+1);
556 const byte *d = sample_nearest(sp, sw, sh, ss, sn1+sa, ui+1, vi+1);
557 int y = sa ? bilerp(a[sn1], b[sn1], c[sn1], d[sn1], uf, vf) : 255;
558 if (y != 0)
559 {
560 int t = 255 - y;
561 for (k = 0; k < sn1; k++)
562 if (fz_overprint_component(eop, k))
563 {
564 int x = bilerp(a[k], b[k], c[k], d[k], uf, vf);
565 dp[k] = x + fz_mul255(dp[k], t);
566 }
567 for (; k < dn1; k++)
568 if (fz_overprint_component(eop, k))
569 dp[k] = 0;
570 if (da)
571 dp[dn1] = y + fz_mul255(dp[dn1], t);
572 if (hp)
573 hp[0] = y + fz_mul255(hp[0], t);
574 if (gp)
575 gp[0] = y + fz_mul255(gp[0], t);
576 }
577 }
578 dp += dn1 + da;
579 if (hp)
580 hp++;
581 if (gp)
582 gp++;
583 u += fa;
584 v += fb;
585 }
586 while (--w);
587 }
588
589 static fz_forceinline void
590 template_affine_solid_g2rgb_lerp(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
591 {
592 do
593 {
594 if (u + HALF >= 0 && u + ONE < sw && v + HALF >= 0 && v + ONE < sh)
595 {
596 affint ui = u >> PREC;
597 affint vi = v >> PREC;
598 int uf = u & MASK;
599 int vf = v & MASK;
600 const byte *a = sample_nearest(sp, sw, sh, ss, 1+sa, ui, vi);
601 const byte *b = sample_nearest(sp, sw, sh, ss, 1+sa, ui+1, vi);
602 const byte *c = sample_nearest(sp, sw, sh, ss, 1+sa, ui, vi+1);
603 const byte *d = sample_nearest(sp, sw, sh, ss, 1+sa, ui+1, vi+1);
604 int y = (sa ? bilerp(a[1], b[1], c[1], d[1], uf, vf) : 255);
605 if (y != 0)
606 {
607 int t = 255 - y;
608 int x = bilerp(a[0], b[0], c[0], d[0], uf, vf);
609 dp[0] = x + fz_mul255(dp[0], t);
610 dp[1] = x + fz_mul255(dp[1], t);
611 dp[2] = x + fz_mul255(dp[2], t);
612 if (da)
613 dp[3] = y + fz_mul255(dp[3], t);
614 if (hp)
615 hp[0] = y + fz_mul255(hp[0], t);
616 if (gp)
617 gp[0] = y + fz_mul255(gp[0], t);
618 }
619 }
620 dp += 3 + da;
621 if (hp)
622 hp++;
623 if (gp)
624 gp++;
625 u += fa;
626 v += fb;
627 }
628 while (--w);
629 }
630
631 static fz_forceinline void
632 template_affine_N_near_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
633 {
634 int k;
635 affint ui = u >> PREC;
636 if (ui < 0 || ui >= sw)
637 return;
638 sp += ui*(sn1+sa);
639 do
640 {
641 affint vi = v >> PREC;
642 if (vi >= 0 && vi < sh)
643 {
644 const byte *sample = sp + (vi * ss);
645 int a = (sa ? sample[sn1] : 255);
646 /* If a is 0, then sample[k] = 0 for all k, as premultiplied */
647 if (a != 0)
648 {
649 int t = 255 - a;
650 if (t == 0)
651 {
652 if (dn1+da == 4 && dn1+sa == 4)
653 {
654 *(int32_t *)dp = *(int32_t *)sample;
655 }
656 else
657 {
658 dp[0] = sample[0];
659 if (sn1 > 1)
660 dp[1] = sample[1];
661 if (sn1 > 2)
662 dp[2] = sample[2];
663 for (k = 3; k < sn1; k++)
664 dp[k] = sample[k];
665 for (k = sn1; k < dn1; k++)
666 dp[k] = 0;
667 if (da)
668 dp[dn1] = a;
669 }
670 if (hp)
671 hp[0] = a;
672 if (gp)
673 gp[0] = a;
674 }
675 else
676 {
677 for (k = 0; k < sn1; k++)
678 dp[k] = sample[k] + fz_mul255(dp[k], t);
679 for (; k < dn1; k++)
680 dp[k] = 0;
681 if (da)
682 dp[dn1] = a + fz_mul255(dp[dn1], t);
683 if (hp)
684 hp[0] = a + fz_mul255(hp[0], t);
685 if (gp)
686 gp[0] = a + fz_mul255(gp[0], t);
687 }
688 }
689 }
690 dp += dn1+da;
691 if (hp)
692 hp++;
693 if (gp)
694 gp++;
695 v += fb;
696 }
697 while (--w);
698 }
699
700 static fz_forceinline void
701 template_affine_N_near_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
702 {
703 int k;
704 affint vi = v >> PREC;
705 if (vi < 0 || vi >= sh)
706 return;
707 sp += vi * ss;
708 do
709 {
710 affint ui = u >> PREC;
711 if (ui >= 0 && ui < sw)
712 {
713 const byte *sample = sp + (ui * (sn1+sa));
714 int a = sa ? sample[sn1] : 255;
715 /* If a is 0, then sample[k] = 0 for all k, as premultiplied */
716 if (a != 0)
717 {
718 int t = 255 - a;
719 if (t == 0)
720 {
721 if (dn1+da == 4 && sn1+sa == 4)
722 {
723 *(int32_t *)dp = *(int32_t *)sample;
724 }
725 else
726 {
727 dp[0] = sample[0];
728 if (sn1 > 1)
729 dp[1] = sample[1];
730 if (sn1 > 2)
731 dp[2] = sample[2];
732 for (k = 3; k < sn1; k++)
733 dp[k] = sample[k];
734 for (k = sn1; k < dn1; k++)
735 dp[k] = 0;
736 if (da)
737 dp[dn1] = a;
738 }
739 if (hp)
740 hp[0] = a;
741 if (gp)
742 gp[0] = a;
743 }
744 else
745 {
746 for (k = 0; k < sn1; k++)
747 dp[k] = sample[k] + fz_mul255(dp[k], t);
748 for (; k < dn1; k++)
749 dp[k] = 0;
750 if (da)
751 dp[dn1] = a + fz_mul255(dp[dn1], t);
752 if (hp)
753 hp[0] = a + fz_mul255(hp[0], t);
754 if (gp)
755 gp[0] = a + fz_mul255(gp[0], t);
756 }
757 }
758 }
759 dp += dn1+da;
760 if (hp)
761 hp++;
762 if (gp)
763 gp++;
764 u += fa;
765 }
766 while (--w);
767 }
768
769 static fz_forceinline void
770 template_affine_N_near(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
771 {
772 int k;
773
774 do
775 {
776 affint ui = u >> PREC;
777 affint vi = v >> PREC;
778 if (ui >= 0 && ui < sw && vi >= 0 && vi < sh)
779 {
780 const byte *sample = sp + (vi * ss) + (ui * (sn1+sa));
781 int a = sa ? sample[sn1] : 255;
782 /* If a is 0, then sample[k] = 0 for all k, as premultiplied */
783 if (a != 0)
784 {
785 int t = 255 - a;
786 if (t == 0)
787 {
788 if (dn1+da == 4 && sn1+sa == 4)
789 {
790 *(int32_t *)dp = *(int32_t *)sample;
791 }
792 else
793 {
794 dp[0] = sample[0];
795 if (sn1 > 1)
796 dp[1] = sample[1];
797 if (sn1 > 2)
798 dp[2] = sample[2];
799 for (k = 3; k < sn1; k++)
800 dp[k] = sample[k];
801 for (; k < dn1; k++)
802 dp[k] = 0;
803 if (da)
804 dp[dn1] = a;
805 }
806 if (hp)
807 hp[0] = a;
808 if (gp)
809 gp[0] = a;
810 }
811 else
812 {
813 for (k = 0; k < sn1; k++)
814 dp[k] = sample[k] + fz_mul255(dp[k], t);
815 for (; k < dn1; k++)
816 dp[k] = 0;
817 if (da)
818 dp[dn1] = a + fz_mul255(dp[dn1], t);
819 if (hp)
820 hp[0] = a + fz_mul255(hp[0], t);
821 if (gp)
822 gp[0] = a + fz_mul255(gp[0], t);
823 }
824 }
825 }
826 dp += dn1+da;
827 if (hp)
828 hp++;
829 if (gp)
830 gp++;
831 u += fa;
832 v += fb;
833 }
834 while (--w);
835 }
836
837 static fz_forceinline void
838 template_affine_N_near_op(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
839 {
840 int k;
841
842 do
843 {
844 affint ui = u >> PREC;
845 affint vi = v >> PREC;
846 if (ui >= 0 && ui < sw && vi >= 0 && vi < sh)
847 {
848 const byte *sample = sp + (vi * ss) + (ui * (sn1+sa));
849 int a = sa ? sample[sn1] : 255;
850 /* If a is 0, then sample[k] = 0 for all k, as premultiplied */
851 if (a != 0)
852 {
853 int t = 255 - a;
854 if (t == 0)
855 {
856 if (fz_overprint_component(eop, 0))
857 dp[0] = sample[0];
858 if (sn1 > 1)
859 if (fz_overprint_component(eop, 1))
860 dp[1] = sample[1];
861 if (sn1 > 2)
862 if (fz_overprint_component(eop, 2))
863 dp[2] = sample[2];
864 for (k = 3; k < sn1; k++)
865 if (fz_overprint_component(eop, k))
866 dp[k] = sample[k];
867 for (; k < dn1; k++)
868 if (fz_overprint_component(eop, k))
869 dp[k] = 0;
870 if (da)
871 dp[dn1] = a;
872 if (hp)
873 hp[0] = a;
874 if (gp)
875 gp[0] = a;
876 }
877 else
878 {
879 for (k = 0; k < sn1; k++)
880 if (fz_overprint_component(eop, k))
881 dp[k] = sample[k] + fz_mul255(dp[k], t);
882 for (; k < dn1; k++)
883 if (fz_overprint_component(eop, k))
884 dp[k] = 0;
885 if (da)
886 dp[dn1] = a + fz_mul255(dp[dn1], t);
887 if (hp)
888 hp[0] = a + fz_mul255(hp[0], t);
889 if (gp)
890 gp[0] = a + fz_mul255(gp[0], t);
891 }
892 }
893 }
894 dp += dn1+da;
895 if (hp)
896 hp++;
897 if (gp)
898 gp++;
899 u += fa;
900 v += fb;
901 }
902 while (--w);
903 }
904
905 static fz_forceinline void
906 template_affine_solid_g2rgb_near_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
907 {
908 affint ui = u >> PREC;
909 if (ui < 0 || ui >= sw)
910 return;
911 sp += ui * (1+sa);
912 do
913 {
914 affint vi = v >> PREC;
915 if (vi >= 0 && vi < sh)
916 {
917 const byte *sample = sp + (vi * ss);
918 int a = (sa ? sample[1] : 255);
919 if (a != 0)
920 {
921 int x = sample[0];
922 int t = 255 - a;
923 if (t == 0)
924 {
925 dp[0] = x;
926 dp[1] = x;
927 dp[2] = x;
928 if (da)
929 dp[3] = a;
930 if (hp)
931 hp[0] = a;
932 if (gp)
933 gp[0] = a;
934 }
935 else
936 {
937 dp[0] = x + fz_mul255(dp[0], t);
938 dp[1] = x + fz_mul255(dp[1], t);
939 dp[2] = x + fz_mul255(dp[2], t);
940 if (da)
941 dp[3] = a + fz_mul255(dp[3], t);
942 if (hp)
943 hp[0] = a + fz_mul255(hp[0], t);
944 if (gp)
945 gp[0] = a + fz_mul255(gp[0], t);
946 }
947 }
948 }
949 dp += 3 + da;
950 if (hp)
951 hp++;
952 if (gp)
953 gp++;
954 v += fb;
955 }
956 while (--w);
957 }
958
959 static fz_forceinline void
960 template_affine_solid_g2rgb_near_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
961 {
962 affint vi = v >> PREC;
963 if (vi < 0 || vi >= sh)
964 return;
965 sp += vi * ss;
966 do
967 {
968 affint ui = u >> PREC;
969 if (ui >= 0 && ui < sw)
970 {
971 const byte *sample = sp + (ui * (1+sa));
972 int a = (sa ? sample[1] : 255);
973 if (a != 0)
974 {
975 int x = sample[0];
976 int t = 255 - a;
977 if (t == 0)
978 {
979 dp[0] = x;
980 dp[1] = x;
981 dp[2] = x;
982 if (da)
983 dp[3] = a;
984 if (hp)
985 hp[0] = a;
986 if (gp)
987 gp[0] = a;
988 }
989 else
990 {
991 dp[0] = x + fz_mul255(dp[0], t);
992 dp[1] = x + fz_mul255(dp[1], t);
993 dp[2] = x + fz_mul255(dp[2], t);
994 if (da)
995 dp[3] = a + fz_mul255(dp[3], t);
996 if (hp)
997 hp[0] = a + fz_mul255(hp[0], t);
998 if (gp)
999 gp[0] = a + fz_mul255(gp[0], t);
1000 }
1001 }
1002 }
1003 dp += 3 + da;
1004 if (hp)
1005 hp++;
1006 if (gp)
1007 gp++;
1008 u += fa;
1009 }
1010 while (--w);
1011 }
1012
1013 static fz_forceinline void
1014 template_affine_solid_g2rgb_near(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
1015 {
1016 do
1017 {
1018 affint ui = u >> PREC;
1019 affint vi = v >> PREC;
1020 if (ui >= 0 && ui < sw && vi >= 0 && vi < sh)
1021 {
1022 const byte *sample = sp + (vi * ss) + (ui * (1+sa));
1023 int a = sa ? sample[1] : 255;
1024 if (a != 0)
1025 {
1026 int x = sample[0];
1027 int t = 255 - a;
1028 if (t == 0)
1029 {
1030 dp[0] = x;
1031 dp[1] = x;
1032 dp[2] = x;
1033 if (da)
1034 dp[3] = a;
1035 if (hp)
1036 hp[0] = a;
1037 if (gp)
1038 gp[0] = a;
1039 }
1040 else
1041 {
1042 dp[0] = x + fz_mul255(dp[0], t);
1043 dp[1] = x + fz_mul255(dp[1], t);
1044 dp[2] = x + fz_mul255(dp[2], t);
1045 if (da)
1046 dp[3] = a + fz_mul255(dp[3], t);
1047 if (hp)
1048 hp[0] = a + fz_mul255(hp[0], t);
1049 if (gp)
1050 gp[0] = a + fz_mul255(gp[0], t);
1051 }
1052 }
1053 }
1054 dp += 3 + da;
1055 if (hp)
1056 hp++;
1057 if (gp)
1058 gp++;
1059 u += fa;
1060 v += fb;
1061 }
1062 while (--w);
1063 }
1064
1065 /* Blend non-premultiplied color in source image mask over destination */
1066
1067 static fz_forceinline void
1068 template_affine_color_N_lerp(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
1069 {
1070 int sa = color[dn1];
1071 int k;
1072
1073 do
1074 {
1075 if (u + HALF >= 0 && u + ONE < sw && v + HALF >= 0 && v + ONE < sh)
1076 {
1077 affint ui = u >> PREC;
1078 affint vi = v >> PREC;
1079 int uf = u & MASK;
1080 int vf = v & MASK;
1081 const byte *a = sample_nearest(sp, sw, sh, ss, 1, ui, vi);
1082 const byte *b = sample_nearest(sp, sw, sh, ss, 1, ui+1, vi);
1083 const byte *c = sample_nearest(sp, sw, sh, ss, 1, ui, vi+1);
1084 const byte *d = sample_nearest(sp, sw, sh, ss, 1, ui+1, vi+1);
1085 int ma = bilerp(a[0], b[0], c[0], d[0], uf, vf);
1086 int masa = FZ_COMBINE(FZ_EXPAND(ma), sa);
1087 if (masa != 0)
1088 {
1089 for (k = 0; k < dn1; k++)
1090 dp[k] = FZ_BLEND(color[k], dp[k], masa);
1091 if (da)
1092 dp[dn1] = FZ_BLEND(255, dp[dn1], masa);
1093 if (hp)
1094 hp[0] = FZ_BLEND(255, hp[0], ma);
1095 if (gp)
1096 gp[0] = FZ_BLEND(255, gp[0], masa);
1097 }
1098 }
1099 dp += dn1 + da;
1100 if (hp)
1101 hp++;
1102 if (gp)
1103 gp++;
1104 u += fa;
1105 v += fb;
1106 }
1107 while (--w);
1108 }
1109
1110 static fz_forceinline void
1111 template_affine_color_N_lerp_op(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1112 {
1113 int sa = color[dn1];
1114 int k;
1115
1116 do
1117 {
1118 if (u + HALF >= 0 && u + ONE < sw && v + HALF >= 0 && v + ONE < sh)
1119 {
1120 affint ui = u >> PREC;
1121 affint vi = v >> PREC;
1122 int uf = u & MASK;
1123 int vf = v & MASK;
1124 const byte *a = sample_nearest(sp, sw, sh, ss, 1, ui, vi);
1125 const byte *b = sample_nearest(sp, sw, sh, ss, 1, ui+1, vi);
1126 const byte *c = sample_nearest(sp, sw, sh, ss, 1, ui, vi+1);
1127 const byte *d = sample_nearest(sp, sw, sh, ss, 1, ui+1, vi+1);
1128 int ma = bilerp(a[0], b[0], c[0], d[0], uf, vf);
1129 int masa = FZ_COMBINE(FZ_EXPAND(ma), sa);
1130 if (masa != 0)
1131 {
1132 for (k = 0; k < dn1; k++)
1133 if (fz_overprint_component(eop, k))
1134 dp[k] = FZ_BLEND(color[k], dp[k], masa);
1135 if (da)
1136 dp[dn1] = FZ_BLEND(255, dp[dn1], masa);
1137 if (hp)
1138 hp[0] = FZ_BLEND(255, hp[0], ma);
1139 if (gp)
1140 gp[0] = FZ_BLEND(255, gp[0], masa);
1141 }
1142 }
1143 dp += dn1 + da;
1144 if (hp)
1145 hp++;
1146 if (gp)
1147 gp++;
1148 u += fa;
1149 v += fb;
1150 }
1151 while (--w);
1152 }
1153
1154 static fz_forceinline void
1155 template_affine_color_N_near(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp)
1156 {
1157 int sa = color[dn1];
1158 int k;
1159
1160 do
1161 {
1162 affint ui = u >> PREC;
1163 affint vi = v >> PREC;
1164 if (ui >= 0 && ui < sw && vi >= 0 && vi < sh)
1165 {
1166 int ma = sp[vi * ss + ui];
1167 int masa = FZ_COMBINE(FZ_EXPAND(ma), sa);
1168 if (masa)
1169 {
1170 for (k = 0; k < dn1; k++)
1171 dp[k] = FZ_BLEND(color[k], dp[k], masa);
1172 if (da)
1173 dp[dn1] = FZ_BLEND(255, dp[dn1], masa);
1174 if (hp)
1175 hp[0] = FZ_BLEND(255, hp[0], ma);
1176 if (gp)
1177 gp[0] = FZ_BLEND(255, gp[0], masa);
1178 }
1179 }
1180 dp += dn1+da;
1181 if (hp)
1182 hp++;
1183 if (gp)
1184 gp++;
1185 u += fa;
1186 v += fb;
1187 }
1188 while (--w);
1189 }
1190
1191 static fz_forceinline void
1192 template_affine_color_N_near_op(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1193 {
1194 int sa = color[dn1];
1195 int k;
1196
1197 do
1198 {
1199 affint ui = u >> PREC;
1200 affint vi = v >> PREC;
1201 if (ui >= 0 && ui < sw && vi >= 0 && vi < sh)
1202 {
1203 int ma = sp[vi * ss + ui];
1204 int masa = FZ_COMBINE(FZ_EXPAND(ma), sa);
1205 if (masa)
1206 {
1207 for (k = 0; k < dn1; k++)
1208 if (fz_overprint_component(eop, k))
1209 dp[k] = FZ_BLEND(color[k], dp[k], masa);
1210 if (da)
1211 dp[dn1] = FZ_BLEND(255, dp[dn1], masa);
1212 if (hp)
1213 hp[0] = FZ_BLEND(255, hp[0], ma);
1214 if (gp)
1215 gp[0] = FZ_BLEND(255, gp[0], masa);
1216 }
1217 }
1218 dp += dn1+da;
1219 if (hp)
1220 hp++;
1221 if (gp)
1222 gp++;
1223 u += fa;
1224 v += fb;
1225 }
1226 while (--w);
1227 }
1228
1229 static void
1230 paint_affine_lerp_da_sa_0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1231 {
1232 TRACK_FN();
1233 template_affine_N_lerp(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 0, 0, hp, gp);
1234 }
1235
1236 static void
1237 paint_affine_lerp_da_sa_alpha_0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1238 {
1239 TRACK_FN();
1240 template_affine_alpha_N_lerp(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 0, 0, alpha, hp, gp);
1241 }
1242
1243 static void
1244 paint_affine_lerp_da_0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1245 {
1246 TRACK_FN();
1247 template_affine_N_lerp(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 0, 0, hp, gp);
1248 }
1249
1250 static void
1251 paint_affine_lerp_da_alpha_0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1252 {
1253 TRACK_FN();
1254 template_affine_alpha_N_lerp(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 0, 0, alpha, hp, gp);
1255 }
1256
1257 static void
1258 paint_affine_lerp_da_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1259 {
1260 TRACK_FN();
1261 template_affine_N_lerp(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, hp, gp);
1262 }
1263
1264 static void
1265 paint_affine_lerp_da_alpha_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1266 {
1267 TRACK_FN();
1268 template_affine_alpha_N_lerp(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
1269 }
1270
1271 static void
1272 paint_affine_lerp_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1273 {
1274 TRACK_FN();
1275 template_affine_N_lerp(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, hp, gp);
1276 }
1277
1278 static void
1279 paint_affine_lerp_alpha_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1280 {
1281 TRACK_FN();
1282 template_affine_alpha_N_lerp(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
1283 }
1284
1285 #if FZ_PLOTTERS_G
1286 static void
1287 paint_affine_lerp_da_sa_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1288 {
1289 TRACK_FN();
1290 template_affine_N_lerp(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, hp, gp);
1291 }
1292
1293 static void
1294 paint_affine_lerp_da_sa_alpha_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1295 {
1296 TRACK_FN();
1297 template_affine_alpha_N_lerp(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
1298 }
1299
1300 static void
1301 paint_affine_lerp_sa_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1302 {
1303 TRACK_FN();
1304 template_affine_N_lerp(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, hp, gp);
1305 }
1306
1307 static void
1308 paint_affine_lerp_sa_alpha_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1309 {
1310 TRACK_FN();
1311 template_affine_alpha_N_lerp(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
1312 }
1313 #endif /* FZ_PLOTTERS_G */
1314
1315 #if FZ_PLOTTERS_RGB
1316 static void
1317 paint_affine_lerp_da_sa_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1318 {
1319 TRACK_FN();
1320 template_affine_N_lerp(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, hp, gp);
1321 }
1322
1323 static void
1324 paint_affine_lerp_da_sa_alpha_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1325 {
1326 TRACK_FN();
1327 template_affine_alpha_N_lerp(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
1328 }
1329
1330 static void
1331 paint_affine_lerp_da_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1332 {
1333 TRACK_FN();
1334 template_affine_N_lerp(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, hp, gp);
1335 }
1336
1337 static void
1338 paint_affine_lerp_da_alpha_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1339 {
1340 TRACK_FN();
1341 template_affine_alpha_N_lerp(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
1342 }
1343
1344 static void
1345 paint_affine_lerp_sa_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1346 {
1347 TRACK_FN();
1348 template_affine_N_lerp(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, hp, gp);
1349 }
1350
1351 static void
1352 paint_affine_lerp_sa_alpha_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1353 {
1354 TRACK_FN();
1355 template_affine_alpha_N_lerp(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
1356 }
1357
1358 static void
1359 paint_affine_lerp_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1360 {
1361 TRACK_FN();
1362 template_affine_N_lerp(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, hp, gp);
1363 }
1364
1365 static void
1366 paint_affine_lerp_alpha_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1367 {
1368 TRACK_FN();
1369 template_affine_alpha_N_lerp(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
1370 }
1371 #endif /* FZ_PLOTTERS_RGB */
1372
1373 #if FZ_PLOTTERS_CMYK
1374 static void
1375 paint_affine_lerp_da_sa_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1376 {
1377 TRACK_FN();
1378 template_affine_N_lerp(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, hp, gp);
1379 }
1380
1381 static void
1382 paint_affine_lerp_da_sa_alpha_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1383 {
1384 TRACK_FN();
1385 template_affine_alpha_N_lerp(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
1386 }
1387
1388 static void
1389 paint_affine_lerp_da_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1390 {
1391 TRACK_FN();
1392 template_affine_N_lerp(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, hp, gp);
1393 }
1394
1395 static void
1396 paint_affine_lerp_da_alpha_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1397 {
1398 TRACK_FN();
1399 template_affine_alpha_N_lerp(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
1400 }
1401
1402 static void
1403 paint_affine_lerp_sa_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1404 {
1405 TRACK_FN();
1406 template_affine_N_lerp(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, hp, gp);
1407 }
1408
1409 static void
1410 paint_affine_lerp_sa_alpha_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1411 {
1412 TRACK_FN();
1413 template_affine_alpha_N_lerp(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
1414 }
1415
1416 static void
1417 paint_affine_lerp_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1418 {
1419 TRACK_FN();
1420 template_affine_N_lerp(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, hp, gp);
1421 }
1422
1423 static void
1424 paint_affine_lerp_alpha_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1425 {
1426 TRACK_FN();
1427 template_affine_alpha_N_lerp(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
1428 }
1429 #endif /* FZ_PLOTTERS_CMYK */
1430
1431 #if FZ_PLOTTERS_N
1432 static void
1433 paint_affine_lerp_da_sa_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1434 {
1435 TRACK_FN();
1436 template_affine_N_lerp(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, hp, gp);
1437 }
1438
1439 static void
1440 paint_affine_lerp_da_sa_alpha_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1441 {
1442 TRACK_FN();
1443 template_affine_alpha_N_lerp(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
1444 }
1445
1446 static void
1447 paint_affine_lerp_da_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1448 {
1449 TRACK_FN();
1450 template_affine_N_lerp(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, hp, gp);
1451 }
1452
1453 static void
1454 paint_affine_lerp_da_alpha_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1455 {
1456 TRACK_FN();
1457 template_affine_alpha_N_lerp(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
1458 }
1459
1460 static void
1461 paint_affine_lerp_sa_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1462 {
1463 TRACK_FN();
1464 template_affine_N_lerp(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, hp, gp);
1465 }
1466
1467 static void
1468 paint_affine_lerp_sa_alpha_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1469 {
1470 TRACK_FN();
1471 template_affine_alpha_N_lerp(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
1472 }
1473
1474 static void
1475 paint_affine_lerp_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1476 {
1477 TRACK_FN();
1478 template_affine_N_lerp(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, hp, gp);
1479 }
1480
1481 static void
1482 paint_affine_lerp_alpha_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1483 {
1484 TRACK_FN();
1485 template_affine_alpha_N_lerp(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
1486 }
1487 #endif /* FZ_PLOTTERS_N */
1488
1489 #if FZ_ENABLE_SPOT_RENDERING
1490 static void
1491 paint_affine_lerp_N_op(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1492 {
1493 TRACK_FN();
1494 template_affine_N_lerp_op(dp, da, sp, sw, sh, ss, sa, u, v, fa, fb, w, dn, sn, hp, gp, eop);
1495 }
1496
1497 static void
1498 paint_affine_lerp_alpha_N_op(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1499 {
1500 TRACK_FN();
1501 template_affine_alpha_N_lerp_op(dp, da, sp, sw, sh, ss, sa, u, v, fa, fb, w, dn, sn, alpha, hp, gp, eop);
1502 }
1503 #endif /* FZ_ENABLE_SPOT_RENDERING */
1504
1505 static paintfn_t *
1506 fz_paint_affine_lerp(int da, int sa, affint fa, affint fb, int n, int alpha, const fz_overprint * FZ_RESTRICT eop)
1507 {
1508 #if FZ_ENABLE_SPOT_RENDERING
1509 if (fz_overprint_required(eop))
1510 {
1511 if (alpha == 255)
1512 return paint_affine_lerp_N_op;
1513 else if (alpha > 0)
1514 return paint_affine_lerp_alpha_N_op;
1515 else
1516 return NULL;
1517 }
1518 #endif /* FZ_ENABLE_SPOT_RENDERING */
1519
1520 switch(n)
1521 {
1522 case 0:
1523 if (da)
1524 {
1525 if (sa)
1526 {
1527 if (alpha == 255)
1528 return paint_affine_lerp_da_sa_0;
1529 else if (alpha > 0)
1530 return paint_affine_lerp_da_sa_alpha_0;
1531 }
1532 else
1533 {
1534 if (alpha == 255)
1535 return paint_affine_lerp_da_0;
1536 else if (alpha > 0)
1537 return paint_affine_lerp_da_alpha_0;
1538 }
1539 }
1540 break;
1541
1542 case 1:
1543 if (sa)
1544 {
1545 #if FZ_PLOTTERS_G
1546 if (da)
1547 {
1548 if (alpha == 255)
1549 return paint_affine_lerp_da_sa_1;
1550 else if (alpha > 0)
1551 return paint_affine_lerp_da_sa_alpha_1;
1552 }
1553 else
1554 {
1555 if (alpha == 255)
1556 return paint_affine_lerp_sa_1;
1557 else if (alpha > 0)
1558 return paint_affine_lerp_sa_alpha_1;
1559 }
1560 #else
1561 goto fallback;
1562 #endif /* FZ_PLOTTERS_H */
1563 }
1564 else
1565 {
1566 if (da)
1567 {
1568 if (alpha == 255)
1569 return paint_affine_lerp_da_1;
1570 else if (alpha > 0)
1571 return paint_affine_lerp_da_alpha_1;
1572 }
1573 else
1574 {
1575 if (alpha == 255)
1576 return paint_affine_lerp_1;
1577 else if (alpha > 0)
1578 return paint_affine_lerp_alpha_1;
1579 }
1580 }
1581 break;
1582
1583 #if FZ_PLOTTERS_RGB
1584 case 3:
1585 if (da)
1586 {
1587 if (sa)
1588 {
1589 if (alpha == 255)
1590 return paint_affine_lerp_da_sa_3;
1591 else if (alpha > 0)
1592 return paint_affine_lerp_da_sa_alpha_3;
1593 }
1594 else
1595 {
1596 if (alpha == 255)
1597 return paint_affine_lerp_da_3;
1598 else if (alpha > 0)
1599 return paint_affine_lerp_da_alpha_3;
1600 }
1601 }
1602 else
1603 {
1604 if (sa)
1605 {
1606 if (alpha == 255)
1607 return paint_affine_lerp_sa_3;
1608 else if (alpha > 0)
1609 return paint_affine_lerp_sa_alpha_3;
1610 }
1611 else
1612 {
1613 if (alpha == 255)
1614 return paint_affine_lerp_3;
1615 else if (alpha > 0)
1616 return paint_affine_lerp_alpha_3;
1617 }
1618 }
1619 break;
1620 #endif /* FZ_PLOTTERS_RGB */
1621
1622 #if FZ_PLOTTERS_CMYK
1623 case 4:
1624 if (da)
1625 {
1626 if (sa)
1627 {
1628 if (alpha == 255)
1629 return paint_affine_lerp_da_sa_4;
1630 else if (alpha > 0)
1631 return paint_affine_lerp_da_sa_alpha_4;
1632 }
1633 else
1634 {
1635 if (alpha == 255)
1636 return paint_affine_lerp_da_4;
1637 else if (alpha > 0)
1638 return paint_affine_lerp_da_alpha_4;
1639 }
1640 }
1641 else
1642 {
1643 if (sa)
1644 {
1645 if (alpha == 255)
1646 return paint_affine_lerp_sa_4;
1647 else if (alpha > 0)
1648 return paint_affine_lerp_sa_alpha_4;
1649 }
1650 else
1651 {
1652 if (alpha == 255)
1653 return paint_affine_lerp_4;
1654 else if (alpha > 0)
1655 return paint_affine_lerp_alpha_4;
1656 }
1657 }
1658 break;
1659 #endif /* FZ_PLOTTERS_CMYK */
1660
1661 #if !FZ_PLOTTERS_G
1662 fallback:
1663 #endif /* FZ_PLOTTERS_G */
1664 default:
1665 #if FZ_PLOTTERS_N
1666 if (da)
1667 {
1668 if (sa)
1669 {
1670 if (alpha == 255)
1671 return paint_affine_lerp_da_sa_N;
1672 else if (alpha > 0)
1673 return paint_affine_lerp_da_sa_alpha_N;
1674 }
1675 else
1676 {
1677 if (alpha == 255)
1678 return paint_affine_lerp_da_N;
1679 else if (alpha > 0)
1680 return paint_affine_lerp_da_alpha_N;
1681 }
1682 }
1683 else
1684 {
1685 if (sa)
1686 {
1687 if (alpha == 255)
1688 return paint_affine_lerp_sa_N;
1689 else if (alpha > 0)
1690 return paint_affine_lerp_sa_alpha_N;
1691 }
1692 else
1693 {
1694 if (alpha == 255)
1695 return paint_affine_lerp_N;
1696 else if (alpha > 0)
1697 return paint_affine_lerp_alpha_N;
1698 }
1699 }
1700 #endif /* FZ_PLOTTERS_N */
1701 break;
1702 }
1703 return NULL;
1704 }
1705
1706 #if FZ_ENABLE_SPOT_RENDERING
1707 static paintfn_t *
1708 fz_paint_affine_lerp_spots(int da, int sa, affint fa, affint fb, int dn, int sn, int alpha, const fz_overprint * FZ_RESTRICT eop)
1709 {
1710 if (fz_overprint_required(eop))
1711 {
1712 if (alpha == 255)
1713 return paint_affine_lerp_N_op;
1714 else if (alpha > 0)
1715 return paint_affine_lerp_alpha_N_op;
1716 }
1717 else if (da)
1718 {
1719 if (sa)
1720 {
1721 if (alpha == 255)
1722 return paint_affine_lerp_da_sa_N;
1723 else if (alpha > 0)
1724 return paint_affine_lerp_da_sa_alpha_N;
1725 }
1726 else
1727 {
1728 if (alpha == 255)
1729 return paint_affine_lerp_da_N;
1730 else if (alpha > 0)
1731 return paint_affine_lerp_da_alpha_N;
1732 }
1733 }
1734 else
1735 {
1736 if (sa)
1737 {
1738 if (alpha == 255)
1739 return paint_affine_lerp_sa_N;
1740 else if (alpha > 0)
1741 return paint_affine_lerp_sa_alpha_N;
1742 }
1743 else
1744 {
1745 if (alpha == 255)
1746 return paint_affine_lerp_N;
1747 else if (alpha > 0)
1748 return paint_affine_lerp_alpha_N;
1749 }
1750 }
1751 return NULL;
1752 }
1753 #endif /* FZ_ENABLE_SPOT_RENDERING */
1754
1755 #if FZ_PLOTTERS_RGB
1756 static void
1757 paint_affine_lerp_da_sa_g2rgb(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1758 {
1759 TRACK_FN();
1760 template_affine_solid_g2rgb_lerp(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, hp, gp);
1761 }
1762
1763 static void
1764 paint_affine_lerp_da_sa_g2rgb_alpha(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1765 {
1766 TRACK_FN();
1767 template_affine_alpha_g2rgb_lerp(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, alpha, hp, gp);
1768 }
1769
1770 static void
1771 paint_affine_lerp_da_g2rgb(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1772 {
1773 TRACK_FN();
1774 template_affine_solid_g2rgb_lerp(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, hp, gp);
1775 }
1776
1777 static void
1778 paint_affine_lerp_da_g2rgb_alpha(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1779 {
1780 TRACK_FN();
1781 template_affine_alpha_g2rgb_lerp(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, alpha, hp, gp);
1782 }
1783
1784 static void
1785 paint_affine_lerp_sa_g2rgb(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1786 {
1787 TRACK_FN();
1788 template_affine_solid_g2rgb_lerp(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, hp, gp);
1789 }
1790
1791 static void
1792 paint_affine_lerp_sa_g2rgb_alpha(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1793 {
1794 TRACK_FN();
1795 template_affine_alpha_g2rgb_lerp(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, alpha, hp, gp);
1796 }
1797
1798 static void
1799 paint_affine_lerp_g2rgb(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1800 {
1801 TRACK_FN();
1802 template_affine_solid_g2rgb_lerp(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, hp, gp);
1803 }
1804
1805 static void
1806 paint_affine_lerp_g2rgb_alpha(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1807 {
1808 TRACK_FN();
1809 template_affine_alpha_g2rgb_lerp(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, alpha, hp, gp);
1810 }
1811
1812 static paintfn_t *
1813 fz_paint_affine_g2rgb_lerp(int da, int sa, affint fa, affint fb, int n, int alpha)
1814 {
1815 if (da)
1816 {
1817 if (sa)
1818 {
1819 if (alpha == 255)
1820 return paint_affine_lerp_da_sa_g2rgb;
1821 else if (alpha > 0)
1822 return paint_affine_lerp_da_sa_g2rgb_alpha;
1823 }
1824 else
1825 {
1826 if (alpha == 255)
1827 return paint_affine_lerp_da_g2rgb;
1828 else if (alpha > 0)
1829 return paint_affine_lerp_da_g2rgb_alpha;
1830 }
1831 }
1832 else
1833 {
1834 if (sa)
1835 {
1836 if (alpha == 255)
1837 return paint_affine_lerp_sa_g2rgb;
1838 else if (alpha > 0)
1839 return paint_affine_lerp_sa_g2rgb_alpha;
1840 }
1841 else
1842 {
1843 if (alpha == 255)
1844 return paint_affine_lerp_g2rgb;
1845 else if (alpha > 0)
1846 return paint_affine_lerp_g2rgb_alpha;
1847 }
1848 }
1849 return NULL;
1850 }
1851 #endif /* FZ_PLOTTERS_RGB */
1852
1853 static void
1854 paint_affine_near_da_sa_0_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1855 {
1856 TRACK_FN();
1857 template_affine_N_near_fa0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 0, 0, hp, gp);
1858 }
1859
1860 static void
1861 paint_affine_near_da_sa_alpha_0_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1862 {
1863 TRACK_FN();
1864 template_affine_alpha_N_near_fa0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 0, 0, alpha, hp, gp);
1865 }
1866
1867 static void
1868 paint_affine_near_da_0_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1869 {
1870 TRACK_FN();
1871 template_affine_N_near_fa0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 0, 0, hp, gp);
1872 }
1873
1874 static void
1875 paint_affine_near_da_alpha_0_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1876 {
1877 TRACK_FN();
1878 template_affine_alpha_N_near_fa0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 0, 0, alpha, hp, gp);
1879 }
1880
1881 static void
1882 paint_affine_near_da_sa_0_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1883 {
1884 TRACK_FN();
1885 template_affine_N_near_fb0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 0, 0, hp, gp);
1886 }
1887
1888 static void
1889 paint_affine_near_da_sa_alpha_0_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1890 {
1891 TRACK_FN();
1892 template_affine_alpha_N_near_fb0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 0, 0, alpha, hp, gp);
1893 }
1894
1895 static void
1896 paint_affine_near_da_0_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1897 {
1898 TRACK_FN();
1899 template_affine_N_near_fb0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 0, 0, hp, gp);
1900 }
1901
1902 static void
1903 paint_affine_near_da_alpha_0_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1904 {
1905 TRACK_FN();
1906 template_affine_alpha_N_near_fb0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 0, 0, alpha, hp, gp);
1907 }
1908
1909 static void
1910 paint_affine_near_da_sa_0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1911 {
1912 TRACK_FN();
1913 template_affine_N_near(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 0, 0, hp, gp);
1914 }
1915
1916 static void
1917 paint_affine_near_da_sa_alpha_0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1918 {
1919 TRACK_FN();
1920 template_affine_alpha_N_near(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 0, 0, alpha, hp, gp);
1921 }
1922
1923 static void
1924 paint_affine_near_da_0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1925 {
1926 TRACK_FN();
1927 template_affine_N_near(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 0, 0, hp, gp);
1928 }
1929
1930 static void
1931 paint_affine_near_da_alpha_0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1932 {
1933 TRACK_FN();
1934 template_affine_alpha_N_near(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 0, 0, alpha, hp, gp);
1935 }
1936
1937 static void
1938 paint_affine_near_1_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int snn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1939 {
1940 TRACK_FN();
1941 template_affine_N_near_fa0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, hp, gp);
1942 }
1943
1944 static void
1945 paint_affine_near_1_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1946 {
1947 TRACK_FN();
1948 template_affine_N_near_fb0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, hp, gp);
1949 }
1950
1951 static void
1952 paint_affine_near_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1953 {
1954 TRACK_FN();
1955 template_affine_N_near(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, hp, gp);
1956 }
1957
1958 static void
1959 paint_affine_near_alpha_1_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1960 {
1961 TRACK_FN();
1962 template_affine_alpha_N_near_fa0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
1963 }
1964
1965 static void
1966 paint_affine_near_alpha_1_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1967 {
1968 TRACK_FN();
1969 template_affine_alpha_N_near_fb0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
1970 }
1971
1972 static void
1973 paint_affine_near_alpha_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1974 {
1975 TRACK_FN();
1976 template_affine_alpha_N_near(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
1977 }
1978
1979 static void
1980 paint_affine_near_da_1_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1981 {
1982 TRACK_FN();
1983 template_affine_N_near_fa0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, hp, gp);
1984 }
1985
1986 static void
1987 paint_affine_near_da_alpha_1_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1988 {
1989 TRACK_FN();
1990 template_affine_alpha_N_near_fa0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
1991 }
1992
1993 static void
1994 paint_affine_near_da_1_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
1995 {
1996 TRACK_FN();
1997 template_affine_N_near_fb0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, hp, gp);
1998 }
1999
2000 static void
2001 paint_affine_near_da_alpha_1_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2002 {
2003 TRACK_FN();
2004 template_affine_alpha_N_near_fb0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
2005 }
2006
2007 static void
2008 paint_affine_near_da_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2009 {
2010 TRACK_FN();
2011 template_affine_N_near(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, hp, gp);
2012 }
2013
2014 static void
2015 paint_affine_near_da_alpha_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2016 {
2017 TRACK_FN();
2018 template_affine_alpha_N_near(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
2019 }
2020
2021 #if FZ_PLOTTERS_G
2022 static void
2023 paint_affine_near_da_sa_1_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2024 {
2025 TRACK_FN();
2026 template_affine_N_near_fa0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, hp, gp);
2027 }
2028
2029 static void
2030 paint_affine_near_da_sa_alpha_1_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2031 {
2032 TRACK_FN();
2033 template_affine_alpha_N_near_fa0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
2034 }
2035
2036 static void
2037 paint_affine_near_sa_1_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2038 {
2039 TRACK_FN();
2040 template_affine_N_near_fa0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, hp, gp);
2041 }
2042
2043 static void
2044 paint_affine_near_sa_alpha_1_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2045 {
2046 TRACK_FN();
2047 template_affine_alpha_N_near_fa0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
2048 }
2049
2050 static void
2051 paint_affine_near_da_sa_1_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2052 {
2053 TRACK_FN();
2054 template_affine_N_near_fb0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, hp, gp);
2055 }
2056
2057 static void
2058 paint_affine_near_da_sa_alpha_1_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2059 {
2060 TRACK_FN();
2061 template_affine_alpha_N_near_fb0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
2062 }
2063
2064 static void
2065 paint_affine_near_sa_alpha_1_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2066 {
2067 TRACK_FN();
2068 template_affine_alpha_N_near_fb0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
2069 }
2070
2071 static void
2072 paint_affine_near_da_sa_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2073 {
2074 TRACK_FN();
2075 template_affine_N_near(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, hp, gp);
2076 }
2077
2078 static void
2079 paint_affine_near_sa_1_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2080 {
2081 TRACK_FN();
2082 template_affine_N_near_fb0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, hp, gp);
2083 }
2084
2085 static void
2086 paint_affine_near_da_sa_alpha_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2087 {
2088 TRACK_FN();
2089 template_affine_alpha_N_near(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
2090 }
2091
2092 static void
2093 paint_affine_near_sa_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2094 {
2095 TRACK_FN();
2096 template_affine_N_near(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, hp, gp);
2097 }
2098
2099 static void
2100 paint_affine_near_sa_alpha_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2101 {
2102 TRACK_FN();
2103 template_affine_alpha_N_near(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 1, 1, alpha, hp, gp);
2104 }
2105 #endif /* FZ_PLOTTERS_G */
2106
2107 #if FZ_PLOTTERS_RGB
2108 static void
2109 paint_affine_near_da_sa_3_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2110 {
2111 TRACK_FN();
2112 template_affine_N_near_fa0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, hp, gp);
2113 }
2114
2115 static void
2116 paint_affine_near_da_sa_alpha_3_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2117 {
2118 TRACK_FN();
2119 template_affine_alpha_N_near_fa0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
2120 }
2121
2122 static void
2123 paint_affine_near_da_3_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2124 {
2125 TRACK_FN();
2126 template_affine_N_near_fa0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, hp, gp);
2127 }
2128
2129 static void
2130 paint_affine_near_da_alpha_3_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2131 {
2132 TRACK_FN();
2133 template_affine_alpha_N_near_fa0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
2134 }
2135
2136 static void
2137 paint_affine_near_sa_3_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2138 {
2139 TRACK_FN();
2140 template_affine_N_near_fa0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, hp, gp);
2141 }
2142
2143 static void
2144 paint_affine_near_sa_alpha_3_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2145 {
2146 TRACK_FN();
2147 template_affine_alpha_N_near_fa0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
2148 }
2149
2150 static void
2151 paint_affine_near_3_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2152 {
2153 TRACK_FN();
2154 template_affine_N_near_fa0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, hp, gp);
2155 }
2156
2157 static void
2158 paint_affine_near_alpha_3_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2159 {
2160 TRACK_FN();
2161 template_affine_alpha_N_near_fa0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
2162 }
2163
2164 static void
2165 paint_affine_near_da_sa_3_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2166 {
2167 TRACK_FN();
2168 template_affine_N_near_fb0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, hp, gp);
2169 }
2170
2171 static void
2172 paint_affine_near_da_sa_alpha_3_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2173 {
2174 TRACK_FN();
2175 template_affine_alpha_N_near_fb0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
2176 }
2177
2178 static void
2179 paint_affine_near_da_3_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2180 {
2181 TRACK_FN();
2182 template_affine_N_near_fb0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, hp, gp);
2183 }
2184
2185 static void
2186 paint_affine_near_da_alpha_3_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2187 {
2188 TRACK_FN();
2189 template_affine_alpha_N_near_fb0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
2190 }
2191
2192 static void
2193 paint_affine_near_sa_alpha_3_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2194 {
2195 TRACK_FN();
2196 template_affine_alpha_N_near_fb0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
2197 }
2198
2199 static void
2200 paint_affine_near_da_sa_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2201 {
2202 TRACK_FN();
2203 template_affine_N_near(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, hp, gp);
2204 }
2205
2206 static void
2207 paint_affine_near_alpha_3_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2208 {
2209 TRACK_FN();
2210 template_affine_alpha_N_near_fb0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
2211 }
2212
2213 static void
2214 paint_affine_near_3_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2215 {
2216 TRACK_FN();
2217 template_affine_N_near_fb0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, hp, gp);
2218 }
2219
2220 static void
2221 paint_affine_near_sa_3_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2222 {
2223 TRACK_FN();
2224 template_affine_N_near_fb0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, hp, gp);
2225 }
2226
2227 static void
2228 paint_affine_near_da_sa_alpha_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2229 {
2230 TRACK_FN();
2231 template_affine_alpha_N_near(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
2232 }
2233
2234 static void
2235 paint_affine_near_da_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2236 {
2237 TRACK_FN();
2238 template_affine_N_near(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, hp, gp);
2239 }
2240
2241 static void
2242 paint_affine_near_sa_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2243 {
2244 TRACK_FN();
2245 template_affine_N_near(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, hp, gp);
2246 }
2247
2248 static void
2249 paint_affine_near_da_alpha_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2250 {
2251 TRACK_FN();
2252 template_affine_alpha_N_near(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
2253 }
2254
2255 static void
2256 paint_affine_near_sa_alpha_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2257 {
2258 TRACK_FN();
2259 template_affine_alpha_N_near(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
2260 }
2261
2262 static void
2263 paint_affine_near_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2264 {
2265 TRACK_FN();
2266 template_affine_N_near(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, hp, gp);
2267 }
2268
2269 static void
2270 paint_affine_near_alpha_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2271 {
2272 TRACK_FN();
2273 template_affine_alpha_N_near(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 3, 3, alpha, hp, gp);
2274 }
2275 #endif /* FZ_PLOTTERS_RGB */
2276
2277 #if FZ_PLOTTERS_CMYK
2278 static void
2279 paint_affine_near_da_sa_4_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2280 {
2281 TRACK_FN();
2282 template_affine_N_near_fa0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, hp, gp);
2283 }
2284
2285 static void
2286 paint_affine_near_da_sa_alpha_4_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2287 {
2288 TRACK_FN();
2289 template_affine_alpha_N_near_fa0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
2290 }
2291
2292 static void
2293 paint_affine_near_da_4_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2294 {
2295 TRACK_FN();
2296 template_affine_N_near_fa0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, hp, gp);
2297 }
2298
2299 static void
2300 paint_affine_near_da_alpha_4_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2301 {
2302 TRACK_FN();
2303 template_affine_alpha_N_near_fa0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
2304 }
2305
2306 static void
2307 paint_affine_near_sa_4_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2308 {
2309 TRACK_FN();
2310 template_affine_N_near_fa0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, hp, gp);
2311 }
2312
2313 static void
2314 paint_affine_near_sa_alpha_4_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2315 {
2316 TRACK_FN();
2317 template_affine_alpha_N_near_fa0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
2318 }
2319
2320 static void
2321 paint_affine_near_4_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2322 {
2323 TRACK_FN();
2324 template_affine_N_near_fa0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, hp, gp);
2325 }
2326
2327 static void
2328 paint_affine_near_alpha_4_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2329 {
2330 TRACK_FN();
2331 template_affine_alpha_N_near_fa0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
2332 }
2333
2334 static void
2335 paint_affine_near_da_sa_4_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2336 {
2337 TRACK_FN();
2338 template_affine_N_near_fb0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, hp, gp);
2339 }
2340
2341 static void
2342 paint_affine_near_da_sa_alpha_4_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2343 {
2344 TRACK_FN();
2345 template_affine_alpha_N_near_fb0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
2346 }
2347
2348 static void
2349 paint_affine_near_da_4_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2350 {
2351 TRACK_FN();
2352 template_affine_N_near_fb0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, hp, gp);
2353 }
2354
2355 static void
2356 paint_affine_near_da_alpha_4_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2357 {
2358 TRACK_FN();
2359 template_affine_alpha_N_near_fb0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
2360 }
2361
2362 static void
2363 paint_affine_near_sa_4_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2364 {
2365 TRACK_FN();
2366 template_affine_N_near_fb0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, hp, gp);
2367 }
2368
2369 static void
2370 paint_affine_near_sa_alpha_4_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2371 {
2372 TRACK_FN();
2373 template_affine_alpha_N_near_fb0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
2374 }
2375
2376 static void
2377 paint_affine_near_4_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2378 {
2379 TRACK_FN();
2380 template_affine_N_near_fb0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, hp, gp);
2381 }
2382
2383 static void
2384 paint_affine_near_alpha_4_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2385 {
2386 TRACK_FN();
2387 template_affine_alpha_N_near_fb0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
2388 }
2389
2390 static void
2391 paint_affine_near_da_sa_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2392 {
2393 TRACK_FN();
2394 template_affine_N_near(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, hp, gp);
2395 }
2396
2397 static void
2398 paint_affine_near_da_sa_alpha_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2399 {
2400 TRACK_FN();
2401 template_affine_alpha_N_near(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
2402 }
2403
2404 static void
2405 paint_affine_near_da_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2406 {
2407 TRACK_FN();
2408 template_affine_N_near(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, hp, gp);
2409 }
2410
2411 static void
2412 paint_affine_near_da_alpha_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2413 {
2414 TRACK_FN();
2415 template_affine_alpha_N_near(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
2416 }
2417
2418 static void
2419 paint_affine_near_sa_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2420 {
2421 TRACK_FN();
2422 template_affine_N_near(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, hp, gp);
2423 }
2424
2425 static void
2426 paint_affine_near_sa_alpha_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2427 {
2428 TRACK_FN();
2429 template_affine_alpha_N_near(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
2430 }
2431
2432 static void
2433 paint_affine_near_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2434 {
2435 TRACK_FN();
2436 template_affine_N_near(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, hp, gp);
2437 }
2438
2439 static void
2440 paint_affine_near_alpha_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2441 {
2442 TRACK_FN();
2443 template_affine_alpha_N_near(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, 4, 4, alpha, hp, gp);
2444 }
2445 #endif /* FZ_PLOTTERS_CMYK */
2446
2447 #if FZ_PLOTTERS_N
2448 static void
2449 paint_affine_near_da_sa_N_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2450 {
2451 TRACK_FN();
2452 template_affine_N_near_fa0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, hp, gp);
2453 }
2454
2455 static void
2456 paint_affine_near_da_sa_alpha_N_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2457 {
2458 TRACK_FN();
2459 template_affine_alpha_N_near_fa0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
2460 }
2461
2462 static void
2463 paint_affine_near_da_N_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2464 {
2465 TRACK_FN();
2466 template_affine_N_near_fa0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, hp, gp);
2467 }
2468
2469 static void
2470 paint_affine_near_da_alpha_N_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2471 {
2472 TRACK_FN();
2473 template_affine_alpha_N_near_fa0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
2474 }
2475
2476 static void
2477 paint_affine_near_sa_N_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2478 {
2479 TRACK_FN();
2480 template_affine_N_near_fa0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, hp, gp);
2481 }
2482
2483 static void
2484 paint_affine_near_sa_alpha_N_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2485 {
2486 TRACK_FN();
2487 template_affine_alpha_N_near_fa0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
2488 }
2489
2490 static void
2491 paint_affine_near_N_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2492 {
2493 TRACK_FN();
2494 template_affine_N_near_fa0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, hp, gp);
2495 }
2496
2497 static void
2498 paint_affine_near_alpha_N_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2499 {
2500 TRACK_FN();
2501 template_affine_alpha_N_near_fa0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
2502 }
2503
2504 static void
2505 paint_affine_near_da_sa_N_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2506 {
2507 TRACK_FN();
2508 template_affine_N_near_fb0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, hp, gp);
2509 }
2510
2511 static void
2512 paint_affine_near_da_sa_alpha_N_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2513 {
2514 TRACK_FN();
2515 template_affine_alpha_N_near_fb0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
2516 }
2517
2518 static void
2519 paint_affine_near_da_N_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2520 {
2521 TRACK_FN();
2522 template_affine_N_near_fb0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, hp, gp);
2523 }
2524
2525 static void
2526 paint_affine_near_da_alpha_N_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2527 {
2528 TRACK_FN();
2529 template_affine_alpha_N_near_fb0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
2530 }
2531
2532 static void
2533 paint_affine_near_sa_N_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2534 {
2535 TRACK_FN();
2536 template_affine_N_near_fb0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, hp, gp);
2537 }
2538
2539 static void
2540 paint_affine_near_sa_alpha_N_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2541 {
2542 TRACK_FN();
2543 template_affine_alpha_N_near_fb0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
2544 }
2545
2546 static void
2547 paint_affine_near_N_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2548 {
2549 TRACK_FN();
2550 template_affine_N_near_fb0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, hp, gp);
2551 }
2552
2553 static void
2554 paint_affine_near_alpha_N_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2555 {
2556 TRACK_FN();
2557 template_affine_alpha_N_near_fb0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
2558 }
2559
2560 static void
2561 paint_affine_near_da_sa_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2562 {
2563 TRACK_FN();
2564 template_affine_N_near(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, hp, gp);
2565 }
2566
2567 static void
2568 paint_affine_near_da_sa_alpha_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2569 {
2570 TRACK_FN();
2571 template_affine_alpha_N_near(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
2572 }
2573
2574 static void
2575 paint_affine_near_da_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2576 {
2577 TRACK_FN();
2578 template_affine_N_near(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, hp, gp);
2579 }
2580
2581 static void
2582 paint_affine_near_da_alpha_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2583 {
2584 TRACK_FN();
2585 template_affine_alpha_N_near(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
2586 }
2587
2588 static void
2589 paint_affine_near_sa_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2590 {
2591 TRACK_FN();
2592 template_affine_N_near(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, hp, gp);
2593 }
2594
2595 static void
2596 paint_affine_near_sa_alpha_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2597 {
2598 TRACK_FN();
2599 template_affine_alpha_N_near(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
2600 }
2601
2602 static void
2603 paint_affine_near_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2604 {
2605 TRACK_FN();
2606 template_affine_N_near(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, hp, gp);
2607 }
2608
2609 static void
2610 paint_affine_near_alpha_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2611 {
2612 TRACK_FN();
2613 template_affine_alpha_N_near(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, dn, sn, alpha, hp, gp);
2614 }
2615 #endif /* FZ_PLOTTERS_N */
2616
2617 #if FZ_ENABLE_SPOT_RENDERING
2618 static void
2619 paint_affine_near_N_op(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2620 {
2621 TRACK_FN();
2622 template_affine_N_near_op(dp, da, sp, sw, sh, ss, sa, u, v, fa, fb, w, dn, sn, hp, gp, eop);
2623 }
2624
2625 static void
2626 paint_affine_near_alpha_N_op(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
2627 {
2628 TRACK_FN();
2629 template_affine_alpha_N_near_op(dp, da, sp, sw, sh, ss, sa, u, v, fa, fb, w, dn, sn, alpha, hp, gp, eop);
2630 }
2631 #endif /* FZ_ENABLE_SPOT_RENDERING */
2632
2633 static paintfn_t *
2634 fz_paint_affine_near(int da, int sa, affint fa, affint fb, int n, int alpha, const fz_overprint * FZ_RESTRICT eop)
2635 {
2636 #if FZ_ENABLE_SPOT_RENDERING
2637 if (fz_overprint_required(eop))
2638 {
2639 if (alpha == 255)
2640 return paint_affine_near_N_op;
2641 else if (alpha > 0)
2642 return paint_affine_near_alpha_N_op;
2643 else
2644 return NULL;
2645 }
2646 #endif /* FZ_ENABLE_SPOT_RENDERING */
2647 switch(n)
2648 {
2649 case 0:
2650 if (da)
2651 {
2652 if (sa)
2653 {
2654 if (alpha == 255)
2655 {
2656 if (fa == 0)
2657 return paint_affine_near_da_sa_0_fa0;
2658 else if (fb == 0)
2659 return paint_affine_near_da_sa_0_fb0;
2660 else
2661 return paint_affine_near_da_sa_0;
2662 }
2663 else if (alpha > 0)
2664 {
2665 if (fa == 0)
2666 return paint_affine_near_da_sa_alpha_0_fa0;
2667 else if (fb == 0)
2668 return paint_affine_near_da_sa_alpha_0_fb0;
2669 else
2670 return paint_affine_near_da_sa_alpha_0;
2671 }
2672 }
2673 else
2674 {
2675 if (alpha == 255)
2676 {
2677 if (fa == 0)
2678 return paint_affine_near_da_0_fa0;
2679 else if (fb == 0)
2680 return paint_affine_near_da_0_fb0;
2681 else
2682 return paint_affine_near_da_0;
2683 }
2684 else if (alpha > 0)
2685 {
2686 if (fa == 0)
2687 return paint_affine_near_da_alpha_0_fa0;
2688 else if (fb == 0)
2689 return paint_affine_near_da_alpha_0_fb0;
2690 else
2691 return paint_affine_near_da_alpha_0;
2692 }
2693 }
2694 }
2695 break;
2696
2697 case 1:
2698 if (sa)
2699 {
2700 #if FZ_PLOTTERS_G
2701 if (da)
2702 {
2703 if (alpha == 255)
2704 {
2705 if (fa == 0)
2706 return paint_affine_near_da_sa_1_fa0;
2707 else if (fb == 0)
2708 return paint_affine_near_da_sa_1_fb0;
2709 else
2710 return paint_affine_near_da_sa_1;
2711 }
2712 else if (alpha > 0)
2713 {
2714 if (fa == 0)
2715 return paint_affine_near_da_sa_alpha_1_fa0;
2716 else if (fb == 0)
2717 return paint_affine_near_da_sa_alpha_1_fb0;
2718 else
2719 return paint_affine_near_da_sa_alpha_1;
2720 }
2721 }
2722 else
2723 {
2724 if (alpha == 255)
2725 {
2726 if (fa == 0)
2727 return paint_affine_near_sa_1_fa0;
2728 else if (fb == 0)
2729 return paint_affine_near_sa_1_fb0;
2730 else
2731 return paint_affine_near_sa_1;
2732 }
2733 else if (alpha > 0)
2734 {
2735 if (fa == 0)
2736 return paint_affine_near_sa_alpha_1_fa0;
2737 else if (fb == 0)
2738 return paint_affine_near_sa_alpha_1_fb0;
2739 else
2740 return paint_affine_near_sa_alpha_1;
2741 }
2742 }
2743 #else
2744 goto fallback;
2745 #endif /* FZ_PLOTTERS_G */
2746 }
2747 else
2748 {
2749 if (da)
2750 {
2751 if (alpha == 255)
2752 {
2753 if (fa == 0)
2754 return paint_affine_near_da_1_fa0;
2755 else if (fb == 0)
2756 return paint_affine_near_da_1_fb0;
2757 else
2758 return paint_affine_near_da_1;
2759 }
2760 else if (alpha > 0)
2761 {
2762 if (fa == 0)
2763 return paint_affine_near_da_alpha_1_fa0;
2764 else if (fb == 0)
2765 return paint_affine_near_da_alpha_1_fb0;
2766 else
2767 return paint_affine_near_da_alpha_1;
2768 }
2769 }
2770 else
2771 {
2772 if (alpha == 255)
2773 {
2774 if (fa == 0)
2775 return paint_affine_near_1_fa0;
2776 else if (fb == 0)
2777 return paint_affine_near_1_fb0;
2778 else
2779 return paint_affine_near_1;
2780 }
2781 else if (alpha > 0)
2782 {
2783 if (fa == 0)
2784 return paint_affine_near_alpha_1_fa0;
2785 else if (fb == 0)
2786 return paint_affine_near_alpha_1_fb0;
2787 else
2788 return paint_affine_near_alpha_1;
2789 }
2790 }
2791 }
2792 break;
2793
2794 #if FZ_PLOTTERS_RGB
2795 case 3:
2796 if (da)
2797 {
2798 if (sa)
2799 {
2800 if (alpha == 255)
2801 {
2802 if (fa == 0)
2803 return paint_affine_near_da_sa_3_fa0;
2804 else if (fb == 0)
2805 return paint_affine_near_da_sa_3_fb0;
2806 else
2807 return paint_affine_near_da_sa_3;
2808 }
2809 else if (alpha > 0)
2810 {
2811 if (fa == 0)
2812 return paint_affine_near_da_sa_alpha_3_fa0;
2813 else if (fb == 0)
2814 return paint_affine_near_da_sa_alpha_3_fb0;
2815 else
2816 return paint_affine_near_da_sa_alpha_3;
2817 }
2818 }
2819 else
2820 {
2821 if (alpha == 255)
2822 {
2823 if (fa == 0)
2824 return paint_affine_near_da_3_fa0;
2825 else if (fb == 0)
2826 return paint_affine_near_da_3_fb0;
2827 else
2828 return paint_affine_near_da_3;
2829 }
2830 else if (alpha > 0)
2831 {
2832 if (fa == 0)
2833 return paint_affine_near_da_alpha_3_fa0;
2834 else if (fb == 0)
2835 return paint_affine_near_da_alpha_3_fb0;
2836 else
2837 return paint_affine_near_da_alpha_3;
2838 }
2839 }
2840 }
2841 else
2842 {
2843 if (sa)
2844 {
2845 if (alpha == 255)
2846 {
2847 if (fa == 0)
2848 return paint_affine_near_sa_3_fa0;
2849 else if (fb == 0)
2850 return paint_affine_near_sa_3_fb0;
2851 else
2852 return paint_affine_near_sa_3;
2853 }
2854 else if (alpha > 0)
2855 {
2856 if (fa == 0)
2857 return paint_affine_near_sa_alpha_3_fa0;
2858 else if (fb == 0)
2859 return paint_affine_near_sa_alpha_3_fb0;
2860 else
2861 return paint_affine_near_sa_alpha_3;
2862 }
2863 }
2864 else
2865 {
2866 if (alpha == 255)
2867 {
2868 if (fa == 0)
2869 return paint_affine_near_3_fa0;
2870 else if (fb == 0)
2871 return paint_affine_near_3_fb0;
2872 else
2873 return paint_affine_near_3;
2874 }
2875 else if (alpha > 0)
2876 {
2877 if (fa == 0)
2878 return paint_affine_near_alpha_3_fa0;
2879 else if (fb == 0)
2880 return paint_affine_near_alpha_3_fb0;
2881 else
2882 return paint_affine_near_alpha_3;
2883 }
2884 }
2885 }
2886 break;
2887 #endif /* FZ_PLOTTERS_RGB */
2888
2889 #if FZ_PLOTTERS_CMYK
2890 case 4:
2891 if (da)
2892 {
2893 if (sa)
2894 {
2895 if (alpha == 255)
2896 {
2897 if (fa == 0)
2898 return paint_affine_near_da_sa_4_fa0;
2899 else if (fb == 0)
2900 return paint_affine_near_da_sa_4_fb0;
2901 else
2902 return paint_affine_near_da_sa_4;
2903 }
2904 else if (alpha > 0)
2905 {
2906 if (fa == 0)
2907 return paint_affine_near_da_sa_alpha_4_fa0;
2908 else if (fb == 0)
2909 return paint_affine_near_da_sa_alpha_4_fb0;
2910 else
2911 return paint_affine_near_da_sa_alpha_4;
2912 }
2913 }
2914 else
2915 {
2916 if (alpha == 255)
2917 {
2918 if (fa == 0)
2919 return paint_affine_near_da_4_fa0;
2920 else if (fb == 0)
2921 return paint_affine_near_da_4_fb0;
2922 else
2923 return paint_affine_near_da_4;
2924 }
2925 else if (alpha > 0)
2926 {
2927 if (fa == 0)
2928 return paint_affine_near_da_alpha_4_fa0;
2929 else if (fb == 0)
2930 return paint_affine_near_da_alpha_4_fb0;
2931 else
2932 return paint_affine_near_da_alpha_4;
2933 }
2934 }
2935 }
2936 else
2937 {
2938 if (sa)
2939 {
2940 if (alpha == 255)
2941 {
2942 if (fa == 0)
2943 return paint_affine_near_sa_4_fa0;
2944 else if (fb == 0)
2945 return paint_affine_near_sa_4_fb0;
2946 else
2947 return paint_affine_near_sa_4;
2948 }
2949 else if (alpha > 0)
2950 {
2951 if (fa == 0)
2952 return paint_affine_near_sa_alpha_4_fa0;
2953 else if (fb == 0)
2954 return paint_affine_near_sa_alpha_4_fb0;
2955 else
2956 return paint_affine_near_sa_alpha_4;
2957 }
2958 }
2959 else
2960 {
2961 if (alpha == 255)
2962 {
2963 if (fa == 0)
2964 return paint_affine_near_4_fa0;
2965 else if (fb == 0)
2966 return paint_affine_near_4_fb0;
2967 else
2968 return paint_affine_near_4;
2969 }
2970 else if (alpha > 0)
2971 {
2972 if (fa == 0)
2973 return paint_affine_near_alpha_4_fa0;
2974 else if (fb == 0)
2975 return paint_affine_near_alpha_4_fb0;
2976 else
2977 return paint_affine_near_alpha_4;
2978 }
2979 }
2980 }
2981 break;
2982 #endif /* FZ_PLOTTERS_CMYK */
2983
2984 #if !FZ_PLOTTERS_G
2985 fallback:
2986 #endif /* FZ_PLOTTERS_G */
2987 default:
2988 #if FZ_PLOTTERS_N
2989 if (da)
2990 {
2991 if (sa)
2992 {
2993 if (alpha == 255)
2994 {
2995 if (fa == 0)
2996 return paint_affine_near_da_sa_N_fa0;
2997 else if (fb == 0)
2998 return paint_affine_near_da_sa_N_fb0;
2999 else
3000 return paint_affine_near_da_sa_N;
3001 }
3002 else if (alpha > 0)
3003 {
3004 if (fa == 0)
3005 return paint_affine_near_da_sa_alpha_N_fa0;
3006 else if (fb == 0)
3007 return paint_affine_near_da_sa_alpha_N_fb0;
3008 else
3009 return paint_affine_near_da_sa_alpha_N;
3010 }
3011 }
3012 else
3013 {
3014 if (alpha == 255)
3015 {
3016 if (fa == 0)
3017 return paint_affine_near_da_N_fa0;
3018 else if (fb == 0)
3019 return paint_affine_near_da_N_fb0;
3020 else
3021 return paint_affine_near_da_N;
3022 }
3023 else if (alpha > 0)
3024 {
3025 if (fa == 0)
3026 return paint_affine_near_da_alpha_N_fa0;
3027 else if (fb == 0)
3028 return paint_affine_near_da_alpha_N_fb0;
3029 else
3030 return paint_affine_near_da_alpha_N;
3031 }
3032 }
3033 }
3034 else
3035 {
3036 if (sa)
3037 {
3038 if (alpha == 255)
3039 {
3040 if (fa == 0)
3041 return paint_affine_near_sa_N_fa0;
3042 else if (fb == 0)
3043 return paint_affine_near_sa_N_fb0;
3044 else
3045 return paint_affine_near_sa_N;
3046 }
3047 else if (alpha > 0)
3048 {
3049 if (fa == 0)
3050 return paint_affine_near_sa_alpha_N_fa0;
3051 else if (fb == 0)
3052 return paint_affine_near_sa_alpha_N_fb0;
3053 else
3054 return paint_affine_near_sa_alpha_N;
3055 }
3056 }
3057 else
3058 {
3059 if (alpha == 255)
3060 {
3061 if (fa == 0)
3062 return paint_affine_near_N_fa0;
3063 else if (fb == 0)
3064 return paint_affine_near_N_fb0;
3065 else
3066 return paint_affine_near_N;
3067 }
3068 else if (alpha > 0)
3069 {
3070 if (fa == 0)
3071 return paint_affine_near_alpha_N_fa0;
3072 else if (fb == 0)
3073 return paint_affine_near_alpha_N_fb0;
3074 else
3075 return paint_affine_near_alpha_N;
3076 }
3077 }
3078 }
3079 #endif /* FZ_PLOTTERS_N */
3080 break;
3081 }
3082 return NULL;
3083 }
3084
3085 #if FZ_ENABLE_SPOT_RENDERING
3086 static paintfn_t *
3087 fz_paint_affine_near_spots(int da, int sa, affint fa, affint fb, int dn, int sn, int alpha, const fz_overprint * FZ_RESTRICT eop)
3088 {
3089 if (fz_overprint_required(eop))
3090 {
3091 if (alpha == 255)
3092 return paint_affine_near_N_op;
3093 else if (alpha > 0)
3094 return paint_affine_near_alpha_N_op;
3095 }
3096 else if (da)
3097 {
3098 if (sa)
3099 {
3100 if (alpha == 255)
3101 {
3102 if (fa == 0)
3103 return paint_affine_near_da_sa_N_fa0;
3104 else if (fb == 0)
3105 return paint_affine_near_da_sa_N_fb0;
3106 else
3107 return paint_affine_near_da_sa_N;
3108 }
3109 else if (alpha > 0)
3110 {
3111 if (fa == 0)
3112 return paint_affine_near_da_sa_alpha_N_fa0;
3113 else if (fb == 0)
3114 return paint_affine_near_da_sa_alpha_N_fb0;
3115 else
3116 return paint_affine_near_da_sa_alpha_N;
3117 }
3118 }
3119 else
3120 {
3121 if (alpha == 255)
3122 {
3123 if (fa == 0)
3124 return paint_affine_near_da_N_fa0;
3125 else if (fb == 0)
3126 return paint_affine_near_da_N_fb0;
3127 else
3128 return paint_affine_near_da_N;
3129 }
3130 else if (alpha > 0)
3131 {
3132 if (fa == 0)
3133 return paint_affine_near_da_alpha_N_fa0;
3134 else if (fb == 0)
3135 return paint_affine_near_da_alpha_N_fb0;
3136 else
3137 return paint_affine_near_da_alpha_N;
3138 }
3139 }
3140 }
3141 else
3142 {
3143 if (sa)
3144 {
3145 if (alpha == 255)
3146 {
3147 if (fa == 0)
3148 return paint_affine_near_sa_N_fa0;
3149 else if (fb == 0)
3150 return paint_affine_near_sa_N_fb0;
3151 else
3152 return paint_affine_near_sa_N;
3153 }
3154 else if (alpha > 0)
3155 {
3156 if (fa == 0)
3157 return paint_affine_near_sa_alpha_N_fa0;
3158 else if (fb == 0)
3159 return paint_affine_near_sa_alpha_N_fb0;
3160 else
3161 return paint_affine_near_sa_alpha_N;
3162 }
3163 }
3164 else
3165 {
3166 if (alpha == 255)
3167 {
3168 if (fa == 0)
3169 return paint_affine_near_N_fa0;
3170 else if (fb == 0)
3171 return paint_affine_near_N_fb0;
3172 else
3173 return paint_affine_near_N;
3174 }
3175 else if (alpha > 0)
3176 {
3177 if (fa == 0)
3178 return paint_affine_near_alpha_N_fa0;
3179 else if (fb == 0)
3180 return paint_affine_near_alpha_N_fb0;
3181 else
3182 return paint_affine_near_alpha_N;
3183 }
3184 }
3185 }
3186 return NULL;
3187 }
3188 #endif /* FZ_ENABLE_SPOT_RENDERING */
3189
3190 #if FZ_PLOTTERS_RGB
3191 static void
3192 paint_affine_near_da_sa_g2rgb_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3193 {
3194 TRACK_FN();
3195 template_affine_solid_g2rgb_near_fa0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, hp, gp);
3196 }
3197
3198 static void
3199 paint_affine_near_da_sa_alpha_g2rgb_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3200 {
3201 TRACK_FN();
3202 template_affine_alpha_g2rgb_near_fa0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, alpha, hp, gp);
3203 }
3204
3205 static void
3206 paint_affine_near_da_g2rgb_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3207 {
3208 TRACK_FN();
3209 template_affine_solid_g2rgb_near_fa0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, hp, gp);
3210 }
3211
3212 static void
3213 paint_affine_near_da_alpha_g2rgb_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3214 {
3215 TRACK_FN();
3216 template_affine_alpha_g2rgb_near_fa0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, alpha, hp, gp);
3217 }
3218
3219 static void
3220 paint_affine_near_sa_g2rgb_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3221 {
3222 TRACK_FN();
3223 template_affine_solid_g2rgb_near_fa0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, hp, gp);
3224 }
3225
3226 static void
3227 paint_affine_near_sa_alpha_g2rgb_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3228 {
3229 TRACK_FN();
3230 template_affine_alpha_g2rgb_near_fa0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, alpha, hp, gp);
3231 }
3232
3233 static void
3234 paint_affine_near_g2rgb_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3235 {
3236 TRACK_FN();
3237 template_affine_solid_g2rgb_near_fa0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, hp, gp);
3238 }
3239
3240 static void
3241 paint_affine_near_alpha_g2rgb_fa0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3242 {
3243 TRACK_FN();
3244 template_affine_alpha_g2rgb_near_fa0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, alpha, hp, gp);
3245 }
3246
3247 static void
3248 paint_affine_near_da_sa_g2rgb_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3249 {
3250 TRACK_FN();
3251 template_affine_solid_g2rgb_near_fb0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, hp, gp);
3252 }
3253
3254 static void
3255 paint_affine_near_da_sa_alpha_g2rgb_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3256 {
3257 TRACK_FN();
3258 template_affine_alpha_g2rgb_near_fb0(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, alpha, hp, gp);
3259 }
3260
3261 static void
3262 paint_affine_near_da_g2rgb_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3263 {
3264 TRACK_FN();
3265 template_affine_solid_g2rgb_near_fb0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, hp, gp);
3266 }
3267
3268 static void
3269 paint_affine_near_da_alpha_g2rgb_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3270 {
3271 TRACK_FN();
3272 template_affine_alpha_g2rgb_near_fb0(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, alpha, hp, gp);
3273 }
3274
3275 static void
3276 paint_affine_near_sa_g2rgb_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3277 {
3278 TRACK_FN();
3279 template_affine_solid_g2rgb_near_fb0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, hp, gp);
3280 }
3281
3282 static void
3283 paint_affine_near_sa_alpha_g2rgb_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3284 {
3285 TRACK_FN();
3286 template_affine_alpha_g2rgb_near_fb0(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, alpha, hp, gp);
3287 }
3288
3289 static void
3290 paint_affine_near_g2rgb_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3291 {
3292 TRACK_FN();
3293 template_affine_solid_g2rgb_near_fb0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, hp, gp);
3294 }
3295
3296 static void
3297 paint_affine_near_alpha_g2rgb_fb0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3298 {
3299 TRACK_FN();
3300 template_affine_alpha_g2rgb_near_fb0(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, alpha, hp, gp);
3301 }
3302
3303 static void
3304 paint_affine_near_da_sa_g2rgb(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3305 {
3306 TRACK_FN();
3307 template_affine_solid_g2rgb_near(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, hp, gp);
3308 }
3309
3310 static void
3311 paint_affine_near_da_sa_alpha_g2rgb(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3312 {
3313 TRACK_FN();
3314 template_affine_alpha_g2rgb_near(dp, 1, sp, sw, sh, ss, 1, u, v, fa, fb, w, alpha, hp, gp);
3315 }
3316
3317 static void
3318 paint_affine_near_da_g2rgb(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3319 {
3320 TRACK_FN();
3321 template_affine_solid_g2rgb_near(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, hp, gp);
3322 }
3323
3324 static void
3325 paint_affine_near_da_alpha_g2rgb(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3326 {
3327 TRACK_FN();
3328 template_affine_alpha_g2rgb_near(dp, 1, sp, sw, sh, ss, 0, u, v, fa, fb, w, alpha, hp, gp);
3329 }
3330
3331 static void
3332 paint_affine_near_sa_g2rgb(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3333 {
3334 TRACK_FN();
3335 template_affine_solid_g2rgb_near(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, hp, gp);
3336 }
3337
3338 static void
3339 paint_affine_near_sa_alpha_g2rgb(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3340 {
3341 TRACK_FN();
3342 template_affine_alpha_g2rgb_near(dp, 0, sp, sw, sh, ss, 1, u, v, fa, fb, w, alpha, hp, gp);
3343 }
3344
3345 static void
3346 paint_affine_near_g2rgb(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3347 {
3348 TRACK_FN();
3349 template_affine_solid_g2rgb_near(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, hp, gp);
3350 }
3351
3352 static void
3353 paint_affine_near_alpha_g2rgb(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn1, int sn1, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3354 {
3355 TRACK_FN();
3356 template_affine_alpha_g2rgb_near(dp, 0, sp, sw, sh, ss, 0, u, v, fa, fb, w, alpha, hp, gp);
3357 }
3358
3359 static paintfn_t *
3360 fz_paint_affine_g2rgb_near(int da, int sa, affint fa, affint fb, int n, int alpha)
3361 {
3362 if (da)
3363 {
3364 if (sa)
3365 {
3366 if (fa == 0)
3367 {
3368 if (alpha == 255)
3369 return paint_affine_near_da_sa_g2rgb_fa0;
3370 else if (alpha > 0)
3371 return paint_affine_near_da_sa_alpha_g2rgb_fa0;
3372 }
3373 else if (fb == 0)
3374 {
3375 if (alpha == 255)
3376 return paint_affine_near_da_sa_g2rgb_fb0;
3377 else if (alpha > 0)
3378 return paint_affine_near_da_sa_alpha_g2rgb_fb0;
3379 }
3380 else
3381 {
3382 if (alpha == 255)
3383 return paint_affine_near_da_sa_g2rgb;
3384 else if (alpha > 0)
3385 return paint_affine_near_da_sa_alpha_g2rgb;
3386 }
3387 }
3388 else
3389 {
3390 if (fa == 0)
3391 {
3392 if (alpha == 255)
3393 return paint_affine_near_da_g2rgb_fa0;
3394 else if (alpha > 0)
3395 return paint_affine_near_da_alpha_g2rgb_fa0;
3396 }
3397 else if (fb == 0)
3398 {
3399 if (alpha == 255)
3400 return paint_affine_near_da_g2rgb_fb0;
3401 else if (alpha > 0)
3402 return paint_affine_near_da_alpha_g2rgb_fb0;
3403 }
3404 else
3405 {
3406 if (alpha == 255)
3407 return paint_affine_near_da_g2rgb;
3408 else if (alpha > 0)
3409 return paint_affine_near_da_alpha_g2rgb;
3410 }
3411 }
3412 }
3413 else
3414 {
3415 if (sa)
3416 {
3417 if (fa == 0)
3418 {
3419 if (alpha == 255)
3420 return paint_affine_near_sa_g2rgb_fa0;
3421 else if (alpha > 0)
3422 return paint_affine_near_sa_alpha_g2rgb_fa0;
3423 }
3424 else if (fb == 0)
3425 {
3426 if (alpha == 255)
3427 return paint_affine_near_sa_g2rgb_fb0;
3428 else if (alpha > 0)
3429 return paint_affine_near_sa_alpha_g2rgb_fb0;
3430 }
3431 else
3432 {
3433 if (alpha == 255)
3434 return paint_affine_near_sa_g2rgb;
3435 else if (alpha > 0)
3436 return paint_affine_near_sa_alpha_g2rgb;
3437 }
3438 }
3439 else
3440 {
3441 if (fa == 0)
3442 {
3443 if (alpha == 255)
3444 return paint_affine_near_g2rgb_fa0;
3445 else if (alpha > 0)
3446 return paint_affine_near_alpha_g2rgb_fa0;
3447 }
3448 else if (fb == 0)
3449 {
3450 if (alpha == 255)
3451 return paint_affine_near_g2rgb_fb0;
3452 else if (alpha > 0)
3453 return paint_affine_near_alpha_g2rgb_fb0;
3454 }
3455 else
3456 {
3457 if (alpha == 255)
3458 return paint_affine_near_g2rgb;
3459 else if (alpha > 0)
3460 return paint_affine_near_alpha_g2rgb;
3461 }
3462 }
3463 }
3464 return NULL;
3465 }
3466 #endif /* FZ_PLOTTERS_RGB */
3467
3468 static void
3469 paint_affine_color_lerp_da_0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3470 {
3471 TRACK_FN();
3472 template_affine_color_N_lerp(dp, 1, sp, sw, sh, ss, u, v, fa, fb, w, 0, 0, color, hp, gp);
3473 }
3474
3475 #if FZ_PLOTTERS_G
3476 static void
3477 paint_affine_color_lerp_da_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3478 {
3479 TRACK_FN();
3480 template_affine_color_N_lerp(dp, 1, sp, sw, sh, ss, u, v, fa, fb, w, 1, 1, color, hp, gp);
3481 }
3482
3483 static void
3484 paint_affine_color_lerp_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3485 {
3486 TRACK_FN();
3487 template_affine_color_N_lerp(dp, 0, sp, sw, sh, ss, u, v, fa, fb, w, 1, 1, color, hp, gp);
3488 }
3489 #endif /* FZ_PLOTTERS_G */
3490
3491 #if FZ_PLOTTERS_RGB
3492 static void
3493 paint_affine_color_lerp_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3494 {
3495 TRACK_FN();
3496 template_affine_color_N_lerp(dp, 0, sp, sw, sh, ss, u, v, fa, fb, w, 3, 3, color, hp, gp);
3497 }
3498
3499 static void
3500 paint_affine_color_lerp_da_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3501 {
3502 TRACK_FN();
3503 template_affine_color_N_lerp(dp, 1, sp, sw, sh, ss, u, v, fa, fb, w, 3, 3, color, hp, gp);
3504 }
3505 #endif /* FZ_PLOTTERS_RGB */
3506
3507 #if FZ_PLOTTERS_CMYK
3508 static void
3509 paint_affine_color_lerp_da_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3510 {
3511 TRACK_FN();
3512 template_affine_color_N_lerp(dp, 1, sp, sw, sh, ss, u, v, fa, fb, w, 4, 4, color, hp, gp);
3513 }
3514
3515 static void
3516 paint_affine_color_lerp_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3517 {
3518 TRACK_FN();
3519 template_affine_color_N_lerp(dp, 0, sp, sw, sh, ss, u, v, fa, fb, w, 4, 4, color, hp, gp);
3520 }
3521 #endif /* FZ_PLOTTERS_G */
3522
3523 #if FZ_PLOTTERS_N
3524 static void
3525 paint_affine_color_lerp_da_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3526 {
3527 TRACK_FN();
3528 template_affine_color_N_lerp(dp, 1, sp, sw, sh, ss, u, v, fa, fb, w, dn, sn, color, hp, gp);
3529 }
3530
3531 static void
3532 paint_affine_color_lerp_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3533 {
3534 TRACK_FN();
3535 template_affine_color_N_lerp(dp, 0, sp, sw, sh, ss, u, v, fa, fb, w, dn, sn, color, hp, gp);
3536 }
3537 #endif /* FZ_PLOTTERS_N */
3538
3539 #if FZ_ENABLE_SPOT_RENDERING
3540 static void
3541 paint_affine_color_lerp_N_op(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3542 {
3543 TRACK_FN();
3544 template_affine_color_N_lerp_op(dp, da, sp, sw, sh, ss, u, v, fa, fb, w, dn, sn, color, hp, gp, eop);
3545 }
3546 #endif /* FZ_ENABLE_SPOT_RENDERING */
3547
3548 static paintfn_t *
3549 fz_paint_affine_color_lerp(int da, int sa, affint fa, affint fb, int n, int alpha, const fz_overprint * FZ_RESTRICT eop)
3550 {
3551 #if FZ_ENABLE_SPOT_RENDERING
3552 if (fz_overprint_required(eop))
3553 return paint_affine_color_lerp_N_op;
3554 #endif /* FZ_ENABLE_SPOT_RENDERING */
3555 switch (n)
3556 {
3557 case 0: return da ? paint_affine_color_lerp_da_0 : NULL;
3558 #if FZ_PLOTTERS_G
3559 case 1: return da ? paint_affine_color_lerp_da_1 : paint_affine_color_lerp_1;
3560 #endif /* FZ_PLOTTERS_G */
3561 #if FZ_PLOTTERS_RGB
3562 case 3: return da ? paint_affine_color_lerp_da_3 : paint_affine_color_lerp_3;
3563 #endif /* FZ_PLOTTERS_RGB */
3564 #if FZ_PLOTTERS_CMYK
3565 case 4: return da ? paint_affine_color_lerp_da_4 : paint_affine_color_lerp_4;
3566 #endif /* FZ_PLOTTERS_CMYK */
3567 #if FZ_PLOTTERS_N
3568 default: return da ? paint_affine_color_lerp_da_N : paint_affine_color_lerp_N;
3569 #endif /* FZ_PLOTTERS_N */
3570 }
3571 }
3572
3573 #if FZ_ENABLE_SPOT_RENDERING
3574 static paintfn_t *
3575 fz_paint_affine_color_lerp_spots(int da, int sa, affint fa, affint fb, int dn, int sn, int alpha, const fz_overprint * FZ_RESTRICT eop)
3576 {
3577 if (fz_overprint_required(eop))
3578 return paint_affine_color_lerp_N_op;
3579 return da ? paint_affine_color_lerp_da_N : paint_affine_color_lerp_N;
3580 }
3581 #endif /* FZ_ENABLE_SPOT_RENDERING */
3582
3583 static void
3584 paint_affine_color_near_da_0(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3585 {
3586 TRACK_FN();
3587 template_affine_color_N_near(dp, 1, sp, sw, sh, ss, u, v, fa, fb, w, 0, 0, color, hp, gp);
3588 }
3589
3590 #if FZ_PLOTTERS_G
3591 static void
3592 paint_affine_color_near_da_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3593 {
3594 TRACK_FN();
3595 template_affine_color_N_near(dp, 1, sp, sw, sh, ss, u, v, fa, fb, w, 1, 1, color, hp, gp);
3596 }
3597
3598 static void
3599 paint_affine_color_near_1(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3600 {
3601 TRACK_FN();
3602 template_affine_color_N_near(dp, 0, sp, sw, sh, ss, u, v, fa, fb, w, 1, 1, color, hp, gp);
3603 }
3604 #endif /* FZ_PLOTTERS_G */
3605
3606 #if FZ_PLOTTERS_RGB
3607 static void
3608 paint_affine_color_near_da_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3609 {
3610 TRACK_FN();
3611 template_affine_color_N_near(dp, 1, sp, sw, sh, ss, u, v, fa, fb, w, 3, 3, color, hp, gp);
3612 }
3613
3614 static void
3615 paint_affine_color_near_3(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3616 {
3617 TRACK_FN();
3618 template_affine_color_N_near(dp, 0, sp, sw, sh, ss, u, v, fa, fb, w, 3, 3, color, hp, gp);
3619 }
3620 #endif /* FZ_PLOTTERS_RGB */
3621
3622 #if FZ_PLOTTERS_CMYK
3623 static void
3624 paint_affine_color_near_da_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3625 {
3626 TRACK_FN();
3627 template_affine_color_N_near(dp, 1, sp, sw, sh, ss, u, v, fa, fb, w, 4, 4, color, hp, gp);
3628 }
3629
3630 static void
3631 paint_affine_color_near_4(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3632 {
3633 TRACK_FN();
3634 template_affine_color_N_near(dp, 0, sp, sw, sh, ss, u, v, fa, fb, w, 4, 4, color, hp, gp);
3635 }
3636 #endif /* FZ_PLOTTERS_CMYK */
3637
3638 #if FZ_PLOTTERS_N
3639 static void
3640 paint_affine_color_near_da_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3641 {
3642 TRACK_FN();
3643 template_affine_color_N_near(dp, 1, sp, sw, sh, ss, u, v, fa, fb, w, dn, sn, color, hp, gp);
3644 }
3645
3646 static void
3647 paint_affine_color_near_N(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3648 {
3649 TRACK_FN();
3650 template_affine_color_N_near(dp, 0, sp, sw, sh, ss, u, v, fa, fb, w, dn, sn, color, hp, gp);
3651 }
3652 #endif /* FZ_PLOTTERS_N */
3653
3654 #if FZ_ENABLE_SPOT_RENDERING
3655 static void
3656 paint_affine_color_near_da_N_op(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3657 {
3658 TRACK_FN();
3659 template_affine_color_N_near_op(dp, 1, sp, sw, sh, ss, u, v, fa, fb, w, dn, sn, color, hp, gp, eop);
3660 }
3661
3662 static void
3663 paint_affine_color_near_N_op(byte * FZ_RESTRICT dp, int da, const byte * FZ_RESTRICT sp, affint sw, affint sh, ptrdiff_t ss, int sa, affint u, affint v, affint fa, affint fb, int w, int dn, int sn, int alpha, const byte * FZ_RESTRICT color, byte * FZ_RESTRICT hp, byte * FZ_RESTRICT gp, const fz_overprint * FZ_RESTRICT eop)
3664 {
3665 TRACK_FN();
3666 template_affine_color_N_near_op(dp, 0, sp, sw, sh, ss, u, v, fa, fb, w, dn, sn, color, hp, gp, eop);
3667 }
3668 #endif /* FZ_ENABLE_SPOT_RENDERING */
3669
3670 static paintfn_t *
3671 fz_paint_affine_color_near(int da, int sa, affint fa, affint fb, int n, int alpha, const fz_overprint * FZ_RESTRICT eop)
3672 {
3673 #if FZ_ENABLE_SPOT_RENDERING
3674 if (fz_overprint_required(eop))
3675 return da ? paint_affine_color_near_da_N_op : paint_affine_color_near_N_op;
3676 #endif /* FZ_ENABLE_SPOT_RENDERING */
3677 switch (n)
3678 {
3679 case 0: return da ? paint_affine_color_near_da_0 : NULL;
3680 #if FZ_PLOTTERS_G
3681 case 1: return da ? paint_affine_color_near_da_1 : paint_affine_color_near_1;
3682 #endif /* FZ_PLOTTERS_G */
3683 #if FZ_PLOTTERS_RGB
3684 case 3: return da ? paint_affine_color_near_da_3 : paint_affine_color_near_3;
3685 #endif /* FZ_PLOTTERS_RGB */
3686 #if FZ_PLOTTERS_CMYK
3687 case 4: return da ? paint_affine_color_near_da_4 : paint_affine_color_near_4;
3688 #endif /* FZ_PLOTTERS_CMYK */
3689 #if FZ_PLOTTERS_N
3690 default: return da ? paint_affine_color_near_da_N : paint_affine_color_near_N;
3691 #else
3692 default: return NULL;
3693 #endif /* FZ_PLOTTERS_N */
3694 }
3695 }
3696
3697 #if FZ_ENABLE_SPOT_RENDERING
3698 static paintfn_t *
3699 fz_paint_affine_color_near_spots(int da, int sa, affint fa, affint fb, int dn, int sn, int alpha, const fz_overprint * FZ_RESTRICT eop)
3700 {
3701 if (fz_overprint_required(eop))
3702 return da ? paint_affine_color_near_da_N_op : paint_affine_color_near_N_op;
3703 return da ? paint_affine_color_near_da_N : paint_affine_color_near_N;
3704 }
3705 #endif /* FZ_ENABLE_SPOT_RENDERING */
3706
3707 /* RJW: The following code was originally written to be sensitive to
3708 * FLT_EPSILON. Given the way the 'minimum representable difference'
3709 * between 2 floats changes size as we scale, we now pick a larger
3710 * value to ensure idempotency even with rounding problems. The
3711 * value we pick is still far smaller than would ever show up with
3712 * antialiasing.
3713 */
3714 #define MY_EPSILON 0.001f
3715
3716 /* We have 2 possible ways of gridfitting images. The first way, considered
3717 * 'safe' in all cases, is to expand an image out to fill a box that entirely
3718 * covers all the pixels touched by the current image. This is our 'standard'
3719 * mechanism.
3720 *
3721 * The alternative, used when we know images are tiled across a page, is to
3722 * round the edge of each image to the closest integer pixel boundary. This
3723 * would not be safe in the general case, but gives less distortion across
3724 * neighbouring images when tiling is used.
3725 */
3726 fz_matrix
3727 fz_gridfit_matrix(int as_tiled, fz_matrix m)
3728 {
3729 if (fabsf(m.b) < FLT_EPSILON && fabsf(m.c) < FLT_EPSILON)
3730 {
3731 if (as_tiled)
3732 {
3733 float f;
3734 /* Nearest boundary for left */
3735 f = (float)(int)(m.e + 0.5f);
3736 m.a += m.e - f; /* Adjust width for change */
3737 m.e = f;
3738 /* Nearest boundary for right (width really) */
3739 m.a = (float)(int)(m.a + 0.5f);
3740 }
3741 else if (m.a > 0)
3742 {
3743 float f;
3744 /* Adjust left hand side onto pixel boundary */
3745 f = (float)(int)(m.e);
3746 if (f - m.e > MY_EPSILON)
3747 f -= 1.0f; /* Ensure it moves left */
3748 m.a += m.e - f; /* width gets wider as f <= m.e */
3749 m.e = f;
3750 /* Adjust right hand side onto pixel boundary */
3751 f = (float)(int)(m.a);
3752 if (m.a - f > MY_EPSILON)
3753 f += 1.0f; /* Ensure it moves right */
3754 m.a = f;
3755 }
3756 else if (m.a < 0)
3757 {
3758 float f;
3759 /* Adjust right hand side onto pixel boundary */
3760 f = (float)(int)(m.e);
3761 if (m.e - f > MY_EPSILON)
3762 f += 1.0f; /* Ensure it moves right */
3763 m.a += m.e - f; /* width gets wider (more -ve) */
3764 m.e = f;
3765 /* Adjust left hand side onto pixel boundary */
3766 f = (float)(int)(m.a);
3767 if (f - m.a > MY_EPSILON)
3768 f -= 1.0f; /* Ensure it moves left */
3769 m.a = f;
3770 }
3771 if (as_tiled)
3772 {
3773 float f;
3774 /* Nearest boundary for top */
3775 f = (float)(int)(m.f + 0.5f);
3776 m.d += m.f - f; /* Adjust width for change */
3777 m.f = f;
3778 /* Nearest boundary for bottom (height really) */
3779 m.d = (float)(int)(m.d + 0.5f);
3780 }
3781 else if (m.d > 0)
3782 {
3783 float f;
3784 /* Adjust top onto pixel boundary */
3785 f = (float)(int)(m.f);
3786 if (f - m.f > MY_EPSILON)
3787 f -= 1.0f; /* Ensure it moves upwards */
3788 m.d += m.f - f; /* width gets wider as f <= m.f */
3789 m.f = f;
3790 /* Adjust bottom onto pixel boundary */
3791 f = (float)(int)(m.d);
3792 if (m.d - f > MY_EPSILON)
3793 f += 1.0f; /* Ensure it moves down */
3794 m.d = f;
3795 }
3796 else if (m.d < 0)
3797 {
3798 float f;
3799 /* Adjust bottom onto pixel boundary */
3800 f = (float)(int)(m.f);
3801 if (m.f - f > MY_EPSILON)
3802 f += 1.0f; /* Ensure it moves down */
3803 m.d += m.f - f; /* width gets wider (more -ve) */
3804 m.f = f;
3805 /* Adjust top onto pixel boundary */
3806 f = (float)(int)(m.d);
3807 if (f - m.d > MY_EPSILON)
3808 f -= 1.0f; /* Ensure it moves up */
3809 m.d = f;
3810 }
3811 }
3812 else if (fabsf(m.a) < FLT_EPSILON && fabsf(m.d) < FLT_EPSILON)
3813 {
3814 if (as_tiled)
3815 {
3816 float f;
3817 /* Nearest boundary for left */
3818 f = (float)(int)(m.e + 0.5f);
3819 m.b += m.e - f; /* Adjust width for change */
3820 m.e = f;
3821 /* Nearest boundary for right (width really) */
3822 m.b = (float)(int)(m.b + 0.5f);
3823 }
3824 else if (m.b > 0)
3825 {
3826 float f;
3827 /* Adjust left hand side onto pixel boundary */
3828 f = (float)(int)(m.f);
3829 if (f - m.f > MY_EPSILON)
3830 f -= 1.0f; /* Ensure it moves left */
3831 m.b += m.f - f; /* width gets wider as f <= m.f */
3832 m.f = f;
3833 /* Adjust right hand side onto pixel boundary */
3834 f = (float)(int)(m.b);
3835 if (m.b - f > MY_EPSILON)
3836 f += 1.0f; /* Ensure it moves right */
3837 m.b = f;
3838 }
3839 else if (m.b < 0)
3840 {
3841 float f;
3842 /* Adjust right hand side onto pixel boundary */
3843 f = (float)(int)(m.f);
3844 if (m.f - f > MY_EPSILON)
3845 f += 1.0f; /* Ensure it moves right */
3846 m.b += m.f - f; /* width gets wider (more -ve) */
3847 m.f = f;
3848 /* Adjust left hand side onto pixel boundary */
3849 f = (float)(int)(m.b);
3850 if (f - m.b > MY_EPSILON)
3851 f -= 1.0f; /* Ensure it moves left */
3852 m.b = f;
3853 }
3854 if (as_tiled)
3855 {
3856 float f;
3857 /* Nearest boundary for left */
3858 f = (float)(int)(m.f + 0.5f);
3859 m.c += m.f - f; /* Adjust width for change */
3860 m.f = f;
3861 /* Nearest boundary for right (width really) */
3862 m.c = (float)(int)(m.c + 0.5f);
3863 }
3864 else if (m.c > 0)
3865 {
3866 float f;
3867 /* Adjust top onto pixel boundary */
3868 f = (float)(int)(m.e);
3869 if (f - m.e > MY_EPSILON)
3870 f -= 1.0f; /* Ensure it moves upwards */
3871 m.c += m.e - f; /* width gets wider as f <= m.e */
3872 m.e = f;
3873 /* Adjust bottom onto pixel boundary */
3874 f = (float)(int)(m.c);
3875 if (m.c - f > MY_EPSILON)
3876 f += 1.0f; /* Ensure it moves down */
3877 m.c = f;
3878 }
3879 else if (m.c < 0)
3880 {
3881 float f;
3882 /* Adjust bottom onto pixel boundary */
3883 f = (float)(int)(m.e);
3884 if (m.e - f > MY_EPSILON)
3885 f += 1.0f; /* Ensure it moves down */
3886 m.c += m.e - f; /* width gets wider (more -ve) */
3887 m.e = f;
3888 /* Adjust top onto pixel boundary */
3889 f = (float)(int)(m.c);
3890 if (f - m.c > MY_EPSILON)
3891 f -= 1.0f; /* Ensure it moves up */
3892 m.c = f;
3893 }
3894 }
3895 return m;
3896 }
3897
3898 /* Draw an image with an affine transform on destination */
3899
3900 static void
3901 fz_paint_image_imp(fz_context *ctx,
3902 fz_pixmap *dst,
3903 const fz_irect *scissor,
3904 fz_pixmap *shape,
3905 fz_pixmap *group_alpha,
3906 fz_pixmap *img,
3907 fz_matrix ctm,
3908 const byte *color,
3909 int alpha,
3910 int lerp_allowed,
3911 const fz_overprint *eop)
3912 {
3913 byte *dp, *sp, *hp, *gp;
3914 affint u, v, fa, fb, fc, fd;
3915 int x, y, w, h;
3916 affint sw, sh, sa, sn, hs, da, dn, gs;
3917 ptrdiff_t ss;
3918 fz_irect bbox;
3919 int dolerp;
3920 paintfn_t *paintfn;
3921 int is_rectilinear;
3922
3923 if (alpha == 0)
3924 return;
3925
3926 /* turn on interpolation for upscaled and non-rectilinear transforms */
3927 dolerp = 0;
3928 is_rectilinear = fz_is_rectilinear(ctm);
3929 if (!is_rectilinear)
3930 dolerp = lerp_allowed;
3931 if (sqrtf(ctm.a * ctm.a + ctm.b * ctm.b) > img->w)
3932 dolerp = lerp_allowed;
3933 if (sqrtf(ctm.c * ctm.c + ctm.d * ctm.d) > img->h)
3934 dolerp = lerp_allowed;
3935
3936 /* except when we shouldn't, at large magnifications */
3937 if (!(img->flags & FZ_PIXMAP_FLAG_INTERPOLATE))
3938 {
3939 if (sqrtf(ctm.a * ctm.a + ctm.b * ctm.b) > img->w * 2)
3940 dolerp = 0;
3941 if (sqrtf(ctm.c * ctm.c + ctm.d * ctm.d) > img->h * 2)
3942 dolerp = 0;
3943 }
3944
3945 bbox = fz_irect_from_rect(fz_transform_rect(fz_unit_rect, ctm));
3946 bbox = fz_intersect_irect(bbox, *scissor);
3947
3948 x = bbox.x0;
3949 if (shape && shape->x > x)
3950 x = shape->x;
3951 if (group_alpha && group_alpha->x > x)
3952 x = group_alpha->x;
3953 y = bbox.y0;
3954 if (shape && shape->y > y)
3955 y = shape->y;
3956 if (group_alpha && group_alpha->y > y)
3957 y = group_alpha->y;
3958 w = bbox.x1;
3959 if (shape && shape->x + shape->w < w)
3960 w = shape->x + shape->w;
3961 if (group_alpha && group_alpha->x + group_alpha->w < w)
3962 w = group_alpha->x + group_alpha->w;
3963 if (w <= x)
3964 return;
3965 w -= x;
3966 h = bbox.y1;
3967 if (shape && shape->y + shape->h < h)
3968 h = shape->y + shape->h;
3969 if (group_alpha && group_alpha->y + group_alpha->h < h)
3970 h = group_alpha->y + group_alpha->h;
3971 if (h <= y)
3972 return;
3973 h -= y;
3974
3975 /* map from screen space (x,y) to image space (u,v) */
3976 ctm = fz_pre_scale(ctm, 1.0f / img->w, 1.0f / img->h);
3977 ctm = fz_invert_matrix(ctm);
3978
3979 fa = (affint)(ctm.a *= ONE);
3980 fb = (affint)(ctm.b *= ONE);
3981 fc = (affint)(ctm.c *= ONE);
3982 fd = (affint)(ctm.d *= ONE);
3983 ctm.e *= ONE;
3984 ctm.f *= ONE;
3985
3986 /* Calculate initial texture positions. Do a half step to start. */
3987 /* Bug 693021: Keep calculation in float for as long as possible to
3988 * avoid overflow. */
3989 u = (int)((ctm.a * x) + (ctm.c * y) + ctm.e + ((ctm.a + ctm.c) * .5f));
3990 v = (int)((ctm.b * x) + (ctm.d * y) + ctm.f + ((ctm.b + ctm.d) * .5f));
3991
3992 dp = dst->samples + (y - dst->y) * (size_t)dst->stride + (x - dst->x) * (size_t)dst->n;
3993 da = dst->alpha;
3994 dn = dst->n - da;
3995 sp = img->samples;
3996 sw = img->w;
3997 sh = img->h;
3998 ss = img->stride;
3999 sa = img->alpha;
4000 sn = img->n - sa;
4001 if (shape)
4002 {
4003 hs = shape->stride;
4004 hp = shape->samples + (y - shape->y) * (size_t)shape->stride + x - shape->x;
4005 }
4006 else
4007 {
4008 hs = 0;
4009 hp = NULL;
4010 }
4011 if (group_alpha)
4012 {
4013 gs = group_alpha->stride;
4014 gp = group_alpha->samples + (y - group_alpha->y) * (size_t)group_alpha->stride + x - group_alpha->x;
4015 }
4016 else
4017 {
4018 gs = 0;
4019 gp = NULL;
4020 }
4021
4022 /* image size overflows fixed point math */
4023 if (sw >= LIMIT || sh >= LIMIT)
4024 {
4025 /* Note this may cause compile warning because fz_warn() is marked as
4026 being like printf(), but actually it treats %ld as matching int64_t. */
4027 fz_warn(ctx, "image too large for fixed point math: %ld x %ld", (int64_t)sw, (int64_t)sh);
4028 return;
4029 }
4030
4031 /* TODO: if (fb == 0 && fa == 1) call fz_paint_span */
4032
4033 /* Sometimes we can get an alpha only input to be
4034 * plotted. In this case treat it as a greyscale
4035 * input. */
4036 if (img->n == sa && color)
4037 {
4038 sa = 0;
4039 sn = 1;
4040 }
4041
4042 #if FZ_PLOTTERS_RGB
4043 if (dn == 3 && dst->s == 0 && img->n == 1 + sa && !color && !fz_overprint_required(eop))
4044 {
4045 if (dolerp)
4046 paintfn = fz_paint_affine_g2rgb_lerp(da, sa, fa, fb, dn, alpha);
4047 else
4048 paintfn = fz_paint_affine_g2rgb_near(da, sa, fa, fb, dn, alpha);
4049 }
4050 else
4051 #endif /* FZ_PLOTTERS_RGB */
4052 #if FZ_ENABLE_SPOT_RENDERING
4053 if (sn != dn)
4054 {
4055 if (dolerp)
4056 {
4057 if (color)
4058 paintfn = fz_paint_affine_color_lerp_spots(da, sa, fa, fb, dn, sn, alpha, eop);
4059 else
4060 paintfn = fz_paint_affine_lerp_spots(da, sa, fa, fb, dn, sn, alpha, eop);
4061 }
4062 else
4063 {
4064 if (color)
4065 paintfn = fz_paint_affine_color_near_spots(da, sa, fa, fb, dn, sn, alpha, eop);
4066 else
4067 paintfn = fz_paint_affine_near_spots(da, sa, fa, fb, dn, sn, alpha, eop);
4068 }
4069 }
4070 else
4071 #endif /* FZ_ENABLE_SPOT_RENDERING */
4072 {
4073 assert((!color && sn == dn) || (color && sn + sa == 1));
4074 if (dolerp)
4075 {
4076 if (color)
4077 paintfn = fz_paint_affine_color_lerp(da, sa, fa, fb, dn, alpha, eop);
4078 else
4079 paintfn = fz_paint_affine_lerp(da, sa, fa, fb, dn, alpha, eop);
4080 }
4081 else
4082 {
4083 if (color)
4084 paintfn = fz_paint_affine_color_near(da, sa, fa, fb, dn, alpha, eop);
4085 else
4086 paintfn = fz_paint_affine_near(da, sa, fa, fb, dn, alpha, eop);
4087 }
4088 }
4089
4090 assert(paintfn);
4091 if (paintfn == NULL)
4092 return;
4093
4094 if (dolerp)
4095 {
4096 u -= HALF;
4097 v -= HALF;
4098 sw = (sw<<PREC) + HALF;
4099 sh = (sh<<PREC) + HALF;
4100 }
4101
4102 while (h--)
4103 {
4104 paintfn(dp, da, sp, sw, sh, ss, sa, u, v, fa, fb, w, dn, sn, alpha, color, hp, gp, eop);
4105 dp += dst->stride;
4106 hp += hs;
4107 gp += gs;
4108 u += fc;
4109 v += fd;
4110 }
4111 }
4112
4113 void
4114 fz_paint_image_with_color(fz_context *ctx, fz_pixmap * FZ_RESTRICT dst, const fz_irect * FZ_RESTRICT scissor, fz_pixmap * FZ_RESTRICT shape, fz_pixmap * FZ_RESTRICT group_alpha, fz_pixmap * FZ_RESTRICT img, fz_matrix ctm, const byte * FZ_RESTRICT color, int lerp_allowed, const fz_overprint * FZ_RESTRICT eop)
4115 {
4116 assert(img->n == 1);
4117 fz_paint_image_imp(ctx, dst, scissor, shape, group_alpha, img, ctm, color, 255, lerp_allowed, eop);
4118 }
4119
4120 void
4121 fz_paint_image(fz_context *ctx, fz_pixmap * FZ_RESTRICT dst, const fz_irect * FZ_RESTRICT scissor, fz_pixmap * FZ_RESTRICT shape, fz_pixmap * FZ_RESTRICT group_alpha, fz_pixmap * FZ_RESTRICT img, fz_matrix ctm, int alpha, int lerp_allowed, const fz_overprint * FZ_RESTRICT eop)
4122 {
4123 fz_paint_image_imp(ctx, dst, scissor, shape, group_alpha, img, ctm, NULL, alpha, lerp_allowed, eop);
4124 }