1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/cairo/libpixman/src/pixman-combine.c.template Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,2461 @@ 1.4 +#ifdef HAVE_CONFIG_H 1.5 +#include <config.h> 1.6 +#endif 1.7 + 1.8 +#include <math.h> 1.9 +#include <string.h> 1.10 + 1.11 +#include "pixman-private.h" 1.12 + 1.13 +#include "pixman-combine.h" 1.14 + 1.15 +/*** per channel helper functions ***/ 1.16 + 1.17 +static void 1.18 +combine_mask_ca (comp4_t *src, comp4_t *mask) 1.19 +{ 1.20 + comp4_t a = *mask; 1.21 + 1.22 + comp4_t x; 1.23 + comp2_t xa; 1.24 + 1.25 + if (!a) 1.26 + { 1.27 + *(src) = 0; 1.28 + return; 1.29 + } 1.30 + 1.31 + x = *(src); 1.32 + if (a == ~0) 1.33 + { 1.34 + x = x >> A_SHIFT; 1.35 + x |= x << G_SHIFT; 1.36 + x |= x << R_SHIFT; 1.37 + *(mask) = x; 1.38 + return; 1.39 + } 1.40 + 1.41 + xa = x >> A_SHIFT; 1.42 + UNcx4_MUL_UNcx4 (x, a); 1.43 + *(src) = x; 1.44 + 1.45 + UNcx4_MUL_UNc (a, xa); 1.46 + *(mask) = a; 1.47 +} 1.48 + 1.49 +static void 1.50 +combine_mask_value_ca (comp4_t *src, const comp4_t *mask) 1.51 +{ 1.52 + comp4_t a = *mask; 1.53 + comp4_t x; 1.54 + 1.55 + if (!a) 1.56 + { 1.57 + *(src) = 0; 1.58 + return; 1.59 + } 1.60 + 1.61 + if (a == ~0) 1.62 + return; 1.63 + 1.64 + x = *(src); 1.65 + UNcx4_MUL_UNcx4 (x, a); 1.66 + *(src) = x; 1.67 +} 1.68 + 1.69 +static void 1.70 +combine_mask_alpha_ca (const comp4_t *src, comp4_t *mask) 1.71 +{ 1.72 + comp4_t a = *(mask); 1.73 + comp4_t x; 1.74 + 1.75 + if (!a) 1.76 + return; 1.77 + 1.78 + x = *(src) >> A_SHIFT; 1.79 + if (x == MASK) 1.80 + return; 1.81 + 1.82 + if (a == ~0) 1.83 + { 1.84 + x |= x << G_SHIFT; 1.85 + x |= x << R_SHIFT; 1.86 + *(mask) = x; 1.87 + return; 1.88 + } 1.89 + 1.90 + UNcx4_MUL_UNc (a, x); 1.91 + *(mask) = a; 1.92 +} 1.93 + 1.94 +/* 1.95 + * There are two ways of handling alpha -- either as a single unified value or 1.96 + * a separate value for each component, hence each macro must have two 1.97 + * versions. The unified alpha version has a 'U' at the end of the name, 1.98 + * the component version has a 'C'. Similarly, functions which deal with 1.99 + * this difference will have two versions using the same convention. 1.100 + */ 1.101 + 1.102 +/* 1.103 + * All of the composing functions 1.104 + */ 1.105 + 1.106 +static force_inline comp4_t 1.107 +combine_mask (const comp4_t *src, const comp4_t *mask, int i) 1.108 +{ 1.109 + comp4_t s, m; 1.110 + 1.111 + if (mask) 1.112 + { 1.113 + m = *(mask + i) >> A_SHIFT; 1.114 + 1.115 + if (!m) 1.116 + return 0; 1.117 + } 1.118 + 1.119 + s = *(src + i); 1.120 + 1.121 + if (mask) 1.122 + UNcx4_MUL_UNc (s, m); 1.123 + 1.124 + return s; 1.125 +} 1.126 + 1.127 +static void 1.128 +combine_clear (pixman_implementation_t *imp, 1.129 + pixman_op_t op, 1.130 + comp4_t * dest, 1.131 + const comp4_t * src, 1.132 + const comp4_t * mask, 1.133 + int width) 1.134 +{ 1.135 + memset (dest, 0, width * sizeof(comp4_t)); 1.136 +} 1.137 + 1.138 +static void 1.139 +combine_dst (pixman_implementation_t *imp, 1.140 + pixman_op_t op, 1.141 + comp4_t * dest, 1.142 + const comp4_t * src, 1.143 + const comp4_t * mask, 1.144 + int width) 1.145 +{ 1.146 + return; 1.147 +} 1.148 + 1.149 +static void 1.150 +combine_src_u (pixman_implementation_t *imp, 1.151 + pixman_op_t op, 1.152 + comp4_t * dest, 1.153 + const comp4_t * src, 1.154 + const comp4_t * mask, 1.155 + int width) 1.156 +{ 1.157 + int i; 1.158 + 1.159 + if (!mask) 1.160 + memcpy (dest, src, width * sizeof (comp4_t)); 1.161 + else 1.162 + { 1.163 + for (i = 0; i < width; ++i) 1.164 + { 1.165 + comp4_t s = combine_mask (src, mask, i); 1.166 + 1.167 + *(dest + i) = s; 1.168 + } 1.169 + } 1.170 +} 1.171 + 1.172 +/* if the Src is opaque, call combine_src_u */ 1.173 +static void 1.174 +combine_over_u (pixman_implementation_t *imp, 1.175 + pixman_op_t op, 1.176 + comp4_t * dest, 1.177 + const comp4_t * src, 1.178 + const comp4_t * mask, 1.179 + int width) 1.180 +{ 1.181 + int i; 1.182 + 1.183 + for (i = 0; i < width; ++i) 1.184 + { 1.185 + comp4_t s = combine_mask (src, mask, i); 1.186 + comp4_t d = *(dest + i); 1.187 + comp4_t ia = ALPHA_c (~s); 1.188 + 1.189 + UNcx4_MUL_UNc_ADD_UNcx4 (d, ia, s); 1.190 + *(dest + i) = d; 1.191 + } 1.192 +} 1.193 + 1.194 +/* if the Dst is opaque, this is a noop */ 1.195 +static void 1.196 +combine_over_reverse_u (pixman_implementation_t *imp, 1.197 + pixman_op_t op, 1.198 + comp4_t * dest, 1.199 + const comp4_t * src, 1.200 + const comp4_t * mask, 1.201 + int width) 1.202 +{ 1.203 + int i; 1.204 + 1.205 + for (i = 0; i < width; ++i) 1.206 + { 1.207 + comp4_t s = combine_mask (src, mask, i); 1.208 + comp4_t d = *(dest + i); 1.209 + comp4_t ia = ALPHA_c (~*(dest + i)); 1.210 + UNcx4_MUL_UNc_ADD_UNcx4 (s, ia, d); 1.211 + *(dest + i) = s; 1.212 + } 1.213 +} 1.214 + 1.215 +/* if the Dst is opaque, call combine_src_u */ 1.216 +static void 1.217 +combine_in_u (pixman_implementation_t *imp, 1.218 + pixman_op_t op, 1.219 + comp4_t * dest, 1.220 + const comp4_t * src, 1.221 + const comp4_t * mask, 1.222 + int width) 1.223 +{ 1.224 + int i; 1.225 + 1.226 + for (i = 0; i < width; ++i) 1.227 + { 1.228 + comp4_t s = combine_mask (src, mask, i); 1.229 + comp4_t a = ALPHA_c (*(dest + i)); 1.230 + UNcx4_MUL_UNc (s, a); 1.231 + *(dest + i) = s; 1.232 + } 1.233 +} 1.234 + 1.235 +/* if the Src is opaque, this is a noop */ 1.236 +static void 1.237 +combine_in_reverse_u (pixman_implementation_t *imp, 1.238 + pixman_op_t op, 1.239 + comp4_t * dest, 1.240 + const comp4_t * src, 1.241 + const comp4_t * mask, 1.242 + int width) 1.243 +{ 1.244 + int i; 1.245 + 1.246 + for (i = 0; i < width; ++i) 1.247 + { 1.248 + comp4_t s = combine_mask (src, mask, i); 1.249 + comp4_t d = *(dest + i); 1.250 + comp4_t a = ALPHA_c (s); 1.251 + UNcx4_MUL_UNc (d, a); 1.252 + *(dest + i) = d; 1.253 + } 1.254 +} 1.255 + 1.256 +/* if the Dst is opaque, call combine_clear */ 1.257 +static void 1.258 +combine_out_u (pixman_implementation_t *imp, 1.259 + pixman_op_t op, 1.260 + comp4_t * dest, 1.261 + const comp4_t * src, 1.262 + const comp4_t * mask, 1.263 + int width) 1.264 +{ 1.265 + int i; 1.266 + 1.267 + for (i = 0; i < width; ++i) 1.268 + { 1.269 + comp4_t s = combine_mask (src, mask, i); 1.270 + comp4_t a = ALPHA_c (~*(dest + i)); 1.271 + UNcx4_MUL_UNc (s, a); 1.272 + *(dest + i) = s; 1.273 + } 1.274 +} 1.275 + 1.276 +/* if the Src is opaque, call combine_clear */ 1.277 +static void 1.278 +combine_out_reverse_u (pixman_implementation_t *imp, 1.279 + pixman_op_t op, 1.280 + comp4_t * dest, 1.281 + const comp4_t * src, 1.282 + const comp4_t * mask, 1.283 + int width) 1.284 +{ 1.285 + int i; 1.286 + 1.287 + for (i = 0; i < width; ++i) 1.288 + { 1.289 + comp4_t s = combine_mask (src, mask, i); 1.290 + comp4_t d = *(dest + i); 1.291 + comp4_t a = ALPHA_c (~s); 1.292 + UNcx4_MUL_UNc (d, a); 1.293 + *(dest + i) = d; 1.294 + } 1.295 +} 1.296 + 1.297 +/* if the Src is opaque, call combine_in_u */ 1.298 +/* if the Dst is opaque, call combine_over_u */ 1.299 +/* if both the Src and Dst are opaque, call combine_src_u */ 1.300 +static void 1.301 +combine_atop_u (pixman_implementation_t *imp, 1.302 + pixman_op_t op, 1.303 + comp4_t * dest, 1.304 + const comp4_t * src, 1.305 + const comp4_t * mask, 1.306 + int width) 1.307 +{ 1.308 + int i; 1.309 + 1.310 + for (i = 0; i < width; ++i) 1.311 + { 1.312 + comp4_t s = combine_mask (src, mask, i); 1.313 + comp4_t d = *(dest + i); 1.314 + comp4_t dest_a = ALPHA_c (d); 1.315 + comp4_t src_ia = ALPHA_c (~s); 1.316 + 1.317 + UNcx4_MUL_UNc_ADD_UNcx4_MUL_UNc (s, dest_a, d, src_ia); 1.318 + *(dest + i) = s; 1.319 + } 1.320 +} 1.321 + 1.322 +/* if the Src is opaque, call combine_over_reverse_u */ 1.323 +/* if the Dst is opaque, call combine_in_reverse_u */ 1.324 +/* if both the Src and Dst are opaque, call combine_dst_u */ 1.325 +static void 1.326 +combine_atop_reverse_u (pixman_implementation_t *imp, 1.327 + pixman_op_t op, 1.328 + comp4_t * dest, 1.329 + const comp4_t * src, 1.330 + const comp4_t * mask, 1.331 + int width) 1.332 +{ 1.333 + int i; 1.334 + 1.335 + for (i = 0; i < width; ++i) 1.336 + { 1.337 + comp4_t s = combine_mask (src, mask, i); 1.338 + comp4_t d = *(dest + i); 1.339 + comp4_t src_a = ALPHA_c (s); 1.340 + comp4_t dest_ia = ALPHA_c (~d); 1.341 + 1.342 + UNcx4_MUL_UNc_ADD_UNcx4_MUL_UNc (s, dest_ia, d, src_a); 1.343 + *(dest + i) = s; 1.344 + } 1.345 +} 1.346 + 1.347 +/* if the Src is opaque, call combine_over_u */ 1.348 +/* if the Dst is opaque, call combine_over_reverse_u */ 1.349 +/* if both the Src and Dst are opaque, call combine_clear */ 1.350 +static void 1.351 +combine_xor_u (pixman_implementation_t *imp, 1.352 + pixman_op_t op, 1.353 + comp4_t * dest, 1.354 + const comp4_t * src, 1.355 + const comp4_t * mask, 1.356 + int width) 1.357 +{ 1.358 + int i; 1.359 + 1.360 + for (i = 0; i < width; ++i) 1.361 + { 1.362 + comp4_t s = combine_mask (src, mask, i); 1.363 + comp4_t d = *(dest + i); 1.364 + comp4_t src_ia = ALPHA_c (~s); 1.365 + comp4_t dest_ia = ALPHA_c (~d); 1.366 + 1.367 + UNcx4_MUL_UNc_ADD_UNcx4_MUL_UNc (s, dest_ia, d, src_ia); 1.368 + *(dest + i) = s; 1.369 + } 1.370 +} 1.371 + 1.372 +static void 1.373 +combine_add_u (pixman_implementation_t *imp, 1.374 + pixman_op_t op, 1.375 + comp4_t * dest, 1.376 + const comp4_t * src, 1.377 + const comp4_t * mask, 1.378 + int width) 1.379 +{ 1.380 + int i; 1.381 + 1.382 + for (i = 0; i < width; ++i) 1.383 + { 1.384 + comp4_t s = combine_mask (src, mask, i); 1.385 + comp4_t d = *(dest + i); 1.386 + UNcx4_ADD_UNcx4 (d, s); 1.387 + *(dest + i) = d; 1.388 + } 1.389 +} 1.390 + 1.391 +/* if the Src is opaque, call combine_add_u */ 1.392 +/* if the Dst is opaque, call combine_add_u */ 1.393 +/* if both the Src and Dst are opaque, call combine_add_u */ 1.394 +static void 1.395 +combine_saturate_u (pixman_implementation_t *imp, 1.396 + pixman_op_t op, 1.397 + comp4_t * dest, 1.398 + const comp4_t * src, 1.399 + const comp4_t * mask, 1.400 + int width) 1.401 +{ 1.402 + int i; 1.403 + 1.404 + for (i = 0; i < width; ++i) 1.405 + { 1.406 + comp4_t s = combine_mask (src, mask, i); 1.407 + comp4_t d = *(dest + i); 1.408 + comp2_t sa, da; 1.409 + 1.410 + sa = s >> A_SHIFT; 1.411 + da = ~d >> A_SHIFT; 1.412 + if (sa > da) 1.413 + { 1.414 + sa = DIV_UNc (da, sa); 1.415 + UNcx4_MUL_UNc (s, sa); 1.416 + } 1.417 + ; 1.418 + UNcx4_ADD_UNcx4 (d, s); 1.419 + *(dest + i) = d; 1.420 + } 1.421 +} 1.422 + 1.423 +/* 1.424 + * PDF blend modes: 1.425 + * The following blend modes have been taken from the PDF ISO 32000 1.426 + * specification, which at this point in time is available from 1.427 + * http://www.adobe.com/devnet/acrobat/pdfs/PDF32000_2008.pdf 1.428 + * The relevant chapters are 11.3.5 and 11.3.6. 1.429 + * The formula for computing the final pixel color given in 11.3.6 is: 1.430 + * αr × Cr = (1 – αs) × αb × Cb + (1 – αb) × αs × Cs + αb × αs × B(Cb, Cs) 1.431 + * with B() being the blend function. 1.432 + * Note that OVER is a special case of this operation, using B(Cb, Cs) = Cs 1.433 + * 1.434 + * These blend modes should match the SVG filter draft specification, as 1.435 + * it has been designed to mirror ISO 32000. Note that at the current point 1.436 + * no released draft exists that shows this, as the formulas have not been 1.437 + * updated yet after the release of ISO 32000. 1.438 + * 1.439 + * The default implementation here uses the PDF_SEPARABLE_BLEND_MODE and 1.440 + * PDF_NON_SEPARABLE_BLEND_MODE macros, which take the blend function as an 1.441 + * argument. Note that this implementation operates on premultiplied colors, 1.442 + * while the PDF specification does not. Therefore the code uses the formula 1.443 + * Cra = (1 – as) . Dca + (1 – ad) . Sca + B(Dca, ad, Sca, as) 1.444 + */ 1.445 + 1.446 +/* 1.447 + * Multiply 1.448 + * B(Dca, ad, Sca, as) = Dca.Sca 1.449 + */ 1.450 + 1.451 +static void 1.452 +combine_multiply_u (pixman_implementation_t *imp, 1.453 + pixman_op_t op, 1.454 + comp4_t * dest, 1.455 + const comp4_t * src, 1.456 + const comp4_t * mask, 1.457 + int width) 1.458 +{ 1.459 + int i; 1.460 + 1.461 + for (i = 0; i < width; ++i) 1.462 + { 1.463 + comp4_t s = combine_mask (src, mask, i); 1.464 + comp4_t d = *(dest + i); 1.465 + comp4_t ss = s; 1.466 + comp4_t src_ia = ALPHA_c (~s); 1.467 + comp4_t dest_ia = ALPHA_c (~d); 1.468 + 1.469 + UNcx4_MUL_UNc_ADD_UNcx4_MUL_UNc (ss, dest_ia, d, src_ia); 1.470 + UNcx4_MUL_UNcx4 (d, s); 1.471 + UNcx4_ADD_UNcx4 (d, ss); 1.472 + 1.473 + *(dest + i) = d; 1.474 + } 1.475 +} 1.476 + 1.477 +static void 1.478 +combine_multiply_ca (pixman_implementation_t *imp, 1.479 + pixman_op_t op, 1.480 + comp4_t * dest, 1.481 + const comp4_t * src, 1.482 + const comp4_t * mask, 1.483 + int width) 1.484 +{ 1.485 + int i; 1.486 + 1.487 + for (i = 0; i < width; ++i) 1.488 + { 1.489 + comp4_t m = *(mask + i); 1.490 + comp4_t s = *(src + i); 1.491 + comp4_t d = *(dest + i); 1.492 + comp4_t r = d; 1.493 + comp4_t dest_ia = ALPHA_c (~d); 1.494 + 1.495 + combine_mask_value_ca (&s, &m); 1.496 + 1.497 + UNcx4_MUL_UNcx4_ADD_UNcx4_MUL_UNc (r, ~m, s, dest_ia); 1.498 + UNcx4_MUL_UNcx4 (d, s); 1.499 + UNcx4_ADD_UNcx4 (r, d); 1.500 + 1.501 + *(dest + i) = r; 1.502 + } 1.503 +} 1.504 + 1.505 +#define PDF_SEPARABLE_BLEND_MODE(name) \ 1.506 + static void \ 1.507 + combine_ ## name ## _u (pixman_implementation_t *imp, \ 1.508 + pixman_op_t op, \ 1.509 + comp4_t * dest, \ 1.510 + const comp4_t * src, \ 1.511 + const comp4_t * mask, \ 1.512 + int width) \ 1.513 + { \ 1.514 + int i; \ 1.515 + for (i = 0; i < width; ++i) { \ 1.516 + comp4_t s = combine_mask (src, mask, i); \ 1.517 + comp4_t d = *(dest + i); \ 1.518 + comp1_t sa = ALPHA_c (s); \ 1.519 + comp1_t isa = ~sa; \ 1.520 + comp1_t da = ALPHA_c (d); \ 1.521 + comp1_t ida = ~da; \ 1.522 + comp4_t result; \ 1.523 + \ 1.524 + result = d; \ 1.525 + UNcx4_MUL_UNc_ADD_UNcx4_MUL_UNc (result, isa, s, ida); \ 1.526 + \ 1.527 + *(dest + i) = result + \ 1.528 + (DIV_ONE_UNc (sa * (comp4_t)da) << A_SHIFT) + \ 1.529 + (blend_ ## name (RED_c (d), da, RED_c (s), sa) << R_SHIFT) + \ 1.530 + (blend_ ## name (GREEN_c (d), da, GREEN_c (s), sa) << G_SHIFT) + \ 1.531 + (blend_ ## name (BLUE_c (d), da, BLUE_c (s), sa)); \ 1.532 + } \ 1.533 + } \ 1.534 + \ 1.535 + static void \ 1.536 + combine_ ## name ## _ca (pixman_implementation_t *imp, \ 1.537 + pixman_op_t op, \ 1.538 + comp4_t * dest, \ 1.539 + const comp4_t * src, \ 1.540 + const comp4_t * mask, \ 1.541 + int width) \ 1.542 + { \ 1.543 + int i; \ 1.544 + for (i = 0; i < width; ++i) { \ 1.545 + comp4_t m = *(mask + i); \ 1.546 + comp4_t s = *(src + i); \ 1.547 + comp4_t d = *(dest + i); \ 1.548 + comp1_t da = ALPHA_c (d); \ 1.549 + comp1_t ida = ~da; \ 1.550 + comp4_t result; \ 1.551 + \ 1.552 + combine_mask_value_ca (&s, &m); \ 1.553 + \ 1.554 + result = d; \ 1.555 + UNcx4_MUL_UNcx4_ADD_UNcx4_MUL_UNc (result, ~m, s, ida); \ 1.556 + \ 1.557 + result += \ 1.558 + (DIV_ONE_UNc (ALPHA_c (m) * (comp4_t)da) << A_SHIFT) + \ 1.559 + (blend_ ## name (RED_c (d), da, RED_c (s), RED_c (m)) << R_SHIFT) + \ 1.560 + (blend_ ## name (GREEN_c (d), da, GREEN_c (s), GREEN_c (m)) << G_SHIFT) + \ 1.561 + (blend_ ## name (BLUE_c (d), da, BLUE_c (s), BLUE_c (m))); \ 1.562 + \ 1.563 + *(dest + i) = result; \ 1.564 + } \ 1.565 + } 1.566 + 1.567 +/* 1.568 + * Screen 1.569 + * B(Dca, ad, Sca, as) = Dca.sa + Sca.da - Dca.Sca 1.570 + */ 1.571 +static inline comp4_t 1.572 +blend_screen (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa) 1.573 +{ 1.574 + return DIV_ONE_UNc (sca * da + dca * sa - sca * dca); 1.575 +} 1.576 + 1.577 +PDF_SEPARABLE_BLEND_MODE (screen) 1.578 + 1.579 +/* 1.580 + * Overlay 1.581 + * B(Dca, Da, Sca, Sa) = 1.582 + * if 2.Dca < Da 1.583 + * 2.Sca.Dca 1.584 + * otherwise 1.585 + * Sa.Da - 2.(Da - Dca).(Sa - Sca) 1.586 + */ 1.587 +static inline comp4_t 1.588 +blend_overlay (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa) 1.589 +{ 1.590 + comp4_t rca; 1.591 + 1.592 + if (2 * dca < da) 1.593 + rca = 2 * sca * dca; 1.594 + else 1.595 + rca = sa * da - 2 * (da - dca) * (sa - sca); 1.596 + return DIV_ONE_UNc (rca); 1.597 +} 1.598 + 1.599 +PDF_SEPARABLE_BLEND_MODE (overlay) 1.600 + 1.601 +/* 1.602 + * Darken 1.603 + * B(Dca, Da, Sca, Sa) = min (Sca.Da, Dca.Sa) 1.604 + */ 1.605 +static inline comp4_t 1.606 +blend_darken (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa) 1.607 +{ 1.608 + comp4_t s, d; 1.609 + 1.610 + s = sca * da; 1.611 + d = dca * sa; 1.612 + return DIV_ONE_UNc (s > d ? d : s); 1.613 +} 1.614 + 1.615 +PDF_SEPARABLE_BLEND_MODE (darken) 1.616 + 1.617 +/* 1.618 + * Lighten 1.619 + * B(Dca, Da, Sca, Sa) = max (Sca.Da, Dca.Sa) 1.620 + */ 1.621 +static inline comp4_t 1.622 +blend_lighten (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa) 1.623 +{ 1.624 + comp4_t s, d; 1.625 + 1.626 + s = sca * da; 1.627 + d = dca * sa; 1.628 + return DIV_ONE_UNc (s > d ? s : d); 1.629 +} 1.630 + 1.631 +PDF_SEPARABLE_BLEND_MODE (lighten) 1.632 + 1.633 +/* 1.634 + * Color dodge 1.635 + * B(Dca, Da, Sca, Sa) = 1.636 + * if Dca == 0 1.637 + * 0 1.638 + * if Sca == Sa 1.639 + * Sa.Da 1.640 + * otherwise 1.641 + * Sa.Da. min (1, Dca / Da / (1 - Sca/Sa)) 1.642 + */ 1.643 +static inline comp4_t 1.644 +blend_color_dodge (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa) 1.645 +{ 1.646 + if (sca >= sa) 1.647 + { 1.648 + return dca == 0 ? 0 : DIV_ONE_UNc (sa * da); 1.649 + } 1.650 + else 1.651 + { 1.652 + comp4_t rca = dca * sa / (sa - sca); 1.653 + return DIV_ONE_UNc (sa * MIN (rca, da)); 1.654 + } 1.655 +} 1.656 + 1.657 +PDF_SEPARABLE_BLEND_MODE (color_dodge) 1.658 + 1.659 +/* 1.660 + * Color burn 1.661 + * B(Dca, Da, Sca, Sa) = 1.662 + * if Dca == Da 1.663 + * Sa.Da 1.664 + * if Sca == 0 1.665 + * 0 1.666 + * otherwise 1.667 + * Sa.Da.(1 - min (1, (1 - Dca/Da).Sa / Sca)) 1.668 + */ 1.669 +static inline comp4_t 1.670 +blend_color_burn (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa) 1.671 +{ 1.672 + if (sca == 0) 1.673 + { 1.674 + return dca < da ? 0 : DIV_ONE_UNc (sa * da); 1.675 + } 1.676 + else 1.677 + { 1.678 + comp4_t rca = (da - dca) * sa / sca; 1.679 + return DIV_ONE_UNc (sa * (MAX (rca, da) - rca)); 1.680 + } 1.681 +} 1.682 + 1.683 +PDF_SEPARABLE_BLEND_MODE (color_burn) 1.684 + 1.685 +/* 1.686 + * Hard light 1.687 + * B(Dca, Da, Sca, Sa) = 1.688 + * if 2.Sca < Sa 1.689 + * 2.Sca.Dca 1.690 + * otherwise 1.691 + * Sa.Da - 2.(Da - Dca).(Sa - Sca) 1.692 + */ 1.693 +static inline comp4_t 1.694 +blend_hard_light (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa) 1.695 +{ 1.696 + if (2 * sca < sa) 1.697 + return DIV_ONE_UNc (2 * sca * dca); 1.698 + else 1.699 + return DIV_ONE_UNc (sa * da - 2 * (da - dca) * (sa - sca)); 1.700 +} 1.701 + 1.702 +PDF_SEPARABLE_BLEND_MODE (hard_light) 1.703 + 1.704 +/* 1.705 + * Soft light 1.706 + * B(Dca, Da, Sca, Sa) = 1.707 + * if (2.Sca <= Sa) 1.708 + * Dca.(Sa - (1 - Dca/Da).(2.Sca - Sa)) 1.709 + * otherwise if Dca.4 <= Da 1.710 + * Dca.(Sa + (2.Sca - Sa).((16.Dca/Da - 12).Dca/Da + 3) 1.711 + * otherwise 1.712 + * (Dca.Sa + (SQRT (Dca/Da).Da - Dca).(2.Sca - Sa)) 1.713 + */ 1.714 +static inline comp4_t 1.715 +blend_soft_light (comp4_t dca_org, 1.716 + comp4_t da_org, 1.717 + comp4_t sca_org, 1.718 + comp4_t sa_org) 1.719 +{ 1.720 + double dca = dca_org * (1.0 / MASK); 1.721 + double da = da_org * (1.0 / MASK); 1.722 + double sca = sca_org * (1.0 / MASK); 1.723 + double sa = sa_org * (1.0 / MASK); 1.724 + double rca; 1.725 + 1.726 + if (2 * sca < sa) 1.727 + { 1.728 + if (da == 0) 1.729 + rca = dca * sa; 1.730 + else 1.731 + rca = dca * sa - dca * (da - dca) * (sa - 2 * sca) / da; 1.732 + } 1.733 + else if (da == 0) 1.734 + { 1.735 + rca = 0; 1.736 + } 1.737 + else if (4 * dca <= da) 1.738 + { 1.739 + rca = dca * sa + 1.740 + (2 * sca - sa) * dca * ((16 * dca / da - 12) * dca / da + 3); 1.741 + } 1.742 + else 1.743 + { 1.744 + rca = dca * sa + (sqrt (dca * da) - dca) * (2 * sca - sa); 1.745 + } 1.746 + return rca * MASK + 0.5; 1.747 +} 1.748 + 1.749 +PDF_SEPARABLE_BLEND_MODE (soft_light) 1.750 + 1.751 +/* 1.752 + * Difference 1.753 + * B(Dca, Da, Sca, Sa) = abs (Dca.Sa - Sca.Da) 1.754 + */ 1.755 +static inline comp4_t 1.756 +blend_difference (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa) 1.757 +{ 1.758 + comp4_t dcasa = dca * sa; 1.759 + comp4_t scada = sca * da; 1.760 + 1.761 + if (scada < dcasa) 1.762 + return DIV_ONE_UNc (dcasa - scada); 1.763 + else 1.764 + return DIV_ONE_UNc (scada - dcasa); 1.765 +} 1.766 + 1.767 +PDF_SEPARABLE_BLEND_MODE (difference) 1.768 + 1.769 +/* 1.770 + * Exclusion 1.771 + * B(Dca, Da, Sca, Sa) = (Sca.Da + Dca.Sa - 2.Sca.Dca) 1.772 + */ 1.773 + 1.774 +/* This can be made faster by writing it directly and not using 1.775 + * PDF_SEPARABLE_BLEND_MODE, but that's a performance optimization */ 1.776 + 1.777 +static inline comp4_t 1.778 +blend_exclusion (comp4_t dca, comp4_t da, comp4_t sca, comp4_t sa) 1.779 +{ 1.780 + return DIV_ONE_UNc (sca * da + dca * sa - 2 * dca * sca); 1.781 +} 1.782 + 1.783 +PDF_SEPARABLE_BLEND_MODE (exclusion) 1.784 + 1.785 +#undef PDF_SEPARABLE_BLEND_MODE 1.786 + 1.787 +/* 1.788 + * PDF nonseperable blend modes are implemented using the following functions 1.789 + * to operate in Hsl space, with Cmax, Cmid, Cmin referring to the max, mid 1.790 + * and min value of the red, green and blue components. 1.791 + * 1.792 + * LUM (C) = 0.3 × Cred + 0.59 × Cgreen + 0.11 × Cblue 1.793 + * 1.794 + * clip_color (C): 1.795 + * l = LUM (C) 1.796 + * min = Cmin 1.797 + * max = Cmax 1.798 + * if n < 0.0 1.799 + * C = l + ( ( ( C – l ) × l ) ⁄ ( l – min ) ) 1.800 + * if x > 1.0 1.801 + * C = l + ( ( ( C – l ) × ( 1 – l ) ) ⁄ ( max – l ) ) 1.802 + * return C 1.803 + * 1.804 + * set_lum (C, l): 1.805 + * d = l – LUM (C) 1.806 + * C += d 1.807 + * return clip_color (C) 1.808 + * 1.809 + * SAT (C) = CH_MAX (C) - CH_MIN (C) 1.810 + * 1.811 + * set_sat (C, s): 1.812 + * if Cmax > Cmin 1.813 + * Cmid = ( ( ( Cmid – Cmin ) × s ) ⁄ ( Cmax – Cmin ) ) 1.814 + * Cmax = s 1.815 + * else 1.816 + * Cmid = Cmax = 0.0 1.817 + * Cmin = 0.0 1.818 + * return C 1.819 + */ 1.820 + 1.821 +/* For premultiplied colors, we need to know what happens when C is 1.822 + * multiplied by a real number. LUM and SAT are linear: 1.823 + * 1.824 + * LUM (r × C) = r × LUM (C) SAT (r * C) = r * SAT (C) 1.825 + * 1.826 + * If we extend clip_color with an extra argument a and change 1.827 + * 1.828 + * if x >= 1.0 1.829 + * 1.830 + * into 1.831 + * 1.832 + * if x >= a 1.833 + * 1.834 + * then clip_color is also linear: 1.835 + * 1.836 + * r * clip_color (C, a) = clip_color (r_c, ra); 1.837 + * 1.838 + * for positive r. 1.839 + * 1.840 + * Similarly, we can extend set_lum with an extra argument that is just passed 1.841 + * on to clip_color: 1.842 + * 1.843 + * r * set_lum ( C, l, a) 1.844 + * 1.845 + * = r × clip_color ( C + l - LUM (C), a) 1.846 + * 1.847 + * = clip_color ( r * C + r × l - r * LUM (C), r * a) 1.848 + * 1.849 + * = set_lum ( r * C, r * l, r * a) 1.850 + * 1.851 + * Finally, set_sat: 1.852 + * 1.853 + * r * set_sat (C, s) = set_sat (x * C, r * s) 1.854 + * 1.855 + * The above holds for all non-zero x, because the x'es in the fraction for 1.856 + * C_mid cancel out. Specifically, it holds for x = r: 1.857 + * 1.858 + * r * set_sat (C, s) = set_sat (r_c, rs) 1.859 + * 1.860 + */ 1.861 + 1.862 +/* So, for the non-separable PDF blend modes, we have (using s, d for 1.863 + * non-premultiplied colors, and S, D for premultiplied: 1.864 + * 1.865 + * Color: 1.866 + * 1.867 + * a_s * a_d * B(s, d) 1.868 + * = a_s * a_d * set_lum (S/a_s, LUM (D/a_d), 1) 1.869 + * = set_lum (S * a_d, a_s * LUM (D), a_s * a_d) 1.870 + * 1.871 + * 1.872 + * Luminosity: 1.873 + * 1.874 + * a_s * a_d * B(s, d) 1.875 + * = a_s * a_d * set_lum (D/a_d, LUM(S/a_s), 1) 1.876 + * = set_lum (a_s * D, a_d * LUM(S), a_s * a_d) 1.877 + * 1.878 + * 1.879 + * Saturation: 1.880 + * 1.881 + * a_s * a_d * B(s, d) 1.882 + * = a_s * a_d * set_lum (set_sat (D/a_d, SAT (S/a_s)), LUM (D/a_d), 1) 1.883 + * = set_lum (a_s * a_d * set_sat (D/a_d, SAT (S/a_s)), 1.884 + * a_s * LUM (D), a_s * a_d) 1.885 + * = set_lum (set_sat (a_s * D, a_d * SAT (S), a_s * LUM (D), a_s * a_d)) 1.886 + * 1.887 + * Hue: 1.888 + * 1.889 + * a_s * a_d * B(s, d) 1.890 + * = a_s * a_d * set_lum (set_sat (S/a_s, SAT (D/a_d)), LUM (D/a_d), 1) 1.891 + * = set_lum (set_sat (a_d * S, a_s * SAT (D)), a_s * LUM (D), a_s * a_d) 1.892 + * 1.893 + */ 1.894 + 1.895 +#define CH_MIN(c) (c[0] < c[1] ? (c[0] < c[2] ? c[0] : c[2]) : (c[1] < c[2] ? c[1] : c[2])) 1.896 +#define CH_MAX(c) (c[0] > c[1] ? (c[0] > c[2] ? c[0] : c[2]) : (c[1] > c[2] ? c[1] : c[2])) 1.897 +#define LUM(c) ((c[0] * 30 + c[1] * 59 + c[2] * 11) / 100) 1.898 +#define SAT(c) (CH_MAX (c) - CH_MIN (c)) 1.899 + 1.900 +#define PDF_NON_SEPARABLE_BLEND_MODE(name) \ 1.901 + static void \ 1.902 + combine_ ## name ## _u (pixman_implementation_t *imp, \ 1.903 + pixman_op_t op, \ 1.904 + comp4_t *dest, \ 1.905 + const comp4_t *src, \ 1.906 + const comp4_t *mask, \ 1.907 + int width) \ 1.908 + { \ 1.909 + int i; \ 1.910 + for (i = 0; i < width; ++i) \ 1.911 + { \ 1.912 + comp4_t s = combine_mask (src, mask, i); \ 1.913 + comp4_t d = *(dest + i); \ 1.914 + comp1_t sa = ALPHA_c (s); \ 1.915 + comp1_t isa = ~sa; \ 1.916 + comp1_t da = ALPHA_c (d); \ 1.917 + comp1_t ida = ~da; \ 1.918 + comp4_t result; \ 1.919 + comp4_t sc[3], dc[3], c[3]; \ 1.920 + \ 1.921 + result = d; \ 1.922 + UNcx4_MUL_UNc_ADD_UNcx4_MUL_UNc (result, isa, s, ida); \ 1.923 + dc[0] = RED_c (d); \ 1.924 + sc[0] = RED_c (s); \ 1.925 + dc[1] = GREEN_c (d); \ 1.926 + sc[1] = GREEN_c (s); \ 1.927 + dc[2] = BLUE_c (d); \ 1.928 + sc[2] = BLUE_c (s); \ 1.929 + blend_ ## name (c, dc, da, sc, sa); \ 1.930 + \ 1.931 + *(dest + i) = result + \ 1.932 + (DIV_ONE_UNc (sa * (comp4_t)da) << A_SHIFT) + \ 1.933 + (DIV_ONE_UNc (c[0]) << R_SHIFT) + \ 1.934 + (DIV_ONE_UNc (c[1]) << G_SHIFT) + \ 1.935 + (DIV_ONE_UNc (c[2])); \ 1.936 + } \ 1.937 + } 1.938 + 1.939 +static void 1.940 +set_lum (comp4_t dest[3], comp4_t src[3], comp4_t sa, comp4_t lum) 1.941 +{ 1.942 + double a, l, min, max; 1.943 + double tmp[3]; 1.944 + 1.945 + a = sa * (1.0 / MASK); 1.946 + 1.947 + l = lum * (1.0 / MASK); 1.948 + tmp[0] = src[0] * (1.0 / MASK); 1.949 + tmp[1] = src[1] * (1.0 / MASK); 1.950 + tmp[2] = src[2] * (1.0 / MASK); 1.951 + 1.952 + l = l - LUM (tmp); 1.953 + tmp[0] += l; 1.954 + tmp[1] += l; 1.955 + tmp[2] += l; 1.956 + 1.957 + /* clip_color */ 1.958 + l = LUM (tmp); 1.959 + min = CH_MIN (tmp); 1.960 + max = CH_MAX (tmp); 1.961 + 1.962 + if (min < 0) 1.963 + { 1.964 + if (l - min == 0.0) 1.965 + { 1.966 + tmp[0] = 0; 1.967 + tmp[1] = 0; 1.968 + tmp[2] = 0; 1.969 + } 1.970 + else 1.971 + { 1.972 + tmp[0] = l + (tmp[0] - l) * l / (l - min); 1.973 + tmp[1] = l + (tmp[1] - l) * l / (l - min); 1.974 + tmp[2] = l + (tmp[2] - l) * l / (l - min); 1.975 + } 1.976 + } 1.977 + if (max > a) 1.978 + { 1.979 + if (max - l == 0.0) 1.980 + { 1.981 + tmp[0] = a; 1.982 + tmp[1] = a; 1.983 + tmp[2] = a; 1.984 + } 1.985 + else 1.986 + { 1.987 + tmp[0] = l + (tmp[0] - l) * (a - l) / (max - l); 1.988 + tmp[1] = l + (tmp[1] - l) * (a - l) / (max - l); 1.989 + tmp[2] = l + (tmp[2] - l) * (a - l) / (max - l); 1.990 + } 1.991 + } 1.992 + 1.993 + dest[0] = tmp[0] * MASK + 0.5; 1.994 + dest[1] = tmp[1] * MASK + 0.5; 1.995 + dest[2] = tmp[2] * MASK + 0.5; 1.996 +} 1.997 + 1.998 +static void 1.999 +set_sat (comp4_t dest[3], comp4_t src[3], comp4_t sat) 1.1000 +{ 1.1001 + int id[3]; 1.1002 + comp4_t min, max; 1.1003 + 1.1004 + if (src[0] > src[1]) 1.1005 + { 1.1006 + if (src[0] > src[2]) 1.1007 + { 1.1008 + id[0] = 0; 1.1009 + if (src[1] > src[2]) 1.1010 + { 1.1011 + id[1] = 1; 1.1012 + id[2] = 2; 1.1013 + } 1.1014 + else 1.1015 + { 1.1016 + id[1] = 2; 1.1017 + id[2] = 1; 1.1018 + } 1.1019 + } 1.1020 + else 1.1021 + { 1.1022 + id[0] = 2; 1.1023 + id[1] = 0; 1.1024 + id[2] = 1; 1.1025 + } 1.1026 + } 1.1027 + else 1.1028 + { 1.1029 + if (src[0] > src[2]) 1.1030 + { 1.1031 + id[0] = 1; 1.1032 + id[1] = 0; 1.1033 + id[2] = 2; 1.1034 + } 1.1035 + else 1.1036 + { 1.1037 + id[2] = 0; 1.1038 + if (src[1] > src[2]) 1.1039 + { 1.1040 + id[0] = 1; 1.1041 + id[1] = 2; 1.1042 + } 1.1043 + else 1.1044 + { 1.1045 + id[0] = 2; 1.1046 + id[1] = 1; 1.1047 + } 1.1048 + } 1.1049 + } 1.1050 + 1.1051 + max = dest[id[0]]; 1.1052 + min = dest[id[2]]; 1.1053 + if (max > min) 1.1054 + { 1.1055 + dest[id[1]] = (dest[id[1]] - min) * sat / (max - min); 1.1056 + dest[id[0]] = sat; 1.1057 + dest[id[2]] = 0; 1.1058 + } 1.1059 + else 1.1060 + { 1.1061 + dest[0] = dest[1] = dest[2] = 0; 1.1062 + } 1.1063 +} 1.1064 + 1.1065 +/* 1.1066 + * Hue: 1.1067 + * B(Cb, Cs) = set_lum (set_sat (Cs, SAT (Cb)), LUM (Cb)) 1.1068 + */ 1.1069 +static inline void 1.1070 +blend_hsl_hue (comp4_t c[3], 1.1071 + comp4_t dc[3], 1.1072 + comp4_t da, 1.1073 + comp4_t sc[3], 1.1074 + comp4_t sa) 1.1075 +{ 1.1076 + c[0] = sc[0] * da; 1.1077 + c[1] = sc[1] * da; 1.1078 + c[2] = sc[2] * da; 1.1079 + set_sat (c, c, SAT (dc) * sa); 1.1080 + set_lum (c, c, sa * da, LUM (dc) * sa); 1.1081 +} 1.1082 + 1.1083 +PDF_NON_SEPARABLE_BLEND_MODE (hsl_hue) 1.1084 + 1.1085 +/* 1.1086 + * Saturation: 1.1087 + * B(Cb, Cs) = set_lum (set_sat (Cb, SAT (Cs)), LUM (Cb)) 1.1088 + */ 1.1089 +static inline void 1.1090 +blend_hsl_saturation (comp4_t c[3], 1.1091 + comp4_t dc[3], 1.1092 + comp4_t da, 1.1093 + comp4_t sc[3], 1.1094 + comp4_t sa) 1.1095 +{ 1.1096 + c[0] = dc[0] * sa; 1.1097 + c[1] = dc[1] * sa; 1.1098 + c[2] = dc[2] * sa; 1.1099 + set_sat (c, c, SAT (sc) * da); 1.1100 + set_lum (c, c, sa * da, LUM (dc) * sa); 1.1101 +} 1.1102 + 1.1103 +PDF_NON_SEPARABLE_BLEND_MODE (hsl_saturation) 1.1104 + 1.1105 +/* 1.1106 + * Color: 1.1107 + * B(Cb, Cs) = set_lum (Cs, LUM (Cb)) 1.1108 + */ 1.1109 +static inline void 1.1110 +blend_hsl_color (comp4_t c[3], 1.1111 + comp4_t dc[3], 1.1112 + comp4_t da, 1.1113 + comp4_t sc[3], 1.1114 + comp4_t sa) 1.1115 +{ 1.1116 + c[0] = sc[0] * da; 1.1117 + c[1] = sc[1] * da; 1.1118 + c[2] = sc[2] * da; 1.1119 + set_lum (c, c, sa * da, LUM (dc) * sa); 1.1120 +} 1.1121 + 1.1122 +PDF_NON_SEPARABLE_BLEND_MODE (hsl_color) 1.1123 + 1.1124 +/* 1.1125 + * Luminosity: 1.1126 + * B(Cb, Cs) = set_lum (Cb, LUM (Cs)) 1.1127 + */ 1.1128 +static inline void 1.1129 +blend_hsl_luminosity (comp4_t c[3], 1.1130 + comp4_t dc[3], 1.1131 + comp4_t da, 1.1132 + comp4_t sc[3], 1.1133 + comp4_t sa) 1.1134 +{ 1.1135 + c[0] = dc[0] * sa; 1.1136 + c[1] = dc[1] * sa; 1.1137 + c[2] = dc[2] * sa; 1.1138 + set_lum (c, c, sa * da, LUM (sc) * da); 1.1139 +} 1.1140 + 1.1141 +PDF_NON_SEPARABLE_BLEND_MODE (hsl_luminosity) 1.1142 + 1.1143 +#undef SAT 1.1144 +#undef LUM 1.1145 +#undef CH_MAX 1.1146 +#undef CH_MIN 1.1147 +#undef PDF_NON_SEPARABLE_BLEND_MODE 1.1148 + 1.1149 +/* All of the disjoint/conjoint composing functions 1.1150 + * 1.1151 + * The four entries in the first column indicate what source contributions 1.1152 + * come from each of the four areas of the picture -- areas covered by neither 1.1153 + * A nor B, areas covered only by A, areas covered only by B and finally 1.1154 + * areas covered by both A and B. 1.1155 + * 1.1156 + * Disjoint Conjoint 1.1157 + * Fa Fb Fa Fb 1.1158 + * (0,0,0,0) 0 0 0 0 1.1159 + * (0,A,0,A) 1 0 1 0 1.1160 + * (0,0,B,B) 0 1 0 1 1.1161 + * (0,A,B,A) 1 min((1-a)/b,1) 1 max(1-a/b,0) 1.1162 + * (0,A,B,B) min((1-b)/a,1) 1 max(1-b/a,0) 1 1.1163 + * (0,0,0,A) max(1-(1-b)/a,0) 0 min(1,b/a) 0 1.1164 + * (0,0,0,B) 0 max(1-(1-a)/b,0) 0 min(a/b,1) 1.1165 + * (0,A,0,0) min(1,(1-b)/a) 0 max(1-b/a,0) 0 1.1166 + * (0,0,B,0) 0 min(1,(1-a)/b) 0 max(1-a/b,0) 1.1167 + * (0,0,B,A) max(1-(1-b)/a,0) min(1,(1-a)/b) min(1,b/a) max(1-a/b,0) 1.1168 + * (0,A,0,B) min(1,(1-b)/a) max(1-(1-a)/b,0) max(1-b/a,0) min(1,a/b) 1.1169 + * (0,A,B,0) min(1,(1-b)/a) min(1,(1-a)/b) max(1-b/a,0) max(1-a/b,0) 1.1170 + * 1.1171 + * See http://marc.info/?l=xfree-render&m=99792000027857&w=2 for more 1.1172 + * information about these operators. 1.1173 + */ 1.1174 + 1.1175 +#define COMBINE_A_OUT 1 1.1176 +#define COMBINE_A_IN 2 1.1177 +#define COMBINE_B_OUT 4 1.1178 +#define COMBINE_B_IN 8 1.1179 + 1.1180 +#define COMBINE_CLEAR 0 1.1181 +#define COMBINE_A (COMBINE_A_OUT | COMBINE_A_IN) 1.1182 +#define COMBINE_B (COMBINE_B_OUT | COMBINE_B_IN) 1.1183 +#define COMBINE_A_OVER (COMBINE_A_OUT | COMBINE_B_OUT | COMBINE_A_IN) 1.1184 +#define COMBINE_B_OVER (COMBINE_A_OUT | COMBINE_B_OUT | COMBINE_B_IN) 1.1185 +#define COMBINE_A_ATOP (COMBINE_B_OUT | COMBINE_A_IN) 1.1186 +#define COMBINE_B_ATOP (COMBINE_A_OUT | COMBINE_B_IN) 1.1187 +#define COMBINE_XOR (COMBINE_A_OUT | COMBINE_B_OUT) 1.1188 + 1.1189 +/* portion covered by a but not b */ 1.1190 +static comp1_t 1.1191 +combine_disjoint_out_part (comp1_t a, comp1_t b) 1.1192 +{ 1.1193 + /* min (1, (1-b) / a) */ 1.1194 + 1.1195 + b = ~b; /* 1 - b */ 1.1196 + if (b >= a) /* 1 - b >= a -> (1-b)/a >= 1 */ 1.1197 + return MASK; /* 1 */ 1.1198 + return DIV_UNc (b, a); /* (1-b) / a */ 1.1199 +} 1.1200 + 1.1201 +/* portion covered by both a and b */ 1.1202 +static comp1_t 1.1203 +combine_disjoint_in_part (comp1_t a, comp1_t b) 1.1204 +{ 1.1205 + /* max (1-(1-b)/a,0) */ 1.1206 + /* = - min ((1-b)/a - 1, 0) */ 1.1207 + /* = 1 - min (1, (1-b)/a) */ 1.1208 + 1.1209 + b = ~b; /* 1 - b */ 1.1210 + if (b >= a) /* 1 - b >= a -> (1-b)/a >= 1 */ 1.1211 + return 0; /* 1 - 1 */ 1.1212 + return ~DIV_UNc(b, a); /* 1 - (1-b) / a */ 1.1213 +} 1.1214 + 1.1215 +/* portion covered by a but not b */ 1.1216 +static comp1_t 1.1217 +combine_conjoint_out_part (comp1_t a, comp1_t b) 1.1218 +{ 1.1219 + /* max (1-b/a,0) */ 1.1220 + /* = 1-min(b/a,1) */ 1.1221 + 1.1222 + /* min (1, (1-b) / a) */ 1.1223 + 1.1224 + if (b >= a) /* b >= a -> b/a >= 1 */ 1.1225 + return 0x00; /* 0 */ 1.1226 + return ~DIV_UNc(b, a); /* 1 - b/a */ 1.1227 +} 1.1228 + 1.1229 +/* portion covered by both a and b */ 1.1230 +static comp1_t 1.1231 +combine_conjoint_in_part (comp1_t a, comp1_t b) 1.1232 +{ 1.1233 + /* min (1,b/a) */ 1.1234 + 1.1235 + if (b >= a) /* b >= a -> b/a >= 1 */ 1.1236 + return MASK; /* 1 */ 1.1237 + return DIV_UNc (b, a); /* b/a */ 1.1238 +} 1.1239 + 1.1240 +#define GET_COMP(v, i) ((comp2_t) (comp1_t) ((v) >> i)) 1.1241 + 1.1242 +#define ADD(x, y, i, t) \ 1.1243 + ((t) = GET_COMP (x, i) + GET_COMP (y, i), \ 1.1244 + (comp4_t) ((comp1_t) ((t) | (0 - ((t) >> G_SHIFT)))) << (i)) 1.1245 + 1.1246 +#define GENERIC(x, y, i, ax, ay, t, u, v) \ 1.1247 + ((t) = (MUL_UNc (GET_COMP (y, i), ay, (u)) + \ 1.1248 + MUL_UNc (GET_COMP (x, i), ax, (v))), \ 1.1249 + (comp4_t) ((comp1_t) ((t) | \ 1.1250 + (0 - ((t) >> G_SHIFT)))) << (i)) 1.1251 + 1.1252 +static void 1.1253 +combine_disjoint_general_u (comp4_t * dest, 1.1254 + const comp4_t *src, 1.1255 + const comp4_t *mask, 1.1256 + int width, 1.1257 + comp1_t combine) 1.1258 +{ 1.1259 + int i; 1.1260 + 1.1261 + for (i = 0; i < width; ++i) 1.1262 + { 1.1263 + comp4_t s = combine_mask (src, mask, i); 1.1264 + comp4_t d = *(dest + i); 1.1265 + comp4_t m, n, o, p; 1.1266 + comp2_t Fa, Fb, t, u, v; 1.1267 + comp1_t sa = s >> A_SHIFT; 1.1268 + comp1_t da = d >> A_SHIFT; 1.1269 + 1.1270 + switch (combine & COMBINE_A) 1.1271 + { 1.1272 + default: 1.1273 + Fa = 0; 1.1274 + break; 1.1275 + 1.1276 + case COMBINE_A_OUT: 1.1277 + Fa = combine_disjoint_out_part (sa, da); 1.1278 + break; 1.1279 + 1.1280 + case COMBINE_A_IN: 1.1281 + Fa = combine_disjoint_in_part (sa, da); 1.1282 + break; 1.1283 + 1.1284 + case COMBINE_A: 1.1285 + Fa = MASK; 1.1286 + break; 1.1287 + } 1.1288 + 1.1289 + switch (combine & COMBINE_B) 1.1290 + { 1.1291 + default: 1.1292 + Fb = 0; 1.1293 + break; 1.1294 + 1.1295 + case COMBINE_B_OUT: 1.1296 + Fb = combine_disjoint_out_part (da, sa); 1.1297 + break; 1.1298 + 1.1299 + case COMBINE_B_IN: 1.1300 + Fb = combine_disjoint_in_part (da, sa); 1.1301 + break; 1.1302 + 1.1303 + case COMBINE_B: 1.1304 + Fb = MASK; 1.1305 + break; 1.1306 + } 1.1307 + m = GENERIC (s, d, 0, Fa, Fb, t, u, v); 1.1308 + n = GENERIC (s, d, G_SHIFT, Fa, Fb, t, u, v); 1.1309 + o = GENERIC (s, d, R_SHIFT, Fa, Fb, t, u, v); 1.1310 + p = GENERIC (s, d, A_SHIFT, Fa, Fb, t, u, v); 1.1311 + s = m | n | o | p; 1.1312 + *(dest + i) = s; 1.1313 + } 1.1314 +} 1.1315 + 1.1316 +static void 1.1317 +combine_disjoint_over_u (pixman_implementation_t *imp, 1.1318 + pixman_op_t op, 1.1319 + comp4_t * dest, 1.1320 + const comp4_t * src, 1.1321 + const comp4_t * mask, 1.1322 + int width) 1.1323 +{ 1.1324 + int i; 1.1325 + 1.1326 + for (i = 0; i < width; ++i) 1.1327 + { 1.1328 + comp4_t s = combine_mask (src, mask, i); 1.1329 + comp2_t a = s >> A_SHIFT; 1.1330 + 1.1331 + if (s != 0x00) 1.1332 + { 1.1333 + comp4_t d = *(dest + i); 1.1334 + a = combine_disjoint_out_part (d >> A_SHIFT, a); 1.1335 + UNcx4_MUL_UNc_ADD_UNcx4 (d, a, s); 1.1336 + 1.1337 + *(dest + i) = d; 1.1338 + } 1.1339 + } 1.1340 +} 1.1341 + 1.1342 +static void 1.1343 +combine_disjoint_in_u (pixman_implementation_t *imp, 1.1344 + pixman_op_t op, 1.1345 + comp4_t * dest, 1.1346 + const comp4_t * src, 1.1347 + const comp4_t * mask, 1.1348 + int width) 1.1349 +{ 1.1350 + combine_disjoint_general_u (dest, src, mask, width, COMBINE_A_IN); 1.1351 +} 1.1352 + 1.1353 +static void 1.1354 +combine_disjoint_in_reverse_u (pixman_implementation_t *imp, 1.1355 + pixman_op_t op, 1.1356 + comp4_t * dest, 1.1357 + const comp4_t * src, 1.1358 + const comp4_t * mask, 1.1359 + int width) 1.1360 +{ 1.1361 + combine_disjoint_general_u (dest, src, mask, width, COMBINE_B_IN); 1.1362 +} 1.1363 + 1.1364 +static void 1.1365 +combine_disjoint_out_u (pixman_implementation_t *imp, 1.1366 + pixman_op_t op, 1.1367 + comp4_t * dest, 1.1368 + const comp4_t * src, 1.1369 + const comp4_t * mask, 1.1370 + int width) 1.1371 +{ 1.1372 + combine_disjoint_general_u (dest, src, mask, width, COMBINE_A_OUT); 1.1373 +} 1.1374 + 1.1375 +static void 1.1376 +combine_disjoint_out_reverse_u (pixman_implementation_t *imp, 1.1377 + pixman_op_t op, 1.1378 + comp4_t * dest, 1.1379 + const comp4_t * src, 1.1380 + const comp4_t * mask, 1.1381 + int width) 1.1382 +{ 1.1383 + combine_disjoint_general_u (dest, src, mask, width, COMBINE_B_OUT); 1.1384 +} 1.1385 + 1.1386 +static void 1.1387 +combine_disjoint_atop_u (pixman_implementation_t *imp, 1.1388 + pixman_op_t op, 1.1389 + comp4_t * dest, 1.1390 + const comp4_t * src, 1.1391 + const comp4_t * mask, 1.1392 + int width) 1.1393 +{ 1.1394 + combine_disjoint_general_u (dest, src, mask, width, COMBINE_A_ATOP); 1.1395 +} 1.1396 + 1.1397 +static void 1.1398 +combine_disjoint_atop_reverse_u (pixman_implementation_t *imp, 1.1399 + pixman_op_t op, 1.1400 + comp4_t * dest, 1.1401 + const comp4_t * src, 1.1402 + const comp4_t * mask, 1.1403 + int width) 1.1404 +{ 1.1405 + combine_disjoint_general_u (dest, src, mask, width, COMBINE_B_ATOP); 1.1406 +} 1.1407 + 1.1408 +static void 1.1409 +combine_disjoint_xor_u (pixman_implementation_t *imp, 1.1410 + pixman_op_t op, 1.1411 + comp4_t * dest, 1.1412 + const comp4_t * src, 1.1413 + const comp4_t * mask, 1.1414 + int width) 1.1415 +{ 1.1416 + combine_disjoint_general_u (dest, src, mask, width, COMBINE_XOR); 1.1417 +} 1.1418 + 1.1419 +static void 1.1420 +combine_conjoint_general_u (comp4_t * dest, 1.1421 + const comp4_t *src, 1.1422 + const comp4_t *mask, 1.1423 + int width, 1.1424 + comp1_t combine) 1.1425 +{ 1.1426 + int i; 1.1427 + 1.1428 + for (i = 0; i < width; ++i) 1.1429 + { 1.1430 + comp4_t s = combine_mask (src, mask, i); 1.1431 + comp4_t d = *(dest + i); 1.1432 + comp4_t m, n, o, p; 1.1433 + comp2_t Fa, Fb, t, u, v; 1.1434 + comp1_t sa = s >> A_SHIFT; 1.1435 + comp1_t da = d >> A_SHIFT; 1.1436 + 1.1437 + switch (combine & COMBINE_A) 1.1438 + { 1.1439 + default: 1.1440 + Fa = 0; 1.1441 + break; 1.1442 + 1.1443 + case COMBINE_A_OUT: 1.1444 + Fa = combine_conjoint_out_part (sa, da); 1.1445 + break; 1.1446 + 1.1447 + case COMBINE_A_IN: 1.1448 + Fa = combine_conjoint_in_part (sa, da); 1.1449 + break; 1.1450 + 1.1451 + case COMBINE_A: 1.1452 + Fa = MASK; 1.1453 + break; 1.1454 + } 1.1455 + 1.1456 + switch (combine & COMBINE_B) 1.1457 + { 1.1458 + default: 1.1459 + Fb = 0; 1.1460 + break; 1.1461 + 1.1462 + case COMBINE_B_OUT: 1.1463 + Fb = combine_conjoint_out_part (da, sa); 1.1464 + break; 1.1465 + 1.1466 + case COMBINE_B_IN: 1.1467 + Fb = combine_conjoint_in_part (da, sa); 1.1468 + break; 1.1469 + 1.1470 + case COMBINE_B: 1.1471 + Fb = MASK; 1.1472 + break; 1.1473 + } 1.1474 + 1.1475 + m = GENERIC (s, d, 0, Fa, Fb, t, u, v); 1.1476 + n = GENERIC (s, d, G_SHIFT, Fa, Fb, t, u, v); 1.1477 + o = GENERIC (s, d, R_SHIFT, Fa, Fb, t, u, v); 1.1478 + p = GENERIC (s, d, A_SHIFT, Fa, Fb, t, u, v); 1.1479 + 1.1480 + s = m | n | o | p; 1.1481 + 1.1482 + *(dest + i) = s; 1.1483 + } 1.1484 +} 1.1485 + 1.1486 +static void 1.1487 +combine_conjoint_over_u (pixman_implementation_t *imp, 1.1488 + pixman_op_t op, 1.1489 + comp4_t * dest, 1.1490 + const comp4_t * src, 1.1491 + const comp4_t * mask, 1.1492 + int width) 1.1493 +{ 1.1494 + combine_conjoint_general_u (dest, src, mask, width, COMBINE_A_OVER); 1.1495 +} 1.1496 + 1.1497 +static void 1.1498 +combine_conjoint_over_reverse_u (pixman_implementation_t *imp, 1.1499 + pixman_op_t op, 1.1500 + comp4_t * dest, 1.1501 + const comp4_t * src, 1.1502 + const comp4_t * mask, 1.1503 + int width) 1.1504 +{ 1.1505 + combine_conjoint_general_u (dest, src, mask, width, COMBINE_B_OVER); 1.1506 +} 1.1507 + 1.1508 +static void 1.1509 +combine_conjoint_in_u (pixman_implementation_t *imp, 1.1510 + pixman_op_t op, 1.1511 + comp4_t * dest, 1.1512 + const comp4_t * src, 1.1513 + const comp4_t * mask, 1.1514 + int width) 1.1515 +{ 1.1516 + combine_conjoint_general_u (dest, src, mask, width, COMBINE_A_IN); 1.1517 +} 1.1518 + 1.1519 +static void 1.1520 +combine_conjoint_in_reverse_u (pixman_implementation_t *imp, 1.1521 + pixman_op_t op, 1.1522 + comp4_t * dest, 1.1523 + const comp4_t * src, 1.1524 + const comp4_t * mask, 1.1525 + int width) 1.1526 +{ 1.1527 + combine_conjoint_general_u (dest, src, mask, width, COMBINE_B_IN); 1.1528 +} 1.1529 + 1.1530 +static void 1.1531 +combine_conjoint_out_u (pixman_implementation_t *imp, 1.1532 + pixman_op_t op, 1.1533 + comp4_t * dest, 1.1534 + const comp4_t * src, 1.1535 + const comp4_t * mask, 1.1536 + int width) 1.1537 +{ 1.1538 + combine_conjoint_general_u (dest, src, mask, width, COMBINE_A_OUT); 1.1539 +} 1.1540 + 1.1541 +static void 1.1542 +combine_conjoint_out_reverse_u (pixman_implementation_t *imp, 1.1543 + pixman_op_t op, 1.1544 + comp4_t * dest, 1.1545 + const comp4_t * src, 1.1546 + const comp4_t * mask, 1.1547 + int width) 1.1548 +{ 1.1549 + combine_conjoint_general_u (dest, src, mask, width, COMBINE_B_OUT); 1.1550 +} 1.1551 + 1.1552 +static void 1.1553 +combine_conjoint_atop_u (pixman_implementation_t *imp, 1.1554 + pixman_op_t op, 1.1555 + comp4_t * dest, 1.1556 + const comp4_t * src, 1.1557 + const comp4_t * mask, 1.1558 + int width) 1.1559 +{ 1.1560 + combine_conjoint_general_u (dest, src, mask, width, COMBINE_A_ATOP); 1.1561 +} 1.1562 + 1.1563 +static void 1.1564 +combine_conjoint_atop_reverse_u (pixman_implementation_t *imp, 1.1565 + pixman_op_t op, 1.1566 + comp4_t * dest, 1.1567 + const comp4_t * src, 1.1568 + const comp4_t * mask, 1.1569 + int width) 1.1570 +{ 1.1571 + combine_conjoint_general_u (dest, src, mask, width, COMBINE_B_ATOP); 1.1572 +} 1.1573 + 1.1574 +static void 1.1575 +combine_conjoint_xor_u (pixman_implementation_t *imp, 1.1576 + pixman_op_t op, 1.1577 + comp4_t * dest, 1.1578 + const comp4_t * src, 1.1579 + const comp4_t * mask, 1.1580 + int width) 1.1581 +{ 1.1582 + combine_conjoint_general_u (dest, src, mask, width, COMBINE_XOR); 1.1583 +} 1.1584 + 1.1585 +/************************************************************************/ 1.1586 +/*********************** Per Channel functions **************************/ 1.1587 +/************************************************************************/ 1.1588 + 1.1589 +static void 1.1590 +combine_clear_ca (pixman_implementation_t *imp, 1.1591 + pixman_op_t op, 1.1592 + comp4_t * dest, 1.1593 + const comp4_t * src, 1.1594 + const comp4_t * mask, 1.1595 + int width) 1.1596 +{ 1.1597 + memset (dest, 0, width * sizeof(comp4_t)); 1.1598 +} 1.1599 + 1.1600 +static void 1.1601 +combine_src_ca (pixman_implementation_t *imp, 1.1602 + pixman_op_t op, 1.1603 + comp4_t * dest, 1.1604 + const comp4_t * src, 1.1605 + const comp4_t * mask, 1.1606 + int width) 1.1607 +{ 1.1608 + int i; 1.1609 + 1.1610 + for (i = 0; i < width; ++i) 1.1611 + { 1.1612 + comp4_t s = *(src + i); 1.1613 + comp4_t m = *(mask + i); 1.1614 + 1.1615 + combine_mask_value_ca (&s, &m); 1.1616 + 1.1617 + *(dest + i) = s; 1.1618 + } 1.1619 +} 1.1620 + 1.1621 +static void 1.1622 +combine_over_ca (pixman_implementation_t *imp, 1.1623 + pixman_op_t op, 1.1624 + comp4_t * dest, 1.1625 + const comp4_t * src, 1.1626 + const comp4_t * mask, 1.1627 + int width) 1.1628 +{ 1.1629 + int i; 1.1630 + 1.1631 + for (i = 0; i < width; ++i) 1.1632 + { 1.1633 + comp4_t s = *(src + i); 1.1634 + comp4_t m = *(mask + i); 1.1635 + comp4_t a; 1.1636 + 1.1637 + combine_mask_ca (&s, &m); 1.1638 + 1.1639 + a = ~m; 1.1640 + if (a) 1.1641 + { 1.1642 + comp4_t d = *(dest + i); 1.1643 + UNcx4_MUL_UNcx4_ADD_UNcx4 (d, a, s); 1.1644 + s = d; 1.1645 + } 1.1646 + 1.1647 + *(dest + i) = s; 1.1648 + } 1.1649 +} 1.1650 + 1.1651 +static void 1.1652 +combine_over_reverse_ca (pixman_implementation_t *imp, 1.1653 + pixman_op_t op, 1.1654 + comp4_t * dest, 1.1655 + const comp4_t * src, 1.1656 + const comp4_t * mask, 1.1657 + int width) 1.1658 +{ 1.1659 + int i; 1.1660 + 1.1661 + for (i = 0; i < width; ++i) 1.1662 + { 1.1663 + comp4_t d = *(dest + i); 1.1664 + comp4_t a = ~d >> A_SHIFT; 1.1665 + 1.1666 + if (a) 1.1667 + { 1.1668 + comp4_t s = *(src + i); 1.1669 + comp4_t m = *(mask + i); 1.1670 + 1.1671 + UNcx4_MUL_UNcx4 (s, m); 1.1672 + UNcx4_MUL_UNc_ADD_UNcx4 (s, a, d); 1.1673 + 1.1674 + *(dest + i) = s; 1.1675 + } 1.1676 + } 1.1677 +} 1.1678 + 1.1679 +static void 1.1680 +combine_in_ca (pixman_implementation_t *imp, 1.1681 + pixman_op_t op, 1.1682 + comp4_t * dest, 1.1683 + const comp4_t * src, 1.1684 + const comp4_t * mask, 1.1685 + int width) 1.1686 +{ 1.1687 + int i; 1.1688 + 1.1689 + for (i = 0; i < width; ++i) 1.1690 + { 1.1691 + comp4_t d = *(dest + i); 1.1692 + comp2_t a = d >> A_SHIFT; 1.1693 + comp4_t s = 0; 1.1694 + 1.1695 + if (a) 1.1696 + { 1.1697 + comp4_t m = *(mask + i); 1.1698 + 1.1699 + s = *(src + i); 1.1700 + combine_mask_value_ca (&s, &m); 1.1701 + 1.1702 + if (a != MASK) 1.1703 + UNcx4_MUL_UNc (s, a); 1.1704 + } 1.1705 + 1.1706 + *(dest + i) = s; 1.1707 + } 1.1708 +} 1.1709 + 1.1710 +static void 1.1711 +combine_in_reverse_ca (pixman_implementation_t *imp, 1.1712 + pixman_op_t op, 1.1713 + comp4_t * dest, 1.1714 + const comp4_t * src, 1.1715 + const comp4_t * mask, 1.1716 + int width) 1.1717 +{ 1.1718 + int i; 1.1719 + 1.1720 + for (i = 0; i < width; ++i) 1.1721 + { 1.1722 + comp4_t s = *(src + i); 1.1723 + comp4_t m = *(mask + i); 1.1724 + comp4_t a; 1.1725 + 1.1726 + combine_mask_alpha_ca (&s, &m); 1.1727 + 1.1728 + a = m; 1.1729 + if (a != ~0) 1.1730 + { 1.1731 + comp4_t d = 0; 1.1732 + 1.1733 + if (a) 1.1734 + { 1.1735 + d = *(dest + i); 1.1736 + UNcx4_MUL_UNcx4 (d, a); 1.1737 + } 1.1738 + 1.1739 + *(dest + i) = d; 1.1740 + } 1.1741 + } 1.1742 +} 1.1743 + 1.1744 +static void 1.1745 +combine_out_ca (pixman_implementation_t *imp, 1.1746 + pixman_op_t op, 1.1747 + comp4_t * dest, 1.1748 + const comp4_t * src, 1.1749 + const comp4_t * mask, 1.1750 + int width) 1.1751 +{ 1.1752 + int i; 1.1753 + 1.1754 + for (i = 0; i < width; ++i) 1.1755 + { 1.1756 + comp4_t d = *(dest + i); 1.1757 + comp2_t a = ~d >> A_SHIFT; 1.1758 + comp4_t s = 0; 1.1759 + 1.1760 + if (a) 1.1761 + { 1.1762 + comp4_t m = *(mask + i); 1.1763 + 1.1764 + s = *(src + i); 1.1765 + combine_mask_value_ca (&s, &m); 1.1766 + 1.1767 + if (a != MASK) 1.1768 + UNcx4_MUL_UNc (s, a); 1.1769 + } 1.1770 + 1.1771 + *(dest + i) = s; 1.1772 + } 1.1773 +} 1.1774 + 1.1775 +static void 1.1776 +combine_out_reverse_ca (pixman_implementation_t *imp, 1.1777 + pixman_op_t op, 1.1778 + comp4_t * dest, 1.1779 + const comp4_t * src, 1.1780 + const comp4_t * mask, 1.1781 + int width) 1.1782 +{ 1.1783 + int i; 1.1784 + 1.1785 + for (i = 0; i < width; ++i) 1.1786 + { 1.1787 + comp4_t s = *(src + i); 1.1788 + comp4_t m = *(mask + i); 1.1789 + comp4_t a; 1.1790 + 1.1791 + combine_mask_alpha_ca (&s, &m); 1.1792 + 1.1793 + a = ~m; 1.1794 + if (a != ~0) 1.1795 + { 1.1796 + comp4_t d = 0; 1.1797 + 1.1798 + if (a) 1.1799 + { 1.1800 + d = *(dest + i); 1.1801 + UNcx4_MUL_UNcx4 (d, a); 1.1802 + } 1.1803 + 1.1804 + *(dest + i) = d; 1.1805 + } 1.1806 + } 1.1807 +} 1.1808 + 1.1809 +static void 1.1810 +combine_atop_ca (pixman_implementation_t *imp, 1.1811 + pixman_op_t op, 1.1812 + comp4_t * dest, 1.1813 + const comp4_t * src, 1.1814 + const comp4_t * mask, 1.1815 + int width) 1.1816 +{ 1.1817 + int i; 1.1818 + 1.1819 + for (i = 0; i < width; ++i) 1.1820 + { 1.1821 + comp4_t d = *(dest + i); 1.1822 + comp4_t s = *(src + i); 1.1823 + comp4_t m = *(mask + i); 1.1824 + comp4_t ad; 1.1825 + comp2_t as = d >> A_SHIFT; 1.1826 + 1.1827 + combine_mask_ca (&s, &m); 1.1828 + 1.1829 + ad = ~m; 1.1830 + 1.1831 + UNcx4_MUL_UNcx4_ADD_UNcx4_MUL_UNc (d, ad, s, as); 1.1832 + 1.1833 + *(dest + i) = d; 1.1834 + } 1.1835 +} 1.1836 + 1.1837 +static void 1.1838 +combine_atop_reverse_ca (pixman_implementation_t *imp, 1.1839 + pixman_op_t op, 1.1840 + comp4_t * dest, 1.1841 + const comp4_t * src, 1.1842 + const comp4_t * mask, 1.1843 + int width) 1.1844 +{ 1.1845 + int i; 1.1846 + 1.1847 + for (i = 0; i < width; ++i) 1.1848 + { 1.1849 + comp4_t d = *(dest + i); 1.1850 + comp4_t s = *(src + i); 1.1851 + comp4_t m = *(mask + i); 1.1852 + comp4_t ad; 1.1853 + comp2_t as = ~d >> A_SHIFT; 1.1854 + 1.1855 + combine_mask_ca (&s, &m); 1.1856 + 1.1857 + ad = m; 1.1858 + 1.1859 + UNcx4_MUL_UNcx4_ADD_UNcx4_MUL_UNc (d, ad, s, as); 1.1860 + 1.1861 + *(dest + i) = d; 1.1862 + } 1.1863 +} 1.1864 + 1.1865 +static void 1.1866 +combine_xor_ca (pixman_implementation_t *imp, 1.1867 + pixman_op_t op, 1.1868 + comp4_t * dest, 1.1869 + const comp4_t * src, 1.1870 + const comp4_t * mask, 1.1871 + int width) 1.1872 +{ 1.1873 + int i; 1.1874 + 1.1875 + for (i = 0; i < width; ++i) 1.1876 + { 1.1877 + comp4_t d = *(dest + i); 1.1878 + comp4_t s = *(src + i); 1.1879 + comp4_t m = *(mask + i); 1.1880 + comp4_t ad; 1.1881 + comp2_t as = ~d >> A_SHIFT; 1.1882 + 1.1883 + combine_mask_ca (&s, &m); 1.1884 + 1.1885 + ad = ~m; 1.1886 + 1.1887 + UNcx4_MUL_UNcx4_ADD_UNcx4_MUL_UNc (d, ad, s, as); 1.1888 + 1.1889 + *(dest + i) = d; 1.1890 + } 1.1891 +} 1.1892 + 1.1893 +static void 1.1894 +combine_add_ca (pixman_implementation_t *imp, 1.1895 + pixman_op_t op, 1.1896 + comp4_t * dest, 1.1897 + const comp4_t * src, 1.1898 + const comp4_t * mask, 1.1899 + int width) 1.1900 +{ 1.1901 + int i; 1.1902 + 1.1903 + for (i = 0; i < width; ++i) 1.1904 + { 1.1905 + comp4_t s = *(src + i); 1.1906 + comp4_t m = *(mask + i); 1.1907 + comp4_t d = *(dest + i); 1.1908 + 1.1909 + combine_mask_value_ca (&s, &m); 1.1910 + 1.1911 + UNcx4_ADD_UNcx4 (d, s); 1.1912 + 1.1913 + *(dest + i) = d; 1.1914 + } 1.1915 +} 1.1916 + 1.1917 +static void 1.1918 +combine_saturate_ca (pixman_implementation_t *imp, 1.1919 + pixman_op_t op, 1.1920 + comp4_t * dest, 1.1921 + const comp4_t * src, 1.1922 + const comp4_t * mask, 1.1923 + int width) 1.1924 +{ 1.1925 + int i; 1.1926 + 1.1927 + for (i = 0; i < width; ++i) 1.1928 + { 1.1929 + comp4_t s, d; 1.1930 + comp2_t sa, sr, sg, sb, da; 1.1931 + comp2_t t, u, v; 1.1932 + comp4_t m, n, o, p; 1.1933 + 1.1934 + d = *(dest + i); 1.1935 + s = *(src + i); 1.1936 + m = *(mask + i); 1.1937 + 1.1938 + combine_mask_ca (&s, &m); 1.1939 + 1.1940 + sa = (m >> A_SHIFT); 1.1941 + sr = (m >> R_SHIFT) & MASK; 1.1942 + sg = (m >> G_SHIFT) & MASK; 1.1943 + sb = m & MASK; 1.1944 + da = ~d >> A_SHIFT; 1.1945 + 1.1946 + if (sb <= da) 1.1947 + m = ADD (s, d, 0, t); 1.1948 + else 1.1949 + m = GENERIC (s, d, 0, (da << G_SHIFT) / sb, MASK, t, u, v); 1.1950 + 1.1951 + if (sg <= da) 1.1952 + n = ADD (s, d, G_SHIFT, t); 1.1953 + else 1.1954 + n = GENERIC (s, d, G_SHIFT, (da << G_SHIFT) / sg, MASK, t, u, v); 1.1955 + 1.1956 + if (sr <= da) 1.1957 + o = ADD (s, d, R_SHIFT, t); 1.1958 + else 1.1959 + o = GENERIC (s, d, R_SHIFT, (da << G_SHIFT) / sr, MASK, t, u, v); 1.1960 + 1.1961 + if (sa <= da) 1.1962 + p = ADD (s, d, A_SHIFT, t); 1.1963 + else 1.1964 + p = GENERIC (s, d, A_SHIFT, (da << G_SHIFT) / sa, MASK, t, u, v); 1.1965 + 1.1966 + *(dest + i) = m | n | o | p; 1.1967 + } 1.1968 +} 1.1969 + 1.1970 +static void 1.1971 +combine_disjoint_general_ca (comp4_t * dest, 1.1972 + const comp4_t *src, 1.1973 + const comp4_t *mask, 1.1974 + int width, 1.1975 + comp1_t combine) 1.1976 +{ 1.1977 + int i; 1.1978 + 1.1979 + for (i = 0; i < width; ++i) 1.1980 + { 1.1981 + comp4_t s, d; 1.1982 + comp4_t m, n, o, p; 1.1983 + comp4_t Fa, Fb; 1.1984 + comp2_t t, u, v; 1.1985 + comp4_t sa; 1.1986 + comp1_t da; 1.1987 + 1.1988 + s = *(src + i); 1.1989 + m = *(mask + i); 1.1990 + d = *(dest + i); 1.1991 + da = d >> A_SHIFT; 1.1992 + 1.1993 + combine_mask_ca (&s, &m); 1.1994 + 1.1995 + sa = m; 1.1996 + 1.1997 + switch (combine & COMBINE_A) 1.1998 + { 1.1999 + default: 1.2000 + Fa = 0; 1.2001 + break; 1.2002 + 1.2003 + case COMBINE_A_OUT: 1.2004 + m = (comp4_t)combine_disjoint_out_part ((comp1_t) (sa >> 0), da); 1.2005 + n = (comp4_t)combine_disjoint_out_part ((comp1_t) (sa >> G_SHIFT), da) << G_SHIFT; 1.2006 + o = (comp4_t)combine_disjoint_out_part ((comp1_t) (sa >> R_SHIFT), da) << R_SHIFT; 1.2007 + p = (comp4_t)combine_disjoint_out_part ((comp1_t) (sa >> A_SHIFT), da) << A_SHIFT; 1.2008 + Fa = m | n | o | p; 1.2009 + break; 1.2010 + 1.2011 + case COMBINE_A_IN: 1.2012 + m = (comp4_t)combine_disjoint_in_part ((comp1_t) (sa >> 0), da); 1.2013 + n = (comp4_t)combine_disjoint_in_part ((comp1_t) (sa >> G_SHIFT), da) << G_SHIFT; 1.2014 + o = (comp4_t)combine_disjoint_in_part ((comp1_t) (sa >> R_SHIFT), da) << R_SHIFT; 1.2015 + p = (comp4_t)combine_disjoint_in_part ((comp1_t) (sa >> A_SHIFT), da) << A_SHIFT; 1.2016 + Fa = m | n | o | p; 1.2017 + break; 1.2018 + 1.2019 + case COMBINE_A: 1.2020 + Fa = ~0; 1.2021 + break; 1.2022 + } 1.2023 + 1.2024 + switch (combine & COMBINE_B) 1.2025 + { 1.2026 + default: 1.2027 + Fb = 0; 1.2028 + break; 1.2029 + 1.2030 + case COMBINE_B_OUT: 1.2031 + m = (comp4_t)combine_disjoint_out_part (da, (comp1_t) (sa >> 0)); 1.2032 + n = (comp4_t)combine_disjoint_out_part (da, (comp1_t) (sa >> G_SHIFT)) << G_SHIFT; 1.2033 + o = (comp4_t)combine_disjoint_out_part (da, (comp1_t) (sa >> R_SHIFT)) << R_SHIFT; 1.2034 + p = (comp4_t)combine_disjoint_out_part (da, (comp1_t) (sa >> A_SHIFT)) << A_SHIFT; 1.2035 + Fb = m | n | o | p; 1.2036 + break; 1.2037 + 1.2038 + case COMBINE_B_IN: 1.2039 + m = (comp4_t)combine_disjoint_in_part (da, (comp1_t) (sa >> 0)); 1.2040 + n = (comp4_t)combine_disjoint_in_part (da, (comp1_t) (sa >> G_SHIFT)) << G_SHIFT; 1.2041 + o = (comp4_t)combine_disjoint_in_part (da, (comp1_t) (sa >> R_SHIFT)) << R_SHIFT; 1.2042 + p = (comp4_t)combine_disjoint_in_part (da, (comp1_t) (sa >> A_SHIFT)) << A_SHIFT; 1.2043 + Fb = m | n | o | p; 1.2044 + break; 1.2045 + 1.2046 + case COMBINE_B: 1.2047 + Fb = ~0; 1.2048 + break; 1.2049 + } 1.2050 + m = GENERIC (s, d, 0, GET_COMP (Fa, 0), GET_COMP (Fb, 0), t, u, v); 1.2051 + n = GENERIC (s, d, G_SHIFT, GET_COMP (Fa, G_SHIFT), GET_COMP (Fb, G_SHIFT), t, u, v); 1.2052 + o = GENERIC (s, d, R_SHIFT, GET_COMP (Fa, R_SHIFT), GET_COMP (Fb, R_SHIFT), t, u, v); 1.2053 + p = GENERIC (s, d, A_SHIFT, GET_COMP (Fa, A_SHIFT), GET_COMP (Fb, A_SHIFT), t, u, v); 1.2054 + 1.2055 + s = m | n | o | p; 1.2056 + 1.2057 + *(dest + i) = s; 1.2058 + } 1.2059 +} 1.2060 + 1.2061 +static void 1.2062 +combine_disjoint_over_ca (pixman_implementation_t *imp, 1.2063 + pixman_op_t op, 1.2064 + comp4_t * dest, 1.2065 + const comp4_t * src, 1.2066 + const comp4_t * mask, 1.2067 + int width) 1.2068 +{ 1.2069 + combine_disjoint_general_ca (dest, src, mask, width, COMBINE_A_OVER); 1.2070 +} 1.2071 + 1.2072 +static void 1.2073 +combine_disjoint_in_ca (pixman_implementation_t *imp, 1.2074 + pixman_op_t op, 1.2075 + comp4_t * dest, 1.2076 + const comp4_t * src, 1.2077 + const comp4_t * mask, 1.2078 + int width) 1.2079 +{ 1.2080 + combine_disjoint_general_ca (dest, src, mask, width, COMBINE_A_IN); 1.2081 +} 1.2082 + 1.2083 +static void 1.2084 +combine_disjoint_in_reverse_ca (pixman_implementation_t *imp, 1.2085 + pixman_op_t op, 1.2086 + comp4_t * dest, 1.2087 + const comp4_t * src, 1.2088 + const comp4_t * mask, 1.2089 + int width) 1.2090 +{ 1.2091 + combine_disjoint_general_ca (dest, src, mask, width, COMBINE_B_IN); 1.2092 +} 1.2093 + 1.2094 +static void 1.2095 +combine_disjoint_out_ca (pixman_implementation_t *imp, 1.2096 + pixman_op_t op, 1.2097 + comp4_t * dest, 1.2098 + const comp4_t * src, 1.2099 + const comp4_t * mask, 1.2100 + int width) 1.2101 +{ 1.2102 + combine_disjoint_general_ca (dest, src, mask, width, COMBINE_A_OUT); 1.2103 +} 1.2104 + 1.2105 +static void 1.2106 +combine_disjoint_out_reverse_ca (pixman_implementation_t *imp, 1.2107 + pixman_op_t op, 1.2108 + comp4_t * dest, 1.2109 + const comp4_t * src, 1.2110 + const comp4_t * mask, 1.2111 + int width) 1.2112 +{ 1.2113 + combine_disjoint_general_ca (dest, src, mask, width, COMBINE_B_OUT); 1.2114 +} 1.2115 + 1.2116 +static void 1.2117 +combine_disjoint_atop_ca (pixman_implementation_t *imp, 1.2118 + pixman_op_t op, 1.2119 + comp4_t * dest, 1.2120 + const comp4_t * src, 1.2121 + const comp4_t * mask, 1.2122 + int width) 1.2123 +{ 1.2124 + combine_disjoint_general_ca (dest, src, mask, width, COMBINE_A_ATOP); 1.2125 +} 1.2126 + 1.2127 +static void 1.2128 +combine_disjoint_atop_reverse_ca (pixman_implementation_t *imp, 1.2129 + pixman_op_t op, 1.2130 + comp4_t * dest, 1.2131 + const comp4_t * src, 1.2132 + const comp4_t * mask, 1.2133 + int width) 1.2134 +{ 1.2135 + combine_disjoint_general_ca (dest, src, mask, width, COMBINE_B_ATOP); 1.2136 +} 1.2137 + 1.2138 +static void 1.2139 +combine_disjoint_xor_ca (pixman_implementation_t *imp, 1.2140 + pixman_op_t op, 1.2141 + comp4_t * dest, 1.2142 + const comp4_t * src, 1.2143 + const comp4_t * mask, 1.2144 + int width) 1.2145 +{ 1.2146 + combine_disjoint_general_ca (dest, src, mask, width, COMBINE_XOR); 1.2147 +} 1.2148 + 1.2149 +static void 1.2150 +combine_conjoint_general_ca (comp4_t * dest, 1.2151 + const comp4_t *src, 1.2152 + const comp4_t *mask, 1.2153 + int width, 1.2154 + comp1_t combine) 1.2155 +{ 1.2156 + int i; 1.2157 + 1.2158 + for (i = 0; i < width; ++i) 1.2159 + { 1.2160 + comp4_t s, d; 1.2161 + comp4_t m, n, o, p; 1.2162 + comp4_t Fa, Fb; 1.2163 + comp2_t t, u, v; 1.2164 + comp4_t sa; 1.2165 + comp1_t da; 1.2166 + 1.2167 + s = *(src + i); 1.2168 + m = *(mask + i); 1.2169 + d = *(dest + i); 1.2170 + da = d >> A_SHIFT; 1.2171 + 1.2172 + combine_mask_ca (&s, &m); 1.2173 + 1.2174 + sa = m; 1.2175 + 1.2176 + switch (combine & COMBINE_A) 1.2177 + { 1.2178 + default: 1.2179 + Fa = 0; 1.2180 + break; 1.2181 + 1.2182 + case COMBINE_A_OUT: 1.2183 + m = (comp4_t)combine_conjoint_out_part ((comp1_t) (sa >> 0), da); 1.2184 + n = (comp4_t)combine_conjoint_out_part ((comp1_t) (sa >> G_SHIFT), da) << G_SHIFT; 1.2185 + o = (comp4_t)combine_conjoint_out_part ((comp1_t) (sa >> R_SHIFT), da) << R_SHIFT; 1.2186 + p = (comp4_t)combine_conjoint_out_part ((comp1_t) (sa >> A_SHIFT), da) << A_SHIFT; 1.2187 + Fa = m | n | o | p; 1.2188 + break; 1.2189 + 1.2190 + case COMBINE_A_IN: 1.2191 + m = (comp4_t)combine_conjoint_in_part ((comp1_t) (sa >> 0), da); 1.2192 + n = (comp4_t)combine_conjoint_in_part ((comp1_t) (sa >> G_SHIFT), da) << G_SHIFT; 1.2193 + o = (comp4_t)combine_conjoint_in_part ((comp1_t) (sa >> R_SHIFT), da) << R_SHIFT; 1.2194 + p = (comp4_t)combine_conjoint_in_part ((comp1_t) (sa >> A_SHIFT), da) << A_SHIFT; 1.2195 + Fa = m | n | o | p; 1.2196 + break; 1.2197 + 1.2198 + case COMBINE_A: 1.2199 + Fa = ~0; 1.2200 + break; 1.2201 + } 1.2202 + 1.2203 + switch (combine & COMBINE_B) 1.2204 + { 1.2205 + default: 1.2206 + Fb = 0; 1.2207 + break; 1.2208 + 1.2209 + case COMBINE_B_OUT: 1.2210 + m = (comp4_t)combine_conjoint_out_part (da, (comp1_t) (sa >> 0)); 1.2211 + n = (comp4_t)combine_conjoint_out_part (da, (comp1_t) (sa >> G_SHIFT)) << G_SHIFT; 1.2212 + o = (comp4_t)combine_conjoint_out_part (da, (comp1_t) (sa >> R_SHIFT)) << R_SHIFT; 1.2213 + p = (comp4_t)combine_conjoint_out_part (da, (comp1_t) (sa >> A_SHIFT)) << A_SHIFT; 1.2214 + Fb = m | n | o | p; 1.2215 + break; 1.2216 + 1.2217 + case COMBINE_B_IN: 1.2218 + m = (comp4_t)combine_conjoint_in_part (da, (comp1_t) (sa >> 0)); 1.2219 + n = (comp4_t)combine_conjoint_in_part (da, (comp1_t) (sa >> G_SHIFT)) << G_SHIFT; 1.2220 + o = (comp4_t)combine_conjoint_in_part (da, (comp1_t) (sa >> R_SHIFT)) << R_SHIFT; 1.2221 + p = (comp4_t)combine_conjoint_in_part (da, (comp1_t) (sa >> A_SHIFT)) << A_SHIFT; 1.2222 + Fb = m | n | o | p; 1.2223 + break; 1.2224 + 1.2225 + case COMBINE_B: 1.2226 + Fb = ~0; 1.2227 + break; 1.2228 + } 1.2229 + m = GENERIC (s, d, 0, GET_COMP (Fa, 0), GET_COMP (Fb, 0), t, u, v); 1.2230 + n = GENERIC (s, d, G_SHIFT, GET_COMP (Fa, G_SHIFT), GET_COMP (Fb, G_SHIFT), t, u, v); 1.2231 + o = GENERIC (s, d, R_SHIFT, GET_COMP (Fa, R_SHIFT), GET_COMP (Fb, R_SHIFT), t, u, v); 1.2232 + p = GENERIC (s, d, A_SHIFT, GET_COMP (Fa, A_SHIFT), GET_COMP (Fb, A_SHIFT), t, u, v); 1.2233 + 1.2234 + s = m | n | o | p; 1.2235 + 1.2236 + *(dest + i) = s; 1.2237 + } 1.2238 +} 1.2239 + 1.2240 +static void 1.2241 +combine_conjoint_over_ca (pixman_implementation_t *imp, 1.2242 + pixman_op_t op, 1.2243 + comp4_t * dest, 1.2244 + const comp4_t * src, 1.2245 + const comp4_t * mask, 1.2246 + int width) 1.2247 +{ 1.2248 + combine_conjoint_general_ca (dest, src, mask, width, COMBINE_A_OVER); 1.2249 +} 1.2250 + 1.2251 +static void 1.2252 +combine_conjoint_over_reverse_ca (pixman_implementation_t *imp, 1.2253 + pixman_op_t op, 1.2254 + comp4_t * dest, 1.2255 + const comp4_t * src, 1.2256 + const comp4_t * mask, 1.2257 + int width) 1.2258 +{ 1.2259 + combine_conjoint_general_ca (dest, src, mask, width, COMBINE_B_OVER); 1.2260 +} 1.2261 + 1.2262 +static void 1.2263 +combine_conjoint_in_ca (pixman_implementation_t *imp, 1.2264 + pixman_op_t op, 1.2265 + comp4_t * dest, 1.2266 + const comp4_t * src, 1.2267 + const comp4_t * mask, 1.2268 + int width) 1.2269 +{ 1.2270 + combine_conjoint_general_ca (dest, src, mask, width, COMBINE_A_IN); 1.2271 +} 1.2272 + 1.2273 +static void 1.2274 +combine_conjoint_in_reverse_ca (pixman_implementation_t *imp, 1.2275 + pixman_op_t op, 1.2276 + comp4_t * dest, 1.2277 + const comp4_t * src, 1.2278 + const comp4_t * mask, 1.2279 + int width) 1.2280 +{ 1.2281 + combine_conjoint_general_ca (dest, src, mask, width, COMBINE_B_IN); 1.2282 +} 1.2283 + 1.2284 +static void 1.2285 +combine_conjoint_out_ca (pixman_implementation_t *imp, 1.2286 + pixman_op_t op, 1.2287 + comp4_t * dest, 1.2288 + const comp4_t * src, 1.2289 + const comp4_t * mask, 1.2290 + int width) 1.2291 +{ 1.2292 + combine_conjoint_general_ca (dest, src, mask, width, COMBINE_A_OUT); 1.2293 +} 1.2294 + 1.2295 +static void 1.2296 +combine_conjoint_out_reverse_ca (pixman_implementation_t *imp, 1.2297 + pixman_op_t op, 1.2298 + comp4_t * dest, 1.2299 + const comp4_t * src, 1.2300 + const comp4_t * mask, 1.2301 + int width) 1.2302 +{ 1.2303 + combine_conjoint_general_ca (dest, src, mask, width, COMBINE_B_OUT); 1.2304 +} 1.2305 + 1.2306 +static void 1.2307 +combine_conjoint_atop_ca (pixman_implementation_t *imp, 1.2308 + pixman_op_t op, 1.2309 + comp4_t * dest, 1.2310 + const comp4_t * src, 1.2311 + const comp4_t * mask, 1.2312 + int width) 1.2313 +{ 1.2314 + combine_conjoint_general_ca (dest, src, mask, width, COMBINE_A_ATOP); 1.2315 +} 1.2316 + 1.2317 +static void 1.2318 +combine_conjoint_atop_reverse_ca (pixman_implementation_t *imp, 1.2319 + pixman_op_t op, 1.2320 + comp4_t * dest, 1.2321 + const comp4_t * src, 1.2322 + const comp4_t * mask, 1.2323 + int width) 1.2324 +{ 1.2325 + combine_conjoint_general_ca (dest, src, mask, width, COMBINE_B_ATOP); 1.2326 +} 1.2327 + 1.2328 +static void 1.2329 +combine_conjoint_xor_ca (pixman_implementation_t *imp, 1.2330 + pixman_op_t op, 1.2331 + comp4_t * dest, 1.2332 + const comp4_t * src, 1.2333 + const comp4_t * mask, 1.2334 + int width) 1.2335 +{ 1.2336 + combine_conjoint_general_ca (dest, src, mask, width, COMBINE_XOR); 1.2337 +} 1.2338 + 1.2339 +void 1.2340 +_pixman_setup_combiner_functions_width (pixman_implementation_t *imp) 1.2341 +{ 1.2342 + /* Unified alpha */ 1.2343 + imp->combine_width[PIXMAN_OP_CLEAR] = combine_clear; 1.2344 + imp->combine_width[PIXMAN_OP_SRC] = combine_src_u; 1.2345 + imp->combine_width[PIXMAN_OP_DST] = combine_dst; 1.2346 + imp->combine_width[PIXMAN_OP_OVER] = combine_over_u; 1.2347 + imp->combine_width[PIXMAN_OP_OVER_REVERSE] = combine_over_reverse_u; 1.2348 + imp->combine_width[PIXMAN_OP_IN] = combine_in_u; 1.2349 + imp->combine_width[PIXMAN_OP_IN_REVERSE] = combine_in_reverse_u; 1.2350 + imp->combine_width[PIXMAN_OP_OUT] = combine_out_u; 1.2351 + imp->combine_width[PIXMAN_OP_OUT_REVERSE] = combine_out_reverse_u; 1.2352 + imp->combine_width[PIXMAN_OP_ATOP] = combine_atop_u; 1.2353 + imp->combine_width[PIXMAN_OP_ATOP_REVERSE] = combine_atop_reverse_u; 1.2354 + imp->combine_width[PIXMAN_OP_XOR] = combine_xor_u; 1.2355 + imp->combine_width[PIXMAN_OP_ADD] = combine_add_u; 1.2356 + imp->combine_width[PIXMAN_OP_SATURATE] = combine_saturate_u; 1.2357 + 1.2358 + /* Disjoint, unified */ 1.2359 + imp->combine_width[PIXMAN_OP_DISJOINT_CLEAR] = combine_clear; 1.2360 + imp->combine_width[PIXMAN_OP_DISJOINT_SRC] = combine_src_u; 1.2361 + imp->combine_width[PIXMAN_OP_DISJOINT_DST] = combine_dst; 1.2362 + imp->combine_width[PIXMAN_OP_DISJOINT_OVER] = combine_disjoint_over_u; 1.2363 + imp->combine_width[PIXMAN_OP_DISJOINT_OVER_REVERSE] = combine_saturate_u; 1.2364 + imp->combine_width[PIXMAN_OP_DISJOINT_IN] = combine_disjoint_in_u; 1.2365 + imp->combine_width[PIXMAN_OP_DISJOINT_IN_REVERSE] = combine_disjoint_in_reverse_u; 1.2366 + imp->combine_width[PIXMAN_OP_DISJOINT_OUT] = combine_disjoint_out_u; 1.2367 + imp->combine_width[PIXMAN_OP_DISJOINT_OUT_REVERSE] = combine_disjoint_out_reverse_u; 1.2368 + imp->combine_width[PIXMAN_OP_DISJOINT_ATOP] = combine_disjoint_atop_u; 1.2369 + imp->combine_width[PIXMAN_OP_DISJOINT_ATOP_REVERSE] = combine_disjoint_atop_reverse_u; 1.2370 + imp->combine_width[PIXMAN_OP_DISJOINT_XOR] = combine_disjoint_xor_u; 1.2371 + 1.2372 + /* Conjoint, unified */ 1.2373 + imp->combine_width[PIXMAN_OP_CONJOINT_CLEAR] = combine_clear; 1.2374 + imp->combine_width[PIXMAN_OP_CONJOINT_SRC] = combine_src_u; 1.2375 + imp->combine_width[PIXMAN_OP_CONJOINT_DST] = combine_dst; 1.2376 + imp->combine_width[PIXMAN_OP_CONJOINT_OVER] = combine_conjoint_over_u; 1.2377 + imp->combine_width[PIXMAN_OP_CONJOINT_OVER_REVERSE] = combine_conjoint_over_reverse_u; 1.2378 + imp->combine_width[PIXMAN_OP_CONJOINT_IN] = combine_conjoint_in_u; 1.2379 + imp->combine_width[PIXMAN_OP_CONJOINT_IN_REVERSE] = combine_conjoint_in_reverse_u; 1.2380 + imp->combine_width[PIXMAN_OP_CONJOINT_OUT] = combine_conjoint_out_u; 1.2381 + imp->combine_width[PIXMAN_OP_CONJOINT_OUT_REVERSE] = combine_conjoint_out_reverse_u; 1.2382 + imp->combine_width[PIXMAN_OP_CONJOINT_ATOP] = combine_conjoint_atop_u; 1.2383 + imp->combine_width[PIXMAN_OP_CONJOINT_ATOP_REVERSE] = combine_conjoint_atop_reverse_u; 1.2384 + imp->combine_width[PIXMAN_OP_CONJOINT_XOR] = combine_conjoint_xor_u; 1.2385 + 1.2386 + imp->combine_width[PIXMAN_OP_MULTIPLY] = combine_multiply_u; 1.2387 + imp->combine_width[PIXMAN_OP_SCREEN] = combine_screen_u; 1.2388 + imp->combine_width[PIXMAN_OP_OVERLAY] = combine_overlay_u; 1.2389 + imp->combine_width[PIXMAN_OP_DARKEN] = combine_darken_u; 1.2390 + imp->combine_width[PIXMAN_OP_LIGHTEN] = combine_lighten_u; 1.2391 + imp->combine_width[PIXMAN_OP_COLOR_DODGE] = combine_color_dodge_u; 1.2392 + imp->combine_width[PIXMAN_OP_COLOR_BURN] = combine_color_burn_u; 1.2393 + imp->combine_width[PIXMAN_OP_HARD_LIGHT] = combine_hard_light_u; 1.2394 + imp->combine_width[PIXMAN_OP_SOFT_LIGHT] = combine_soft_light_u; 1.2395 + imp->combine_width[PIXMAN_OP_DIFFERENCE] = combine_difference_u; 1.2396 + imp->combine_width[PIXMAN_OP_EXCLUSION] = combine_exclusion_u; 1.2397 + imp->combine_width[PIXMAN_OP_HSL_HUE] = combine_hsl_hue_u; 1.2398 + imp->combine_width[PIXMAN_OP_HSL_SATURATION] = combine_hsl_saturation_u; 1.2399 + imp->combine_width[PIXMAN_OP_HSL_COLOR] = combine_hsl_color_u; 1.2400 + imp->combine_width[PIXMAN_OP_HSL_LUMINOSITY] = combine_hsl_luminosity_u; 1.2401 + 1.2402 + /* Component alpha combiners */ 1.2403 + imp->combine_width_ca[PIXMAN_OP_CLEAR] = combine_clear_ca; 1.2404 + imp->combine_width_ca[PIXMAN_OP_SRC] = combine_src_ca; 1.2405 + /* dest */ 1.2406 + imp->combine_width_ca[PIXMAN_OP_OVER] = combine_over_ca; 1.2407 + imp->combine_width_ca[PIXMAN_OP_OVER_REVERSE] = combine_over_reverse_ca; 1.2408 + imp->combine_width_ca[PIXMAN_OP_IN] = combine_in_ca; 1.2409 + imp->combine_width_ca[PIXMAN_OP_IN_REVERSE] = combine_in_reverse_ca; 1.2410 + imp->combine_width_ca[PIXMAN_OP_OUT] = combine_out_ca; 1.2411 + imp->combine_width_ca[PIXMAN_OP_OUT_REVERSE] = combine_out_reverse_ca; 1.2412 + imp->combine_width_ca[PIXMAN_OP_ATOP] = combine_atop_ca; 1.2413 + imp->combine_width_ca[PIXMAN_OP_ATOP_REVERSE] = combine_atop_reverse_ca; 1.2414 + imp->combine_width_ca[PIXMAN_OP_XOR] = combine_xor_ca; 1.2415 + imp->combine_width_ca[PIXMAN_OP_ADD] = combine_add_ca; 1.2416 + imp->combine_width_ca[PIXMAN_OP_SATURATE] = combine_saturate_ca; 1.2417 + 1.2418 + /* Disjoint CA */ 1.2419 + imp->combine_width_ca[PIXMAN_OP_DISJOINT_CLEAR] = combine_clear_ca; 1.2420 + imp->combine_width_ca[PIXMAN_OP_DISJOINT_SRC] = combine_src_ca; 1.2421 + imp->combine_width_ca[PIXMAN_OP_DISJOINT_DST] = combine_dst; 1.2422 + imp->combine_width_ca[PIXMAN_OP_DISJOINT_OVER] = combine_disjoint_over_ca; 1.2423 + imp->combine_width_ca[PIXMAN_OP_DISJOINT_OVER_REVERSE] = combine_saturate_ca; 1.2424 + imp->combine_width_ca[PIXMAN_OP_DISJOINT_IN] = combine_disjoint_in_ca; 1.2425 + imp->combine_width_ca[PIXMAN_OP_DISJOINT_IN_REVERSE] = combine_disjoint_in_reverse_ca; 1.2426 + imp->combine_width_ca[PIXMAN_OP_DISJOINT_OUT] = combine_disjoint_out_ca; 1.2427 + imp->combine_width_ca[PIXMAN_OP_DISJOINT_OUT_REVERSE] = combine_disjoint_out_reverse_ca; 1.2428 + imp->combine_width_ca[PIXMAN_OP_DISJOINT_ATOP] = combine_disjoint_atop_ca; 1.2429 + imp->combine_width_ca[PIXMAN_OP_DISJOINT_ATOP_REVERSE] = combine_disjoint_atop_reverse_ca; 1.2430 + imp->combine_width_ca[PIXMAN_OP_DISJOINT_XOR] = combine_disjoint_xor_ca; 1.2431 + 1.2432 + /* Conjoint CA */ 1.2433 + imp->combine_width_ca[PIXMAN_OP_CONJOINT_CLEAR] = combine_clear_ca; 1.2434 + imp->combine_width_ca[PIXMAN_OP_CONJOINT_SRC] = combine_src_ca; 1.2435 + imp->combine_width_ca[PIXMAN_OP_CONJOINT_DST] = combine_dst; 1.2436 + imp->combine_width_ca[PIXMAN_OP_CONJOINT_OVER] = combine_conjoint_over_ca; 1.2437 + imp->combine_width_ca[PIXMAN_OP_CONJOINT_OVER_REVERSE] = combine_conjoint_over_reverse_ca; 1.2438 + imp->combine_width_ca[PIXMAN_OP_CONJOINT_IN] = combine_conjoint_in_ca; 1.2439 + imp->combine_width_ca[PIXMAN_OP_CONJOINT_IN_REVERSE] = combine_conjoint_in_reverse_ca; 1.2440 + imp->combine_width_ca[PIXMAN_OP_CONJOINT_OUT] = combine_conjoint_out_ca; 1.2441 + imp->combine_width_ca[PIXMAN_OP_CONJOINT_OUT_REVERSE] = combine_conjoint_out_reverse_ca; 1.2442 + imp->combine_width_ca[PIXMAN_OP_CONJOINT_ATOP] = combine_conjoint_atop_ca; 1.2443 + imp->combine_width_ca[PIXMAN_OP_CONJOINT_ATOP_REVERSE] = combine_conjoint_atop_reverse_ca; 1.2444 + imp->combine_width_ca[PIXMAN_OP_CONJOINT_XOR] = combine_conjoint_xor_ca; 1.2445 + 1.2446 + imp->combine_width_ca[PIXMAN_OP_MULTIPLY] = combine_multiply_ca; 1.2447 + imp->combine_width_ca[PIXMAN_OP_SCREEN] = combine_screen_ca; 1.2448 + imp->combine_width_ca[PIXMAN_OP_OVERLAY] = combine_overlay_ca; 1.2449 + imp->combine_width_ca[PIXMAN_OP_DARKEN] = combine_darken_ca; 1.2450 + imp->combine_width_ca[PIXMAN_OP_LIGHTEN] = combine_lighten_ca; 1.2451 + imp->combine_width_ca[PIXMAN_OP_COLOR_DODGE] = combine_color_dodge_ca; 1.2452 + imp->combine_width_ca[PIXMAN_OP_COLOR_BURN] = combine_color_burn_ca; 1.2453 + imp->combine_width_ca[PIXMAN_OP_HARD_LIGHT] = combine_hard_light_ca; 1.2454 + imp->combine_width_ca[PIXMAN_OP_SOFT_LIGHT] = combine_soft_light_ca; 1.2455 + imp->combine_width_ca[PIXMAN_OP_DIFFERENCE] = combine_difference_ca; 1.2456 + imp->combine_width_ca[PIXMAN_OP_EXCLUSION] = combine_exclusion_ca; 1.2457 + 1.2458 + /* It is not clear that these make sense, so make them noops for now */ 1.2459 + imp->combine_width_ca[PIXMAN_OP_HSL_HUE] = combine_dst; 1.2460 + imp->combine_width_ca[PIXMAN_OP_HSL_SATURATION] = combine_dst; 1.2461 + imp->combine_width_ca[PIXMAN_OP_HSL_COLOR] = combine_dst; 1.2462 + imp->combine_width_ca[PIXMAN_OP_HSL_LUMINOSITY] = combine_dst; 1.2463 +} 1.2464 +