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-inlines.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,
111 pixman_composite_info_t *info)
113 PIXMAN_COMPOSITE_ARGS (info);
114 uint32_t *src, *src_line;
115 uint32_t *dst, *dst_line;
116 uint8_t *mask, *mask_line;
117 int src_stride, mask_stride, dst_stride;
122 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1);
123 PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint8_t, mask_stride, mask_line, 1);
124 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1);
129 src_line += src_stride;
131 dst_line += dst_stride;
133 mask_line += mask_stride;
141 s = *src | 0xff000000;
150 *dst = over (d, *dst);
160 fast_composite_in_n_8_8 (pixman_implementation_t *imp,
161 pixman_composite_info_t *info)
163 PIXMAN_COMPOSITE_ARGS (info);
165 uint8_t *dst_line, *dst;
166 uint8_t *mask_line, *mask, m;
167 int dst_stride, mask_stride;
171 src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format);
175 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint8_t, dst_stride, dst_line, 1);
176 PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint8_t, mask_stride, mask_line, 1);
183 dst_line += dst_stride;
185 mask_line += mask_stride;
195 *dst = MUL_UN8 (m, *dst, t);
206 dst_line += dst_stride;
208 mask_line += mask_stride;
214 m = MUL_UN8 (m, srca, t);
219 *dst = MUL_UN8 (m, *dst, t);
228 fast_composite_in_8_8 (pixman_implementation_t *imp,
229 pixman_composite_info_t *info)
231 PIXMAN_COMPOSITE_ARGS (info);
232 uint8_t *dst_line, *dst;
233 uint8_t *src_line, *src;
234 int dst_stride, src_stride;
239 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint8_t, src_stride, src_line, 1);
240 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint8_t, dst_stride, dst_line, 1);
245 dst_line += dst_stride;
247 src_line += src_stride;
257 *dst = MUL_UN8 (s, *dst, t);
265 fast_composite_over_n_8_8888 (pixman_implementation_t *imp,
266 pixman_composite_info_t *info)
268 PIXMAN_COMPOSITE_ARGS (info);
270 uint32_t *dst_line, *dst, d;
271 uint8_t *mask_line, *mask, m;
272 int dst_stride, mask_stride;
275 src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format);
281 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1);
282 PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint8_t, mask_stride, mask_line, 1);
287 dst_line += dst_stride;
289 mask_line += mask_stride;
300 *dst = over (src, *dst);
305 *dst = over (d, *dst);
313 fast_composite_add_n_8888_8888_ca (pixman_implementation_t *imp,
314 pixman_composite_info_t *info)
316 PIXMAN_COMPOSITE_ARGS (info);
318 uint32_t *dst_line, *dst, d;
319 uint32_t *mask_line, *mask, ma;
320 int dst_stride, mask_stride;
323 src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format);
328 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1);
329 PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint32_t, mask_stride, mask_line, 1);
334 dst_line += dst_stride;
336 mask_line += mask_stride;
348 UN8x4_MUL_UN8x4_ADD_UN8x4 (s, ma, d);
359 fast_composite_over_n_8888_8888_ca (pixman_implementation_t *imp,
360 pixman_composite_info_t *info)
362 PIXMAN_COMPOSITE_ARGS (info);
363 uint32_t src, srca, s;
364 uint32_t *dst_line, *dst, d;
365 uint32_t *mask_line, *mask, ma;
366 int dst_stride, mask_stride;
369 src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format);
375 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1);
376 PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint32_t, mask_stride, mask_line, 1);
381 dst_line += dst_stride;
383 mask_line += mask_stride;
389 if (ma == 0xffffffff)
394 *dst = over (src, *dst);
401 UN8x4_MUL_UN8x4 (s, ma);
402 UN8x4_MUL_UN8 (ma, srca);
404 UN8x4_MUL_UN8x4_ADD_UN8x4 (d, ma, s);
415 fast_composite_over_n_8_0888 (pixman_implementation_t *imp,
416 pixman_composite_info_t *info)
418 PIXMAN_COMPOSITE_ARGS (info);
420 uint8_t *dst_line, *dst;
422 uint8_t *mask_line, *mask, m;
423 int dst_stride, mask_stride;
426 src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format);
432 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint8_t, dst_stride, dst_line, 3);
433 PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint8_t, mask_stride, mask_line, 1);
438 dst_line += dst_stride;
440 mask_line += mask_stride;
461 d = over (in (src, m), fetch_24 (dst));
470 fast_composite_over_n_8_0565 (pixman_implementation_t *imp,
471 pixman_composite_info_t *info)
473 PIXMAN_COMPOSITE_ARGS (info);
475 uint16_t *dst_line, *dst;
477 uint8_t *mask_line, *mask, m;
478 int dst_stride, mask_stride;
481 src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format);
487 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint16_t, dst_stride, dst_line, 1);
488 PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint8_t, mask_stride, mask_line, 1);
493 dst_line += dst_stride;
495 mask_line += mask_stride;
510 d = over (src, CONVERT_0565_TO_0888 (d));
512 *dst = CONVERT_8888_TO_0565 (d);
517 d = over (in (src, m), CONVERT_0565_TO_0888 (d));
518 *dst = CONVERT_8888_TO_0565 (d);
526 fast_composite_over_n_8888_0565_ca (pixman_implementation_t *imp,
527 pixman_composite_info_t *info)
529 PIXMAN_COMPOSITE_ARGS (info);
530 uint32_t src, srca, s;
532 uint16_t *dst_line, *dst;
534 uint32_t *mask_line, *mask, ma;
535 int dst_stride, mask_stride;
538 src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format);
544 src16 = CONVERT_8888_TO_0565 (src);
546 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint16_t, dst_stride, dst_line, 1);
547 PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint32_t, mask_stride, mask_line, 1);
552 dst_line += dst_stride;
554 mask_line += mask_stride;
560 if (ma == 0xffffffff)
569 d = over (src, CONVERT_0565_TO_0888 (d));
570 *dst = CONVERT_8888_TO_0565 (d);
576 d = CONVERT_0565_TO_0888 (d);
580 UN8x4_MUL_UN8x4 (s, ma);
581 UN8x4_MUL_UN8 (ma, srca);
583 UN8x4_MUL_UN8x4_ADD_UN8x4 (d, ma, s);
585 *dst = CONVERT_8888_TO_0565 (d);
593 fast_composite_over_8888_8888 (pixman_implementation_t *imp,
594 pixman_composite_info_t *info)
596 PIXMAN_COMPOSITE_ARGS (info);
597 uint32_t *dst_line, *dst;
598 uint32_t *src_line, *src, s;
599 int dst_stride, src_stride;
603 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1);
604 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1);
609 dst_line += dst_stride;
611 src_line += src_stride;
621 *dst = over (s, *dst);
628 fast_composite_src_x888_8888 (pixman_implementation_t *imp,
629 pixman_composite_info_t *info)
631 PIXMAN_COMPOSITE_ARGS (info);
632 uint32_t *dst_line, *dst;
633 uint32_t *src_line, *src;
634 int dst_stride, src_stride;
637 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1);
638 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1);
643 dst_line += dst_stride;
645 src_line += src_stride;
649 *dst++ = (*src++) | 0xff000000;
655 fast_composite_over_8888_0888 (pixman_implementation_t *imp,
656 pixman_composite_info_t *info)
658 PIXMAN_COMPOSITE_ARGS (info);
659 uint8_t *dst_line, *dst;
661 uint32_t *src_line, *src, s;
663 int dst_stride, src_stride;
666 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint8_t, dst_stride, dst_line, 3);
667 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1);
672 dst_line += dst_stride;
674 src_line += src_stride;
686 d = over (s, fetch_24 (dst));
697 fast_composite_over_8888_0565 (pixman_implementation_t *imp,
698 pixman_composite_info_t *info)
700 PIXMAN_COMPOSITE_ARGS (info);
701 uint16_t *dst_line, *dst;
703 uint32_t *src_line, *src, s;
705 int dst_stride, src_stride;
708 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1);
709 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint16_t, dst_stride, dst_line, 1);
714 dst_line += dst_stride;
716 src_line += src_stride;
732 d = over (s, CONVERT_0565_TO_0888 (d));
734 *dst = CONVERT_8888_TO_0565 (d);
742 fast_composite_src_x888_0565 (pixman_implementation_t *imp,
743 pixman_composite_info_t *info)
745 PIXMAN_COMPOSITE_ARGS (info);
746 uint16_t *dst_line, *dst;
747 uint32_t *src_line, *src, s;
748 int dst_stride, src_stride;
751 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1);
752 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint16_t, dst_stride, dst_line, 1);
757 dst_line += dst_stride;
759 src_line += src_stride;
765 *dst = CONVERT_8888_TO_0565 (s);
772 fast_composite_add_8_8 (pixman_implementation_t *imp,
773 pixman_composite_info_t *info)
775 PIXMAN_COMPOSITE_ARGS (info);
776 uint8_t *dst_line, *dst;
777 uint8_t *src_line, *src;
778 int dst_stride, src_stride;
783 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint8_t, src_stride, src_line, 1);
784 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint8_t, dst_stride, dst_line, 1);
789 dst_line += dst_stride;
791 src_line += src_stride;
803 s = t | (0 - (t >> 8));
813 fast_composite_add_0565_0565 (pixman_implementation_t *imp,
814 pixman_composite_info_t *info)
816 PIXMAN_COMPOSITE_ARGS (info);
817 uint16_t *dst_line, *dst;
819 uint16_t *src_line, *src;
821 int dst_stride, src_stride;
824 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint16_t, src_stride, src_line, 1);
825 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint16_t, dst_stride, dst_line, 1);
830 dst_line += dst_stride;
832 src_line += src_stride;
841 s = CONVERT_0565_TO_8888 (s);
844 d = CONVERT_0565_TO_8888 (d);
845 UN8x4_ADD_UN8x4 (s, d);
847 *dst = CONVERT_8888_TO_0565 (s);
855 fast_composite_add_8888_8888 (pixman_implementation_t *imp,
856 pixman_composite_info_t *info)
858 PIXMAN_COMPOSITE_ARGS (info);
859 uint32_t *dst_line, *dst;
860 uint32_t *src_line, *src;
861 int dst_stride, src_stride;
865 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1);
866 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1);
871 dst_line += dst_stride;
873 src_line += src_stride;
885 UN8x4_ADD_UN8x4 (s, d);
895 fast_composite_add_n_8_8 (pixman_implementation_t *imp,
896 pixman_composite_info_t *info)
898 PIXMAN_COMPOSITE_ARGS (info);
899 uint8_t *dst_line, *dst;
900 uint8_t *mask_line, *mask;
901 int dst_stride, mask_stride;
906 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint8_t, dst_stride, dst_line, 1);
907 PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint8_t, mask_stride, mask_line, 1);
908 src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format);
914 dst_line += dst_stride;
916 mask_line += mask_stride;
929 m = MUL_UN8 (sa, a, tmp);
930 r = ADD_UN8 (m, d, tmp);
937 #ifdef WORDS_BIGENDIAN
938 #define CREATE_BITMASK(n) (0x80000000 >> (n))
939 #define UPDATE_BITMASK(n) ((n) >> 1)
941 #define CREATE_BITMASK(n) (1 << (n))
942 #define UPDATE_BITMASK(n) ((n) << 1)
945 #define TEST_BIT(p, n) \
946 (*((p) + ((n) >> 5)) & CREATE_BITMASK ((n) & 31))
947 #define SET_BIT(p, n) \
948 do { *((p) + ((n) >> 5)) |= CREATE_BITMASK ((n) & 31); } while (0);
951 fast_composite_add_1_1 (pixman_implementation_t *imp,
952 pixman_composite_info_t *info)
954 PIXMAN_COMPOSITE_ARGS (info);
955 uint32_t *dst_line, *dst;
956 uint32_t *src_line, *src;
957 int dst_stride, src_stride;
960 PIXMAN_IMAGE_GET_LINE (src_image, 0, src_y, uint32_t,
961 src_stride, src_line, 1);
962 PIXMAN_IMAGE_GET_LINE (dest_image, 0, dest_y, uint32_t,
963 dst_stride, dst_line, 1);
968 dst_line += dst_stride;
970 src_line += src_stride;
976 * TODO: improve performance by processing uint32_t data instead
979 if (TEST_BIT (src, src_x + w))
980 SET_BIT (dst, dest_x + w);
986 fast_composite_over_n_1_8888 (pixman_implementation_t *imp,
987 pixman_composite_info_t *info)
989 PIXMAN_COMPOSITE_ARGS (info);
991 uint32_t *dst, *dst_line;
992 uint32_t *mask, *mask_line;
993 int mask_stride, dst_stride;
994 uint32_t bitcache, bitmask;
1000 src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format);
1005 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t,
1006 dst_stride, dst_line, 1);
1007 PIXMAN_IMAGE_GET_LINE (mask_image, 0, mask_y, uint32_t,
1008 mask_stride, mask_line, 1);
1009 mask_line += mask_x >> 5;
1016 dst_line += dst_stride;
1018 mask_line += mask_stride;
1022 bitmask = CREATE_BITMASK (mask_x & 31);
1029 bitmask = CREATE_BITMASK (0);
1031 if (bitcache & bitmask)
1033 bitmask = UPDATE_BITMASK (bitmask);
1043 dst_line += dst_stride;
1045 mask_line += mask_stride;
1049 bitmask = CREATE_BITMASK (mask_x & 31);
1056 bitmask = CREATE_BITMASK (0);
1058 if (bitcache & bitmask)
1059 *dst = over (src, *dst);
1060 bitmask = UPDATE_BITMASK (bitmask);
1068 fast_composite_over_n_1_0565 (pixman_implementation_t *imp,
1069 pixman_composite_info_t *info)
1071 PIXMAN_COMPOSITE_ARGS (info);
1073 uint16_t *dst, *dst_line;
1074 uint32_t *mask, *mask_line;
1075 int mask_stride, dst_stride;
1076 uint32_t bitcache, bitmask;
1084 src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format);
1089 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint16_t,
1090 dst_stride, dst_line, 1);
1091 PIXMAN_IMAGE_GET_LINE (mask_image, 0, mask_y, uint32_t,
1092 mask_stride, mask_line, 1);
1093 mask_line += mask_x >> 5;
1097 src565 = CONVERT_8888_TO_0565 (src);
1101 dst_line += dst_stride;
1103 mask_line += mask_stride;
1107 bitmask = CREATE_BITMASK (mask_x & 31);
1114 bitmask = CREATE_BITMASK (0);
1116 if (bitcache & bitmask)
1118 bitmask = UPDATE_BITMASK (bitmask);
1128 dst_line += dst_stride;
1130 mask_line += mask_stride;
1134 bitmask = CREATE_BITMASK (mask_x & 31);
1141 bitmask = CREATE_BITMASK (0);
1143 if (bitcache & bitmask)
1145 d = over (src, CONVERT_0565_TO_0888 (*dst));
1146 *dst = CONVERT_8888_TO_0565 (d);
1148 bitmask = UPDATE_BITMASK (bitmask);
1160 fast_composite_solid_fill (pixman_implementation_t *imp,
1161 pixman_composite_info_t *info)
1163 PIXMAN_COMPOSITE_ARGS (info);
1166 src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format);
1168 if (dest_image->bits.format == PIXMAN_a1)
1172 else if (dest_image->bits.format == PIXMAN_a8)
1176 else if (dest_image->bits.format == PIXMAN_r5g6b5 ||
1177 dest_image->bits.format == PIXMAN_b5g6r5)
1179 src = CONVERT_8888_TO_0565 (src);
1182 pixman_fill (dest_image->bits.bits, dest_image->bits.rowstride,
1183 PIXMAN_FORMAT_BPP (dest_image->bits.format),
1190 fast_composite_src_memcpy (pixman_implementation_t *imp,
1191 pixman_composite_info_t *info)
1193 PIXMAN_COMPOSITE_ARGS (info);
1194 int bpp = PIXMAN_FORMAT_BPP (dest_image->bits.format) / 8;
1195 uint32_t n_bytes = width * bpp;
1196 int dst_stride, src_stride;
1200 src_stride = src_image->bits.rowstride * 4;
1201 dst_stride = dest_image->bits.rowstride * 4;
1203 src = (uint8_t *)src_image->bits.bits + src_y * src_stride + src_x * bpp;
1204 dst = (uint8_t *)dest_image->bits.bits + dest_y * dst_stride + dest_x * bpp;
1208 memcpy (dst, src, n_bytes);
1215 FAST_NEAREST (8888_8888_cover, 8888, 8888, uint32_t, uint32_t, SRC, COVER)
1216 FAST_NEAREST (8888_8888_none, 8888, 8888, uint32_t, uint32_t, SRC, NONE)
1217 FAST_NEAREST (8888_8888_pad, 8888, 8888, uint32_t, uint32_t, SRC, PAD)
1218 FAST_NEAREST (8888_8888_normal, 8888, 8888, uint32_t, uint32_t, SRC, NORMAL)
1219 FAST_NEAREST (x888_8888_cover, x888, 8888, uint32_t, uint32_t, SRC, COVER)
1220 FAST_NEAREST (x888_8888_pad, x888, 8888, uint32_t, uint32_t, SRC, PAD)
1221 FAST_NEAREST (x888_8888_normal, x888, 8888, uint32_t, uint32_t, SRC, NORMAL)
1222 FAST_NEAREST (8888_8888_cover, 8888, 8888, uint32_t, uint32_t, OVER, COVER)
1223 FAST_NEAREST (8888_8888_none, 8888, 8888, uint32_t, uint32_t, OVER, NONE)
1224 FAST_NEAREST (8888_8888_pad, 8888, 8888, uint32_t, uint32_t, OVER, PAD)
1225 FAST_NEAREST (8888_8888_normal, 8888, 8888, uint32_t, uint32_t, OVER, NORMAL)
1226 FAST_NEAREST (8888_565_cover, 8888, 0565, uint32_t, uint16_t, SRC, COVER)
1227 FAST_NEAREST (8888_565_none, 8888, 0565, uint32_t, uint16_t, SRC, NONE)
1228 FAST_NEAREST (8888_565_pad, 8888, 0565, uint32_t, uint16_t, SRC, PAD)
1229 FAST_NEAREST (8888_565_normal, 8888, 0565, uint32_t, uint16_t, SRC, NORMAL)
1230 FAST_NEAREST (565_565_normal, 0565, 0565, uint16_t, uint16_t, SRC, NORMAL)
1231 FAST_NEAREST (8888_565_cover, 8888, 0565, uint32_t, uint16_t, OVER, COVER)
1232 FAST_NEAREST (8888_565_none, 8888, 0565, uint32_t, uint16_t, OVER, NONE)
1233 FAST_NEAREST (8888_565_pad, 8888, 0565, uint32_t, uint16_t, OVER, PAD)
1234 FAST_NEAREST (8888_565_normal, 8888, 0565, uint32_t, uint16_t, OVER, NORMAL)
1236 #define REPEAT_MIN_WIDTH 32
1239 fast_composite_tiled_repeat (pixman_implementation_t *imp,
1240 pixman_composite_info_t *info)
1242 PIXMAN_COMPOSITE_ARGS (info);
1243 pixman_composite_func_t func;
1244 pixman_format_code_t mask_format;
1245 uint32_t src_flags, mask_flags;
1247 src_flags = (info->src_flags & ~FAST_PATH_NORMAL_REPEAT) |
1248 FAST_PATH_SAMPLES_COVER_CLIP_NEAREST;
1252 mask_format = mask_image->common.extended_format_code;
1253 mask_flags = info->mask_flags;
1257 mask_format = PIXMAN_null;
1258 mask_flags = FAST_PATH_IS_OPAQUE;
1261 if (_pixman_lookup_composite_function (
1262 imp->toplevel, info->op,
1263 src_image->common.extended_format_code, src_flags,
1264 mask_format, mask_flags,
1265 dest_image->common.extended_format_code, info->dest_flags,
1269 int32_t width_remain;
1273 pixman_image_t extended_src_image;
1274 uint32_t extended_src[REPEAT_MIN_WIDTH * 2];
1275 pixman_bool_t need_src_extension;
1279 pixman_composite_info_t info2 = *info;
1281 src_bpp = PIXMAN_FORMAT_BPP (src_image->bits.format);
1283 if (src_image->bits.width < REPEAT_MIN_WIDTH &&
1284 (src_bpp == 32 || src_bpp == 16 || src_bpp == 8))
1287 sx = MOD (sx, src_image->bits.width);
1291 while (src_width < REPEAT_MIN_WIDTH && src_width <= sx)
1292 src_width += src_image->bits.width;
1294 src_stride = (src_width * (src_bpp >> 3) + 3) / (int) sizeof (uint32_t);
1296 /* Initialize/validate stack-allocated temporary image */
1297 _pixman_bits_image_init (&extended_src_image, src_image->bits.format,
1298 src_width, 1, &extended_src[0], src_stride);
1299 _pixman_image_validate (&extended_src_image);
1301 info2.src_image = &extended_src_image;
1302 need_src_extension = TRUE;
1306 src_width = src_image->bits.width;
1307 need_src_extension = FALSE;
1313 while (--height >= 0)
1315 sx = MOD (sx, src_width);
1316 sy = MOD (sy, src_image->bits.height);
1318 if (need_src_extension)
1322 PIXMAN_IMAGE_GET_LINE (src_image, 0, sy, uint32_t, src_stride, src_line, 1);
1324 for (i = 0; i < src_width; )
1326 for (j = 0; j < src_image->bits.width; j++, i++)
1327 extended_src[i] = src_line[j];
1330 else if (src_bpp == 16)
1332 uint16_t *src_line_16;
1334 PIXMAN_IMAGE_GET_LINE (src_image, 0, sy, uint16_t, src_stride,
1336 src_line = (uint32_t*)src_line_16;
1338 for (i = 0; i < src_width; )
1340 for (j = 0; j < src_image->bits.width; j++, i++)
1341 ((uint16_t*)extended_src)[i] = ((uint16_t*)src_line)[j];
1344 else if (src_bpp == 8)
1346 uint8_t *src_line_8;
1348 PIXMAN_IMAGE_GET_LINE (src_image, 0, sy, uint8_t, src_stride,
1350 src_line = (uint32_t*)src_line_8;
1352 for (i = 0; i < src_width; )
1354 for (j = 0; j < src_image->bits.width; j++, i++)
1355 ((uint8_t*)extended_src)[i] = ((uint8_t*)src_line)[j];
1366 width_remain = width;
1368 while (width_remain > 0)
1370 num_pixels = src_width - sx;
1372 if (num_pixels > width_remain)
1373 num_pixels = width_remain;
1376 info2.width = num_pixels;
1381 width_remain -= num_pixels;
1382 info2.mask_x += num_pixels;
1383 info2.dest_x += num_pixels;
1389 info2.mask_x = info->mask_x;
1391 info2.dest_x = info->dest_x;
1395 if (need_src_extension)
1396 _pixman_image_fini (&extended_src_image);
1400 _pixman_log_error (FUNC, "Didn't find a suitable function ");
1404 /* Use more unrolling for src_0565_0565 because it is typically CPU bound */
1405 static force_inline void
1406 scaled_nearest_scanline_565_565_SRC (uint16_t * dst,
1407 const uint16_t * src,
1410 pixman_fixed_t unit_x,
1411 pixman_fixed_t max_vx,
1412 pixman_bool_t fully_transparent_src)
1414 uint16_t tmp1, tmp2, tmp3, tmp4;
1415 while ((w -= 4) >= 0)
1417 tmp1 = src[pixman_fixed_to_int (vx)];
1419 tmp2 = src[pixman_fixed_to_int (vx)];
1421 tmp3 = src[pixman_fixed_to_int (vx)];
1423 tmp4 = src[pixman_fixed_to_int (vx)];
1432 tmp1 = src[pixman_fixed_to_int (vx)];
1434 tmp2 = src[pixman_fixed_to_int (vx)];
1440 *dst++ = src[pixman_fixed_to_int (vx)];
1443 FAST_NEAREST_MAINLOOP (565_565_cover_SRC,
1444 scaled_nearest_scanline_565_565_SRC,
1445 uint16_t, uint16_t, COVER)
1446 FAST_NEAREST_MAINLOOP (565_565_none_SRC,
1447 scaled_nearest_scanline_565_565_SRC,
1448 uint16_t, uint16_t, NONE)
1449 FAST_NEAREST_MAINLOOP (565_565_pad_SRC,
1450 scaled_nearest_scanline_565_565_SRC,
1451 uint16_t, uint16_t, PAD)
1453 static force_inline uint32_t
1454 fetch_nearest (pixman_repeat_t src_repeat,
1455 pixman_format_code_t format,
1456 uint32_t *src, int x, int src_width)
1458 if (repeat (src_repeat, &x, src_width))
1460 if (format == PIXMAN_x8r8g8b8)
1461 return *(src + x) | 0xff000000;
1471 static force_inline void
1472 combine_over (uint32_t s, uint32_t *dst)
1476 uint8_t ia = 0xff - (s >> 24);
1479 UN8x4_MUL_UN8_ADD_UN8x4 (*dst, ia, s);
1485 static force_inline void
1486 combine_src (uint32_t s, uint32_t *dst)
1492 fast_composite_scaled_nearest (pixman_implementation_t *imp,
1493 pixman_composite_info_t *info)
1495 PIXMAN_COMPOSITE_ARGS (info);
1498 int dst_stride, src_stride;
1499 int src_width, src_height;
1500 pixman_repeat_t src_repeat;
1501 pixman_fixed_t unit_x, unit_y;
1502 pixman_format_code_t src_format;
1506 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1);
1507 /* pass in 0 instead of src_x and src_y because src_x and src_y need to be
1508 * transformed from destination space to source space
1510 PIXMAN_IMAGE_GET_LINE (src_image, 0, 0, uint32_t, src_stride, src_line, 1);
1512 /* reference point is the center of the pixel */
1513 v.vector[0] = pixman_int_to_fixed (src_x) + pixman_fixed_1 / 2;
1514 v.vector[1] = pixman_int_to_fixed (src_y) + pixman_fixed_1 / 2;
1515 v.vector[2] = pixman_fixed_1;
1517 if (!pixman_transform_point_3d (src_image->common.transform, &v))
1520 unit_x = src_image->common.transform->matrix[0][0];
1521 unit_y = src_image->common.transform->matrix[1][1];
1523 /* Round down to closest integer, ensuring that 0.5 rounds to 0, not 1 */
1524 v.vector[0] -= pixman_fixed_e;
1525 v.vector[1] -= pixman_fixed_e;
1527 src_height = src_image->bits.height;
1528 src_width = src_image->bits.width;
1529 src_repeat = src_image->common.repeat;
1530 src_format = src_image->bits.format;
1535 pixman_fixed_t vx = v.vector[0];
1536 int y = pixman_fixed_to_int (vy);
1537 uint32_t *dst = dst_line;
1539 dst_line += dst_stride;
1541 /* adjust the y location by a unit vector in the y direction
1542 * this is equivalent to transforming y+1 of the destination point to source space */
1545 if (!repeat (src_repeat, &y, src_height))
1547 if (op == PIXMAN_OP_SRC)
1548 memset (dst, 0, sizeof (*dst) * width);
1554 uint32_t *src = src_line + y * src_stride;
1561 x1 = pixman_fixed_to_int (vx);
1564 x2 = pixman_fixed_to_int (vx);
1569 s1 = fetch_nearest (src_repeat, src_format, src, x1, src_width);
1570 s2 = fetch_nearest (src_repeat, src_format, src, x2, src_width);
1572 if (op == PIXMAN_OP_OVER)
1574 combine_over (s1, dst++);
1575 combine_over (s2, dst++);
1579 combine_src (s1, dst++);
1580 combine_src (s2, dst++);
1589 x = pixman_fixed_to_int (vx);
1592 s = fetch_nearest (src_repeat, src_format, src, x, src_width);
1594 if (op == PIXMAN_OP_OVER)
1595 combine_over (s, dst++);
1597 combine_src (s, dst++);
1603 #define CACHE_LINE_SIZE 64
1605 #define FAST_SIMPLE_ROTATE(suffix, pix_type) \
1608 blt_rotated_90_trivial_##suffix (pix_type *dst, \
1610 const pix_type *src, \
1616 for (y = 0; y < h; y++) \
1618 const pix_type *s = src + (h - y - 1); \
1619 pix_type *d = dst + dst_stride * y; \
1620 for (x = 0; x < w; x++) \
1629 blt_rotated_270_trivial_##suffix (pix_type *dst, \
1631 const pix_type *src, \
1637 for (y = 0; y < h; y++) \
1639 const pix_type *s = src + src_stride * (w - 1) + y; \
1640 pix_type *d = dst + dst_stride * y; \
1641 for (x = 0; x < w; x++) \
1650 blt_rotated_90_##suffix (pix_type *dst, \
1652 const pix_type *src, \
1658 int leading_pixels = 0, trailing_pixels = 0; \
1659 const int TILE_SIZE = CACHE_LINE_SIZE / sizeof(pix_type); \
1662 * split processing into handling destination as TILE_SIZExH cache line \
1663 * aligned vertical stripes (optimistically assuming that destination \
1664 * stride is a multiple of cache line, if not - it will be just a bit \
1668 if ((uintptr_t)dst & (CACHE_LINE_SIZE - 1)) \
1670 leading_pixels = TILE_SIZE - (((uintptr_t)dst & \
1671 (CACHE_LINE_SIZE - 1)) / sizeof(pix_type)); \
1672 if (leading_pixels > W) \
1673 leading_pixels = W; \
1675 /* unaligned leading part NxH (where N < TILE_SIZE) */ \
1676 blt_rotated_90_trivial_##suffix ( \
1684 dst += leading_pixels; \
1685 src += leading_pixels * src_stride; \
1686 W -= leading_pixels; \
1689 if ((uintptr_t)(dst + W) & (CACHE_LINE_SIZE - 1)) \
1691 trailing_pixels = (((uintptr_t)(dst + W) & \
1692 (CACHE_LINE_SIZE - 1)) / sizeof(pix_type)); \
1693 if (trailing_pixels > W) \
1694 trailing_pixels = W; \
1695 W -= trailing_pixels; \
1698 for (x = 0; x < W; x += TILE_SIZE) \
1700 /* aligned middle part TILE_SIZExH */ \
1701 blt_rotated_90_trivial_##suffix ( \
1704 src + src_stride * x, \
1710 if (trailing_pixels) \
1712 /* unaligned trailing part NxH (where N < TILE_SIZE) */ \
1713 blt_rotated_90_trivial_##suffix ( \
1716 src + W * src_stride, \
1724 blt_rotated_270_##suffix (pix_type *dst, \
1726 const pix_type *src, \
1732 int leading_pixels = 0, trailing_pixels = 0; \
1733 const int TILE_SIZE = CACHE_LINE_SIZE / sizeof(pix_type); \
1736 * split processing into handling destination as TILE_SIZExH cache line \
1737 * aligned vertical stripes (optimistically assuming that destination \
1738 * stride is a multiple of cache line, if not - it will be just a bit \
1742 if ((uintptr_t)dst & (CACHE_LINE_SIZE - 1)) \
1744 leading_pixels = TILE_SIZE - (((uintptr_t)dst & \
1745 (CACHE_LINE_SIZE - 1)) / sizeof(pix_type)); \
1746 if (leading_pixels > W) \
1747 leading_pixels = W; \
1749 /* unaligned leading part NxH (where N < TILE_SIZE) */ \
1750 blt_rotated_270_trivial_##suffix ( \
1753 src + src_stride * (W - leading_pixels), \
1758 dst += leading_pixels; \
1759 W -= leading_pixels; \
1762 if ((uintptr_t)(dst + W) & (CACHE_LINE_SIZE - 1)) \
1764 trailing_pixels = (((uintptr_t)(dst + W) & \
1765 (CACHE_LINE_SIZE - 1)) / sizeof(pix_type)); \
1766 if (trailing_pixels > W) \
1767 trailing_pixels = W; \
1768 W -= trailing_pixels; \
1769 src += trailing_pixels * src_stride; \
1772 for (x = 0; x < W; x += TILE_SIZE) \
1774 /* aligned middle part TILE_SIZExH */ \
1775 blt_rotated_270_trivial_##suffix ( \
1778 src + src_stride * (W - x - TILE_SIZE), \
1784 if (trailing_pixels) \
1786 /* unaligned trailing part NxH (where N < TILE_SIZE) */ \
1787 blt_rotated_270_trivial_##suffix ( \
1790 src - trailing_pixels * src_stride, \
1798 fast_composite_rotate_90_##suffix (pixman_implementation_t *imp, \
1799 pixman_composite_info_t *info) \
1801 PIXMAN_COMPOSITE_ARGS (info); \
1802 pix_type *dst_line; \
1803 pix_type *src_line; \
1804 int dst_stride, src_stride; \
1805 int src_x_t, src_y_t; \
1807 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, pix_type, \
1808 dst_stride, dst_line, 1); \
1809 src_x_t = -src_y + pixman_fixed_to_int ( \
1810 src_image->common.transform->matrix[0][2] + \
1811 pixman_fixed_1 / 2 - pixman_fixed_e) - height;\
1812 src_y_t = src_x + pixman_fixed_to_int ( \
1813 src_image->common.transform->matrix[1][2] + \
1814 pixman_fixed_1 / 2 - pixman_fixed_e); \
1815 PIXMAN_IMAGE_GET_LINE (src_image, src_x_t, src_y_t, pix_type, \
1816 src_stride, src_line, 1); \
1817 blt_rotated_90_##suffix (dst_line, dst_stride, src_line, src_stride, \
1822 fast_composite_rotate_270_##suffix (pixman_implementation_t *imp, \
1823 pixman_composite_info_t *info) \
1825 PIXMAN_COMPOSITE_ARGS (info); \
1826 pix_type *dst_line; \
1827 pix_type *src_line; \
1828 int dst_stride, src_stride; \
1829 int src_x_t, src_y_t; \
1831 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, pix_type, \
1832 dst_stride, dst_line, 1); \
1833 src_x_t = src_y + pixman_fixed_to_int ( \
1834 src_image->common.transform->matrix[0][2] + \
1835 pixman_fixed_1 / 2 - pixman_fixed_e); \
1836 src_y_t = -src_x + pixman_fixed_to_int ( \
1837 src_image->common.transform->matrix[1][2] + \
1838 pixman_fixed_1 / 2 - pixman_fixed_e) - width; \
1839 PIXMAN_IMAGE_GET_LINE (src_image, src_x_t, src_y_t, pix_type, \
1840 src_stride, src_line, 1); \
1841 blt_rotated_270_##suffix (dst_line, dst_stride, src_line, src_stride, \
1845 FAST_SIMPLE_ROTATE (8, uint8_t)
1846 FAST_SIMPLE_ROTATE (565, uint16_t)
1847 FAST_SIMPLE_ROTATE (8888, uint32_t)
1849 static const pixman_fast_path_t c_fast_paths[] =
1851 PIXMAN_STD_FAST_PATH (OVER, solid, a8, r5g6b5, fast_composite_over_n_8_0565),
1852 PIXMAN_STD_FAST_PATH (OVER, solid, a8, b5g6r5, fast_composite_over_n_8_0565),
1853 PIXMAN_STD_FAST_PATH (OVER, solid, a8, r8g8b8, fast_composite_over_n_8_0888),
1854 PIXMAN_STD_FAST_PATH (OVER, solid, a8, b8g8r8, fast_composite_over_n_8_0888),
1855 PIXMAN_STD_FAST_PATH (OVER, solid, a8, a8r8g8b8, fast_composite_over_n_8_8888),
1856 PIXMAN_STD_FAST_PATH (OVER, solid, a8, x8r8g8b8, fast_composite_over_n_8_8888),
1857 PIXMAN_STD_FAST_PATH (OVER, solid, a8, a8b8g8r8, fast_composite_over_n_8_8888),
1858 PIXMAN_STD_FAST_PATH (OVER, solid, a8, x8b8g8r8, fast_composite_over_n_8_8888),
1859 PIXMAN_STD_FAST_PATH (OVER, solid, a1, a8r8g8b8, fast_composite_over_n_1_8888),
1860 PIXMAN_STD_FAST_PATH (OVER, solid, a1, x8r8g8b8, fast_composite_over_n_1_8888),
1861 PIXMAN_STD_FAST_PATH (OVER, solid, a1, a8b8g8r8, fast_composite_over_n_1_8888),
1862 PIXMAN_STD_FAST_PATH (OVER, solid, a1, x8b8g8r8, fast_composite_over_n_1_8888),
1863 PIXMAN_STD_FAST_PATH (OVER, solid, a1, r5g6b5, fast_composite_over_n_1_0565),
1864 PIXMAN_STD_FAST_PATH (OVER, solid, a1, b5g6r5, fast_composite_over_n_1_0565),
1865 PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8r8g8b8, a8r8g8b8, fast_composite_over_n_8888_8888_ca),
1866 PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8r8g8b8, x8r8g8b8, fast_composite_over_n_8888_8888_ca),
1867 PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8r8g8b8, r5g6b5, fast_composite_over_n_8888_0565_ca),
1868 PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8b8g8r8, a8b8g8r8, fast_composite_over_n_8888_8888_ca),
1869 PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8b8g8r8, x8b8g8r8, fast_composite_over_n_8888_8888_ca),
1870 PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8b8g8r8, b5g6r5, fast_composite_over_n_8888_0565_ca),
1871 PIXMAN_STD_FAST_PATH (OVER, x8r8g8b8, a8, x8r8g8b8, fast_composite_over_x888_8_8888),
1872 PIXMAN_STD_FAST_PATH (OVER, x8r8g8b8, a8, a8r8g8b8, fast_composite_over_x888_8_8888),
1873 PIXMAN_STD_FAST_PATH (OVER, x8b8g8r8, a8, x8b8g8r8, fast_composite_over_x888_8_8888),
1874 PIXMAN_STD_FAST_PATH (OVER, x8b8g8r8, a8, a8b8g8r8, fast_composite_over_x888_8_8888),
1875 PIXMAN_STD_FAST_PATH (OVER, a8r8g8b8, null, a8r8g8b8, fast_composite_over_8888_8888),
1876 PIXMAN_STD_FAST_PATH (OVER, a8r8g8b8, null, x8r8g8b8, fast_composite_over_8888_8888),
1877 PIXMAN_STD_FAST_PATH (OVER, a8r8g8b8, null, r5g6b5, fast_composite_over_8888_0565),
1878 PIXMAN_STD_FAST_PATH (OVER, a8b8g8r8, null, a8b8g8r8, fast_composite_over_8888_8888),
1879 PIXMAN_STD_FAST_PATH (OVER, a8b8g8r8, null, x8b8g8r8, fast_composite_over_8888_8888),
1880 PIXMAN_STD_FAST_PATH (OVER, a8b8g8r8, null, b5g6r5, fast_composite_over_8888_0565),
1881 PIXMAN_STD_FAST_PATH (ADD, r5g6b5, null, r5g6b5, fast_composite_add_0565_0565),
1882 PIXMAN_STD_FAST_PATH (ADD, b5g6r5, null, b5g6r5, fast_composite_add_0565_0565),
1883 PIXMAN_STD_FAST_PATH (ADD, a8r8g8b8, null, a8r8g8b8, fast_composite_add_8888_8888),
1884 PIXMAN_STD_FAST_PATH (ADD, a8b8g8r8, null, a8b8g8r8, fast_composite_add_8888_8888),
1885 PIXMAN_STD_FAST_PATH (ADD, a8, null, a8, fast_composite_add_8_8),
1886 PIXMAN_STD_FAST_PATH (ADD, a1, null, a1, fast_composite_add_1_1),
1887 PIXMAN_STD_FAST_PATH_CA (ADD, solid, a8r8g8b8, a8r8g8b8, fast_composite_add_n_8888_8888_ca),
1888 PIXMAN_STD_FAST_PATH (ADD, solid, a8, a8, fast_composite_add_n_8_8),
1889 PIXMAN_STD_FAST_PATH (SRC, solid, null, a8r8g8b8, fast_composite_solid_fill),
1890 PIXMAN_STD_FAST_PATH (SRC, solid, null, x8r8g8b8, fast_composite_solid_fill),
1891 PIXMAN_STD_FAST_PATH (SRC, solid, null, a8b8g8r8, fast_composite_solid_fill),
1892 PIXMAN_STD_FAST_PATH (SRC, solid, null, x8b8g8r8, fast_composite_solid_fill),
1893 PIXMAN_STD_FAST_PATH (SRC, solid, null, a1, fast_composite_solid_fill),
1894 PIXMAN_STD_FAST_PATH (SRC, solid, null, a8, fast_composite_solid_fill),
1895 PIXMAN_STD_FAST_PATH (SRC, solid, null, r5g6b5, fast_composite_solid_fill),
1896 PIXMAN_STD_FAST_PATH (SRC, x8r8g8b8, null, a8r8g8b8, fast_composite_src_x888_8888),
1897 PIXMAN_STD_FAST_PATH (SRC, x8b8g8r8, null, a8b8g8r8, fast_composite_src_x888_8888),
1898 PIXMAN_STD_FAST_PATH (SRC, a8r8g8b8, null, x8r8g8b8, fast_composite_src_memcpy),
1899 PIXMAN_STD_FAST_PATH (SRC, a8r8g8b8, null, a8r8g8b8, fast_composite_src_memcpy),
1900 PIXMAN_STD_FAST_PATH (SRC, x8r8g8b8, null, x8r8g8b8, fast_composite_src_memcpy),
1901 PIXMAN_STD_FAST_PATH (SRC, a8b8g8r8, null, x8b8g8r8, fast_composite_src_memcpy),
1902 PIXMAN_STD_FAST_PATH (SRC, a8b8g8r8, null, a8b8g8r8, fast_composite_src_memcpy),
1903 PIXMAN_STD_FAST_PATH (SRC, x8b8g8r8, null, x8b8g8r8, fast_composite_src_memcpy),
1904 PIXMAN_STD_FAST_PATH (SRC, b8g8r8a8, null, b8g8r8x8, fast_composite_src_memcpy),
1905 PIXMAN_STD_FAST_PATH (SRC, b8g8r8a8, null, b8g8r8a8, fast_composite_src_memcpy),
1906 PIXMAN_STD_FAST_PATH (SRC, b8g8r8x8, null, b8g8r8x8, fast_composite_src_memcpy),
1907 PIXMAN_STD_FAST_PATH (SRC, r5g6b5, null, r5g6b5, fast_composite_src_memcpy),
1908 PIXMAN_STD_FAST_PATH (SRC, b5g6r5, null, b5g6r5, fast_composite_src_memcpy),
1909 PIXMAN_STD_FAST_PATH (SRC, r8g8b8, null, r8g8b8, fast_composite_src_memcpy),
1910 PIXMAN_STD_FAST_PATH (SRC, b8g8r8, null, b8g8r8, fast_composite_src_memcpy),
1911 PIXMAN_STD_FAST_PATH (SRC, x1r5g5b5, null, x1r5g5b5, fast_composite_src_memcpy),
1912 PIXMAN_STD_FAST_PATH (SRC, a1r5g5b5, null, x1r5g5b5, fast_composite_src_memcpy),
1913 PIXMAN_STD_FAST_PATH (SRC, a8, null, a8, fast_composite_src_memcpy),
1914 PIXMAN_STD_FAST_PATH (SRC, a8r8g8b8, null, r5g6b5, fast_composite_src_x888_0565),
1915 PIXMAN_STD_FAST_PATH (SRC, x8r8g8b8, null, r5g6b5, fast_composite_src_x888_0565),
1916 PIXMAN_STD_FAST_PATH (SRC, a8b8g8r8, null, b5g6r5, fast_composite_src_x888_0565),
1917 PIXMAN_STD_FAST_PATH (SRC, x8b8g8r8, null, b5g6r5, fast_composite_src_x888_0565),
1918 PIXMAN_STD_FAST_PATH (IN, a8, null, a8, fast_composite_in_8_8),
1919 PIXMAN_STD_FAST_PATH (IN, solid, a8, a8, fast_composite_in_n_8_8),
1921 SIMPLE_NEAREST_FAST_PATH (SRC, x8r8g8b8, x8r8g8b8, 8888_8888),
1922 SIMPLE_NEAREST_FAST_PATH (SRC, a8r8g8b8, x8r8g8b8, 8888_8888),
1923 SIMPLE_NEAREST_FAST_PATH (SRC, x8b8g8r8, x8b8g8r8, 8888_8888),
1924 SIMPLE_NEAREST_FAST_PATH (SRC, a8b8g8r8, x8b8g8r8, 8888_8888),
1926 SIMPLE_NEAREST_FAST_PATH (SRC, a8r8g8b8, a8r8g8b8, 8888_8888),
1927 SIMPLE_NEAREST_FAST_PATH (SRC, a8b8g8r8, a8b8g8r8, 8888_8888),
1929 SIMPLE_NEAREST_FAST_PATH (SRC, x8r8g8b8, r5g6b5, 8888_565),
1930 SIMPLE_NEAREST_FAST_PATH (SRC, a8r8g8b8, r5g6b5, 8888_565),
1932 SIMPLE_NEAREST_FAST_PATH (SRC, r5g6b5, r5g6b5, 565_565),
1934 SIMPLE_NEAREST_FAST_PATH_COVER (SRC, x8r8g8b8, a8r8g8b8, x888_8888),
1935 SIMPLE_NEAREST_FAST_PATH_COVER (SRC, x8b8g8r8, a8b8g8r8, x888_8888),
1936 SIMPLE_NEAREST_FAST_PATH_PAD (SRC, x8r8g8b8, a8r8g8b8, x888_8888),
1937 SIMPLE_NEAREST_FAST_PATH_PAD (SRC, x8b8g8r8, a8b8g8r8, x888_8888),
1938 SIMPLE_NEAREST_FAST_PATH_NORMAL (SRC, x8r8g8b8, a8r8g8b8, x888_8888),
1939 SIMPLE_NEAREST_FAST_PATH_NORMAL (SRC, x8b8g8r8, a8b8g8r8, x888_8888),
1941 SIMPLE_NEAREST_FAST_PATH (OVER, a8r8g8b8, x8r8g8b8, 8888_8888),
1942 SIMPLE_NEAREST_FAST_PATH (OVER, a8b8g8r8, x8b8g8r8, 8888_8888),
1943 SIMPLE_NEAREST_FAST_PATH (OVER, a8r8g8b8, a8r8g8b8, 8888_8888),
1944 SIMPLE_NEAREST_FAST_PATH (OVER, a8b8g8r8, a8b8g8r8, 8888_8888),
1946 SIMPLE_NEAREST_FAST_PATH (OVER, a8r8g8b8, r5g6b5, 8888_565),
1948 #define NEAREST_FAST_PATH(op,s,d) \
1949 { PIXMAN_OP_ ## op, \
1950 PIXMAN_ ## s, SCALED_NEAREST_FLAGS, \
1952 PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \
1953 fast_composite_scaled_nearest, \
1956 NEAREST_FAST_PATH (SRC, x8r8g8b8, x8r8g8b8),
1957 NEAREST_FAST_PATH (SRC, a8r8g8b8, x8r8g8b8),
1958 NEAREST_FAST_PATH (SRC, x8b8g8r8, x8b8g8r8),
1959 NEAREST_FAST_PATH (SRC, a8b8g8r8, x8b8g8r8),
1961 NEAREST_FAST_PATH (SRC, x8r8g8b8, a8r8g8b8),
1962 NEAREST_FAST_PATH (SRC, a8r8g8b8, a8r8g8b8),
1963 NEAREST_FAST_PATH (SRC, x8b8g8r8, a8b8g8r8),
1964 NEAREST_FAST_PATH (SRC, a8b8g8r8, a8b8g8r8),
1966 NEAREST_FAST_PATH (OVER, x8r8g8b8, x8r8g8b8),
1967 NEAREST_FAST_PATH (OVER, a8r8g8b8, x8r8g8b8),
1968 NEAREST_FAST_PATH (OVER, x8b8g8r8, x8b8g8r8),
1969 NEAREST_FAST_PATH (OVER, a8b8g8r8, x8b8g8r8),
1971 NEAREST_FAST_PATH (OVER, x8r8g8b8, a8r8g8b8),
1972 NEAREST_FAST_PATH (OVER, a8r8g8b8, a8r8g8b8),
1973 NEAREST_FAST_PATH (OVER, x8b8g8r8, a8b8g8r8),
1974 NEAREST_FAST_PATH (OVER, a8b8g8r8, a8b8g8r8),
1976 #define SIMPLE_ROTATE_FLAGS(angle) \
1977 (FAST_PATH_ROTATE_ ## angle ## _TRANSFORM | \
1978 FAST_PATH_NEAREST_FILTER | \
1979 FAST_PATH_SAMPLES_COVER_CLIP_NEAREST | \
1980 FAST_PATH_STANDARD_FLAGS)
1982 #define SIMPLE_ROTATE_FAST_PATH(op,s,d,suffix) \
1983 { PIXMAN_OP_ ## op, \
1984 PIXMAN_ ## s, SIMPLE_ROTATE_FLAGS (90), \
1986 PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \
1987 fast_composite_rotate_90_##suffix, \
1989 { PIXMAN_OP_ ## op, \
1990 PIXMAN_ ## s, SIMPLE_ROTATE_FLAGS (270), \
1992 PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \
1993 fast_composite_rotate_270_##suffix, \
1996 SIMPLE_ROTATE_FAST_PATH (SRC, a8r8g8b8, a8r8g8b8, 8888),
1997 SIMPLE_ROTATE_FAST_PATH (SRC, a8r8g8b8, x8r8g8b8, 8888),
1998 SIMPLE_ROTATE_FAST_PATH (SRC, x8r8g8b8, x8r8g8b8, 8888),
1999 SIMPLE_ROTATE_FAST_PATH (SRC, r5g6b5, r5g6b5, 565),
2000 SIMPLE_ROTATE_FAST_PATH (SRC, a8, a8, 8),
2002 /* Simple repeat fast path entry. */
2005 (FAST_PATH_STANDARD_FLAGS | FAST_PATH_ID_TRANSFORM | FAST_PATH_BITS_IMAGE |
2006 FAST_PATH_NORMAL_REPEAT),
2008 PIXMAN_any, FAST_PATH_STD_DEST_FLAGS,
2009 fast_composite_tiled_repeat
2015 #ifdef WORDS_BIGENDIAN
2016 #define A1_FILL_MASK(n, offs) (((1U << (n)) - 1) << (32 - (offs) - (n)))
2018 #define A1_FILL_MASK(n, offs) (((1U << (n)) - 1) << (offs))
2021 static force_inline void
2022 pixman_fill1_line (uint32_t *dst, int offs, int width, int v)
2026 int leading_pixels = 32 - offs;
2027 if (leading_pixels >= width)
2030 *dst |= A1_FILL_MASK (width, offs);
2032 *dst &= ~A1_FILL_MASK (width, offs);
2038 *dst++ |= A1_FILL_MASK (leading_pixels, offs);
2040 *dst++ &= ~A1_FILL_MASK (leading_pixels, offs);
2041 width -= leading_pixels;
2047 *dst++ = 0xFFFFFFFF;
2055 *dst |= A1_FILL_MASK (width, 0);
2057 *dst &= ~A1_FILL_MASK (width, 0);
2062 pixman_fill1 (uint32_t *bits,
2070 uint32_t *dst = bits + y * stride + (x >> 5);
2077 pixman_fill1_line (dst, offs, width, 1);
2085 pixman_fill1_line (dst, offs, width, 0);
2092 pixman_fill8 (uint32_t *bits,
2100 int byte_stride = stride * (int) sizeof (uint32_t);
2101 uint8_t *dst = (uint8_t *) bits;
2102 uint8_t v = xor & 0xff;
2105 dst = dst + y * byte_stride + x;
2109 for (i = 0; i < width; ++i)
2117 pixman_fill16 (uint32_t *bits,
2126 (stride * (int)sizeof (uint32_t)) / (int)sizeof (uint16_t);
2127 uint16_t *dst = (uint16_t *)bits;
2128 uint16_t v = xor & 0xffff;
2131 dst = dst + y * short_stride + x;
2135 for (i = 0; i < width; ++i)
2138 dst += short_stride;
2143 pixman_fill32 (uint32_t *bits,
2153 bits = bits + y * stride + x;
2157 for (i = 0; i < width; ++i)
2164 static pixman_bool_t
2165 fast_path_fill (pixman_implementation_t *imp,
2178 pixman_fill1 (bits, stride, x, y, width, height, xor);
2182 pixman_fill8 (bits, stride, x, y, width, height, xor);
2186 pixman_fill16 (bits, stride, x, y, width, height, xor);
2190 pixman_fill32 (bits, stride, x, y, width, height, xor);
2194 return _pixman_implementation_fill (
2195 imp->delegate, bits, stride, bpp, x, y, width, height, xor);
2202 pixman_implementation_t *
2203 _pixman_implementation_create_fast_path (pixman_implementation_t *fallback)
2205 pixman_implementation_t *imp = _pixman_implementation_create (fallback, c_fast_paths);
2207 imp->fill = fast_path_fill;