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