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_8888_8888 (pixman_implementation_t *imp,
814 pixman_composite_info_t *info)
816 PIXMAN_COMPOSITE_ARGS (info);
817 uint32_t *dst_line, *dst;
818 uint32_t *src_line, *src;
819 int dst_stride, src_stride;
823 PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1);
824 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1);
829 dst_line += dst_stride;
831 src_line += src_stride;
843 UN8x4_ADD_UN8x4 (s, d);
853 fast_composite_add_n_8_8 (pixman_implementation_t *imp,
854 pixman_composite_info_t *info)
856 PIXMAN_COMPOSITE_ARGS (info);
857 uint8_t *dst_line, *dst;
858 uint8_t *mask_line, *mask;
859 int dst_stride, mask_stride;
864 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint8_t, dst_stride, dst_line, 1);
865 PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint8_t, mask_stride, mask_line, 1);
866 src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format);
872 dst_line += dst_stride;
874 mask_line += mask_stride;
887 m = MUL_UN8 (sa, a, tmp);
888 r = ADD_UN8 (m, d, tmp);
895 #ifdef WORDS_BIGENDIAN
896 #define CREATE_BITMASK(n) (0x80000000 >> (n))
897 #define UPDATE_BITMASK(n) ((n) >> 1)
899 #define CREATE_BITMASK(n) (1 << (n))
900 #define UPDATE_BITMASK(n) ((n) << 1)
903 #define TEST_BIT(p, n) \
904 (*((p) + ((n) >> 5)) & CREATE_BITMASK ((n) & 31))
905 #define SET_BIT(p, n) \
906 do { *((p) + ((n) >> 5)) |= CREATE_BITMASK ((n) & 31); } while (0);
909 fast_composite_add_1000_1000 (pixman_implementation_t *imp,
910 pixman_composite_info_t *info)
912 PIXMAN_COMPOSITE_ARGS (info);
913 uint32_t *dst_line, *dst;
914 uint32_t *src_line, *src;
915 int dst_stride, src_stride;
918 PIXMAN_IMAGE_GET_LINE (src_image, 0, src_y, uint32_t,
919 src_stride, src_line, 1);
920 PIXMAN_IMAGE_GET_LINE (dest_image, 0, dest_y, uint32_t,
921 dst_stride, dst_line, 1);
926 dst_line += dst_stride;
928 src_line += src_stride;
934 * TODO: improve performance by processing uint32_t data instead
937 if (TEST_BIT (src, src_x + w))
938 SET_BIT (dst, dest_x + w);
944 fast_composite_over_n_1_8888 (pixman_implementation_t *imp,
945 pixman_composite_info_t *info)
947 PIXMAN_COMPOSITE_ARGS (info);
949 uint32_t *dst, *dst_line;
950 uint32_t *mask, *mask_line;
951 int mask_stride, dst_stride;
952 uint32_t bitcache, bitmask;
958 src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format);
963 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t,
964 dst_stride, dst_line, 1);
965 PIXMAN_IMAGE_GET_LINE (mask_image, 0, mask_y, uint32_t,
966 mask_stride, mask_line, 1);
967 mask_line += mask_x >> 5;
974 dst_line += dst_stride;
976 mask_line += mask_stride;
980 bitmask = CREATE_BITMASK (mask_x & 31);
987 bitmask = CREATE_BITMASK (0);
989 if (bitcache & bitmask)
991 bitmask = UPDATE_BITMASK (bitmask);
1001 dst_line += dst_stride;
1003 mask_line += mask_stride;
1007 bitmask = CREATE_BITMASK (mask_x & 31);
1014 bitmask = CREATE_BITMASK (0);
1016 if (bitcache & bitmask)
1017 *dst = over (src, *dst);
1018 bitmask = UPDATE_BITMASK (bitmask);
1026 fast_composite_over_n_1_0565 (pixman_implementation_t *imp,
1027 pixman_composite_info_t *info)
1029 PIXMAN_COMPOSITE_ARGS (info);
1031 uint16_t *dst, *dst_line;
1032 uint32_t *mask, *mask_line;
1033 int mask_stride, dst_stride;
1034 uint32_t bitcache, bitmask;
1042 src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format);
1047 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint16_t,
1048 dst_stride, dst_line, 1);
1049 PIXMAN_IMAGE_GET_LINE (mask_image, 0, mask_y, uint32_t,
1050 mask_stride, mask_line, 1);
1051 mask_line += mask_x >> 5;
1055 src565 = CONVERT_8888_TO_0565 (src);
1059 dst_line += dst_stride;
1061 mask_line += mask_stride;
1065 bitmask = CREATE_BITMASK (mask_x & 31);
1072 bitmask = CREATE_BITMASK (0);
1074 if (bitcache & bitmask)
1076 bitmask = UPDATE_BITMASK (bitmask);
1086 dst_line += dst_stride;
1088 mask_line += mask_stride;
1092 bitmask = CREATE_BITMASK (mask_x & 31);
1099 bitmask = CREATE_BITMASK (0);
1101 if (bitcache & bitmask)
1103 d = over (src, CONVERT_0565_TO_0888 (*dst));
1104 *dst = CONVERT_8888_TO_0565 (d);
1106 bitmask = UPDATE_BITMASK (bitmask);
1118 fast_composite_solid_fill (pixman_implementation_t *imp,
1119 pixman_composite_info_t *info)
1121 PIXMAN_COMPOSITE_ARGS (info);
1124 src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format);
1126 if (dest_image->bits.format == PIXMAN_a1)
1130 else if (dest_image->bits.format == PIXMAN_a8)
1134 else if (dest_image->bits.format == PIXMAN_r5g6b5 ||
1135 dest_image->bits.format == PIXMAN_b5g6r5)
1137 src = CONVERT_8888_TO_0565 (src);
1140 pixman_fill (dest_image->bits.bits, dest_image->bits.rowstride,
1141 PIXMAN_FORMAT_BPP (dest_image->bits.format),
1148 fast_composite_src_memcpy (pixman_implementation_t *imp,
1149 pixman_composite_info_t *info)
1151 PIXMAN_COMPOSITE_ARGS (info);
1152 int bpp = PIXMAN_FORMAT_BPP (dest_image->bits.format) / 8;
1153 uint32_t n_bytes = width * bpp;
1154 int dst_stride, src_stride;
1158 src_stride = src_image->bits.rowstride * 4;
1159 dst_stride = dest_image->bits.rowstride * 4;
1161 src = (uint8_t *)src_image->bits.bits + src_y * src_stride + src_x * bpp;
1162 dst = (uint8_t *)dest_image->bits.bits + dest_y * dst_stride + dest_x * bpp;
1166 memcpy (dst, src, n_bytes);
1173 FAST_NEAREST (8888_8888_cover, 8888, 8888, uint32_t, uint32_t, SRC, COVER)
1174 FAST_NEAREST (8888_8888_none, 8888, 8888, uint32_t, uint32_t, SRC, NONE)
1175 FAST_NEAREST (8888_8888_pad, 8888, 8888, uint32_t, uint32_t, SRC, PAD)
1176 FAST_NEAREST (8888_8888_normal, 8888, 8888, uint32_t, uint32_t, SRC, NORMAL)
1177 FAST_NEAREST (x888_8888_cover, x888, 8888, uint32_t, uint32_t, SRC, COVER)
1178 FAST_NEAREST (x888_8888_pad, x888, 8888, uint32_t, uint32_t, SRC, PAD)
1179 FAST_NEAREST (x888_8888_normal, x888, 8888, uint32_t, uint32_t, SRC, NORMAL)
1180 FAST_NEAREST (8888_8888_cover, 8888, 8888, uint32_t, uint32_t, OVER, COVER)
1181 FAST_NEAREST (8888_8888_none, 8888, 8888, uint32_t, uint32_t, OVER, NONE)
1182 FAST_NEAREST (8888_8888_pad, 8888, 8888, uint32_t, uint32_t, OVER, PAD)
1183 FAST_NEAREST (8888_8888_normal, 8888, 8888, uint32_t, uint32_t, OVER, NORMAL)
1184 FAST_NEAREST (8888_565_cover, 8888, 0565, uint32_t, uint16_t, SRC, COVER)
1185 FAST_NEAREST (8888_565_none, 8888, 0565, uint32_t, uint16_t, SRC, NONE)
1186 FAST_NEAREST (8888_565_pad, 8888, 0565, uint32_t, uint16_t, SRC, PAD)
1187 FAST_NEAREST (8888_565_normal, 8888, 0565, uint32_t, uint16_t, SRC, NORMAL)
1188 FAST_NEAREST (565_565_normal, 0565, 0565, uint16_t, uint16_t, SRC, NORMAL)
1189 FAST_NEAREST (8888_565_cover, 8888, 0565, uint32_t, uint16_t, OVER, COVER)
1190 FAST_NEAREST (8888_565_none, 8888, 0565, uint32_t, uint16_t, OVER, NONE)
1191 FAST_NEAREST (8888_565_pad, 8888, 0565, uint32_t, uint16_t, OVER, PAD)
1192 FAST_NEAREST (8888_565_normal, 8888, 0565, uint32_t, uint16_t, OVER, NORMAL)
1194 /* Use more unrolling for src_0565_0565 because it is typically CPU bound */
1195 static force_inline void
1196 scaled_nearest_scanline_565_565_SRC (uint16_t * dst,
1197 const uint16_t * src,
1200 pixman_fixed_t unit_x,
1201 pixman_fixed_t max_vx,
1202 pixman_bool_t fully_transparent_src)
1204 uint16_t tmp1, tmp2, tmp3, tmp4;
1205 while ((w -= 4) >= 0)
1207 tmp1 = src[pixman_fixed_to_int (vx)];
1209 tmp2 = src[pixman_fixed_to_int (vx)];
1211 tmp3 = src[pixman_fixed_to_int (vx)];
1213 tmp4 = src[pixman_fixed_to_int (vx)];
1222 tmp1 = src[pixman_fixed_to_int (vx)];
1224 tmp2 = src[pixman_fixed_to_int (vx)];
1230 *dst++ = src[pixman_fixed_to_int (vx)];
1233 FAST_NEAREST_MAINLOOP (565_565_cover_SRC,
1234 scaled_nearest_scanline_565_565_SRC,
1235 uint16_t, uint16_t, COVER)
1236 FAST_NEAREST_MAINLOOP (565_565_none_SRC,
1237 scaled_nearest_scanline_565_565_SRC,
1238 uint16_t, uint16_t, NONE)
1239 FAST_NEAREST_MAINLOOP (565_565_pad_SRC,
1240 scaled_nearest_scanline_565_565_SRC,
1241 uint16_t, uint16_t, PAD)
1243 static force_inline uint32_t
1244 fetch_nearest (pixman_repeat_t src_repeat,
1245 pixman_format_code_t format,
1246 uint32_t *src, int x, int src_width)
1248 if (repeat (src_repeat, &x, src_width))
1250 if (format == PIXMAN_x8r8g8b8)
1251 return *(src + x) | 0xff000000;
1261 static force_inline void
1262 combine_over (uint32_t s, uint32_t *dst)
1266 uint8_t ia = 0xff - (s >> 24);
1269 UN8x4_MUL_UN8_ADD_UN8x4 (*dst, ia, s);
1275 static force_inline void
1276 combine_src (uint32_t s, uint32_t *dst)
1282 fast_composite_scaled_nearest (pixman_implementation_t *imp,
1283 pixman_composite_info_t *info)
1285 PIXMAN_COMPOSITE_ARGS (info);
1288 int dst_stride, src_stride;
1289 int src_width, src_height;
1290 pixman_repeat_t src_repeat;
1291 pixman_fixed_t unit_x, unit_y;
1292 pixman_format_code_t src_format;
1296 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1);
1297 /* pass in 0 instead of src_x and src_y because src_x and src_y need to be
1298 * transformed from destination space to source space
1300 PIXMAN_IMAGE_GET_LINE (src_image, 0, 0, uint32_t, src_stride, src_line, 1);
1302 /* reference point is the center of the pixel */
1303 v.vector[0] = pixman_int_to_fixed (src_x) + pixman_fixed_1 / 2;
1304 v.vector[1] = pixman_int_to_fixed (src_y) + pixman_fixed_1 / 2;
1305 v.vector[2] = pixman_fixed_1;
1307 if (!pixman_transform_point_3d (src_image->common.transform, &v))
1310 unit_x = src_image->common.transform->matrix[0][0];
1311 unit_y = src_image->common.transform->matrix[1][1];
1313 /* Round down to closest integer, ensuring that 0.5 rounds to 0, not 1 */
1314 v.vector[0] -= pixman_fixed_e;
1315 v.vector[1] -= pixman_fixed_e;
1317 src_height = src_image->bits.height;
1318 src_width = src_image->bits.width;
1319 src_repeat = src_image->common.repeat;
1320 src_format = src_image->bits.format;
1325 pixman_fixed_t vx = v.vector[0];
1326 int y = pixman_fixed_to_int (vy);
1327 uint32_t *dst = dst_line;
1329 dst_line += dst_stride;
1331 /* adjust the y location by a unit vector in the y direction
1332 * this is equivalent to transforming y+1 of the destination point to source space */
1335 if (!repeat (src_repeat, &y, src_height))
1337 if (op == PIXMAN_OP_SRC)
1338 memset (dst, 0, sizeof (*dst) * width);
1344 uint32_t *src = src_line + y * src_stride;
1351 x1 = pixman_fixed_to_int (vx);
1354 x2 = pixman_fixed_to_int (vx);
1359 s1 = fetch_nearest (src_repeat, src_format, src, x1, src_width);
1360 s2 = fetch_nearest (src_repeat, src_format, src, x2, src_width);
1362 if (op == PIXMAN_OP_OVER)
1364 combine_over (s1, dst++);
1365 combine_over (s2, dst++);
1369 combine_src (s1, dst++);
1370 combine_src (s2, dst++);
1379 x = pixman_fixed_to_int (vx);
1382 s = fetch_nearest (src_repeat, src_format, src, x, src_width);
1384 if (op == PIXMAN_OP_OVER)
1385 combine_over (s, dst++);
1387 combine_src (s, dst++);
1393 #define CACHE_LINE_SIZE 64
1395 #define FAST_SIMPLE_ROTATE(suffix, pix_type) \
1398 blt_rotated_90_trivial_##suffix (pix_type *dst, \
1400 const pix_type *src, \
1406 for (y = 0; y < h; y++) \
1408 const pix_type *s = src + (h - y - 1); \
1409 pix_type *d = dst + dst_stride * y; \
1410 for (x = 0; x < w; x++) \
1419 blt_rotated_270_trivial_##suffix (pix_type *dst, \
1421 const pix_type *src, \
1427 for (y = 0; y < h; y++) \
1429 const pix_type *s = src + src_stride * (w - 1) + y; \
1430 pix_type *d = dst + dst_stride * y; \
1431 for (x = 0; x < w; x++) \
1440 blt_rotated_90_##suffix (pix_type *dst, \
1442 const pix_type *src, \
1448 int leading_pixels = 0, trailing_pixels = 0; \
1449 const int TILE_SIZE = CACHE_LINE_SIZE / sizeof(pix_type); \
1452 * split processing into handling destination as TILE_SIZExH cache line \
1453 * aligned vertical stripes (optimistically assuming that destination \
1454 * stride is a multiple of cache line, if not - it will be just a bit \
1458 if ((uintptr_t)dst & (CACHE_LINE_SIZE - 1)) \
1460 leading_pixels = TILE_SIZE - (((uintptr_t)dst & \
1461 (CACHE_LINE_SIZE - 1)) / sizeof(pix_type)); \
1462 if (leading_pixels > W) \
1463 leading_pixels = W; \
1465 /* unaligned leading part NxH (where N < TILE_SIZE) */ \
1466 blt_rotated_90_trivial_##suffix ( \
1474 dst += leading_pixels; \
1475 src += leading_pixels * src_stride; \
1476 W -= leading_pixels; \
1479 if ((uintptr_t)(dst + W) & (CACHE_LINE_SIZE - 1)) \
1481 trailing_pixels = (((uintptr_t)(dst + W) & \
1482 (CACHE_LINE_SIZE - 1)) / sizeof(pix_type)); \
1483 if (trailing_pixels > W) \
1484 trailing_pixels = W; \
1485 W -= trailing_pixels; \
1488 for (x = 0; x < W; x += TILE_SIZE) \
1490 /* aligned middle part TILE_SIZExH */ \
1491 blt_rotated_90_trivial_##suffix ( \
1494 src + src_stride * x, \
1500 if (trailing_pixels) \
1502 /* unaligned trailing part NxH (where N < TILE_SIZE) */ \
1503 blt_rotated_90_trivial_##suffix ( \
1506 src + W * src_stride, \
1514 blt_rotated_270_##suffix (pix_type *dst, \
1516 const pix_type *src, \
1522 int leading_pixels = 0, trailing_pixels = 0; \
1523 const int TILE_SIZE = CACHE_LINE_SIZE / sizeof(pix_type); \
1526 * split processing into handling destination as TILE_SIZExH cache line \
1527 * aligned vertical stripes (optimistically assuming that destination \
1528 * stride is a multiple of cache line, if not - it will be just a bit \
1532 if ((uintptr_t)dst & (CACHE_LINE_SIZE - 1)) \
1534 leading_pixels = TILE_SIZE - (((uintptr_t)dst & \
1535 (CACHE_LINE_SIZE - 1)) / sizeof(pix_type)); \
1536 if (leading_pixels > W) \
1537 leading_pixels = W; \
1539 /* unaligned leading part NxH (where N < TILE_SIZE) */ \
1540 blt_rotated_270_trivial_##suffix ( \
1543 src + src_stride * (W - leading_pixels), \
1548 dst += leading_pixels; \
1549 W -= leading_pixels; \
1552 if ((uintptr_t)(dst + W) & (CACHE_LINE_SIZE - 1)) \
1554 trailing_pixels = (((uintptr_t)(dst + W) & \
1555 (CACHE_LINE_SIZE - 1)) / sizeof(pix_type)); \
1556 if (trailing_pixels > W) \
1557 trailing_pixels = W; \
1558 W -= trailing_pixels; \
1559 src += trailing_pixels * src_stride; \
1562 for (x = 0; x < W; x += TILE_SIZE) \
1564 /* aligned middle part TILE_SIZExH */ \
1565 blt_rotated_270_trivial_##suffix ( \
1568 src + src_stride * (W - x - TILE_SIZE), \
1574 if (trailing_pixels) \
1576 /* unaligned trailing part NxH (where N < TILE_SIZE) */ \
1577 blt_rotated_270_trivial_##suffix ( \
1580 src - trailing_pixels * src_stride, \
1588 fast_composite_rotate_90_##suffix (pixman_implementation_t *imp, \
1589 pixman_composite_info_t *info) \
1591 PIXMAN_COMPOSITE_ARGS (info); \
1592 pix_type *dst_line; \
1593 pix_type *src_line; \
1594 int dst_stride, src_stride; \
1595 int src_x_t, src_y_t; \
1597 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, pix_type, \
1598 dst_stride, dst_line, 1); \
1599 src_x_t = -src_y + pixman_fixed_to_int ( \
1600 src_image->common.transform->matrix[0][2] + \
1601 pixman_fixed_1 / 2 - pixman_fixed_e) - height;\
1602 src_y_t = src_x + pixman_fixed_to_int ( \
1603 src_image->common.transform->matrix[1][2] + \
1604 pixman_fixed_1 / 2 - pixman_fixed_e); \
1605 PIXMAN_IMAGE_GET_LINE (src_image, src_x_t, src_y_t, pix_type, \
1606 src_stride, src_line, 1); \
1607 blt_rotated_90_##suffix (dst_line, dst_stride, src_line, src_stride, \
1612 fast_composite_rotate_270_##suffix (pixman_implementation_t *imp, \
1613 pixman_composite_info_t *info) \
1615 PIXMAN_COMPOSITE_ARGS (info); \
1616 pix_type *dst_line; \
1617 pix_type *src_line; \
1618 int dst_stride, src_stride; \
1619 int src_x_t, src_y_t; \
1621 PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, pix_type, \
1622 dst_stride, dst_line, 1); \
1623 src_x_t = src_y + pixman_fixed_to_int ( \
1624 src_image->common.transform->matrix[0][2] + \
1625 pixman_fixed_1 / 2 - pixman_fixed_e); \
1626 src_y_t = -src_x + pixman_fixed_to_int ( \
1627 src_image->common.transform->matrix[1][2] + \
1628 pixman_fixed_1 / 2 - pixman_fixed_e) - width; \
1629 PIXMAN_IMAGE_GET_LINE (src_image, src_x_t, src_y_t, pix_type, \
1630 src_stride, src_line, 1); \
1631 blt_rotated_270_##suffix (dst_line, dst_stride, src_line, src_stride, \
1635 FAST_SIMPLE_ROTATE (8, uint8_t)
1636 FAST_SIMPLE_ROTATE (565, uint16_t)
1637 FAST_SIMPLE_ROTATE (8888, uint32_t)
1639 static const pixman_fast_path_t c_fast_paths[] =
1641 PIXMAN_STD_FAST_PATH (OVER, solid, a8, r5g6b5, fast_composite_over_n_8_0565),
1642 PIXMAN_STD_FAST_PATH (OVER, solid, a8, b5g6r5, fast_composite_over_n_8_0565),
1643 PIXMAN_STD_FAST_PATH (OVER, solid, a8, r8g8b8, fast_composite_over_n_8_0888),
1644 PIXMAN_STD_FAST_PATH (OVER, solid, a8, b8g8r8, fast_composite_over_n_8_0888),
1645 PIXMAN_STD_FAST_PATH (OVER, solid, a8, a8r8g8b8, fast_composite_over_n_8_8888),
1646 PIXMAN_STD_FAST_PATH (OVER, solid, a8, x8r8g8b8, fast_composite_over_n_8_8888),
1647 PIXMAN_STD_FAST_PATH (OVER, solid, a8, a8b8g8r8, fast_composite_over_n_8_8888),
1648 PIXMAN_STD_FAST_PATH (OVER, solid, a8, x8b8g8r8, fast_composite_over_n_8_8888),
1649 PIXMAN_STD_FAST_PATH (OVER, solid, a1, a8r8g8b8, fast_composite_over_n_1_8888),
1650 PIXMAN_STD_FAST_PATH (OVER, solid, a1, x8r8g8b8, fast_composite_over_n_1_8888),
1651 PIXMAN_STD_FAST_PATH (OVER, solid, a1, a8b8g8r8, fast_composite_over_n_1_8888),
1652 PIXMAN_STD_FAST_PATH (OVER, solid, a1, x8b8g8r8, fast_composite_over_n_1_8888),
1653 PIXMAN_STD_FAST_PATH (OVER, solid, a1, r5g6b5, fast_composite_over_n_1_0565),
1654 PIXMAN_STD_FAST_PATH (OVER, solid, a1, b5g6r5, fast_composite_over_n_1_0565),
1655 PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8r8g8b8, a8r8g8b8, fast_composite_over_n_8888_8888_ca),
1656 PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8r8g8b8, x8r8g8b8, fast_composite_over_n_8888_8888_ca),
1657 PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8r8g8b8, r5g6b5, fast_composite_over_n_8888_0565_ca),
1658 PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8b8g8r8, a8b8g8r8, fast_composite_over_n_8888_8888_ca),
1659 PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8b8g8r8, x8b8g8r8, fast_composite_over_n_8888_8888_ca),
1660 PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8b8g8r8, b5g6r5, fast_composite_over_n_8888_0565_ca),
1661 PIXMAN_STD_FAST_PATH (OVER, x8r8g8b8, a8, x8r8g8b8, fast_composite_over_x888_8_8888),
1662 PIXMAN_STD_FAST_PATH (OVER, x8r8g8b8, a8, a8r8g8b8, fast_composite_over_x888_8_8888),
1663 PIXMAN_STD_FAST_PATH (OVER, x8b8g8r8, a8, x8b8g8r8, fast_composite_over_x888_8_8888),
1664 PIXMAN_STD_FAST_PATH (OVER, x8b8g8r8, a8, a8b8g8r8, fast_composite_over_x888_8_8888),
1665 PIXMAN_STD_FAST_PATH (OVER, a8r8g8b8, null, a8r8g8b8, fast_composite_over_8888_8888),
1666 PIXMAN_STD_FAST_PATH (OVER, a8r8g8b8, null, x8r8g8b8, fast_composite_over_8888_8888),
1667 PIXMAN_STD_FAST_PATH (OVER, a8r8g8b8, null, r5g6b5, fast_composite_over_8888_0565),
1668 PIXMAN_STD_FAST_PATH (OVER, a8b8g8r8, null, a8b8g8r8, fast_composite_over_8888_8888),
1669 PIXMAN_STD_FAST_PATH (OVER, a8b8g8r8, null, x8b8g8r8, fast_composite_over_8888_8888),
1670 PIXMAN_STD_FAST_PATH (OVER, a8b8g8r8, null, b5g6r5, fast_composite_over_8888_0565),
1671 PIXMAN_STD_FAST_PATH (ADD, a8r8g8b8, null, a8r8g8b8, fast_composite_add_8888_8888),
1672 PIXMAN_STD_FAST_PATH (ADD, a8b8g8r8, null, a8b8g8r8, fast_composite_add_8888_8888),
1673 PIXMAN_STD_FAST_PATH (ADD, a8, null, a8, fast_composite_add_8_8),
1674 PIXMAN_STD_FAST_PATH (ADD, a1, null, a1, fast_composite_add_1000_1000),
1675 PIXMAN_STD_FAST_PATH_CA (ADD, solid, a8r8g8b8, a8r8g8b8, fast_composite_add_n_8888_8888_ca),
1676 PIXMAN_STD_FAST_PATH (ADD, solid, a8, a8, fast_composite_add_n_8_8),
1677 PIXMAN_STD_FAST_PATH (SRC, solid, null, a8r8g8b8, fast_composite_solid_fill),
1678 PIXMAN_STD_FAST_PATH (SRC, solid, null, x8r8g8b8, fast_composite_solid_fill),
1679 PIXMAN_STD_FAST_PATH (SRC, solid, null, a8b8g8r8, fast_composite_solid_fill),
1680 PIXMAN_STD_FAST_PATH (SRC, solid, null, x8b8g8r8, fast_composite_solid_fill),
1681 PIXMAN_STD_FAST_PATH (SRC, solid, null, a1, fast_composite_solid_fill),
1682 PIXMAN_STD_FAST_PATH (SRC, solid, null, a8, fast_composite_solid_fill),
1683 PIXMAN_STD_FAST_PATH (SRC, solid, null, r5g6b5, fast_composite_solid_fill),
1684 PIXMAN_STD_FAST_PATH (SRC, x8r8g8b8, null, a8r8g8b8, fast_composite_src_x888_8888),
1685 PIXMAN_STD_FAST_PATH (SRC, x8b8g8r8, null, a8b8g8r8, fast_composite_src_x888_8888),
1686 PIXMAN_STD_FAST_PATH (SRC, a8r8g8b8, null, x8r8g8b8, fast_composite_src_memcpy),
1687 PIXMAN_STD_FAST_PATH (SRC, a8r8g8b8, null, a8r8g8b8, fast_composite_src_memcpy),
1688 PIXMAN_STD_FAST_PATH (SRC, x8r8g8b8, null, x8r8g8b8, fast_composite_src_memcpy),
1689 PIXMAN_STD_FAST_PATH (SRC, a8b8g8r8, null, x8b8g8r8, fast_composite_src_memcpy),
1690 PIXMAN_STD_FAST_PATH (SRC, a8b8g8r8, null, a8b8g8r8, fast_composite_src_memcpy),
1691 PIXMAN_STD_FAST_PATH (SRC, x8b8g8r8, null, x8b8g8r8, fast_composite_src_memcpy),
1692 PIXMAN_STD_FAST_PATH (SRC, b8g8r8a8, null, b8g8r8x8, fast_composite_src_memcpy),
1693 PIXMAN_STD_FAST_PATH (SRC, b8g8r8a8, null, b8g8r8a8, fast_composite_src_memcpy),
1694 PIXMAN_STD_FAST_PATH (SRC, b8g8r8x8, null, b8g8r8x8, fast_composite_src_memcpy),
1695 PIXMAN_STD_FAST_PATH (SRC, r5g6b5, null, r5g6b5, fast_composite_src_memcpy),
1696 PIXMAN_STD_FAST_PATH (SRC, b5g6r5, null, b5g6r5, fast_composite_src_memcpy),
1697 PIXMAN_STD_FAST_PATH (SRC, r8g8b8, null, r8g8b8, fast_composite_src_memcpy),
1698 PIXMAN_STD_FAST_PATH (SRC, b8g8r8, null, b8g8r8, fast_composite_src_memcpy),
1699 PIXMAN_STD_FAST_PATH (SRC, x1r5g5b5, null, x1r5g5b5, fast_composite_src_memcpy),
1700 PIXMAN_STD_FAST_PATH (SRC, a1r5g5b5, null, x1r5g5b5, fast_composite_src_memcpy),
1701 PIXMAN_STD_FAST_PATH (SRC, a8, null, a8, fast_composite_src_memcpy),
1702 PIXMAN_STD_FAST_PATH (SRC, a8r8g8b8, null, r5g6b5, fast_composite_src_x888_0565),
1703 PIXMAN_STD_FAST_PATH (SRC, x8r8g8b8, null, r5g6b5, fast_composite_src_x888_0565),
1704 PIXMAN_STD_FAST_PATH (SRC, a8b8g8r8, null, b5g6r5, fast_composite_src_x888_0565),
1705 PIXMAN_STD_FAST_PATH (SRC, x8b8g8r8, null, b5g6r5, fast_composite_src_x888_0565),
1706 PIXMAN_STD_FAST_PATH (IN, a8, null, a8, fast_composite_in_8_8),
1707 PIXMAN_STD_FAST_PATH (IN, solid, a8, a8, fast_composite_in_n_8_8),
1709 SIMPLE_NEAREST_FAST_PATH (SRC, x8r8g8b8, x8r8g8b8, 8888_8888),
1710 SIMPLE_NEAREST_FAST_PATH (SRC, a8r8g8b8, x8r8g8b8, 8888_8888),
1711 SIMPLE_NEAREST_FAST_PATH (SRC, x8b8g8r8, x8b8g8r8, 8888_8888),
1712 SIMPLE_NEAREST_FAST_PATH (SRC, a8b8g8r8, x8b8g8r8, 8888_8888),
1714 SIMPLE_NEAREST_FAST_PATH (SRC, a8r8g8b8, a8r8g8b8, 8888_8888),
1715 SIMPLE_NEAREST_FAST_PATH (SRC, a8b8g8r8, a8b8g8r8, 8888_8888),
1717 SIMPLE_NEAREST_FAST_PATH (SRC, x8r8g8b8, r5g6b5, 8888_565),
1718 SIMPLE_NEAREST_FAST_PATH (SRC, a8r8g8b8, r5g6b5, 8888_565),
1720 SIMPLE_NEAREST_FAST_PATH (SRC, r5g6b5, r5g6b5, 565_565),
1722 SIMPLE_NEAREST_FAST_PATH_COVER (SRC, x8r8g8b8, a8r8g8b8, x888_8888),
1723 SIMPLE_NEAREST_FAST_PATH_COVER (SRC, x8b8g8r8, a8b8g8r8, x888_8888),
1724 SIMPLE_NEAREST_FAST_PATH_PAD (SRC, x8r8g8b8, a8r8g8b8, x888_8888),
1725 SIMPLE_NEAREST_FAST_PATH_PAD (SRC, x8b8g8r8, a8b8g8r8, x888_8888),
1726 SIMPLE_NEAREST_FAST_PATH_NORMAL (SRC, x8r8g8b8, a8r8g8b8, x888_8888),
1727 SIMPLE_NEAREST_FAST_PATH_NORMAL (SRC, x8b8g8r8, a8b8g8r8, x888_8888),
1729 SIMPLE_NEAREST_FAST_PATH (OVER, a8r8g8b8, x8r8g8b8, 8888_8888),
1730 SIMPLE_NEAREST_FAST_PATH (OVER, a8b8g8r8, x8b8g8r8, 8888_8888),
1731 SIMPLE_NEAREST_FAST_PATH (OVER, a8r8g8b8, a8r8g8b8, 8888_8888),
1732 SIMPLE_NEAREST_FAST_PATH (OVER, a8b8g8r8, a8b8g8r8, 8888_8888),
1734 SIMPLE_NEAREST_FAST_PATH (OVER, a8r8g8b8, r5g6b5, 8888_565),
1736 #define NEAREST_FAST_PATH(op,s,d) \
1737 { PIXMAN_OP_ ## op, \
1738 PIXMAN_ ## s, SCALED_NEAREST_FLAGS, \
1740 PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \
1741 fast_composite_scaled_nearest, \
1744 NEAREST_FAST_PATH (SRC, x8r8g8b8, x8r8g8b8),
1745 NEAREST_FAST_PATH (SRC, a8r8g8b8, x8r8g8b8),
1746 NEAREST_FAST_PATH (SRC, x8b8g8r8, x8b8g8r8),
1747 NEAREST_FAST_PATH (SRC, a8b8g8r8, x8b8g8r8),
1749 NEAREST_FAST_PATH (SRC, x8r8g8b8, a8r8g8b8),
1750 NEAREST_FAST_PATH (SRC, a8r8g8b8, a8r8g8b8),
1751 NEAREST_FAST_PATH (SRC, x8b8g8r8, a8b8g8r8),
1752 NEAREST_FAST_PATH (SRC, a8b8g8r8, a8b8g8r8),
1754 NEAREST_FAST_PATH (OVER, x8r8g8b8, x8r8g8b8),
1755 NEAREST_FAST_PATH (OVER, a8r8g8b8, x8r8g8b8),
1756 NEAREST_FAST_PATH (OVER, x8b8g8r8, x8b8g8r8),
1757 NEAREST_FAST_PATH (OVER, a8b8g8r8, x8b8g8r8),
1759 NEAREST_FAST_PATH (OVER, x8r8g8b8, a8r8g8b8),
1760 NEAREST_FAST_PATH (OVER, a8r8g8b8, a8r8g8b8),
1761 NEAREST_FAST_PATH (OVER, x8b8g8r8, a8b8g8r8),
1762 NEAREST_FAST_PATH (OVER, a8b8g8r8, a8b8g8r8),
1764 #define SIMPLE_ROTATE_FLAGS(angle) \
1765 (FAST_PATH_ROTATE_ ## angle ## _TRANSFORM | \
1766 FAST_PATH_NEAREST_FILTER | \
1767 FAST_PATH_SAMPLES_COVER_CLIP_NEAREST | \
1768 FAST_PATH_STANDARD_FLAGS)
1770 #define SIMPLE_ROTATE_FAST_PATH(op,s,d,suffix) \
1771 { PIXMAN_OP_ ## op, \
1772 PIXMAN_ ## s, SIMPLE_ROTATE_FLAGS (90), \
1774 PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \
1775 fast_composite_rotate_90_##suffix, \
1777 { PIXMAN_OP_ ## op, \
1778 PIXMAN_ ## s, SIMPLE_ROTATE_FLAGS (270), \
1780 PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \
1781 fast_composite_rotate_270_##suffix, \
1784 SIMPLE_ROTATE_FAST_PATH (SRC, a8r8g8b8, a8r8g8b8, 8888),
1785 SIMPLE_ROTATE_FAST_PATH (SRC, a8r8g8b8, x8r8g8b8, 8888),
1786 SIMPLE_ROTATE_FAST_PATH (SRC, x8r8g8b8, x8r8g8b8, 8888),
1787 SIMPLE_ROTATE_FAST_PATH (SRC, r5g6b5, r5g6b5, 565),
1788 SIMPLE_ROTATE_FAST_PATH (SRC, a8, a8, 8),
1793 #ifdef WORDS_BIGENDIAN
1794 #define A1_FILL_MASK(n, offs) (((1 << (n)) - 1) << (32 - (offs) - (n)))
1796 #define A1_FILL_MASK(n, offs) (((1 << (n)) - 1) << (offs))
1799 static force_inline void
1800 pixman_fill1_line (uint32_t *dst, int offs, int width, int v)
1804 int leading_pixels = 32 - offs;
1805 if (leading_pixels >= width)
1808 *dst |= A1_FILL_MASK (width, offs);
1810 *dst &= ~A1_FILL_MASK (width, offs);
1816 *dst++ |= A1_FILL_MASK (leading_pixels, offs);
1818 *dst++ &= ~A1_FILL_MASK (leading_pixels, offs);
1819 width -= leading_pixels;
1825 *dst++ = 0xFFFFFFFF;
1833 *dst |= A1_FILL_MASK (width, 0);
1835 *dst &= ~A1_FILL_MASK (width, 0);
1840 pixman_fill1 (uint32_t *bits,
1848 uint32_t *dst = bits + y * stride + (x >> 5);
1855 pixman_fill1_line (dst, offs, width, 1);
1863 pixman_fill1_line (dst, offs, width, 0);
1870 pixman_fill8 (uint32_t *bits,
1878 int byte_stride = stride * (int) sizeof (uint32_t);
1879 uint8_t *dst = (uint8_t *) bits;
1880 uint8_t v = xor & 0xff;
1883 dst = dst + y * byte_stride + x;
1887 for (i = 0; i < width; ++i)
1895 pixman_fill16 (uint32_t *bits,
1904 (stride * (int)sizeof (uint32_t)) / (int)sizeof (uint16_t);
1905 uint16_t *dst = (uint16_t *)bits;
1906 uint16_t v = xor & 0xffff;
1909 dst = dst + y * short_stride + x;
1913 for (i = 0; i < width; ++i)
1916 dst += short_stride;
1921 pixman_fill32 (uint32_t *bits,
1931 bits = bits + y * stride + x;
1935 for (i = 0; i < width; ++i)
1942 static pixman_bool_t
1943 fast_path_fill (pixman_implementation_t *imp,
1956 pixman_fill1 (bits, stride, x, y, width, height, xor);
1960 pixman_fill8 (bits, stride, x, y, width, height, xor);
1964 pixman_fill16 (bits, stride, x, y, width, height, xor);
1968 pixman_fill32 (bits, stride, x, y, width, height, xor);
1972 return _pixman_implementation_fill (
1973 imp->delegate, bits, stride, bpp, x, y, width, height, xor);
1980 pixman_implementation_t *
1981 _pixman_implementation_create_fast_path (pixman_implementation_t *fallback)
1983 pixman_implementation_t *imp = _pixman_implementation_create (fallback, c_fast_paths);
1985 imp->fill = fast_path_fill;