8 #include "pixman-private.h"
10 #include "pixman-combine.h"
12 /*** per channel helper functions ***/
15 combine_mask_ca (comp4_t *src, comp4_t *mask)
39 UNcx4_MUL_UNcx4(x, a);
46 combine_mask_value_ca (comp4_t *src, const comp4_t *mask)
61 UNcx4_MUL_UNcx4(x, a);
66 combine_mask_alpha_ca (const comp4_t *src, comp4_t *mask)
74 x = *(src) >> A_SHIFT;
93 * There are two ways of handling alpha -- either as a single unified value or
94 * a separate value for each component, hence each macro must have two
95 * versions. The unified alpha version has a 'U' at the end of the name,
96 * the component version has a 'C'. Similarly, functions which deal with
97 * this difference will have two versions using the same convention.
101 * All of the composing functions
104 static force_inline comp4_t
105 combine_mask (const comp4_t *src, const comp4_t *mask, int i)
111 m = *(mask + i) >> A_SHIFT;
120 UNcx4_MUL_UNc (s, m);
126 combine_clear (pixman_implementation_t *imp, pixman_op_t op,
127 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
129 memset(dest, 0, width*sizeof(comp4_t));
133 combine_src_u (pixman_implementation_t *imp, pixman_op_t op,
134 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
139 memcpy (dest, src, width * sizeof (comp4_t));
142 for (i = 0; i < width; ++i)
144 comp4_t s = combine_mask (src, mask, i);
151 /* if the Src is opaque, call combine_src_u */
153 combine_over_u (pixman_implementation_t *imp, pixman_op_t op,
154 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
157 for (i = 0; i < width; ++i) {
158 comp4_t s = combine_mask (src, mask, i);
159 comp4_t d = *(dest + i);
160 comp4_t ia = ALPHA_c(~s);
162 UNcx4_MUL_UNc_ADD_UNcx4(d, ia, s);
167 /* if the Dst is opaque, this is a noop */
169 combine_over_reverse_u (pixman_implementation_t *imp, pixman_op_t op,
170 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
173 for (i = 0; i < width; ++i) {
174 comp4_t s = combine_mask (src, mask, i);
175 comp4_t d = *(dest + i);
176 comp4_t ia = ALPHA_c(~*(dest + i));
177 UNcx4_MUL_UNc_ADD_UNcx4(s, ia, d);
182 /* if the Dst is opaque, call combine_src_u */
184 combine_in_u (pixman_implementation_t *imp, pixman_op_t op,
185 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
188 for (i = 0; i < width; ++i) {
189 comp4_t s = combine_mask (src, mask, i);
190 comp4_t a = ALPHA_c(*(dest + i));
196 /* if the Src is opaque, this is a noop */
198 combine_in_reverse_u (pixman_implementation_t *imp, pixman_op_t op,
199 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
202 for (i = 0; i < width; ++i) {
203 comp4_t s = combine_mask (src, mask, i);
204 comp4_t d = *(dest + i);
205 comp4_t a = ALPHA_c(s);
211 /* if the Dst is opaque, call combine_clear */
213 combine_out_u (pixman_implementation_t *imp, pixman_op_t op,
214 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
217 for (i = 0; i < width; ++i) {
218 comp4_t s = combine_mask (src, mask, i);
219 comp4_t a = ALPHA_c(~*(dest + i));
225 /* if the Src is opaque, call combine_clear */
227 combine_out_reverse_u (pixman_implementation_t *imp, pixman_op_t op,
228 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
231 for (i = 0; i < width; ++i) {
232 comp4_t s = combine_mask (src, mask, i);
233 comp4_t d = *(dest + i);
234 comp4_t a = ALPHA_c(~s);
240 /* if the Src is opaque, call combine_in_u */
241 /* if the Dst is opaque, call combine_over_u */
242 /* if both the Src and Dst are opaque, call combine_src_u */
244 combine_atop_u (pixman_implementation_t *imp, pixman_op_t op,
245 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
248 for (i = 0; i < width; ++i) {
249 comp4_t s = combine_mask (src, mask, i);
250 comp4_t d = *(dest + i);
251 comp4_t dest_a = ALPHA_c(d);
252 comp4_t src_ia = ALPHA_c(~s);
254 UNcx4_MUL_UNc_ADD_UNcx4_MUL_UNc(s, dest_a, d, src_ia);
259 /* if the Src is opaque, call combine_over_reverse_u */
260 /* if the Dst is opaque, call combine_in_reverse_u */
261 /* if both the Src and Dst are opaque, call combine_dst_u */
263 combine_atop_reverse_u (pixman_implementation_t *imp, pixman_op_t op,
264 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
267 for (i = 0; i < width; ++i) {
268 comp4_t s = combine_mask (src, mask, i);
269 comp4_t d = *(dest + i);
270 comp4_t src_a = ALPHA_c(s);
271 comp4_t dest_ia = ALPHA_c(~d);
273 UNcx4_MUL_UNc_ADD_UNcx4_MUL_UNc(s, dest_ia, d, src_a);
278 /* if the Src is opaque, call combine_over_u */
279 /* if the Dst is opaque, call combine_over_reverse_u */
280 /* if both the Src and Dst are opaque, call combine_clear */
282 combine_xor_u (pixman_implementation_t *imp, pixman_op_t op,
283 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
286 for (i = 0; i < width; ++i) {
287 comp4_t s = combine_mask (src, mask, i);
288 comp4_t d = *(dest + i);
289 comp4_t src_ia = ALPHA_c(~s);
290 comp4_t dest_ia = ALPHA_c(~d);
292 UNcx4_MUL_UNc_ADD_UNcx4_MUL_UNc(s, dest_ia, d, src_ia);
298 combine_add_u (pixman_implementation_t *imp, pixman_op_t op,
299 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
302 for (i = 0; i < width; ++i) {
303 comp4_t s = combine_mask (src, mask, i);
304 comp4_t d = *(dest + i);
305 UNcx4_ADD_UNcx4(d, s);
310 /* if the Src is opaque, call combine_add_u */
311 /* if the Dst is opaque, call combine_add_u */
312 /* if both the Src and Dst are opaque, call combine_add_u */
314 combine_saturate_u (pixman_implementation_t *imp, pixman_op_t op,
315 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
318 for (i = 0; i < width; ++i) {
319 comp4_t s = combine_mask (src, mask, i);
320 comp4_t d = *(dest + i);
327 sa = DIV_UNc(da, sa);
328 UNcx4_MUL_UNc(s, sa);
330 UNcx4_ADD_UNcx4(d, s);
337 * The following blend modes have been taken from the PDF ISO 32000
338 * specification, which at this point in time is available from
339 * http://www.adobe.com/devnet/acrobat/pdfs/PDF32000_2008.pdf
340 * The relevant chapters are 11.3.5 and 11.3.6.
341 * The formula for computing the final pixel color given in 11.3.6 is:
342 * αr × Cr = (1 – αs) × αb × Cb + (1 – αb) × αs × Cs + αb × αs × B(Cb, Cs)
343 * with B() being the blend function.
344 * Note that OVER is a special case of this operation, using B(Cb, Cs) = Cs
346 * These blend modes should match the SVG filter draft specification, as
347 * it has been designed to mirror ISO 32000. Note that at the current point
348 * no released draft exists that shows this, as the formulas have not been
349 * updated yet after the release of ISO 32000.
351 * The default implementation here uses the PDF_SEPARABLE_BLEND_MODE and
352 * PDF_NON_SEPARABLE_BLEND_MODE macros, which take the blend function as an
353 * argument. Note that this implementation operates on premultiplied colors,
354 * while the PDF specification does not. Therefore the code uses the formula
355 * ar.Cra = (1 – as) . Dca + (1 – ad) . Sca + B(Dca, ad, Sca, as)
360 * B(Dca, ad, Sca, as) = Dca.Sca
364 combine_multiply_u (pixman_implementation_t *imp, pixman_op_t op,
365 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
368 for (i = 0; i < width; ++i) {
369 comp4_t s = combine_mask (src, mask, i);
370 comp4_t d = *(dest + i);
372 comp4_t src_ia = ALPHA_c (~s);
373 comp4_t dest_ia = ALPHA_c (~d);
375 UNcx4_MUL_UNc_ADD_UNcx4_MUL_UNc (ss, dest_ia, d, src_ia);
376 UNcx4_MUL_UNcx4 (d, s);
377 UNcx4_ADD_UNcx4 (d, ss);
383 combine_multiply_ca (pixman_implementation_t *imp, pixman_op_t op,
384 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
387 for (i = 0; i < width; ++i) {
388 comp4_t m = *(mask + i);
389 comp4_t s = *(src + i);
390 comp4_t d = *(dest + i);
392 comp4_t dest_ia = ALPHA_c (~d);
394 combine_mask_value_ca (&s, &m);
396 UNcx4_MUL_UNcx4_ADD_UNcx4_MUL_UNc (r, ~m, s, dest_ia);
397 UNcx4_MUL_UNcx4 (d, s);
398 UNcx4_ADD_UNcx4 (r, d);
404 #define PDF_SEPARABLE_BLEND_MODE(name) \
406 combine_ ## name ## _u (pixman_implementation_t *imp, pixman_op_t op, \
407 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width) \
410 for (i = 0; i < width; ++i) { \
411 comp4_t s = combine_mask (src, mask, i); \
412 comp4_t d = *(dest + i); \
413 comp1_t sa = ALPHA_c(s); \
415 comp1_t da = ALPHA_c(d); \
420 UNcx4_MUL_UNc_ADD_UNcx4_MUL_UNc(result, isa, s, ida); \
422 *(dest + i) = result + \
423 (DIV_ONE_UNc (sa * da) << A_SHIFT) + \
424 (blend_ ## name (RED_c (d), da, RED_c (s), sa) << R_SHIFT) + \
425 (blend_ ## name (GREEN_c (d), da, GREEN_c (s), sa) << G_SHIFT) + \
426 (blend_ ## name (BLUE_c (d), da, BLUE_c (s), sa)); \
431 combine_ ## name ## _ca (pixman_implementation_t *imp, pixman_op_t op, \
432 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width) \
435 for (i = 0; i < width; ++i) { \
436 comp4_t m = *(mask + i); \
437 comp4_t s = *(src + i); \
438 comp4_t d = *(dest + i); \
439 comp1_t da = ALPHA_c(d); \
443 combine_mask_value_ca (&s, &m); \
446 UNcx4_MUL_UNcx4_ADD_UNcx4_MUL_UNc (result, ~m, s, ida); \
449 (DIV_ONE_UNc (ALPHA_c (m) * da) << A_SHIFT) + \
450 (blend_ ## name (RED_c (d), da, RED_c (s), RED_c (m)) << R_SHIFT) + \
451 (blend_ ## name (GREEN_c (d), da, GREEN_c (s), GREEN_c (m)) << G_SHIFT) + \
452 (blend_ ## name (BLUE_c (d), da, BLUE_c (s), BLUE_c (m))); \
454 *(dest + i) = result; \
460 * B(Dca, ad, Sca, as) = Dca.sa + Sca.da - Dca.Sca
463 static inline comp4_t
464 blend_screen (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa)
466 return DIV_ONE_UNc (sca * da + dca * sa - sca * dca);
469 PDF_SEPARABLE_BLEND_MODE (screen)
473 * B(Dca, ab, Sca, as) =
477 * Sa.Da - 2.(Da - Dca).(Sa - Sca)
480 static inline comp4_t
481 blend_overlay (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa)
488 rca = sa * da - 2 * (da - dca) * (sa - sca);
489 return DIV_ONE_UNc (rca);
492 PDF_SEPARABLE_BLEND_MODE (overlay)
496 * B(Dca, ab, Sca, as) = min (Sca.Da, Dca.Sa)
499 static inline comp4_t
500 blend_darken (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa)
506 return DIV_ONE_UNc (s > d ? d : s);
509 PDF_SEPARABLE_BLEND_MODE (darken)
513 * B(Dca, ab, Sca, as) = max (Sca.Da, Dca.Sa)
516 static inline comp4_t
517 blend_lighten (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa)
523 return DIV_ONE_UNc (s > d ? s : d);
526 PDF_SEPARABLE_BLEND_MODE (lighten)
530 * B(Dca, ab, Sca, as) =
534 * Da.Sa. min (Dca / Da / (1 - Sca/Sa))
537 static inline comp4_t
538 blend_color_dodge (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa)
541 return dca == 0 ? 0 : DIV_ONE_UNc (sa * da);
543 comp4_t rca = dca * sa * sa / (sa - sca);
544 return DIV_ONE_UNc (rca > sa * da ? sa * da : rca);
548 PDF_SEPARABLE_BLEND_MODE (color_dodge)
552 * B(Dca, ab, Sca, as) =
556 * Sa.Da.(1 - min (1, (1 - Dca/Da).Sa / Sca))
559 static inline comp4_t
560 blend_color_burn (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa)
563 return dca < da ? 0 : DIV_ONE_UNc (sa * da);
565 comp4_t sada = sa * da;
566 comp4_t rca = (da - dca) * sa * sa / sca;
567 return DIV_ONE_UNc (rca > sada ? 0 : sada - rca);
571 PDF_SEPARABLE_BLEND_MODE (color_burn)
575 * B(Dca, ab, Sca, as) =
579 * Sa.Da - 2.(Da - Dca).(Sa - Sca)
581 static inline comp4_t
582 blend_hard_light (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa)
585 return DIV_ONE_UNc (2 * sca * dca);
587 return DIV_ONE_UNc (sa * da - 2 * (da - dca) * (sa - sca));
590 PDF_SEPARABLE_BLEND_MODE (hard_light)
594 * B(Dca, ab, Sca, as) =
596 * Dca.(Sa - (1 - Dca/Da).(2.Sca - Sa))
597 * otherwise if Dca.4 <= Da
598 * Dca.(Sa + (2.Sca - Sa).((16.Dca/Da - 12).Dca/Da + 3)
600 * (Dca.Sa + (SQRT (Dca/Da).Da - Dca).(2.Sca - Sa))
603 static inline comp4_t
604 blend_soft_light (comp4_t dca_org, comp4_t da_org, comp4_t sca_org, comp4_t sa_org)
606 double dca = dca_org * (1.0 / MASK);
607 double da = da_org * (1.0 / MASK);
608 double sca = sca_org * (1.0 / MASK);
609 double sa = sa_org * (1.0 / MASK);
616 rca = dca * sa - dca * (da - dca) * (sa - 2 * sca) / da;
617 } else if (da == 0) {
619 } else if (4 * dca <= da) {
620 rca = dca * sa + (2 * sca - sa) * dca * ((16 * dca / da - 12) * dca / da + 3);
622 rca = dca * sa + (sqrt (dca * da) - dca) * (2 * sca - sa);
624 return rca * MASK + 0.5;
627 PDF_SEPARABLE_BLEND_MODE (soft_light)
631 * B(Dca, ab, Sca, as) = abs (Dca.Sa - Sca.Da)
634 static inline comp4_t
635 blend_difference (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa)
637 comp4_t dcasa = dca * sa;
638 comp4_t scada = sca * da;
641 return DIV_ONE_UNc (dcasa - scada);
643 return DIV_ONE_UNc (scada - dcasa);
646 PDF_SEPARABLE_BLEND_MODE (difference)
650 * B(Dca, ab, Sca, as) = (Sca.Da + Dca.Sa - 2.Sca.Dca)
653 /* This can be made faster by writing it directly and not using
654 * PDF_SEPARABLE_BLEND_MODE, but that's a performance optimization */
656 static inline comp4_t
657 blend_exclusion (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa)
659 return DIV_ONE_UNc (sca * da + dca * sa - 2 * dca * sca);
662 PDF_SEPARABLE_BLEND_MODE (exclusion)
664 #undef PDF_SEPARABLE_BLEND_MODE
667 * PDF nonseperable blend modes are implemented using the following functions
668 * to operate in Hsl space, with Cmax, Cmid, Cmin referring to the max, mid
669 * and min value of the red, green and blue components.
671 * LUM (C) = 0.3 × Cred + 0.59 × Cgreen + 0.11 × Cblue
678 * C = l + ( ( ( C – l ) × l ) ⁄ ( l – min ) )
680 * C = l + ( ( ( C – l ) × ( 1 – l ) ) ⁄ ( max – l ) )
686 * return clip_color (C)
688 * SAT (C) = CH_MAX (C) - CH_MIN (C)
692 * Cmid = ( ( ( Cmid – Cmin ) × s ) ⁄ ( Cmax – Cmin ) )
700 /* For premultiplied colors, we need to know what happens when C is
701 * multiplied by a real number. LUM and SAT are linear:
703 * LUM (r × C) = r × LUM (C) SAT (r * C) = r * SAT (C)
705 * If we extend clip_color with an extra argument a and change
713 * then clip_color is also linear:
715 * r * clip_color (C, a) = clip_color (r_c, ra);
719 * Similarly, we can extend set_lum with an extra argument that is just passed
722 * r * set_lum ( C, l, a)
724 * = r × clip_color ( C + l - LUM (C), a)
726 * = clip_color ( r * C + r × l - r * LUM (C), r * a)
728 * = set_lum ( r * C, r * l, r * a)
732 * r * set_sat (C, s) = set_sat (x * C, r * s)
734 * The above holds for all non-zero x, because they x'es in the fraction for
735 * C_mid cancel out. Specifically, it holds for x = r:
737 * r * set_sat (C, s) = set_sat (r_c, rs)
741 /* So, for the non-separable PDF blend modes, we have (using s, d for non-premultiplied
742 * colors, and S, D for premultiplied:
746 * a_s * a_d * B(s, d)
747 * = a_s * a_d * set_lum (S/a_s, LUM (D/a_d), 1)
748 * = set_lum (S * a_d, a_s * LUM (D), a_s * a_d)
753 * a_s * a_d * B(s, d)
754 * = a_s * a_d * set_lum (D/a_d, LUM(S/a_s), 1)
755 * = set_lum (a_s * D, a_d * LUM(S), a_s * a_d)
760 * a_s * a_d * B(s, d)
761 * = a_s * a_d * set_lum (set_sat (D/a_d, SAT (S/a_s)), LUM (D/a_d), 1)
762 * = set_lum (a_s * a_d * set_sat (D/a_d, SAT (S/a_s)), a_s * LUM (D), a_s * a_d)
763 * = set_lum (set_sat (a_s * D, a_d * SAT (S), a_s * LUM (D), a_s * a_d))
767 * a_s * a_d * B(s, d)
768 * = a_s * a_d * set_lum (set_sat (S/a_s, SAT (D/a_d)), LUM (D/a_d), 1)
769 * = a_s * a_d * set_lum (set_sat (a_d * S, a_s * SAT (D)), a_s * LUM (D), a_s * a_d)
773 #define CH_MIN(c) (c[0] < c[1] ? (c[0] < c[2] ? c[0] : c[2]) : (c[1] < c[2] ? c[1] : c[2]))
774 #define CH_MAX(c) (c[0] > c[1] ? (c[0] > c[2] ? c[0] : c[2]) : (c[1] > c[2] ? c[1] : c[2]))
775 #define LUM(c) ((c[0] * 30 + c[1] * 59 + c[2] * 11) / 100)
776 #define SAT(c) (CH_MAX (c) - CH_MIN (c))
778 #define PDF_NON_SEPARABLE_BLEND_MODE(name) \
780 combine_ ## name ## _u (pixman_implementation_t *imp, pixman_op_t op, \
781 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width) \
784 for (i = 0; i < width; ++i) { \
785 comp4_t s = combine_mask (src, mask, i); \
786 comp4_t d = *(dest + i); \
787 comp1_t sa = ALPHA_c(s); \
789 comp1_t da = ALPHA_c(d); \
792 comp4_t sc[3], dc[3], c[3]; \
795 UNcx4_MUL_UNc_ADD_UNcx4_MUL_UNc(result, isa, s, ida); \
798 dc[1] = GREEN_c (d); \
799 sc[1] = GREEN_c (s); \
800 dc[2] = BLUE_c (d); \
801 sc[2] = BLUE_c (s); \
802 blend_ ## name (c, dc, da, sc, sa); \
804 *(dest + i) = result + \
805 (DIV_ONE_UNc (sa * da) << A_SHIFT) + \
806 (DIV_ONE_UNc (c[0]) << R_SHIFT) + \
807 (DIV_ONE_UNc (c[1]) << G_SHIFT) + \
808 (DIV_ONE_UNc (c[2])); \
813 set_lum (comp4_t dest[3], comp4_t src[3], comp4_t sa, comp4_t lum)
815 double a, l, min, max;
818 a = sa * (1.0 / MASK);
819 l = lum * (1.0 / MASK);
820 tmp[0] = src[0] * (1.0 / MASK);
821 tmp[1] = src[1] * (1.0 / MASK);
822 tmp[2] = src[2] * (1.0 / MASK);
834 tmp[0] = l + (tmp[0] - l) * l / (l - min);
835 tmp[1] = l + (tmp[1] - l) * l / (l - min);
836 tmp[2] = l + (tmp[2] - l) * l / (l - min);
839 tmp[0] = l + (tmp[0] - l) * (a - l) / (max - l);
840 tmp[1] = l + (tmp[1] - l) * (a - l) / (max - l);
841 tmp[2] = l + (tmp[2] - l) * (a - l) / (max - l);
843 dest[0] = tmp[0] * MASK + 0.5;
844 dest[1] = tmp[1] * MASK + 0.5;
845 dest[2] = tmp[2] * MASK + 0.5;
849 set_sat (comp4_t dest[3], comp4_t src[3], comp4_t sat)
854 if (src[0] > src[1]) {
855 if (src[0] > src[2]) {
857 if (src[1] > src[2]) {
870 if (src[0] > src[2]) {
876 if (src[1] > src[2]) {
888 dest[id[1]] = (dest[id[1]] - min) * sat / (max - min);
892 dest[0] = dest[1] = dest[2] = 0;
898 * B(Cb, Cs) = set_lum (set_sat (Cs, SAT (Cb)), LUM (Cb))
901 blend_hsl_hue (comp4_t c[3], comp4_t dc[3], comp4_t da, comp4_t sc[3], comp4_t sa)
906 set_sat (c, c, SAT (dc) * sa);
907 set_lum (c, c, sa * da, LUM (dc) * sa);
910 PDF_NON_SEPARABLE_BLEND_MODE (hsl_hue)
914 * B(Cb, Cs) = set_lum (set_sat (Cb, SAT (Cs)), LUM (Cb))
917 blend_hsl_saturation (comp4_t c[3], comp4_t dc[3], comp4_t da, comp4_t sc[3], comp4_t sa)
922 set_sat (c, c, SAT (sc) * da);
923 set_lum (c, c, sa * da, LUM (dc) * sa);
926 PDF_NON_SEPARABLE_BLEND_MODE (hsl_saturation)
930 * B(Cb, Cs) = set_lum (Cs, LUM (Cb))
933 blend_hsl_color (comp4_t c[3], comp4_t dc[3], comp4_t da, comp4_t sc[3], comp4_t sa)
938 set_lum (c, c, sa * da, LUM (dc) * sa);
941 PDF_NON_SEPARABLE_BLEND_MODE (hsl_color)
945 * B(Cb, Cs) = set_lum (Cb, LUM (Cs))
948 blend_hsl_luminosity (comp4_t c[3], comp4_t dc[3], comp4_t da, comp4_t sc[3], comp4_t sa)
953 set_lum (c, c, sa * da, LUM (sc) * da);
956 PDF_NON_SEPARABLE_BLEND_MODE (hsl_luminosity)
962 #undef PDF_NON_SEPARABLE_BLEND_MODE
966 * All of the disjoint composing functions
968 The four entries in the first column indicate what source contributions
969 come from each of the four areas of the picture -- areas covered by neither
970 A nor B, areas covered only by A, areas covered only by B and finally
971 areas covered by both A and B.
978 (0,A,B,A) 1 min((1-a)/b,1) 1 max(1-a/b,0)
979 (0,A,B,B) min((1-b)/a,1) 1 max(1-b/a,0) 1
980 (0,0,0,A) max(1-(1-b)/a,0) 0 min(1,b/a) 0
981 (0,0,0,B) 0 max(1-(1-a)/b,0) 0 min(a/b,1)
982 (0,A,0,0) min(1,(1-b)/a) 0 max(1-b/a,0) 0
983 (0,0,B,0) 0 min(1,(1-a)/b) 0 max(1-a/b,0)
984 (0,0,B,A) max(1-(1-b)/a,0) min(1,(1-a)/b) min(1,b/a) max(1-a/b,0)
985 (0,A,0,B) min(1,(1-b)/a) max(1-(1-a)/b,0) max(1-b/a,0) min(1,a/b)
986 (0,A,B,0) min(1,(1-b)/a) min(1,(1-a)/b) max(1-b/a,0) max(1-a/b,0)
990 #define COMBINE_A_OUT 1
991 #define COMBINE_A_IN 2
992 #define COMBINE_B_OUT 4
993 #define COMBINE_B_IN 8
995 #define COMBINE_CLEAR 0
996 #define COMBINE_A (COMBINE_A_OUT|COMBINE_A_IN)
997 #define COMBINE_B (COMBINE_B_OUT|COMBINE_B_IN)
998 #define COMBINE_A_OVER (COMBINE_A_OUT|COMBINE_B_OUT|COMBINE_A_IN)
999 #define COMBINE_B_OVER (COMBINE_A_OUT|COMBINE_B_OUT|COMBINE_B_IN)
1000 #define COMBINE_A_ATOP (COMBINE_B_OUT|COMBINE_A_IN)
1001 #define COMBINE_B_ATOP (COMBINE_A_OUT|COMBINE_B_IN)
1002 #define COMBINE_XOR (COMBINE_A_OUT|COMBINE_B_OUT)
1004 /* portion covered by a but not b */
1006 combine_disjoint_out_part (comp1_t a, comp1_t b)
1008 /* min (1, (1-b) / a) */
1011 if (b >= a) /* 1 - b >= a -> (1-b)/a >= 1 */
1012 return MASK; /* 1 */
1013 return DIV_UNc(b,a); /* (1-b) / a */
1016 /* portion covered by both a and b */
1018 combine_disjoint_in_part (comp1_t a, comp1_t b)
1020 /* max (1-(1-b)/a,0) */
1021 /* = - min ((1-b)/a - 1, 0) */
1022 /* = 1 - min (1, (1-b)/a) */
1025 if (b >= a) /* 1 - b >= a -> (1-b)/a >= 1 */
1026 return 0; /* 1 - 1 */
1027 return ~DIV_UNc(b,a); /* 1 - (1-b) / a */
1030 /* portion covered by a but not b */
1032 combine_conjoint_out_part (comp1_t a, comp1_t b)
1035 /* = 1-min(b/a,1) */
1037 /* min (1, (1-b) / a) */
1039 if (b >= a) /* b >= a -> b/a >= 1 */
1040 return 0x00; /* 0 */
1041 return ~DIV_UNc(b,a); /* 1 - b/a */
1044 /* portion covered by both a and b */
1046 combine_conjoint_in_part (comp1_t a, comp1_t b)
1050 if (b >= a) /* b >= a -> b/a >= 1 */
1051 return MASK; /* 1 */
1052 return DIV_UNc(b,a); /* b/a */
1055 #define GET_COMP(v,i) ((comp2_t) (comp1_t) ((v) >> i))
1057 #define ADD(x,y,i,t) ((t) = GET_COMP(x,i) + GET_COMP(y,i), \
1058 (comp4_t) ((comp1_t) ((t) | (0 - ((t) >> G_SHIFT)))) << (i))
1060 #define GENERIC(x,y,i,ax,ay,t,u,v) ((t) = (MUL_UNc(GET_COMP(y,i),ay,(u)) + \
1061 MUL_UNc(GET_COMP(x,i),ax,(v))), \
1062 (comp4_t) ((comp1_t) ((t) | \
1063 (0 - ((t) >> G_SHIFT)))) << (i))
1066 combine_disjoint_general_u (comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width, comp1_t combine)
1069 for (i = 0; i < width; ++i) {
1070 comp4_t s = combine_mask (src, mask, i);
1071 comp4_t d = *(dest + i);
1073 comp2_t Fa, Fb, t, u, v;
1074 comp1_t sa = s >> A_SHIFT;
1075 comp1_t da = d >> A_SHIFT;
1077 switch (combine & COMBINE_A) {
1082 Fa = combine_disjoint_out_part (sa, da);
1085 Fa = combine_disjoint_in_part (sa, da);
1092 switch (combine & COMBINE_B) {
1097 Fb = combine_disjoint_out_part (da, sa);
1100 Fb = combine_disjoint_in_part (da, sa);
1106 m = GENERIC (s,d,0,Fa,Fb,t, u, v);
1107 n = GENERIC (s,d,G_SHIFT,Fa,Fb,t, u, v);
1108 o = GENERIC (s,d,R_SHIFT,Fa,Fb,t, u, v);
1109 p = GENERIC (s,d,A_SHIFT,Fa,Fb,t, u, v);
1116 combine_disjoint_over_u (pixman_implementation_t *imp, pixman_op_t op,
1117 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1120 for (i = 0; i < width; ++i) {
1121 comp4_t s = combine_mask (src, mask, i);
1122 comp2_t a = s >> A_SHIFT;
1128 comp4_t d = *(dest + i);
1129 a = combine_disjoint_out_part (d >> A_SHIFT, a);
1130 UNcx4_MUL_UNc_ADD_UNcx4(d, a, s);
1139 combine_disjoint_in_u (pixman_implementation_t *imp, pixman_op_t op,
1140 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1142 combine_disjoint_general_u (dest, src, mask, width, COMBINE_A_IN);
1146 combine_disjoint_in_reverse_u (pixman_implementation_t *imp, pixman_op_t op,
1147 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1149 combine_disjoint_general_u (dest, src, mask, width, COMBINE_B_IN);
1153 combine_disjoint_out_u (pixman_implementation_t *imp, pixman_op_t op,
1154 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1156 combine_disjoint_general_u (dest, src, mask, width, COMBINE_A_OUT);
1160 combine_disjoint_out_reverse_u (pixman_implementation_t *imp, pixman_op_t op,
1161 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1163 combine_disjoint_general_u (dest, src, mask, width, COMBINE_B_OUT);
1167 combine_disjoint_atop_u (pixman_implementation_t *imp, pixman_op_t op,
1168 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1170 combine_disjoint_general_u (dest, src, mask, width, COMBINE_A_ATOP);
1174 combine_disjoint_atop_reverse_u (pixman_implementation_t *imp, pixman_op_t op,
1175 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1177 combine_disjoint_general_u (dest, src, mask, width, COMBINE_B_ATOP);
1181 combine_disjoint_xor_u (pixman_implementation_t *imp, pixman_op_t op,
1182 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1184 combine_disjoint_general_u (dest, src, mask, width, COMBINE_XOR);
1188 combine_conjoint_general_u (comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width, comp1_t combine)
1191 for (i = 0; i < width; ++i) {
1192 comp4_t s = combine_mask (src, mask, i);
1193 comp4_t d = *(dest + i);
1195 comp2_t Fa, Fb, t, u, v;
1196 comp1_t sa = s >> A_SHIFT;
1197 comp1_t da = d >> A_SHIFT;
1199 switch (combine & COMBINE_A) {
1204 Fa = combine_conjoint_out_part (sa, da);
1207 Fa = combine_conjoint_in_part (sa, da);
1214 switch (combine & COMBINE_B) {
1219 Fb = combine_conjoint_out_part (da, sa);
1222 Fb = combine_conjoint_in_part (da, sa);
1228 m = GENERIC (s,d,0,Fa,Fb,t, u, v);
1229 n = GENERIC (s,d,G_SHIFT,Fa,Fb,t, u, v);
1230 o = GENERIC (s,d,R_SHIFT,Fa,Fb,t, u, v);
1231 p = GENERIC (s,d,A_SHIFT,Fa,Fb,t, u, v);
1238 combine_conjoint_over_u (pixman_implementation_t *imp, pixman_op_t op,
1239 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1241 combine_conjoint_general_u (dest, src, mask, width, COMBINE_A_OVER);
1246 combine_conjoint_over_reverse_u (pixman_implementation_t *imp, pixman_op_t op,
1247 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1249 combine_conjoint_general_u (dest, src, mask, width, COMBINE_B_OVER);
1254 combine_conjoint_in_u (pixman_implementation_t *imp, pixman_op_t op,
1255 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1257 combine_conjoint_general_u (dest, src, mask, width, COMBINE_A_IN);
1262 combine_conjoint_in_reverse_u (pixman_implementation_t *imp, pixman_op_t op,
1263 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1265 combine_conjoint_general_u (dest, src, mask, width, COMBINE_B_IN);
1269 combine_conjoint_out_u (pixman_implementation_t *imp, pixman_op_t op,
1270 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1272 combine_conjoint_general_u (dest, src, mask, width, COMBINE_A_OUT);
1276 combine_conjoint_out_reverse_u (pixman_implementation_t *imp, pixman_op_t op,
1277 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1279 combine_conjoint_general_u (dest, src, mask, width, COMBINE_B_OUT);
1283 combine_conjoint_atop_u (pixman_implementation_t *imp, pixman_op_t op,
1284 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1286 combine_conjoint_general_u (dest, src, mask, width, COMBINE_A_ATOP);
1290 combine_conjoint_atop_reverse_u (pixman_implementation_t *imp, pixman_op_t op,
1291 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1293 combine_conjoint_general_u (dest, src, mask, width, COMBINE_B_ATOP);
1297 combine_conjoint_xor_u (pixman_implementation_t *imp, pixman_op_t op,
1298 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1300 combine_conjoint_general_u (dest, src, mask, width, COMBINE_XOR);
1303 /********************************************************************************/
1304 /*************************** Per Channel functions ******************************/
1305 /********************************************************************************/
1308 combine_clear_ca (pixman_implementation_t *imp, pixman_op_t op,
1309 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1311 memset(dest, 0, width*sizeof(comp4_t));
1315 combine_src_ca (pixman_implementation_t *imp, pixman_op_t op,
1316 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1320 for (i = 0; i < width; ++i) {
1321 comp4_t s = *(src + i);
1322 comp4_t m = *(mask + i);
1324 combine_mask_value_ca (&s, &m);
1331 combine_over_ca (pixman_implementation_t *imp, pixman_op_t op,
1332 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1336 for (i = 0; i < width; ++i) {
1337 comp4_t s = *(src + i);
1338 comp4_t m = *(mask + i);
1341 combine_mask_ca (&s, &m);
1348 comp4_t d = *(dest + i);
1349 UNcx4_MUL_UNcx4_ADD_UNcx4(d, a, s);
1358 combine_over_reverse_ca (pixman_implementation_t *imp, pixman_op_t op,
1359 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1363 for (i = 0; i < width; ++i) {
1364 comp4_t d = *(dest + i);
1365 comp4_t a = ~d >> A_SHIFT;
1369 comp4_t s = *(src + i);
1370 comp4_t m = *(mask + i);
1372 combine_mask_value_ca (&s, &m);
1376 UNcx4_MUL_UNc_ADD_UNcx4(s, a, d);
1384 combine_in_ca (pixman_implementation_t *imp, pixman_op_t op,
1385 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1389 for (i = 0; i < width; ++i) {
1390 comp4_t d = *(dest + i);
1391 comp2_t a = d >> A_SHIFT;
1395 comp4_t m = *(mask + i);
1398 combine_mask_value_ca (&s, &m);
1401 UNcx4_MUL_UNc(s, a);
1409 combine_in_reverse_ca (pixman_implementation_t *imp, pixman_op_t op,
1410 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1414 for (i = 0; i < width; ++i) {
1415 comp4_t s = *(src + i);
1416 comp4_t m = *(mask + i);
1419 combine_mask_alpha_ca (&s, &m);
1428 UNcx4_MUL_UNcx4(d, a);
1436 combine_out_ca (pixman_implementation_t *imp, pixman_op_t op,
1437 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1441 for (i = 0; i < width; ++i) {
1442 comp4_t d = *(dest + i);
1443 comp2_t a = ~d >> A_SHIFT;
1447 comp4_t m = *(mask + i);
1450 combine_mask_value_ca (&s, &m);
1454 UNcx4_MUL_UNc(s, a);
1462 combine_out_reverse_ca (pixman_implementation_t *imp, pixman_op_t op,
1463 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1467 for (i = 0; i < width; ++i) {
1468 comp4_t s = *(src + i);
1469 comp4_t m = *(mask + i);
1472 combine_mask_alpha_ca (&s, &m);
1481 UNcx4_MUL_UNcx4(d, a);
1489 combine_atop_ca (pixman_implementation_t *imp, pixman_op_t op,
1490 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1494 for (i = 0; i < width; ++i) {
1495 comp4_t d = *(dest + i);
1496 comp4_t s = *(src + i);
1497 comp4_t m = *(mask + i);
1499 comp2_t as = d >> A_SHIFT;
1501 combine_mask_ca (&s, &m);
1505 UNcx4_MUL_UNcx4_ADD_UNcx4_MUL_UNc(d, ad, s, as);
1511 combine_atop_reverse_ca (pixman_implementation_t *imp, pixman_op_t op,
1512 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1516 for (i = 0; i < width; ++i) {
1518 comp4_t d = *(dest + i);
1519 comp4_t s = *(src + i);
1520 comp4_t m = *(mask + i);
1522 comp2_t as = ~d >> A_SHIFT;
1524 combine_mask_ca (&s, &m);
1528 UNcx4_MUL_UNcx4_ADD_UNcx4_MUL_UNc(d, ad, s, as);
1534 combine_xor_ca (pixman_implementation_t *imp, pixman_op_t op,
1535 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1539 for (i = 0; i < width; ++i) {
1540 comp4_t d = *(dest + i);
1541 comp4_t s = *(src + i);
1542 comp4_t m = *(mask + i);
1544 comp2_t as = ~d >> A_SHIFT;
1546 combine_mask_ca (&s, &m);
1550 UNcx4_MUL_UNcx4_ADD_UNcx4_MUL_UNc(d, ad, s, as);
1556 combine_add_ca (pixman_implementation_t *imp, pixman_op_t op,
1557 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1561 for (i = 0; i < width; ++i) {
1562 comp4_t s = *(src + i);
1563 comp4_t m = *(mask + i);
1564 comp4_t d = *(dest + i);
1566 combine_mask_value_ca (&s, &m);
1568 UNcx4_ADD_UNcx4(d, s);
1574 combine_saturate_ca (pixman_implementation_t *imp, pixman_op_t op,
1575 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1579 for (i = 0; i < width; ++i) {
1581 comp2_t sa, sr, sg, sb, da;
1589 combine_mask_ca (&s, &m);
1591 sa = (m >> A_SHIFT);
1592 sr = (m >> R_SHIFT) & MASK;
1593 sg = (m >> G_SHIFT) & MASK;
1600 m = GENERIC (s, d, 0, (da << G_SHIFT) / sb, MASK, t, u, v);
1603 n = ADD(s,d,G_SHIFT,t);
1605 n = GENERIC (s, d, G_SHIFT, (da << G_SHIFT) / sg, MASK, t, u, v);
1608 o = ADD(s,d,R_SHIFT,t);
1610 o = GENERIC (s, d, R_SHIFT, (da << G_SHIFT) / sr, MASK, t, u, v);
1613 p = ADD(s,d,A_SHIFT,t);
1615 p = GENERIC (s, d, A_SHIFT, (da << G_SHIFT) / sa, MASK, t, u, v);
1617 *(dest + i) = m|n|o|p;
1622 combine_disjoint_general_ca (comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width, comp1_t combine)
1626 for (i = 0; i < width; ++i) {
1639 combine_mask_ca (&s, &m);
1643 switch (combine & COMBINE_A) {
1648 m = (comp4_t)combine_disjoint_out_part ((comp1_t) (sa >> 0), da);
1649 n = (comp4_t)combine_disjoint_out_part ((comp1_t) (sa >> G_SHIFT), da) << G_SHIFT;
1650 o = (comp4_t)combine_disjoint_out_part ((comp1_t) (sa >> R_SHIFT), da) << R_SHIFT;
1651 p = (comp4_t)combine_disjoint_out_part ((comp1_t) (sa >> A_SHIFT), da) << A_SHIFT;
1655 m = (comp4_t)combine_disjoint_in_part ((comp1_t) (sa >> 0), da);
1656 n = (comp4_t)combine_disjoint_in_part ((comp1_t) (sa >> G_SHIFT), da) << G_SHIFT;
1657 o = (comp4_t)combine_disjoint_in_part ((comp1_t) (sa >> R_SHIFT), da) << R_SHIFT;
1658 p = (comp4_t)combine_disjoint_in_part ((comp1_t) (sa >> A_SHIFT), da) << A_SHIFT;
1666 switch (combine & COMBINE_B) {
1671 m = (comp4_t)combine_disjoint_out_part (da, (comp1_t) (sa >> 0));
1672 n = (comp4_t)combine_disjoint_out_part (da, (comp1_t) (sa >> G_SHIFT)) << G_SHIFT;
1673 o = (comp4_t)combine_disjoint_out_part (da, (comp1_t) (sa >> R_SHIFT)) << R_SHIFT;
1674 p = (comp4_t)combine_disjoint_out_part (da, (comp1_t) (sa >> A_SHIFT)) << A_SHIFT;
1678 m = (comp4_t)combine_disjoint_in_part (da, (comp1_t) (sa >> 0));
1679 n = (comp4_t)combine_disjoint_in_part (da, (comp1_t) (sa >> G_SHIFT)) << G_SHIFT;
1680 o = (comp4_t)combine_disjoint_in_part (da, (comp1_t) (sa >> R_SHIFT)) << R_SHIFT;
1681 p = (comp4_t)combine_disjoint_in_part (da, (comp1_t) (sa >> A_SHIFT)) << A_SHIFT;
1688 m = GENERIC (s,d,0,GET_COMP(Fa,0),GET_COMP(Fb,0),t, u, v);
1689 n = GENERIC (s,d,G_SHIFT,GET_COMP(Fa,G_SHIFT),GET_COMP(Fb,G_SHIFT),t, u, v);
1690 o = GENERIC (s,d,R_SHIFT,GET_COMP(Fa,R_SHIFT),GET_COMP(Fb,R_SHIFT),t, u, v);
1691 p = GENERIC (s,d,A_SHIFT,GET_COMP(Fa,A_SHIFT),GET_COMP(Fb,A_SHIFT),t, u, v);
1698 combine_disjoint_over_ca (pixman_implementation_t *imp, pixman_op_t op,
1699 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1701 combine_disjoint_general_ca (dest, src, mask, width, COMBINE_A_OVER);
1705 combine_disjoint_in_ca (pixman_implementation_t *imp, pixman_op_t op,
1706 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1708 combine_disjoint_general_ca (dest, src, mask, width, COMBINE_A_IN);
1712 combine_disjoint_in_reverse_ca (pixman_implementation_t *imp, pixman_op_t op,
1713 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1715 combine_disjoint_general_ca (dest, src, mask, width, COMBINE_B_IN);
1719 combine_disjoint_out_ca (pixman_implementation_t *imp, pixman_op_t op,
1720 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1722 combine_disjoint_general_ca (dest, src, mask, width, COMBINE_A_OUT);
1726 combine_disjoint_out_reverse_ca (pixman_implementation_t *imp, pixman_op_t op,
1727 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1729 combine_disjoint_general_ca (dest, src, mask, width, COMBINE_B_OUT);
1733 combine_disjoint_atop_ca (pixman_implementation_t *imp, pixman_op_t op,
1734 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1736 combine_disjoint_general_ca (dest, src, mask, width, COMBINE_A_ATOP);
1740 combine_disjoint_atop_reverse_ca (pixman_implementation_t *imp, pixman_op_t op,
1741 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1743 combine_disjoint_general_ca (dest, src, mask, width, COMBINE_B_ATOP);
1747 combine_disjoint_xor_ca (pixman_implementation_t *imp, pixman_op_t op,
1748 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1750 combine_disjoint_general_ca (dest, src, mask, width, COMBINE_XOR);
1754 combine_conjoint_general_ca (comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width, comp1_t combine)
1758 for (i = 0; i < width; ++i) {
1771 combine_mask_ca (&s, &m);
1775 switch (combine & COMBINE_A) {
1780 m = (comp4_t)combine_conjoint_out_part ((comp1_t) (sa >> 0), da);
1781 n = (comp4_t)combine_conjoint_out_part ((comp1_t) (sa >> G_SHIFT), da) << G_SHIFT;
1782 o = (comp4_t)combine_conjoint_out_part ((comp1_t) (sa >> R_SHIFT), da) << R_SHIFT;
1783 p = (comp4_t)combine_conjoint_out_part ((comp1_t) (sa >> A_SHIFT), da) << A_SHIFT;
1787 m = (comp4_t)combine_conjoint_in_part ((comp1_t) (sa >> 0), da);
1788 n = (comp4_t)combine_conjoint_in_part ((comp1_t) (sa >> G_SHIFT), da) << G_SHIFT;
1789 o = (comp4_t)combine_conjoint_in_part ((comp1_t) (sa >> R_SHIFT), da) << R_SHIFT;
1790 p = (comp4_t)combine_conjoint_in_part ((comp1_t) (sa >> A_SHIFT), da) << A_SHIFT;
1798 switch (combine & COMBINE_B) {
1803 m = (comp4_t)combine_conjoint_out_part (da, (comp1_t) (sa >> 0));
1804 n = (comp4_t)combine_conjoint_out_part (da, (comp1_t) (sa >> G_SHIFT)) << G_SHIFT;
1805 o = (comp4_t)combine_conjoint_out_part (da, (comp1_t) (sa >> R_SHIFT)) << R_SHIFT;
1806 p = (comp4_t)combine_conjoint_out_part (da, (comp1_t) (sa >> A_SHIFT)) << A_SHIFT;
1810 m = (comp4_t)combine_conjoint_in_part (da, (comp1_t) (sa >> 0));
1811 n = (comp4_t)combine_conjoint_in_part (da, (comp1_t) (sa >> G_SHIFT)) << G_SHIFT;
1812 o = (comp4_t)combine_conjoint_in_part (da, (comp1_t) (sa >> R_SHIFT)) << R_SHIFT;
1813 p = (comp4_t)combine_conjoint_in_part (da, (comp1_t) (sa >> A_SHIFT)) << A_SHIFT;
1820 m = GENERIC (s,d,0,GET_COMP(Fa,0),GET_COMP(Fb,0),t, u, v);
1821 n = GENERIC (s,d,G_SHIFT,GET_COMP(Fa,G_SHIFT),GET_COMP(Fb,G_SHIFT),t, u, v);
1822 o = GENERIC (s,d,R_SHIFT,GET_COMP(Fa,R_SHIFT),GET_COMP(Fb,R_SHIFT),t, u, v);
1823 p = GENERIC (s,d,A_SHIFT,GET_COMP(Fa,A_SHIFT),GET_COMP(Fb,A_SHIFT),t, u, v);
1830 combine_conjoint_over_ca (pixman_implementation_t *imp, pixman_op_t op,
1831 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1833 combine_conjoint_general_ca (dest, src, mask, width, COMBINE_A_OVER);
1837 combine_conjoint_over_reverse_ca (pixman_implementation_t *imp, pixman_op_t op,
1838 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1840 combine_conjoint_general_ca (dest, src, mask, width, COMBINE_B_OVER);
1844 combine_conjoint_in_ca (pixman_implementation_t *imp, pixman_op_t op,
1845 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1847 combine_conjoint_general_ca (dest, src, mask, width, COMBINE_A_IN);
1851 combine_conjoint_in_reverse_ca (pixman_implementation_t *imp, pixman_op_t op,
1852 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1854 combine_conjoint_general_ca (dest, src, mask, width, COMBINE_B_IN);
1858 combine_conjoint_out_ca (pixman_implementation_t *imp, pixman_op_t op,
1859 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1861 combine_conjoint_general_ca (dest, src, mask, width, COMBINE_A_OUT);
1865 combine_conjoint_out_reverse_ca (pixman_implementation_t *imp, pixman_op_t op,
1866 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1868 combine_conjoint_general_ca (dest, src, mask, width, COMBINE_B_OUT);
1872 combine_conjoint_atop_ca (pixman_implementation_t *imp, pixman_op_t op,
1873 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1875 combine_conjoint_general_ca (dest, src, mask, width, COMBINE_A_ATOP);
1879 combine_conjoint_atop_reverse_ca (pixman_implementation_t *imp, pixman_op_t op,
1880 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1882 combine_conjoint_general_ca (dest, src, mask, width, COMBINE_B_ATOP);
1886 combine_conjoint_xor_ca (pixman_implementation_t *imp, pixman_op_t op,
1887 comp4_t *dest, const comp4_t *src, const comp4_t *mask, int width)
1889 combine_conjoint_general_ca (dest, src, mask, width, COMBINE_XOR);
1893 _pixman_setup_combiner_functions_width (pixman_implementation_t *imp)
1896 imp->combine_width[PIXMAN_OP_CLEAR] = combine_clear;
1897 imp->combine_width[PIXMAN_OP_SRC] = combine_src_u;
1899 imp->combine_width[PIXMAN_OP_OVER] = combine_over_u;
1900 imp->combine_width[PIXMAN_OP_OVER_REVERSE] = combine_over_reverse_u;
1901 imp->combine_width[PIXMAN_OP_IN] = combine_in_u;
1902 imp->combine_width[PIXMAN_OP_IN_REVERSE] = combine_in_reverse_u;
1903 imp->combine_width[PIXMAN_OP_OUT] = combine_out_u;
1904 imp->combine_width[PIXMAN_OP_OUT_REVERSE] = combine_out_reverse_u;
1905 imp->combine_width[PIXMAN_OP_ATOP] = combine_atop_u;
1906 imp->combine_width[PIXMAN_OP_ATOP_REVERSE] = combine_atop_reverse_u;
1907 imp->combine_width[PIXMAN_OP_XOR] = combine_xor_u;
1908 imp->combine_width[PIXMAN_OP_ADD] = combine_add_u;
1909 imp->combine_width[PIXMAN_OP_SATURATE] = combine_saturate_u;
1911 /* Disjoint, unified */
1912 imp->combine_width[PIXMAN_OP_DISJOINT_CLEAR] = combine_clear;
1913 imp->combine_width[PIXMAN_OP_DISJOINT_SRC] = combine_src_u;
1915 imp->combine_width[PIXMAN_OP_DISJOINT_OVER] = combine_disjoint_over_u;
1916 imp->combine_width[PIXMAN_OP_DISJOINT_OVER_REVERSE] = combine_saturate_u;
1917 imp->combine_width[PIXMAN_OP_DISJOINT_IN] = combine_disjoint_in_u;
1918 imp->combine_width[PIXMAN_OP_DISJOINT_IN_REVERSE] = combine_disjoint_in_reverse_u;
1919 imp->combine_width[PIXMAN_OP_DISJOINT_OUT] = combine_disjoint_out_u;
1920 imp->combine_width[PIXMAN_OP_DISJOINT_OUT_REVERSE] = combine_disjoint_out_reverse_u;
1921 imp->combine_width[PIXMAN_OP_DISJOINT_ATOP] = combine_disjoint_atop_u;
1922 imp->combine_width[PIXMAN_OP_DISJOINT_ATOP_REVERSE] = combine_disjoint_atop_reverse_u;
1923 imp->combine_width[PIXMAN_OP_DISJOINT_XOR] = combine_disjoint_xor_u;
1925 /* Conjoint, unified */
1926 imp->combine_width[PIXMAN_OP_CONJOINT_CLEAR] = combine_clear;
1927 imp->combine_width[PIXMAN_OP_CONJOINT_SRC] = combine_src_u;
1929 imp->combine_width[PIXMAN_OP_CONJOINT_OVER] = combine_conjoint_over_u;
1930 imp->combine_width[PIXMAN_OP_CONJOINT_OVER_REVERSE] = combine_conjoint_over_reverse_u;
1931 imp->combine_width[PIXMAN_OP_CONJOINT_IN] = combine_conjoint_in_u;
1932 imp->combine_width[PIXMAN_OP_CONJOINT_IN_REVERSE] = combine_conjoint_in_reverse_u;
1933 imp->combine_width[PIXMAN_OP_CONJOINT_OUT] = combine_conjoint_out_u;
1934 imp->combine_width[PIXMAN_OP_CONJOINT_OUT_REVERSE] = combine_conjoint_out_reverse_u;
1935 imp->combine_width[PIXMAN_OP_CONJOINT_ATOP] = combine_conjoint_atop_u;
1936 imp->combine_width[PIXMAN_OP_CONJOINT_ATOP_REVERSE] = combine_conjoint_atop_reverse_u;
1937 imp->combine_width[PIXMAN_OP_CONJOINT_XOR] = combine_conjoint_xor_u;
1939 imp->combine_width[PIXMAN_OP_MULTIPLY] = combine_multiply_u;
1940 imp->combine_width[PIXMAN_OP_SCREEN] = combine_screen_u;
1941 imp->combine_width[PIXMAN_OP_OVERLAY] = combine_overlay_u;
1942 imp->combine_width[PIXMAN_OP_DARKEN] = combine_darken_u;
1943 imp->combine_width[PIXMAN_OP_LIGHTEN] = combine_lighten_u;
1944 imp->combine_width[PIXMAN_OP_COLOR_DODGE] = combine_color_dodge_u;
1945 imp->combine_width[PIXMAN_OP_COLOR_BURN] = combine_color_burn_u;
1946 imp->combine_width[PIXMAN_OP_HARD_LIGHT] = combine_hard_light_u;
1947 imp->combine_width[PIXMAN_OP_SOFT_LIGHT] = combine_soft_light_u;
1948 imp->combine_width[PIXMAN_OP_DIFFERENCE] = combine_difference_u;
1949 imp->combine_width[PIXMAN_OP_EXCLUSION] = combine_exclusion_u;
1950 imp->combine_width[PIXMAN_OP_HSL_HUE] = combine_hsl_hue_u;
1951 imp->combine_width[PIXMAN_OP_HSL_SATURATION] = combine_hsl_saturation_u;
1952 imp->combine_width[PIXMAN_OP_HSL_COLOR] = combine_hsl_color_u;
1953 imp->combine_width[PIXMAN_OP_HSL_LUMINOSITY] = combine_hsl_luminosity_u;
1955 /* Component alpha combiners */
1956 imp->combine_width_ca[PIXMAN_OP_CLEAR] = combine_clear_ca;
1957 imp->combine_width_ca[PIXMAN_OP_SRC] = combine_src_ca;
1959 imp->combine_width_ca[PIXMAN_OP_OVER] = combine_over_ca;
1960 imp->combine_width_ca[PIXMAN_OP_OVER_REVERSE] = combine_over_reverse_ca;
1961 imp->combine_width_ca[PIXMAN_OP_IN] = combine_in_ca;
1962 imp->combine_width_ca[PIXMAN_OP_IN_REVERSE] = combine_in_reverse_ca;
1963 imp->combine_width_ca[PIXMAN_OP_OUT] = combine_out_ca;
1964 imp->combine_width_ca[PIXMAN_OP_OUT_REVERSE] = combine_out_reverse_ca;
1965 imp->combine_width_ca[PIXMAN_OP_ATOP] = combine_atop_ca;
1966 imp->combine_width_ca[PIXMAN_OP_ATOP_REVERSE] = combine_atop_reverse_ca;
1967 imp->combine_width_ca[PIXMAN_OP_XOR] = combine_xor_ca;
1968 imp->combine_width_ca[PIXMAN_OP_ADD] = combine_add_ca;
1969 imp->combine_width_ca[PIXMAN_OP_SATURATE] = combine_saturate_ca;
1972 imp->combine_width_ca[PIXMAN_OP_DISJOINT_CLEAR] = combine_clear_ca;
1973 imp->combine_width_ca[PIXMAN_OP_DISJOINT_SRC] = combine_src_ca;
1975 imp->combine_width_ca[PIXMAN_OP_DISJOINT_OVER] = combine_disjoint_over_ca;
1976 imp->combine_width_ca[PIXMAN_OP_DISJOINT_OVER_REVERSE] = combine_saturate_ca;
1977 imp->combine_width_ca[PIXMAN_OP_DISJOINT_IN] = combine_disjoint_in_ca;
1978 imp->combine_width_ca[PIXMAN_OP_DISJOINT_IN_REVERSE] = combine_disjoint_in_reverse_ca;
1979 imp->combine_width_ca[PIXMAN_OP_DISJOINT_OUT] = combine_disjoint_out_ca;
1980 imp->combine_width_ca[PIXMAN_OP_DISJOINT_OUT_REVERSE] = combine_disjoint_out_reverse_ca;
1981 imp->combine_width_ca[PIXMAN_OP_DISJOINT_ATOP] = combine_disjoint_atop_ca;
1982 imp->combine_width_ca[PIXMAN_OP_DISJOINT_ATOP_REVERSE] = combine_disjoint_atop_reverse_ca;
1983 imp->combine_width_ca[PIXMAN_OP_DISJOINT_XOR] = combine_disjoint_xor_ca;
1986 imp->combine_width_ca[PIXMAN_OP_CONJOINT_CLEAR] = combine_clear_ca;
1987 imp->combine_width_ca[PIXMAN_OP_CONJOINT_SRC] = combine_src_ca;
1989 imp->combine_width_ca[PIXMAN_OP_CONJOINT_OVER] = combine_conjoint_over_ca;
1990 imp->combine_width_ca[PIXMAN_OP_CONJOINT_OVER_REVERSE] = combine_conjoint_over_reverse_ca;
1991 imp->combine_width_ca[PIXMAN_OP_CONJOINT_IN] = combine_conjoint_in_ca;
1992 imp->combine_width_ca[PIXMAN_OP_CONJOINT_IN_REVERSE] = combine_conjoint_in_reverse_ca;
1993 imp->combine_width_ca[PIXMAN_OP_CONJOINT_OUT] = combine_conjoint_out_ca;
1994 imp->combine_width_ca[PIXMAN_OP_CONJOINT_OUT_REVERSE] = combine_conjoint_out_reverse_ca;
1995 imp->combine_width_ca[PIXMAN_OP_CONJOINT_ATOP] = combine_conjoint_atop_ca;
1996 imp->combine_width_ca[PIXMAN_OP_CONJOINT_ATOP_REVERSE] = combine_conjoint_atop_reverse_ca;
1997 imp->combine_width_ca[PIXMAN_OP_CONJOINT_XOR] = combine_conjoint_xor_ca;
1999 imp->combine_width_ca[PIXMAN_OP_MULTIPLY] = combine_multiply_ca;
2000 imp->combine_width_ca[PIXMAN_OP_SCREEN] = combine_screen_ca;
2001 imp->combine_width_ca[PIXMAN_OP_OVERLAY] = combine_overlay_ca;
2002 imp->combine_width_ca[PIXMAN_OP_DARKEN] = combine_darken_ca;
2003 imp->combine_width_ca[PIXMAN_OP_LIGHTEN] = combine_lighten_ca;
2004 imp->combine_width_ca[PIXMAN_OP_COLOR_DODGE] = combine_color_dodge_ca;
2005 imp->combine_width_ca[PIXMAN_OP_COLOR_BURN] = combine_color_burn_ca;
2006 imp->combine_width_ca[PIXMAN_OP_HARD_LIGHT] = combine_hard_light_ca;
2007 imp->combine_width_ca[PIXMAN_OP_SOFT_LIGHT] = combine_soft_light_ca;
2008 imp->combine_width_ca[PIXMAN_OP_DIFFERENCE] = combine_difference_ca;
2009 imp->combine_width_ca[PIXMAN_OP_EXCLUSION] = combine_exclusion_ca;
2010 /* It is not clear that these make sense, so leave them out for now */
2011 imp->combine_width_ca[PIXMAN_OP_HSL_HUE] = NULL;
2012 imp->combine_width_ca[PIXMAN_OP_HSL_SATURATION] = NULL;
2013 imp->combine_width_ca[PIXMAN_OP_HSL_COLOR] = NULL;
2014 imp->combine_width_ca[PIXMAN_OP_HSL_LUMINOSITY] = NULL;