1 /* -*- Mode: c; c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t; -*- */
3 * Copyright © 2000 SuSE, Inc.
4 * Copyright © 2007 Red Hat, Inc.
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of SuSE not be used in advertising or
11 * publicity pertaining to distribution of the software without specific,
12 * written prior permission. SuSE makes no representations about the
13 * suitability of this software for any purpose. It is provided "as is"
14 * without express or implied warranty.
16 * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
18 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 * Author: Keith Packard, SuSE, Inc.
31 #include "pixman-private.h"
32 #include "pixman-combine32.h"
33 #include "pixman-fast-path.h"
35 static force_inline uint32_t
38 if (((unsigned long)a) & 1)
40 #ifdef WORDS_BIGENDIAN
41 return (*a << 16) | (*(uint16_t *)(a + 1));
43 return *a | (*(uint16_t *)(a + 1) << 8);
48 #ifdef WORDS_BIGENDIAN
49 return (*(uint16_t *)a << 8) | *(a + 2);
51 return *(uint16_t *)a | (*(a + 2) << 16);
56 static force_inline void
60 if (((unsigned long)a) & 1)
62 #ifdef WORDS_BIGENDIAN
63 *a = (uint8_t) (v >> 16);
64 *(uint16_t *)(a + 1) = (uint16_t) (v);
67 *(uint16_t *)(a + 1) = (uint16_t) (v >> 8);
72 #ifdef WORDS_BIGENDIAN
73 *(uint16_t *)a = (uint16_t)(v >> 8);
74 *(a + 2) = (uint8_t)v;
76 *(uint16_t *)a = (uint16_t)v;
77 *(a + 2) = (uint8_t)(v >> 16);
82 static force_inline uint32_t
86 uint32_t a = ~src >> 24;
88 UN8x4_MUL_UN8_ADD_UN8x4 (dest, a, src);
110 fast_composite_over_x888_8_8888 (pixman_implementation_t *imp,
112 pixman_image_t * src_image,
113 pixman_image_t * mask_image,
114 pixman_image_t * dst_image,
124 uint32_t *src, *src_line;
125 uint32_t *dst, *dst_line;
126 uint8_t *mask, *mask_line;
127 int src_stride, mask_stride, dst_stride;
132 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1);
133 PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint8_t, mask_stride, mask_line, 1);
134 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1);
139 src_line += src_stride;
141 dst_line += dst_stride;
143 mask_line += mask_stride;
151 s = *src | 0xff000000;
160 *dst = over (d, *dst);
170 fast_composite_in_n_8_8 (pixman_implementation_t *imp,
172 pixman_image_t * src_image,
173 pixman_image_t * mask_image,
174 pixman_image_t * dest_image,
185 uint8_t *dst_line, *dst;
186 uint8_t *mask_line, *mask, m;
187 int dst_stride, mask_stride;
191 src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format);
195 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint8_t, dst_stride, dst_line, 1);
196 PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint8_t, mask_stride, mask_line, 1);
203 dst_line += dst_stride;
205 mask_line += mask_stride;
215 *dst = MUL_UN8 (m, *dst, t);
226 dst_line += dst_stride;
228 mask_line += mask_stride;
234 m = MUL_UN8 (m, srca, t);
239 *dst = MUL_UN8 (m, *dst, t);
248 fast_composite_in_8_8 (pixman_implementation_t *imp,
250 pixman_image_t * src_image,
251 pixman_image_t * mask_image,
252 pixman_image_t * dest_image,
262 uint8_t *dst_line, *dst;
263 uint8_t *src_line, *src;
264 int dst_stride, src_stride;
269 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint8_t, src_stride, src_line, 1);
270 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint8_t, dst_stride, dst_line, 1);
275 dst_line += dst_stride;
277 src_line += src_stride;
287 *dst = MUL_UN8 (s, *dst, t);
295 fast_composite_over_n_8_8888 (pixman_implementation_t *imp,
297 pixman_image_t * src_image,
298 pixman_image_t * mask_image,
299 pixman_image_t * dst_image,
310 uint32_t *dst_line, *dst, d;
311 uint8_t *mask_line, *mask, m;
312 int dst_stride, mask_stride;
315 src = _pixman_image_get_solid (imp, src_image, dst_image->bits.format);
321 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1);
322 PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint8_t, mask_stride, mask_line, 1);
327 dst_line += dst_stride;
329 mask_line += mask_stride;
340 *dst = over (src, *dst);
345 *dst = over (d, *dst);
353 fast_composite_add_n_8888_8888_ca (pixman_implementation_t *imp,
355 pixman_image_t * src_image,
356 pixman_image_t * mask_image,
357 pixman_image_t * dst_image,
368 uint32_t *dst_line, *dst, d;
369 uint32_t *mask_line, *mask, ma;
370 int dst_stride, mask_stride;
373 src = _pixman_image_get_solid (imp, src_image, dst_image->bits.format);
378 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1);
379 PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint32_t, mask_stride, mask_line, 1);
384 dst_line += dst_stride;
386 mask_line += mask_stride;
398 UN8x4_MUL_UN8x4_ADD_UN8x4 (s, ma, d);
409 fast_composite_over_n_8888_8888_ca (pixman_implementation_t *imp,
411 pixman_image_t * src_image,
412 pixman_image_t * mask_image,
413 pixman_image_t * dst_image,
423 uint32_t src, srca, s;
424 uint32_t *dst_line, *dst, d;
425 uint32_t *mask_line, *mask, ma;
426 int dst_stride, mask_stride;
429 src = _pixman_image_get_solid (imp, src_image, dst_image->bits.format);
435 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1);
436 PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint32_t, mask_stride, mask_line, 1);
441 dst_line += dst_stride;
443 mask_line += mask_stride;
449 if (ma == 0xffffffff)
454 *dst = over (src, *dst);
461 UN8x4_MUL_UN8x4 (s, ma);
462 UN8x4_MUL_UN8 (ma, srca);
464 UN8x4_MUL_UN8x4_ADD_UN8x4 (d, ma, s);
475 fast_composite_over_n_8_0888 (pixman_implementation_t *imp,
477 pixman_image_t * src_image,
478 pixman_image_t * mask_image,
479 pixman_image_t * dst_image,
490 uint8_t *dst_line, *dst;
492 uint8_t *mask_line, *mask, m;
493 int dst_stride, mask_stride;
496 src = _pixman_image_get_solid (imp, src_image, dst_image->bits.format);
502 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, uint8_t, dst_stride, dst_line, 3);
503 PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint8_t, mask_stride, mask_line, 1);
508 dst_line += dst_stride;
510 mask_line += mask_stride;
531 d = over (in (src, m), fetch_24 (dst));
540 fast_composite_over_n_8_0565 (pixman_implementation_t *imp,
542 pixman_image_t * src_image,
543 pixman_image_t * mask_image,
544 pixman_image_t * dst_image,
555 uint16_t *dst_line, *dst;
557 uint8_t *mask_line, *mask, m;
558 int dst_stride, mask_stride;
561 src = _pixman_image_get_solid (imp, src_image, dst_image->bits.format);
567 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, uint16_t, dst_stride, dst_line, 1);
568 PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint8_t, mask_stride, mask_line, 1);
573 dst_line += dst_stride;
575 mask_line += mask_stride;
590 d = over (src, CONVERT_0565_TO_0888 (d));
592 *dst = CONVERT_8888_TO_0565 (d);
597 d = over (in (src, m), CONVERT_0565_TO_0888 (d));
598 *dst = CONVERT_8888_TO_0565 (d);
606 fast_composite_over_n_8888_0565_ca (pixman_implementation_t *imp,
608 pixman_image_t * src_image,
609 pixman_image_t * mask_image,
610 pixman_image_t * dst_image,
620 uint32_t src, srca, s;
622 uint16_t *dst_line, *dst;
624 uint32_t *mask_line, *mask, ma;
625 int dst_stride, mask_stride;
628 src = _pixman_image_get_solid (imp, src_image, dst_image->bits.format);
634 src16 = CONVERT_8888_TO_0565 (src);
636 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, uint16_t, dst_stride, dst_line, 1);
637 PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint32_t, mask_stride, mask_line, 1);
642 dst_line += dst_stride;
644 mask_line += mask_stride;
650 if (ma == 0xffffffff)
659 d = over (src, CONVERT_0565_TO_0888 (d));
660 *dst = CONVERT_8888_TO_0565 (d);
666 d = CONVERT_0565_TO_0888 (d);
670 UN8x4_MUL_UN8x4 (s, ma);
671 UN8x4_MUL_UN8 (ma, srca);
673 UN8x4_MUL_UN8x4_ADD_UN8x4 (d, ma, s);
675 *dst = CONVERT_8888_TO_0565 (d);
683 fast_composite_over_8888_8888 (pixman_implementation_t *imp,
685 pixman_image_t * src_image,
686 pixman_image_t * mask_image,
687 pixman_image_t * dst_image,
697 uint32_t *dst_line, *dst;
698 uint32_t *src_line, *src, s;
699 int dst_stride, src_stride;
703 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1);
704 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1);
709 dst_line += dst_stride;
711 src_line += src_stride;
721 *dst = over (s, *dst);
728 fast_composite_src_x888_8888 (pixman_implementation_t *imp,
730 pixman_image_t * src_image,
731 pixman_image_t * mask_image,
732 pixman_image_t * dst_image,
742 uint32_t *dst_line, *dst;
743 uint32_t *src_line, *src;
744 int dst_stride, src_stride;
747 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1);
748 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1);
753 dst_line += dst_stride;
755 src_line += src_stride;
759 *dst++ = (*src++) | 0xff000000;
765 fast_composite_over_8888_0888 (pixman_implementation_t *imp,
767 pixman_image_t * src_image,
768 pixman_image_t * mask_image,
769 pixman_image_t * dst_image,
779 uint8_t *dst_line, *dst;
781 uint32_t *src_line, *src, s;
783 int dst_stride, src_stride;
786 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, uint8_t, dst_stride, dst_line, 3);
787 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1);
792 dst_line += dst_stride;
794 src_line += src_stride;
806 d = over (s, fetch_24 (dst));
817 fast_composite_over_8888_0565 (pixman_implementation_t *imp,
819 pixman_image_t * src_image,
820 pixman_image_t * mask_image,
821 pixman_image_t * dst_image,
831 uint16_t *dst_line, *dst;
833 uint32_t *src_line, *src, s;
835 int dst_stride, src_stride;
838 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1);
839 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, uint16_t, dst_stride, dst_line, 1);
844 dst_line += dst_stride;
846 src_line += src_stride;
862 d = over (s, CONVERT_0565_TO_0888 (d));
864 *dst = CONVERT_8888_TO_0565 (d);
872 fast_composite_src_x888_0565 (pixman_implementation_t *imp,
874 pixman_image_t * src_image,
875 pixman_image_t * mask_image,
876 pixman_image_t * dst_image,
886 uint16_t *dst_line, *dst;
887 uint32_t *src_line, *src, s;
888 int dst_stride, src_stride;
891 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1);
892 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, uint16_t, dst_stride, dst_line, 1);
897 dst_line += dst_stride;
899 src_line += src_stride;
905 *dst = CONVERT_8888_TO_0565 (s);
912 fast_composite_add_8_8 (pixman_implementation_t *imp,
914 pixman_image_t * src_image,
915 pixman_image_t * mask_image,
916 pixman_image_t * dst_image,
926 uint8_t *dst_line, *dst;
927 uint8_t *src_line, *src;
928 int dst_stride, src_stride;
933 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint8_t, src_stride, src_line, 1);
934 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, uint8_t, dst_stride, dst_line, 1);
939 dst_line += dst_stride;
941 src_line += src_stride;
953 s = t | (0 - (t >> 8));
963 fast_composite_add_8888_8888 (pixman_implementation_t *imp,
965 pixman_image_t * src_image,
966 pixman_image_t * mask_image,
967 pixman_image_t * dst_image,
977 uint32_t *dst_line, *dst;
978 uint32_t *src_line, *src;
979 int dst_stride, src_stride;
983 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1);
984 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1);
989 dst_line += dst_stride;
991 src_line += src_stride;
1003 UN8x4_ADD_UN8x4 (s, d);
1013 fast_composite_add_n_8_8 (pixman_implementation_t *imp,
1015 pixman_image_t * src_image,
1016 pixman_image_t * mask_image,
1017 pixman_image_t * dst_image,
1027 uint8_t *dst_line, *dst;
1028 uint8_t *mask_line, *mask;
1029 int dst_stride, mask_stride;
1034 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, uint8_t, dst_stride, dst_line, 1);
1035 PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint8_t, mask_stride, mask_line, 1);
1036 src = _pixman_image_get_solid (imp, src_image, dst_image->bits.format);
1042 dst_line += dst_stride;
1044 mask_line += mask_stride;
1057 m = MUL_UN8 (sa, a, tmp);
1058 r = ADD_UN8 (m, d, tmp);
1065 #ifdef WORDS_BIGENDIAN
1066 #define CREATE_BITMASK(n) (0x80000000 >> (n))
1067 #define UPDATE_BITMASK(n) ((n) >> 1)
1069 #define CREATE_BITMASK(n) (1 << (n))
1070 #define UPDATE_BITMASK(n) ((n) << 1)
1073 #define TEST_BIT(p, n) \
1074 (*((p) + ((n) >> 5)) & CREATE_BITMASK ((n) & 31))
1075 #define SET_BIT(p, n) \
1076 do { *((p) + ((n) >> 5)) |= CREATE_BITMASK ((n) & 31); } while (0);
1079 fast_composite_add_1000_1000 (pixman_implementation_t *imp,
1081 pixman_image_t * src_image,
1082 pixman_image_t * mask_image,
1083 pixman_image_t * dst_image,
1093 uint32_t *dst_line, *dst;
1094 uint32_t *src_line, *src;
1095 int dst_stride, src_stride;
1098 PIXMAN_IMAGE_GET_LINE (src_image, 0, src_y, uint32_t,
1099 src_stride, src_line, 1);
1100 PIXMAN_IMAGE_GET_LINE (dst_image, 0, dest_y, uint32_t,
1101 dst_stride, dst_line, 1);
1106 dst_line += dst_stride;
1108 src_line += src_stride;
1114 * TODO: improve performance by processing uint32_t data instead
1115 * of individual bits
1117 if (TEST_BIT (src, src_x + w))
1118 SET_BIT (dst, dest_x + w);
1124 fast_composite_over_n_1_8888 (pixman_implementation_t *imp,
1126 pixman_image_t * src_image,
1127 pixman_image_t * mask_image,
1128 pixman_image_t * dst_image,
1139 uint32_t *dst, *dst_line;
1140 uint32_t *mask, *mask_line;
1141 int mask_stride, dst_stride;
1142 uint32_t bitcache, bitmask;
1148 src = _pixman_image_get_solid (imp, src_image, dst_image->bits.format);
1153 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, uint32_t,
1154 dst_stride, dst_line, 1);
1155 PIXMAN_IMAGE_GET_LINE (mask_image, 0, mask_y, uint32_t,
1156 mask_stride, mask_line, 1);
1157 mask_line += mask_x >> 5;
1164 dst_line += dst_stride;
1166 mask_line += mask_stride;
1170 bitmask = CREATE_BITMASK (mask_x & 31);
1177 bitmask = CREATE_BITMASK (0);
1179 if (bitcache & bitmask)
1181 bitmask = UPDATE_BITMASK (bitmask);
1191 dst_line += dst_stride;
1193 mask_line += mask_stride;
1197 bitmask = CREATE_BITMASK (mask_x & 31);
1204 bitmask = CREATE_BITMASK (0);
1206 if (bitcache & bitmask)
1207 *dst = over (src, *dst);
1208 bitmask = UPDATE_BITMASK (bitmask);
1216 fast_composite_over_n_1_0565 (pixman_implementation_t *imp,
1218 pixman_image_t * src_image,
1219 pixman_image_t * mask_image,
1220 pixman_image_t * dst_image,
1231 uint16_t *dst, *dst_line;
1232 uint32_t *mask, *mask_line;
1233 int mask_stride, dst_stride;
1234 uint32_t bitcache, bitmask;
1242 src = _pixman_image_get_solid (imp, src_image, dst_image->bits.format);
1247 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, uint16_t,
1248 dst_stride, dst_line, 1);
1249 PIXMAN_IMAGE_GET_LINE (mask_image, 0, mask_y, uint32_t,
1250 mask_stride, mask_line, 1);
1251 mask_line += mask_x >> 5;
1255 src565 = CONVERT_8888_TO_0565 (src);
1259 dst_line += dst_stride;
1261 mask_line += mask_stride;
1265 bitmask = CREATE_BITMASK (mask_x & 31);
1272 bitmask = CREATE_BITMASK (0);
1274 if (bitcache & bitmask)
1276 bitmask = UPDATE_BITMASK (bitmask);
1286 dst_line += dst_stride;
1288 mask_line += mask_stride;
1292 bitmask = CREATE_BITMASK (mask_x & 31);
1299 bitmask = CREATE_BITMASK (0);
1301 if (bitcache & bitmask)
1303 d = over (src, CONVERT_0565_TO_0888 (*dst));
1304 *dst = CONVERT_8888_TO_0565 (d);
1306 bitmask = UPDATE_BITMASK (bitmask);
1318 fast_composite_solid_fill (pixman_implementation_t *imp,
1320 pixman_image_t * src_image,
1321 pixman_image_t * mask_image,
1322 pixman_image_t * dst_image,
1334 src = _pixman_image_get_solid (imp, src_image, dst_image->bits.format);
1336 if (dst_image->bits.format == PIXMAN_a1)
1340 else if (dst_image->bits.format == PIXMAN_a8)
1344 else if (dst_image->bits.format == PIXMAN_r5g6b5 ||
1345 dst_image->bits.format == PIXMAN_b5g6r5)
1347 src = CONVERT_8888_TO_0565 (src);
1350 pixman_fill (dst_image->bits.bits, dst_image->bits.rowstride,
1351 PIXMAN_FORMAT_BPP (dst_image->bits.format),
1358 fast_composite_src_memcpy (pixman_implementation_t *imp,
1360 pixman_image_t * src_image,
1361 pixman_image_t * mask_image,
1362 pixman_image_t * dst_image,
1372 int bpp = PIXMAN_FORMAT_BPP (dst_image->bits.format) / 8;
1373 uint32_t n_bytes = width * bpp;
1374 int dst_stride, src_stride;
1378 src_stride = src_image->bits.rowstride * 4;
1379 dst_stride = dst_image->bits.rowstride * 4;
1381 src = (uint8_t *)src_image->bits.bits + src_y * src_stride + src_x * bpp;
1382 dst = (uint8_t *)dst_image->bits.bits + dest_y * dst_stride + dest_x * bpp;
1386 memcpy (dst, src, n_bytes);
1393 FAST_NEAREST (8888_8888_cover, 8888, 8888, uint32_t, uint32_t, SRC, COVER)
1394 FAST_NEAREST (8888_8888_none, 8888, 8888, uint32_t, uint32_t, SRC, NONE)
1395 FAST_NEAREST (8888_8888_pad, 8888, 8888, uint32_t, uint32_t, SRC, PAD)
1396 FAST_NEAREST (8888_8888_normal, 8888, 8888, uint32_t, uint32_t, SRC, NORMAL)
1397 FAST_NEAREST (8888_8888_cover, 8888, 8888, uint32_t, uint32_t, OVER, COVER)
1398 FAST_NEAREST (8888_8888_none, 8888, 8888, uint32_t, uint32_t, OVER, NONE)
1399 FAST_NEAREST (8888_8888_pad, 8888, 8888, uint32_t, uint32_t, OVER, PAD)
1400 FAST_NEAREST (8888_8888_normal, 8888, 8888, uint32_t, uint32_t, OVER, NORMAL)
1401 FAST_NEAREST (8888_565_cover, 8888, 0565, uint32_t, uint16_t, SRC, COVER)
1402 FAST_NEAREST (8888_565_none, 8888, 0565, uint32_t, uint16_t, SRC, NONE)
1403 FAST_NEAREST (8888_565_pad, 8888, 0565, uint32_t, uint16_t, SRC, PAD)
1404 FAST_NEAREST (8888_565_normal, 8888, 0565, uint32_t, uint16_t, SRC, NORMAL)
1405 FAST_NEAREST (565_565_normal, 0565, 0565, uint16_t, uint16_t, SRC, NORMAL)
1406 FAST_NEAREST (8888_565_cover, 8888, 0565, uint32_t, uint16_t, OVER, COVER)
1407 FAST_NEAREST (8888_565_none, 8888, 0565, uint32_t, uint16_t, OVER, NONE)
1408 FAST_NEAREST (8888_565_pad, 8888, 0565, uint32_t, uint16_t, OVER, PAD)
1409 FAST_NEAREST (8888_565_normal, 8888, 0565, uint32_t, uint16_t, OVER, NORMAL)
1411 /* Use more unrolling for src_0565_0565 because it is typically CPU bound */
1412 static force_inline void
1413 scaled_nearest_scanline_565_565_SRC (uint16_t * dst,
1414 const uint16_t * src,
1417 pixman_fixed_t unit_x,
1418 pixman_fixed_t max_vx,
1419 pixman_bool_t fully_transparent_src)
1421 uint16_t tmp1, tmp2, tmp3, tmp4;
1422 while ((w -= 4) >= 0)
1424 tmp1 = src[pixman_fixed_to_int (vx)];
1426 tmp2 = src[pixman_fixed_to_int (vx)];
1428 tmp3 = src[pixman_fixed_to_int (vx)];
1430 tmp4 = src[pixman_fixed_to_int (vx)];
1439 tmp1 = src[pixman_fixed_to_int (vx)];
1441 tmp2 = src[pixman_fixed_to_int (vx)];
1447 *dst++ = src[pixman_fixed_to_int (vx)];
1450 FAST_NEAREST_MAINLOOP (565_565_cover_SRC,
1451 scaled_nearest_scanline_565_565_SRC,
1452 uint16_t, uint16_t, COVER)
1453 FAST_NEAREST_MAINLOOP (565_565_none_SRC,
1454 scaled_nearest_scanline_565_565_SRC,
1455 uint16_t, uint16_t, NONE)
1456 FAST_NEAREST_MAINLOOP (565_565_pad_SRC,
1457 scaled_nearest_scanline_565_565_SRC,
1458 uint16_t, uint16_t, PAD)
1460 static force_inline uint32_t
1461 fetch_nearest (pixman_repeat_t src_repeat,
1462 pixman_format_code_t format,
1463 uint32_t *src, int x, int src_width)
1465 if (repeat (src_repeat, &x, src_width))
1467 if (format == PIXMAN_x8r8g8b8)
1468 return *(src + x) | 0xff000000;
1478 static force_inline void
1479 combine_over (uint32_t s, uint32_t *dst)
1483 uint8_t ia = 0xff - (s >> 24);
1486 UN8x4_MUL_UN8_ADD_UN8x4 (*dst, ia, s);
1492 static force_inline void
1493 combine_src (uint32_t s, uint32_t *dst)
1499 fast_composite_scaled_nearest (pixman_implementation_t *imp,
1501 pixman_image_t * src_image,
1502 pixman_image_t * mask_image,
1503 pixman_image_t * dst_image,
1515 int dst_stride, src_stride;
1516 int src_width, src_height;
1517 pixman_repeat_t src_repeat;
1518 pixman_fixed_t unit_x, unit_y;
1519 pixman_format_code_t src_format;
1523 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1);
1524 /* pass in 0 instead of src_x and src_y because src_x and src_y need to be
1525 * transformed from destination space to source space
1527 PIXMAN_IMAGE_GET_LINE (src_image, 0, 0, uint32_t, src_stride, src_line, 1);
1529 /* reference point is the center of the pixel */
1530 v.vector[0] = pixman_int_to_fixed (src_x) + pixman_fixed_1 / 2;
1531 v.vector[1] = pixman_int_to_fixed (src_y) + pixman_fixed_1 / 2;
1532 v.vector[2] = pixman_fixed_1;
1534 if (!pixman_transform_point_3d (src_image->common.transform, &v))
1537 unit_x = src_image->common.transform->matrix[0][0];
1538 unit_y = src_image->common.transform->matrix[1][1];
1540 /* Round down to closest integer, ensuring that 0.5 rounds to 0, not 1 */
1541 v.vector[0] -= pixman_fixed_e;
1542 v.vector[1] -= pixman_fixed_e;
1544 src_height = src_image->bits.height;
1545 src_width = src_image->bits.width;
1546 src_repeat = src_image->common.repeat;
1547 src_format = src_image->bits.format;
1552 pixman_fixed_t vx = v.vector[0];
1553 int y = pixman_fixed_to_int (vy);
1554 uint32_t *dst = dst_line;
1556 dst_line += dst_stride;
1558 /* adjust the y location by a unit vector in the y direction
1559 * this is equivalent to transforming y+1 of the destination point to source space */
1562 if (!repeat (src_repeat, &y, src_height))
1564 if (op == PIXMAN_OP_SRC)
1565 memset (dst, 0, sizeof (*dst) * width);
1571 uint32_t *src = src_line + y * src_stride;
1578 x1 = pixman_fixed_to_int (vx);
1581 x2 = pixman_fixed_to_int (vx);
1586 s1 = fetch_nearest (src_repeat, src_format, src, x1, src_width);
1587 s2 = fetch_nearest (src_repeat, src_format, src, x2, src_width);
1589 if (op == PIXMAN_OP_OVER)
1591 combine_over (s1, dst++);
1592 combine_over (s2, dst++);
1596 combine_src (s1, dst++);
1597 combine_src (s2, dst++);
1606 x = pixman_fixed_to_int (vx);
1609 s = fetch_nearest (src_repeat, src_format, src, x, src_width);
1611 if (op == PIXMAN_OP_OVER)
1612 combine_over (s, dst++);
1614 combine_src (s, dst++);
1620 #define CACHE_LINE_SIZE 64
1622 #define FAST_SIMPLE_ROTATE(suffix, pix_type) \
1625 blt_rotated_90_trivial_##suffix (pix_type *dst, \
1627 const pix_type *src, \
1633 for (y = 0; y < h; y++) \
1635 const pix_type *s = src + (h - y - 1); \
1636 pix_type *d = dst + dst_stride * y; \
1637 for (x = 0; x < w; x++) \
1646 blt_rotated_270_trivial_##suffix (pix_type *dst, \
1648 const pix_type *src, \
1654 for (y = 0; y < h; y++) \
1656 const pix_type *s = src + src_stride * (w - 1) + y; \
1657 pix_type *d = dst + dst_stride * y; \
1658 for (x = 0; x < w; x++) \
1667 blt_rotated_90_##suffix (pix_type *dst, \
1669 const pix_type *src, \
1675 int leading_pixels = 0, trailing_pixels = 0; \
1676 const int TILE_SIZE = CACHE_LINE_SIZE / sizeof(pix_type); \
1679 * split processing into handling destination as TILE_SIZExH cache line \
1680 * aligned vertical stripes (optimistically assuming that destination \
1681 * stride is a multiple of cache line, if not - it will be just a bit \
1685 if ((uintptr_t)dst & (CACHE_LINE_SIZE - 1)) \
1687 leading_pixels = TILE_SIZE - (((uintptr_t)dst & \
1688 (CACHE_LINE_SIZE - 1)) / sizeof(pix_type)); \
1689 if (leading_pixels > W) \
1690 leading_pixels = W; \
1692 /* unaligned leading part NxH (where N < TILE_SIZE) */ \
1693 blt_rotated_90_trivial_##suffix ( \
1701 dst += leading_pixels; \
1702 src += leading_pixels * src_stride; \
1703 W -= leading_pixels; \
1706 if ((uintptr_t)(dst + W) & (CACHE_LINE_SIZE - 1)) \
1708 trailing_pixels = (((uintptr_t)(dst + W) & \
1709 (CACHE_LINE_SIZE - 1)) / sizeof(pix_type)); \
1710 if (trailing_pixels > W) \
1711 trailing_pixels = W; \
1712 W -= trailing_pixels; \
1715 for (x = 0; x < W; x += TILE_SIZE) \
1717 /* aligned middle part TILE_SIZExH */ \
1718 blt_rotated_90_trivial_##suffix ( \
1721 src + src_stride * x, \
1727 if (trailing_pixels) \
1729 /* unaligned trailing part NxH (where N < TILE_SIZE) */ \
1730 blt_rotated_90_trivial_##suffix ( \
1733 src + W * src_stride, \
1741 blt_rotated_270_##suffix (pix_type *dst, \
1743 const pix_type *src, \
1749 int leading_pixels = 0, trailing_pixels = 0; \
1750 const int TILE_SIZE = CACHE_LINE_SIZE / sizeof(pix_type); \
1753 * split processing into handling destination as TILE_SIZExH cache line \
1754 * aligned vertical stripes (optimistically assuming that destination \
1755 * stride is a multiple of cache line, if not - it will be just a bit \
1759 if ((uintptr_t)dst & (CACHE_LINE_SIZE - 1)) \
1761 leading_pixels = TILE_SIZE - (((uintptr_t)dst & \
1762 (CACHE_LINE_SIZE - 1)) / sizeof(pix_type)); \
1763 if (leading_pixels > W) \
1764 leading_pixels = W; \
1766 /* unaligned leading part NxH (where N < TILE_SIZE) */ \
1767 blt_rotated_270_trivial_##suffix ( \
1770 src + src_stride * (W - leading_pixels), \
1775 dst += leading_pixels; \
1776 W -= leading_pixels; \
1779 if ((uintptr_t)(dst + W) & (CACHE_LINE_SIZE - 1)) \
1781 trailing_pixels = (((uintptr_t)(dst + W) & \
1782 (CACHE_LINE_SIZE - 1)) / sizeof(pix_type)); \
1783 if (trailing_pixels > W) \
1784 trailing_pixels = W; \
1785 W -= trailing_pixels; \
1786 src += trailing_pixels * src_stride; \
1789 for (x = 0; x < W; x += TILE_SIZE) \
1791 /* aligned middle part TILE_SIZExH */ \
1792 blt_rotated_270_trivial_##suffix ( \
1795 src + src_stride * (W - x - TILE_SIZE), \
1801 if (trailing_pixels) \
1803 /* unaligned trailing part NxH (where N < TILE_SIZE) */ \
1804 blt_rotated_270_trivial_##suffix ( \
1807 src - trailing_pixels * src_stride, \
1815 fast_composite_rotate_90_##suffix (pixman_implementation_t *imp, \
1817 pixman_image_t * src_image, \
1818 pixman_image_t * mask_image, \
1819 pixman_image_t * dst_image, \
1829 pix_type *dst_line; \
1830 pix_type *src_line; \
1831 int dst_stride, src_stride; \
1832 int src_x_t, src_y_t; \
1834 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, pix_type, \
1835 dst_stride, dst_line, 1); \
1836 src_x_t = -src_y + pixman_fixed_to_int ( \
1837 src_image->common.transform->matrix[0][2] + \
1838 pixman_fixed_1 / 2 - pixman_fixed_e) - height;\
1839 src_y_t = src_x + pixman_fixed_to_int ( \
1840 src_image->common.transform->matrix[1][2] + \
1841 pixman_fixed_1 / 2 - pixman_fixed_e); \
1842 PIXMAN_IMAGE_GET_LINE (src_image, src_x_t, src_y_t, pix_type, \
1843 src_stride, src_line, 1); \
1844 blt_rotated_90_##suffix (dst_line, dst_stride, src_line, src_stride, \
1849 fast_composite_rotate_270_##suffix (pixman_implementation_t *imp, \
1851 pixman_image_t * src_image, \
1852 pixman_image_t * mask_image, \
1853 pixman_image_t * dst_image, \
1863 pix_type *dst_line; \
1864 pix_type *src_line; \
1865 int dst_stride, src_stride; \
1866 int src_x_t, src_y_t; \
1868 PIXMAN_IMAGE_GET_LINE (dst_image, dest_x, dest_y, pix_type, \
1869 dst_stride, dst_line, 1); \
1870 src_x_t = src_y + pixman_fixed_to_int ( \
1871 src_image->common.transform->matrix[0][2] + \
1872 pixman_fixed_1 / 2 - pixman_fixed_e); \
1873 src_y_t = -src_x + pixman_fixed_to_int ( \
1874 src_image->common.transform->matrix[1][2] + \
1875 pixman_fixed_1 / 2 - pixman_fixed_e) - width; \
1876 PIXMAN_IMAGE_GET_LINE (src_image, src_x_t, src_y_t, pix_type, \
1877 src_stride, src_line, 1); \
1878 blt_rotated_270_##suffix (dst_line, dst_stride, src_line, src_stride, \
1882 FAST_SIMPLE_ROTATE (8, uint8_t)
1883 FAST_SIMPLE_ROTATE (565, uint16_t)
1884 FAST_SIMPLE_ROTATE (8888, uint32_t)
1886 static const pixman_fast_path_t c_fast_paths[] =
1888 PIXMAN_STD_FAST_PATH (OVER, solid, a8, r5g6b5, fast_composite_over_n_8_0565),
1889 PIXMAN_STD_FAST_PATH (OVER, solid, a8, b5g6r5, fast_composite_over_n_8_0565),
1890 PIXMAN_STD_FAST_PATH (OVER, solid, a8, r8g8b8, fast_composite_over_n_8_0888),
1891 PIXMAN_STD_FAST_PATH (OVER, solid, a8, b8g8r8, fast_composite_over_n_8_0888),
1892 PIXMAN_STD_FAST_PATH (OVER, solid, a8, a8r8g8b8, fast_composite_over_n_8_8888),
1893 PIXMAN_STD_FAST_PATH (OVER, solid, a8, x8r8g8b8, fast_composite_over_n_8_8888),
1894 PIXMAN_STD_FAST_PATH (OVER, solid, a8, a8b8g8r8, fast_composite_over_n_8_8888),
1895 PIXMAN_STD_FAST_PATH (OVER, solid, a8, x8b8g8r8, fast_composite_over_n_8_8888),
1896 PIXMAN_STD_FAST_PATH (OVER, solid, a1, a8r8g8b8, fast_composite_over_n_1_8888),
1897 PIXMAN_STD_FAST_PATH (OVER, solid, a1, x8r8g8b8, fast_composite_over_n_1_8888),
1898 PIXMAN_STD_FAST_PATH (OVER, solid, a1, a8b8g8r8, fast_composite_over_n_1_8888),
1899 PIXMAN_STD_FAST_PATH (OVER, solid, a1, x8b8g8r8, fast_composite_over_n_1_8888),
1900 PIXMAN_STD_FAST_PATH (OVER, solid, a1, r5g6b5, fast_composite_over_n_1_0565),
1901 PIXMAN_STD_FAST_PATH (OVER, solid, a1, b5g6r5, fast_composite_over_n_1_0565),
1902 PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8r8g8b8, a8r8g8b8, fast_composite_over_n_8888_8888_ca),
1903 PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8r8g8b8, x8r8g8b8, fast_composite_over_n_8888_8888_ca),
1904 PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8r8g8b8, r5g6b5, fast_composite_over_n_8888_0565_ca),
1905 PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8b8g8r8, a8b8g8r8, fast_composite_over_n_8888_8888_ca),
1906 PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8b8g8r8, x8b8g8r8, fast_composite_over_n_8888_8888_ca),
1907 PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8b8g8r8, b5g6r5, fast_composite_over_n_8888_0565_ca),
1908 PIXMAN_STD_FAST_PATH (OVER, x8r8g8b8, a8, x8r8g8b8, fast_composite_over_x888_8_8888),
1909 PIXMAN_STD_FAST_PATH (OVER, x8r8g8b8, a8, a8r8g8b8, fast_composite_over_x888_8_8888),
1910 PIXMAN_STD_FAST_PATH (OVER, x8b8g8r8, a8, x8b8g8r8, fast_composite_over_x888_8_8888),
1911 PIXMAN_STD_FAST_PATH (OVER, x8b8g8r8, a8, a8b8g8r8, fast_composite_over_x888_8_8888),
1912 PIXMAN_STD_FAST_PATH (OVER, a8r8g8b8, null, a8r8g8b8, fast_composite_over_8888_8888),
1913 PIXMAN_STD_FAST_PATH (OVER, a8r8g8b8, null, x8r8g8b8, fast_composite_over_8888_8888),
1914 PIXMAN_STD_FAST_PATH (OVER, a8r8g8b8, null, r5g6b5, fast_composite_over_8888_0565),
1915 PIXMAN_STD_FAST_PATH (OVER, a8b8g8r8, null, a8b8g8r8, fast_composite_over_8888_8888),
1916 PIXMAN_STD_FAST_PATH (OVER, a8b8g8r8, null, x8b8g8r8, fast_composite_over_8888_8888),
1917 PIXMAN_STD_FAST_PATH (OVER, a8b8g8r8, null, b5g6r5, fast_composite_over_8888_0565),
1918 PIXMAN_STD_FAST_PATH (ADD, a8r8g8b8, null, a8r8g8b8, fast_composite_add_8888_8888),
1919 PIXMAN_STD_FAST_PATH (ADD, a8b8g8r8, null, a8b8g8r8, fast_composite_add_8888_8888),
1920 PIXMAN_STD_FAST_PATH (ADD, a8, null, a8, fast_composite_add_8_8),
1921 PIXMAN_STD_FAST_PATH (ADD, a1, null, a1, fast_composite_add_1000_1000),
1922 PIXMAN_STD_FAST_PATH_CA (ADD, solid, a8r8g8b8, a8r8g8b8, fast_composite_add_n_8888_8888_ca),
1923 PIXMAN_STD_FAST_PATH (ADD, solid, a8, a8, fast_composite_add_n_8_8),
1924 PIXMAN_STD_FAST_PATH (SRC, solid, null, a8r8g8b8, fast_composite_solid_fill),
1925 PIXMAN_STD_FAST_PATH (SRC, solid, null, x8r8g8b8, fast_composite_solid_fill),
1926 PIXMAN_STD_FAST_PATH (SRC, solid, null, a8b8g8r8, fast_composite_solid_fill),
1927 PIXMAN_STD_FAST_PATH (SRC, solid, null, x8b8g8r8, fast_composite_solid_fill),
1928 PIXMAN_STD_FAST_PATH (SRC, solid, null, a1, fast_composite_solid_fill),
1929 PIXMAN_STD_FAST_PATH (SRC, solid, null, a8, fast_composite_solid_fill),
1930 PIXMAN_STD_FAST_PATH (SRC, solid, null, r5g6b5, fast_composite_solid_fill),
1931 PIXMAN_STD_FAST_PATH (SRC, x8r8g8b8, null, a8r8g8b8, fast_composite_src_x888_8888),
1932 PIXMAN_STD_FAST_PATH (SRC, x8b8g8r8, null, a8b8g8r8, fast_composite_src_x888_8888),
1933 PIXMAN_STD_FAST_PATH (SRC, a8r8g8b8, null, x8r8g8b8, fast_composite_src_memcpy),
1934 PIXMAN_STD_FAST_PATH (SRC, a8r8g8b8, null, a8r8g8b8, fast_composite_src_memcpy),
1935 PIXMAN_STD_FAST_PATH (SRC, x8r8g8b8, null, x8r8g8b8, fast_composite_src_memcpy),
1936 PIXMAN_STD_FAST_PATH (SRC, a8b8g8r8, null, x8b8g8r8, fast_composite_src_memcpy),
1937 PIXMAN_STD_FAST_PATH (SRC, a8b8g8r8, null, a8b8g8r8, fast_composite_src_memcpy),
1938 PIXMAN_STD_FAST_PATH (SRC, x8b8g8r8, null, x8b8g8r8, fast_composite_src_memcpy),
1939 PIXMAN_STD_FAST_PATH (SRC, b8g8r8a8, null, b8g8r8x8, fast_composite_src_memcpy),
1940 PIXMAN_STD_FAST_PATH (SRC, b8g8r8a8, null, b8g8r8a8, fast_composite_src_memcpy),
1941 PIXMAN_STD_FAST_PATH (SRC, b8g8r8x8, null, b8g8r8x8, fast_composite_src_memcpy),
1942 PIXMAN_STD_FAST_PATH (SRC, r5g6b5, null, r5g6b5, fast_composite_src_memcpy),
1943 PIXMAN_STD_FAST_PATH (SRC, b5g6r5, null, b5g6r5, fast_composite_src_memcpy),
1944 PIXMAN_STD_FAST_PATH (SRC, r8g8b8, null, r8g8b8, fast_composite_src_memcpy),
1945 PIXMAN_STD_FAST_PATH (SRC, b8g8r8, null, b8g8r8, fast_composite_src_memcpy),
1946 PIXMAN_STD_FAST_PATH (SRC, x1r5g5b5, null, x1r5g5b5, fast_composite_src_memcpy),
1947 PIXMAN_STD_FAST_PATH (SRC, a1r5g5b5, null, x1r5g5b5, fast_composite_src_memcpy),
1948 PIXMAN_STD_FAST_PATH (SRC, a8, null, a8, fast_composite_src_memcpy),
1949 PIXMAN_STD_FAST_PATH (SRC, a8r8g8b8, null, r5g6b5, fast_composite_src_x888_0565),
1950 PIXMAN_STD_FAST_PATH (SRC, x8r8g8b8, null, r5g6b5, fast_composite_src_x888_0565),
1951 PIXMAN_STD_FAST_PATH (SRC, a8b8g8r8, null, b5g6r5, fast_composite_src_x888_0565),
1952 PIXMAN_STD_FAST_PATH (SRC, x8b8g8r8, null, b5g6r5, fast_composite_src_x888_0565),
1953 PIXMAN_STD_FAST_PATH (IN, a8, null, a8, fast_composite_in_8_8),
1954 PIXMAN_STD_FAST_PATH (IN, solid, a8, a8, fast_composite_in_n_8_8),
1956 SIMPLE_NEAREST_FAST_PATH (SRC, x8r8g8b8, x8r8g8b8, 8888_8888),
1957 SIMPLE_NEAREST_FAST_PATH (SRC, a8r8g8b8, x8r8g8b8, 8888_8888),
1958 SIMPLE_NEAREST_FAST_PATH (SRC, x8b8g8r8, x8b8g8r8, 8888_8888),
1959 SIMPLE_NEAREST_FAST_PATH (SRC, a8b8g8r8, x8b8g8r8, 8888_8888),
1961 SIMPLE_NEAREST_FAST_PATH (SRC, a8r8g8b8, a8r8g8b8, 8888_8888),
1962 SIMPLE_NEAREST_FAST_PATH (SRC, a8b8g8r8, a8b8g8r8, 8888_8888),
1964 SIMPLE_NEAREST_FAST_PATH (SRC, x8r8g8b8, r5g6b5, 8888_565),
1965 SIMPLE_NEAREST_FAST_PATH (SRC, a8r8g8b8, r5g6b5, 8888_565),
1967 SIMPLE_NEAREST_FAST_PATH (SRC, r5g6b5, r5g6b5, 565_565),
1969 SIMPLE_NEAREST_FAST_PATH (OVER, a8r8g8b8, x8r8g8b8, 8888_8888),
1970 SIMPLE_NEAREST_FAST_PATH (OVER, a8b8g8r8, x8b8g8r8, 8888_8888),
1971 SIMPLE_NEAREST_FAST_PATH (OVER, a8r8g8b8, a8r8g8b8, 8888_8888),
1972 SIMPLE_NEAREST_FAST_PATH (OVER, a8b8g8r8, a8b8g8r8, 8888_8888),
1974 SIMPLE_NEAREST_FAST_PATH (OVER, a8r8g8b8, r5g6b5, 8888_565),
1976 #define NEAREST_FAST_PATH(op,s,d) \
1977 { PIXMAN_OP_ ## op, \
1978 PIXMAN_ ## s, SCALED_NEAREST_FLAGS, \
1980 PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \
1981 fast_composite_scaled_nearest, \
1984 NEAREST_FAST_PATH (SRC, x8r8g8b8, x8r8g8b8),
1985 NEAREST_FAST_PATH (SRC, a8r8g8b8, x8r8g8b8),
1986 NEAREST_FAST_PATH (SRC, x8b8g8r8, x8b8g8r8),
1987 NEAREST_FAST_PATH (SRC, a8b8g8r8, x8b8g8r8),
1989 NEAREST_FAST_PATH (SRC, x8r8g8b8, a8r8g8b8),
1990 NEAREST_FAST_PATH (SRC, a8r8g8b8, a8r8g8b8),
1991 NEAREST_FAST_PATH (SRC, x8b8g8r8, a8b8g8r8),
1992 NEAREST_FAST_PATH (SRC, a8b8g8r8, a8b8g8r8),
1994 NEAREST_FAST_PATH (OVER, x8r8g8b8, x8r8g8b8),
1995 NEAREST_FAST_PATH (OVER, a8r8g8b8, x8r8g8b8),
1996 NEAREST_FAST_PATH (OVER, x8b8g8r8, x8b8g8r8),
1997 NEAREST_FAST_PATH (OVER, a8b8g8r8, x8b8g8r8),
1999 NEAREST_FAST_PATH (OVER, x8r8g8b8, a8r8g8b8),
2000 NEAREST_FAST_PATH (OVER, a8r8g8b8, a8r8g8b8),
2001 NEAREST_FAST_PATH (OVER, x8b8g8r8, a8b8g8r8),
2002 NEAREST_FAST_PATH (OVER, a8b8g8r8, a8b8g8r8),
2004 #define SIMPLE_ROTATE_FLAGS(angle) \
2005 (FAST_PATH_ROTATE_ ## angle ## _TRANSFORM | \
2006 FAST_PATH_NEAREST_FILTER | \
2007 FAST_PATH_SAMPLES_COVER_CLIP | \
2008 FAST_PATH_STANDARD_FLAGS)
2010 #define SIMPLE_ROTATE_FAST_PATH(op,s,d,suffix) \
2011 { PIXMAN_OP_ ## op, \
2012 PIXMAN_ ## s, SIMPLE_ROTATE_FLAGS (90), \
2014 PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \
2015 fast_composite_rotate_90_##suffix, \
2017 { PIXMAN_OP_ ## op, \
2018 PIXMAN_ ## s, SIMPLE_ROTATE_FLAGS (270), \
2020 PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \
2021 fast_composite_rotate_270_##suffix, \
2024 SIMPLE_ROTATE_FAST_PATH (SRC, a8r8g8b8, a8r8g8b8, 8888),
2025 SIMPLE_ROTATE_FAST_PATH (SRC, a8r8g8b8, x8r8g8b8, 8888),
2026 SIMPLE_ROTATE_FAST_PATH (SRC, x8r8g8b8, x8r8g8b8, 8888),
2027 SIMPLE_ROTATE_FAST_PATH (SRC, r5g6b5, r5g6b5, 565),
2028 SIMPLE_ROTATE_FAST_PATH (SRC, a8, a8, 8),
2033 #ifdef WORDS_BIGENDIAN
2034 #define A1_FILL_MASK(n, offs) (((1 << (n)) - 1) << (32 - (offs) - (n)))
2036 #define A1_FILL_MASK(n, offs) (((1 << (n)) - 1) << (offs))
2039 static force_inline void
2040 pixman_fill1_line (uint32_t *dst, int offs, int width, int v)
2044 int leading_pixels = 32 - offs;
2045 if (leading_pixels >= width)
2048 *dst |= A1_FILL_MASK (width, offs);
2050 *dst &= ~A1_FILL_MASK (width, offs);
2056 *dst++ |= A1_FILL_MASK (leading_pixels, offs);
2058 *dst++ &= ~A1_FILL_MASK (leading_pixels, offs);
2059 width -= leading_pixels;
2065 *dst++ = 0xFFFFFFFF;
2073 *dst |= A1_FILL_MASK (width, 0);
2075 *dst &= ~A1_FILL_MASK (width, 0);
2080 pixman_fill1 (uint32_t *bits,
2088 uint32_t *dst = bits + y * stride + (x >> 5);
2095 pixman_fill1_line (dst, offs, width, 1);
2103 pixman_fill1_line (dst, offs, width, 0);
2110 pixman_fill8 (uint32_t *bits,
2118 int byte_stride = stride * (int) sizeof (uint32_t);
2119 uint8_t *dst = (uint8_t *) bits;
2120 uint8_t v = xor & 0xff;
2123 dst = dst + y * byte_stride + x;
2127 for (i = 0; i < width; ++i)
2135 pixman_fill16 (uint32_t *bits,
2144 (stride * (int)sizeof (uint32_t)) / (int)sizeof (uint16_t);
2145 uint16_t *dst = (uint16_t *)bits;
2146 uint16_t v = xor & 0xffff;
2149 dst = dst + y * short_stride + x;
2153 for (i = 0; i < width; ++i)
2156 dst += short_stride;
2161 pixman_fill32 (uint32_t *bits,
2171 bits = bits + y * stride + x;
2175 for (i = 0; i < width; ++i)
2182 static pixman_bool_t
2183 fast_path_fill (pixman_implementation_t *imp,
2196 pixman_fill1 (bits, stride, x, y, width, height, xor);
2200 pixman_fill8 (bits, stride, x, y, width, height, xor);
2204 pixman_fill16 (bits, stride, x, y, width, height, xor);
2208 pixman_fill32 (bits, stride, x, y, width, height, xor);
2212 return _pixman_implementation_fill (
2213 imp->delegate, bits, stride, bpp, x, y, width, height, xor);
2220 pixman_implementation_t *
2221 _pixman_implementation_create_fast_path (pixman_implementation_t *fallback)
2223 pixman_implementation_t *imp = _pixman_implementation_create (fallback, c_fast_paths);
2225 imp->fill = fast_path_fill;