michael@0: /* -*- Mode: c; c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t; -*- */ michael@0: /* michael@0: * Copyright © 2000 SuSE, Inc. michael@0: * Copyright © 2007 Red Hat, Inc. michael@0: * michael@0: * Permission to use, copy, modify, distribute, and sell this software and its michael@0: * documentation for any purpose is hereby granted without fee, provided that michael@0: * the above copyright notice appear in all copies and that both that michael@0: * copyright notice and this permission notice appear in supporting michael@0: * documentation, and that the name of SuSE not be used in advertising or michael@0: * publicity pertaining to distribution of the software without specific, michael@0: * written prior permission. SuSE makes no representations about the michael@0: * suitability of this software for any purpose. It is provided "as is" michael@0: * without express or implied warranty. michael@0: * michael@0: * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL michael@0: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE michael@0: * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES michael@0: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION michael@0: * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN michael@0: * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. michael@0: * michael@0: * Author: Keith Packard, SuSE, Inc. michael@0: */ michael@0: michael@0: #ifdef HAVE_CONFIG_H michael@0: #include michael@0: #endif michael@0: #include michael@0: #include michael@0: #include "pixman-private.h" michael@0: #include "pixman-combine32.h" michael@0: #include "pixman-inlines.h" michael@0: michael@0: static force_inline uint32_t michael@0: fetch_24 (uint8_t *a) michael@0: { michael@0: if (((uintptr_t)a) & 1) michael@0: { michael@0: #ifdef WORDS_BIGENDIAN michael@0: return (*a << 16) | (*(uint16_t *)(a + 1)); michael@0: #else michael@0: return *a | (*(uint16_t *)(a + 1) << 8); michael@0: #endif michael@0: } michael@0: else michael@0: { michael@0: #ifdef WORDS_BIGENDIAN michael@0: return (*(uint16_t *)a << 8) | *(a + 2); michael@0: #else michael@0: return *(uint16_t *)a | (*(a + 2) << 16); michael@0: #endif michael@0: } michael@0: } michael@0: michael@0: static force_inline void michael@0: store_24 (uint8_t *a, michael@0: uint32_t v) michael@0: { michael@0: if (((uintptr_t)a) & 1) michael@0: { michael@0: #ifdef WORDS_BIGENDIAN michael@0: *a = (uint8_t) (v >> 16); michael@0: *(uint16_t *)(a + 1) = (uint16_t) (v); michael@0: #else michael@0: *a = (uint8_t) (v); michael@0: *(uint16_t *)(a + 1) = (uint16_t) (v >> 8); michael@0: #endif michael@0: } michael@0: else michael@0: { michael@0: #ifdef WORDS_BIGENDIAN michael@0: *(uint16_t *)a = (uint16_t)(v >> 8); michael@0: *(a + 2) = (uint8_t)v; michael@0: #else michael@0: *(uint16_t *)a = (uint16_t)v; michael@0: *(a + 2) = (uint8_t)(v >> 16); michael@0: #endif michael@0: } michael@0: } michael@0: michael@0: static force_inline uint32_t michael@0: over (uint32_t src, michael@0: uint32_t dest) michael@0: { michael@0: uint32_t a = ~src >> 24; michael@0: michael@0: UN8x4_MUL_UN8_ADD_UN8x4 (dest, a, src); michael@0: michael@0: return dest; michael@0: } michael@0: michael@0: static force_inline uint32_t michael@0: in (uint32_t x, michael@0: uint8_t y) michael@0: { michael@0: uint16_t a = y; michael@0: michael@0: UN8x4_MUL_UN8 (x, a); michael@0: michael@0: return x; michael@0: } michael@0: michael@0: /* michael@0: * Naming convention: michael@0: * michael@0: * op_src_mask_dest michael@0: */ michael@0: static void michael@0: fast_composite_over_x888_8_8888 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t *src, *src_line; michael@0: uint32_t *dst, *dst_line; michael@0: uint8_t *mask, *mask_line; michael@0: int src_stride, mask_stride, dst_stride; michael@0: uint8_t m; michael@0: uint32_t s, d; michael@0: int32_t w; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint8_t, mask_stride, mask_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1); michael@0: michael@0: while (height--) michael@0: { michael@0: src = src_line; michael@0: src_line += src_stride; michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: mask = mask_line; michael@0: mask_line += mask_stride; michael@0: michael@0: w = width; michael@0: while (w--) michael@0: { michael@0: m = *mask++; michael@0: if (m) michael@0: { michael@0: s = *src | 0xff000000; michael@0: michael@0: if (m == 0xff) michael@0: { michael@0: *dst = s; michael@0: } michael@0: else michael@0: { michael@0: d = in (s, m); michael@0: *dst = over (d, *dst); michael@0: } michael@0: } michael@0: src++; michael@0: dst++; michael@0: } michael@0: } michael@0: } michael@0: michael@0: static void michael@0: fast_composite_in_n_8_8 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t src, srca; michael@0: uint8_t *dst_line, *dst; michael@0: uint8_t *mask_line, *mask, m; michael@0: int dst_stride, mask_stride; michael@0: int32_t w; michael@0: uint16_t t; michael@0: michael@0: src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format); michael@0: michael@0: srca = src >> 24; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint8_t, dst_stride, dst_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint8_t, mask_stride, mask_line, 1); michael@0: michael@0: if (srca == 0xff) michael@0: { michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: mask = mask_line; michael@0: mask_line += mask_stride; michael@0: w = width; michael@0: michael@0: while (w--) michael@0: { michael@0: m = *mask++; michael@0: michael@0: if (m == 0) michael@0: *dst = 0; michael@0: else if (m != 0xff) michael@0: *dst = MUL_UN8 (m, *dst, t); michael@0: michael@0: dst++; michael@0: } michael@0: } michael@0: } michael@0: else michael@0: { michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: mask = mask_line; michael@0: mask_line += mask_stride; michael@0: w = width; michael@0: michael@0: while (w--) michael@0: { michael@0: m = *mask++; michael@0: m = MUL_UN8 (m, srca, t); michael@0: michael@0: if (m == 0) michael@0: *dst = 0; michael@0: else if (m != 0xff) michael@0: *dst = MUL_UN8 (m, *dst, t); michael@0: michael@0: dst++; michael@0: } michael@0: } michael@0: } michael@0: } michael@0: michael@0: static void michael@0: fast_composite_in_8_8 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint8_t *dst_line, *dst; michael@0: uint8_t *src_line, *src; michael@0: int dst_stride, src_stride; michael@0: int32_t w; michael@0: uint8_t s; michael@0: uint16_t t; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint8_t, src_stride, src_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint8_t, dst_stride, dst_line, 1); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: src = src_line; michael@0: src_line += src_stride; michael@0: w = width; michael@0: michael@0: while (w--) michael@0: { michael@0: s = *src++; michael@0: michael@0: if (s == 0) michael@0: *dst = 0; michael@0: else if (s != 0xff) michael@0: *dst = MUL_UN8 (s, *dst, t); michael@0: michael@0: dst++; michael@0: } michael@0: } michael@0: } michael@0: michael@0: static void michael@0: fast_composite_over_n_8_8888 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t src, srca; michael@0: uint32_t *dst_line, *dst, d; michael@0: uint8_t *mask_line, *mask, m; michael@0: int dst_stride, mask_stride; michael@0: int32_t w; michael@0: michael@0: src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format); michael@0: michael@0: srca = src >> 24; michael@0: if (src == 0) michael@0: return; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint8_t, mask_stride, mask_line, 1); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: mask = mask_line; michael@0: mask_line += mask_stride; michael@0: w = width; michael@0: michael@0: while (w--) michael@0: { michael@0: m = *mask++; michael@0: if (m == 0xff) michael@0: { michael@0: if (srca == 0xff) michael@0: *dst = src; michael@0: else michael@0: *dst = over (src, *dst); michael@0: } michael@0: else if (m) michael@0: { michael@0: d = in (src, m); michael@0: *dst = over (d, *dst); michael@0: } michael@0: dst++; michael@0: } michael@0: } michael@0: } michael@0: michael@0: static void michael@0: fast_composite_add_n_8888_8888_ca (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t src, s; michael@0: uint32_t *dst_line, *dst, d; michael@0: uint32_t *mask_line, *mask, ma; michael@0: int dst_stride, mask_stride; michael@0: int32_t w; michael@0: michael@0: src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format); michael@0: michael@0: if (src == 0) michael@0: return; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint32_t, mask_stride, mask_line, 1); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: mask = mask_line; michael@0: mask_line += mask_stride; michael@0: w = width; michael@0: michael@0: while (w--) michael@0: { michael@0: ma = *mask++; michael@0: michael@0: if (ma) michael@0: { michael@0: d = *dst; michael@0: s = src; michael@0: michael@0: UN8x4_MUL_UN8x4_ADD_UN8x4 (s, ma, d); michael@0: michael@0: *dst = s; michael@0: } michael@0: michael@0: dst++; michael@0: } michael@0: } michael@0: } michael@0: michael@0: static void michael@0: fast_composite_over_n_8888_8888_ca (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t src, srca, s; michael@0: uint32_t *dst_line, *dst, d; michael@0: uint32_t *mask_line, *mask, ma; michael@0: int dst_stride, mask_stride; michael@0: int32_t w; michael@0: michael@0: src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format); michael@0: michael@0: srca = src >> 24; michael@0: if (src == 0) michael@0: return; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint32_t, mask_stride, mask_line, 1); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: mask = mask_line; michael@0: mask_line += mask_stride; michael@0: w = width; michael@0: michael@0: while (w--) michael@0: { michael@0: ma = *mask++; michael@0: if (ma == 0xffffffff) michael@0: { michael@0: if (srca == 0xff) michael@0: *dst = src; michael@0: else michael@0: *dst = over (src, *dst); michael@0: } michael@0: else if (ma) michael@0: { michael@0: d = *dst; michael@0: s = src; michael@0: michael@0: UN8x4_MUL_UN8x4 (s, ma); michael@0: UN8x4_MUL_UN8 (ma, srca); michael@0: ma = ~ma; michael@0: UN8x4_MUL_UN8x4_ADD_UN8x4 (d, ma, s); michael@0: michael@0: *dst = d; michael@0: } michael@0: michael@0: dst++; michael@0: } michael@0: } michael@0: } michael@0: michael@0: static void michael@0: fast_composite_over_n_8_0888 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t src, srca; michael@0: uint8_t *dst_line, *dst; michael@0: uint32_t d; michael@0: uint8_t *mask_line, *mask, m; michael@0: int dst_stride, mask_stride; michael@0: int32_t w; michael@0: michael@0: src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format); michael@0: michael@0: srca = src >> 24; michael@0: if (src == 0) michael@0: return; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint8_t, dst_stride, dst_line, 3); michael@0: PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint8_t, mask_stride, mask_line, 1); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: mask = mask_line; michael@0: mask_line += mask_stride; michael@0: w = width; michael@0: michael@0: while (w--) michael@0: { michael@0: m = *mask++; michael@0: if (m == 0xff) michael@0: { michael@0: if (srca == 0xff) michael@0: { michael@0: d = src; michael@0: } michael@0: else michael@0: { michael@0: d = fetch_24 (dst); michael@0: d = over (src, d); michael@0: } michael@0: store_24 (dst, d); michael@0: } michael@0: else if (m) michael@0: { michael@0: d = over (in (src, m), fetch_24 (dst)); michael@0: store_24 (dst, d); michael@0: } michael@0: dst += 3; michael@0: } michael@0: } michael@0: } michael@0: michael@0: static void michael@0: fast_composite_over_n_8_0565 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t src, srca; michael@0: uint16_t *dst_line, *dst; michael@0: uint32_t d; michael@0: uint8_t *mask_line, *mask, m; michael@0: int dst_stride, mask_stride; michael@0: int32_t w; michael@0: michael@0: src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format); michael@0: michael@0: srca = src >> 24; michael@0: if (src == 0) michael@0: return; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint16_t, dst_stride, dst_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint8_t, mask_stride, mask_line, 1); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: mask = mask_line; michael@0: mask_line += mask_stride; michael@0: w = width; michael@0: michael@0: while (w--) michael@0: { michael@0: m = *mask++; michael@0: if (m == 0xff) michael@0: { michael@0: if (srca == 0xff) michael@0: { michael@0: d = src; michael@0: } michael@0: else michael@0: { michael@0: d = *dst; michael@0: d = over (src, convert_0565_to_0888 (d)); michael@0: } michael@0: *dst = convert_8888_to_0565 (d); michael@0: } michael@0: else if (m) michael@0: { michael@0: d = *dst; michael@0: d = over (in (src, m), convert_0565_to_0888 (d)); michael@0: *dst = convert_8888_to_0565 (d); michael@0: } michael@0: dst++; michael@0: } michael@0: } michael@0: } michael@0: michael@0: static void michael@0: fast_composite_over_n_8888_0565_ca (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t src, srca, s; michael@0: uint16_t src16; michael@0: uint16_t *dst_line, *dst; michael@0: uint32_t d; michael@0: uint32_t *mask_line, *mask, ma; michael@0: int dst_stride, mask_stride; michael@0: int32_t w; michael@0: michael@0: src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format); michael@0: michael@0: srca = src >> 24; michael@0: if (src == 0) michael@0: return; michael@0: michael@0: src16 = convert_8888_to_0565 (src); michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint16_t, dst_stride, dst_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint32_t, mask_stride, mask_line, 1); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: mask = mask_line; michael@0: mask_line += mask_stride; michael@0: w = width; michael@0: michael@0: while (w--) michael@0: { michael@0: ma = *mask++; michael@0: if (ma == 0xffffffff) michael@0: { michael@0: if (srca == 0xff) michael@0: { michael@0: *dst = src16; michael@0: } michael@0: else michael@0: { michael@0: d = *dst; michael@0: d = over (src, convert_0565_to_0888 (d)); michael@0: *dst = convert_8888_to_0565 (d); michael@0: } michael@0: } michael@0: else if (ma) michael@0: { michael@0: d = *dst; michael@0: d = convert_0565_to_0888 (d); michael@0: michael@0: s = src; michael@0: michael@0: UN8x4_MUL_UN8x4 (s, ma); michael@0: UN8x4_MUL_UN8 (ma, srca); michael@0: ma = ~ma; michael@0: UN8x4_MUL_UN8x4_ADD_UN8x4 (d, ma, s); michael@0: michael@0: *dst = convert_8888_to_0565 (d); michael@0: } michael@0: dst++; michael@0: } michael@0: } michael@0: } michael@0: michael@0: static void michael@0: fast_composite_over_8888_8888 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t *dst_line, *dst; michael@0: uint32_t *src_line, *src, s; michael@0: int dst_stride, src_stride; michael@0: uint8_t a; michael@0: int32_t w; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: src = src_line; michael@0: src_line += src_stride; michael@0: w = width; michael@0: michael@0: while (w--) michael@0: { michael@0: s = *src++; michael@0: a = s >> 24; michael@0: if (a == 0xff) michael@0: *dst = s; michael@0: else if (s) michael@0: *dst = over (s, *dst); michael@0: dst++; michael@0: } michael@0: } michael@0: } michael@0: michael@0: static void michael@0: fast_composite_src_x888_8888 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t *dst_line, *dst; michael@0: uint32_t *src_line, *src; michael@0: int dst_stride, src_stride; michael@0: int32_t w; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: src = src_line; michael@0: src_line += src_stride; michael@0: w = width; michael@0: michael@0: while (w--) michael@0: *dst++ = (*src++) | 0xff000000; michael@0: } michael@0: } michael@0: michael@0: #if 0 michael@0: static void michael@0: fast_composite_over_8888_0888 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint8_t *dst_line, *dst; michael@0: uint32_t d; michael@0: uint32_t *src_line, *src, s; michael@0: uint8_t a; michael@0: int dst_stride, src_stride; michael@0: int32_t w; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint8_t, dst_stride, dst_line, 3); michael@0: PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: src = src_line; michael@0: src_line += src_stride; michael@0: w = width; michael@0: michael@0: while (w--) michael@0: { michael@0: s = *src++; michael@0: a = s >> 24; michael@0: if (a) michael@0: { michael@0: if (a == 0xff) michael@0: d = s; michael@0: else michael@0: d = over (s, fetch_24 (dst)); michael@0: michael@0: store_24 (dst, d); michael@0: } michael@0: dst += 3; michael@0: } michael@0: } michael@0: } michael@0: #endif michael@0: michael@0: static void michael@0: fast_composite_over_8888_0565 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint16_t *dst_line, *dst; michael@0: uint32_t d; michael@0: uint32_t *src_line, *src, s; michael@0: uint8_t a; michael@0: int dst_stride, src_stride; michael@0: int32_t w; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint16_t, dst_stride, dst_line, 1); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: src = src_line; michael@0: src_line += src_stride; michael@0: w = width; michael@0: michael@0: while (w--) michael@0: { michael@0: s = *src++; michael@0: a = s >> 24; michael@0: if (s) michael@0: { michael@0: if (a == 0xff) michael@0: { michael@0: d = s; michael@0: } michael@0: else michael@0: { michael@0: d = *dst; michael@0: d = over (s, convert_0565_to_0888 (d)); michael@0: } michael@0: *dst = convert_8888_to_0565 (d); michael@0: } michael@0: dst++; michael@0: } michael@0: } michael@0: } michael@0: michael@0: static void michael@0: fast_composite_add_8_8 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint8_t *dst_line, *dst; michael@0: uint8_t *src_line, *src; michael@0: int dst_stride, src_stride; michael@0: int32_t w; michael@0: uint8_t s, d; michael@0: uint16_t t; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint8_t, src_stride, src_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint8_t, dst_stride, dst_line, 1); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: src = src_line; michael@0: src_line += src_stride; michael@0: w = width; michael@0: michael@0: while (w--) michael@0: { michael@0: s = *src++; michael@0: if (s) michael@0: { michael@0: if (s != 0xff) michael@0: { michael@0: d = *dst; michael@0: t = d + s; michael@0: s = t | (0 - (t >> 8)); michael@0: } michael@0: *dst = s; michael@0: } michael@0: dst++; michael@0: } michael@0: } michael@0: } michael@0: michael@0: static void michael@0: fast_composite_add_0565_0565 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint16_t *dst_line, *dst; michael@0: uint32_t d; michael@0: uint16_t *src_line, *src; michael@0: uint32_t s; michael@0: int dst_stride, src_stride; michael@0: int32_t w; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint16_t, src_stride, src_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint16_t, dst_stride, dst_line, 1); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: src = src_line; michael@0: src_line += src_stride; michael@0: w = width; michael@0: michael@0: while (w--) michael@0: { michael@0: s = *src++; michael@0: if (s) michael@0: { michael@0: d = *dst; michael@0: s = convert_0565_to_8888 (s); michael@0: if (d) michael@0: { michael@0: d = convert_0565_to_8888 (d); michael@0: UN8x4_ADD_UN8x4 (s, d); michael@0: } michael@0: *dst = convert_8888_to_0565 (s); michael@0: } michael@0: dst++; michael@0: } michael@0: } michael@0: } michael@0: michael@0: static void michael@0: fast_composite_add_8888_8888 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t *dst_line, *dst; michael@0: uint32_t *src_line, *src; michael@0: int dst_stride, src_stride; michael@0: int32_t w; michael@0: uint32_t s, d; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (src_image, src_x, src_y, uint32_t, src_stride, src_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: src = src_line; michael@0: src_line += src_stride; michael@0: w = width; michael@0: michael@0: while (w--) michael@0: { michael@0: s = *src++; michael@0: if (s) michael@0: { michael@0: if (s != 0xffffffff) michael@0: { michael@0: d = *dst; michael@0: if (d) michael@0: UN8x4_ADD_UN8x4 (s, d); michael@0: } michael@0: *dst = s; michael@0: } michael@0: dst++; michael@0: } michael@0: } michael@0: } michael@0: michael@0: static void michael@0: fast_composite_add_n_8_8 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint8_t *dst_line, *dst; michael@0: uint8_t *mask_line, *mask; michael@0: int dst_stride, mask_stride; michael@0: int32_t w; michael@0: uint32_t src; michael@0: uint8_t sa; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint8_t, dst_stride, dst_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, uint8_t, mask_stride, mask_line, 1); michael@0: src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format); michael@0: sa = (src >> 24); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: mask = mask_line; michael@0: mask_line += mask_stride; michael@0: w = width; michael@0: michael@0: while (w--) michael@0: { michael@0: uint16_t tmp; michael@0: uint16_t a; michael@0: uint32_t m, d; michael@0: uint32_t r; michael@0: michael@0: a = *mask++; michael@0: d = *dst; michael@0: michael@0: m = MUL_UN8 (sa, a, tmp); michael@0: r = ADD_UN8 (m, d, tmp); michael@0: michael@0: *dst++ = r; michael@0: } michael@0: } michael@0: } michael@0: michael@0: #ifdef WORDS_BIGENDIAN michael@0: #define CREATE_BITMASK(n) (0x80000000 >> (n)) michael@0: #define UPDATE_BITMASK(n) ((n) >> 1) michael@0: #else michael@0: #define CREATE_BITMASK(n) (1 << (n)) michael@0: #define UPDATE_BITMASK(n) ((n) << 1) michael@0: #endif michael@0: michael@0: #define TEST_BIT(p, n) \ michael@0: (*((p) + ((n) >> 5)) & CREATE_BITMASK ((n) & 31)) michael@0: #define SET_BIT(p, n) \ michael@0: do { *((p) + ((n) >> 5)) |= CREATE_BITMASK ((n) & 31); } while (0); michael@0: michael@0: static void michael@0: fast_composite_add_1_1 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t *dst_line, *dst; michael@0: uint32_t *src_line, *src; michael@0: int dst_stride, src_stride; michael@0: int32_t w; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (src_image, 0, src_y, uint32_t, michael@0: src_stride, src_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, 0, dest_y, uint32_t, michael@0: dst_stride, dst_line, 1); michael@0: michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: src = src_line; michael@0: src_line += src_stride; michael@0: w = width; michael@0: michael@0: while (w--) michael@0: { michael@0: /* michael@0: * TODO: improve performance by processing uint32_t data instead michael@0: * of individual bits michael@0: */ michael@0: if (TEST_BIT (src, src_x + w)) michael@0: SET_BIT (dst, dest_x + w); michael@0: } michael@0: } michael@0: } michael@0: michael@0: static void michael@0: fast_composite_over_n_1_8888 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t src, srca; michael@0: uint32_t *dst, *dst_line; michael@0: uint32_t *mask, *mask_line; michael@0: int mask_stride, dst_stride; michael@0: uint32_t bitcache, bitmask; michael@0: int32_t w; michael@0: michael@0: if (width <= 0) michael@0: return; michael@0: michael@0: src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format); michael@0: srca = src >> 24; michael@0: if (src == 0) michael@0: return; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, michael@0: dst_stride, dst_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (mask_image, 0, mask_y, uint32_t, michael@0: mask_stride, mask_line, 1); michael@0: mask_line += mask_x >> 5; michael@0: michael@0: if (srca == 0xff) michael@0: { michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: mask = mask_line; michael@0: mask_line += mask_stride; michael@0: w = width; michael@0: michael@0: bitcache = *mask++; michael@0: bitmask = CREATE_BITMASK (mask_x & 31); michael@0: michael@0: while (w--) michael@0: { michael@0: if (bitmask == 0) michael@0: { michael@0: bitcache = *mask++; michael@0: bitmask = CREATE_BITMASK (0); michael@0: } michael@0: if (bitcache & bitmask) michael@0: *dst = src; michael@0: bitmask = UPDATE_BITMASK (bitmask); michael@0: dst++; michael@0: } michael@0: } michael@0: } michael@0: else michael@0: { michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: mask = mask_line; michael@0: mask_line += mask_stride; michael@0: w = width; michael@0: michael@0: bitcache = *mask++; michael@0: bitmask = CREATE_BITMASK (mask_x & 31); michael@0: michael@0: while (w--) michael@0: { michael@0: if (bitmask == 0) michael@0: { michael@0: bitcache = *mask++; michael@0: bitmask = CREATE_BITMASK (0); michael@0: } michael@0: if (bitcache & bitmask) michael@0: *dst = over (src, *dst); michael@0: bitmask = UPDATE_BITMASK (bitmask); michael@0: dst++; michael@0: } michael@0: } michael@0: } michael@0: } michael@0: michael@0: static void michael@0: fast_composite_over_n_1_0565 (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t src, srca; michael@0: uint16_t *dst, *dst_line; michael@0: uint32_t *mask, *mask_line; michael@0: int mask_stride, dst_stride; michael@0: uint32_t bitcache, bitmask; michael@0: int32_t w; michael@0: uint32_t d; michael@0: uint16_t src565; michael@0: michael@0: if (width <= 0) michael@0: return; michael@0: michael@0: src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format); michael@0: srca = src >> 24; michael@0: if (src == 0) michael@0: return; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint16_t, michael@0: dst_stride, dst_line, 1); michael@0: PIXMAN_IMAGE_GET_LINE (mask_image, 0, mask_y, uint32_t, michael@0: mask_stride, mask_line, 1); michael@0: mask_line += mask_x >> 5; michael@0: michael@0: if (srca == 0xff) michael@0: { michael@0: src565 = convert_8888_to_0565 (src); michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: mask = mask_line; michael@0: mask_line += mask_stride; michael@0: w = width; michael@0: michael@0: bitcache = *mask++; michael@0: bitmask = CREATE_BITMASK (mask_x & 31); michael@0: michael@0: while (w--) michael@0: { michael@0: if (bitmask == 0) michael@0: { michael@0: bitcache = *mask++; michael@0: bitmask = CREATE_BITMASK (0); michael@0: } michael@0: if (bitcache & bitmask) michael@0: *dst = src565; michael@0: bitmask = UPDATE_BITMASK (bitmask); michael@0: dst++; michael@0: } michael@0: } michael@0: } michael@0: else michael@0: { michael@0: while (height--) michael@0: { michael@0: dst = dst_line; michael@0: dst_line += dst_stride; michael@0: mask = mask_line; michael@0: mask_line += mask_stride; michael@0: w = width; michael@0: michael@0: bitcache = *mask++; michael@0: bitmask = CREATE_BITMASK (mask_x & 31); michael@0: michael@0: while (w--) michael@0: { michael@0: if (bitmask == 0) michael@0: { michael@0: bitcache = *mask++; michael@0: bitmask = CREATE_BITMASK (0); michael@0: } michael@0: if (bitcache & bitmask) michael@0: { michael@0: d = over (src, convert_0565_to_0888 (*dst)); michael@0: *dst = convert_8888_to_0565 (d); michael@0: } michael@0: bitmask = UPDATE_BITMASK (bitmask); michael@0: dst++; michael@0: } michael@0: } michael@0: } michael@0: } michael@0: michael@0: /* michael@0: * Simple bitblt michael@0: */ michael@0: michael@0: static void michael@0: fast_composite_solid_fill (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t src; michael@0: michael@0: src = _pixman_image_get_solid (imp, src_image, dest_image->bits.format); michael@0: michael@0: if (dest_image->bits.format == PIXMAN_a1) michael@0: { michael@0: src = src >> 31; michael@0: } michael@0: else if (dest_image->bits.format == PIXMAN_a8) michael@0: { michael@0: src = src >> 24; michael@0: } michael@0: else if (dest_image->bits.format == PIXMAN_r5g6b5 || michael@0: dest_image->bits.format == PIXMAN_b5g6r5) michael@0: { michael@0: src = convert_8888_to_0565 (src); michael@0: } michael@0: michael@0: pixman_fill (dest_image->bits.bits, dest_image->bits.rowstride, michael@0: PIXMAN_FORMAT_BPP (dest_image->bits.format), michael@0: dest_x, dest_y, michael@0: width, height, michael@0: src); michael@0: } michael@0: michael@0: static void michael@0: fast_composite_src_memcpy (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: int bpp = PIXMAN_FORMAT_BPP (dest_image->bits.format) / 8; michael@0: uint32_t n_bytes = width * bpp; michael@0: int dst_stride, src_stride; michael@0: uint8_t *dst; michael@0: uint8_t *src; michael@0: michael@0: src_stride = src_image->bits.rowstride * 4; michael@0: dst_stride = dest_image->bits.rowstride * 4; michael@0: michael@0: src = (uint8_t *)src_image->bits.bits + src_y * src_stride + src_x * bpp; michael@0: dst = (uint8_t *)dest_image->bits.bits + dest_y * dst_stride + dest_x * bpp; michael@0: michael@0: while (height--) michael@0: { michael@0: memcpy (dst, src, n_bytes); michael@0: michael@0: dst += dst_stride; michael@0: src += src_stride; michael@0: } michael@0: } michael@0: michael@0: FAST_NEAREST (8888_8888_cover, 8888, 8888, uint32_t, uint32_t, SRC, COVER) michael@0: FAST_NEAREST (8888_8888_none, 8888, 8888, uint32_t, uint32_t, SRC, NONE) michael@0: FAST_NEAREST (8888_8888_pad, 8888, 8888, uint32_t, uint32_t, SRC, PAD) michael@0: FAST_NEAREST (8888_8888_normal, 8888, 8888, uint32_t, uint32_t, SRC, NORMAL) michael@0: FAST_NEAREST (x888_8888_cover, x888, 8888, uint32_t, uint32_t, SRC, COVER) michael@0: FAST_NEAREST (x888_8888_pad, x888, 8888, uint32_t, uint32_t, SRC, PAD) michael@0: FAST_NEAREST (x888_8888_normal, x888, 8888, uint32_t, uint32_t, SRC, NORMAL) michael@0: FAST_NEAREST (8888_8888_cover, 8888, 8888, uint32_t, uint32_t, OVER, COVER) michael@0: FAST_NEAREST (8888_8888_none, 8888, 8888, uint32_t, uint32_t, OVER, NONE) michael@0: FAST_NEAREST (8888_8888_pad, 8888, 8888, uint32_t, uint32_t, OVER, PAD) michael@0: FAST_NEAREST (8888_8888_normal, 8888, 8888, uint32_t, uint32_t, OVER, NORMAL) michael@0: FAST_NEAREST (8888_565_cover, 8888, 0565, uint32_t, uint16_t, SRC, COVER) michael@0: FAST_NEAREST (8888_565_none, 8888, 0565, uint32_t, uint16_t, SRC, NONE) michael@0: FAST_NEAREST (8888_565_pad, 8888, 0565, uint32_t, uint16_t, SRC, PAD) michael@0: FAST_NEAREST (8888_565_normal, 8888, 0565, uint32_t, uint16_t, SRC, NORMAL) michael@0: FAST_NEAREST (565_565_normal, 0565, 0565, uint16_t, uint16_t, SRC, NORMAL) michael@0: FAST_NEAREST (8888_565_cover, 8888, 0565, uint32_t, uint16_t, OVER, COVER) michael@0: FAST_NEAREST (8888_565_none, 8888, 0565, uint32_t, uint16_t, OVER, NONE) michael@0: FAST_NEAREST (8888_565_pad, 8888, 0565, uint32_t, uint16_t, OVER, PAD) michael@0: FAST_NEAREST (8888_565_normal, 8888, 0565, uint32_t, uint16_t, OVER, NORMAL) michael@0: michael@0: static force_inline void michael@0: scaled_bilinear_scanline_8888_565_OVER (uint16_t * dst, michael@0: const uint32_t * mask, michael@0: const uint32_t * src_top, michael@0: const uint32_t * src_bottom, michael@0: int32_t w, michael@0: int wt, michael@0: int wb, michael@0: pixman_fixed_t vx, michael@0: pixman_fixed_t unit_x, michael@0: pixman_fixed_t max_vx, michael@0: pixman_bool_t zero_src) michael@0: { michael@0: while ((w -= 1) >= 0) michael@0: { michael@0: uint32_t tl = src_top [pixman_fixed_to_int (vx)]; michael@0: uint32_t tr = src_top [pixman_fixed_to_int (vx) + 1]; michael@0: uint32_t bl = src_bottom [pixman_fixed_to_int (vx)]; michael@0: uint32_t br = src_bottom [pixman_fixed_to_int (vx) + 1]; michael@0: uint32_t src, result; michael@0: uint16_t d; michael@0: d = *dst; michael@0: src = bilinear_interpolation (tl, tr, michael@0: bl, br, michael@0: pixman_fixed_to_bilinear_weight(vx), michael@0: wb); michael@0: vx += unit_x; michael@0: result = over (src, convert_0565_to_0888 (d)); michael@0: *dst++ = convert_8888_to_0565 (result); michael@0: } michael@0: } michael@0: michael@0: static force_inline void michael@0: scaled_bilinear_scanline_8888_8888_OVER (uint32_t * dst, michael@0: const uint32_t * mask, michael@0: const uint32_t * src_top, michael@0: const uint32_t * src_bottom, michael@0: int32_t w, michael@0: int wt, michael@0: int wb, michael@0: pixman_fixed_t vx, michael@0: pixman_fixed_t unit_x, michael@0: pixman_fixed_t max_vx, michael@0: pixman_bool_t zero_src) michael@0: { michael@0: while ((w -= 1) >= 0) michael@0: { michael@0: uint32_t tl = src_top [pixman_fixed_to_int (vx)]; michael@0: uint32_t tr = src_top [pixman_fixed_to_int (vx) + 1]; michael@0: uint32_t bl = src_bottom [pixman_fixed_to_int (vx)]; michael@0: uint32_t br = src_bottom [pixman_fixed_to_int (vx) + 1]; michael@0: uint32_t src; michael@0: uint32_t d; michael@0: uint32_t result; michael@0: d = *dst; michael@0: src = bilinear_interpolation (tl, tr, michael@0: bl, br, michael@0: pixman_fixed_to_bilinear_weight(vx), michael@0: wb); michael@0: vx += unit_x; michael@0: *dst++ = over (src, d); michael@0: } michael@0: } michael@0: michael@0: #ifndef LOWER_QUALITY_INTERPOLATION michael@0: michael@0: static force_inline void michael@0: scaled_bilinear_scanline_565_565_SRC (uint16_t * dst, michael@0: const uint32_t * mask, michael@0: const uint16_t * src_top, michael@0: const uint16_t * src_bottom, michael@0: int32_t w, michael@0: int wt, michael@0: int wb, michael@0: pixman_fixed_t vx, michael@0: pixman_fixed_t unit_x, michael@0: pixman_fixed_t max_vx, michael@0: pixman_bool_t zero_src) michael@0: { michael@0: while ((w -= 1) >= 0) michael@0: { michael@0: uint16_t tl = src_top [pixman_fixed_to_int (vx)]; michael@0: uint16_t tr = src_top [pixman_fixed_to_int (vx) + 1]; michael@0: uint16_t bl = src_bottom [pixman_fixed_to_int (vx)]; michael@0: uint16_t br = src_bottom [pixman_fixed_to_int (vx) + 1]; michael@0: uint32_t d; michael@0: d = bilinear_interpolation(convert_0565_to_8888 (tl), michael@0: convert_0565_to_8888 (tr), michael@0: convert_0565_to_8888 (bl), michael@0: convert_0565_to_8888 (br), michael@0: pixman_fixed_to_bilinear_weight (vx), michael@0: wb); michael@0: vx += unit_x; michael@0: *dst++ = convert_8888_to_0565 (d); michael@0: } michael@0: } michael@0: michael@0: #else michael@0: michael@0: /* This is a clever low resolution bilinear interpolation inspired by the code michael@0: in Skia */ michael@0: michael@0: /* This takes the green component from the 565 representation and moves it: michael@0: 00000000 00000000 rrrrrggg gggbbbbb michael@0: michael@0: 00000ggg ggg00000 rrrrr000 000bbbbb michael@0: michael@0: This gives us 5 extra bits of space before each component to let us do michael@0: SWAR style optimizations michael@0: */ michael@0: michael@0: #define GREEN_MASK (((1 << 6) - 1) << 5) michael@0: michael@0: static inline uint32_t michael@0: expand_rgb_565 (uint16_t c) { michael@0: return ((c & GREEN_MASK) << 16) | (c & ~GREEN_MASK); michael@0: } michael@0: michael@0: static inline uint16_t michael@0: compact_rgb_565 (uint32_t c) { michael@0: return ((c >> 16) & GREEN_MASK) | (c & ~GREEN_MASK); michael@0: } michael@0: michael@0: static inline uint16_t michael@0: bilinear_interpolation_565(uint16_t tl, uint16_t tr, michael@0: uint16_t bl, uint16_t br, michael@0: int x, int y) michael@0: { michael@0: int xy; michael@0: uint32_t a00 = expand_rgb_565 (tl); michael@0: uint32_t a01 = expand_rgb_565 (tr); michael@0: uint32_t a10 = expand_rgb_565 (bl); michael@0: uint32_t a11 = expand_rgb_565 (br); michael@0: michael@0: xy = (x * y) >> 3; michael@0: return compact_rgb_565 ((a00 * (32 - 2*y - 2*x + xy) + michael@0: a01 * (2*x - xy) + michael@0: a10 * (2*y - xy) + michael@0: a11 * xy) >> 5); michael@0: } michael@0: michael@0: static force_inline void michael@0: scaled_bilinear_scanline_565_565_SRC (uint16_t * dst, michael@0: const uint32_t * mask, michael@0: const uint16_t * src_top, michael@0: const uint16_t * src_bottom, michael@0: int32_t w, michael@0: int wt, michael@0: int wb, michael@0: pixman_fixed_t vx, michael@0: pixman_fixed_t unit_x, michael@0: pixman_fixed_t max_vx, michael@0: pixman_bool_t zero_src) michael@0: { michael@0: while ((w -= 1) >= 0) michael@0: { michael@0: uint16_t tl = src_top [pixman_fixed_to_int (vx)]; michael@0: uint16_t tr = src_top [pixman_fixed_to_int (vx) + 1]; michael@0: uint16_t bl = src_bottom [pixman_fixed_to_int (vx)]; michael@0: uint16_t br = src_bottom [pixman_fixed_to_int (vx) + 1]; michael@0: michael@0: uint16_t d = bilinear_interpolation_565 (tl, tr, bl, br, michael@0: pixman_fixed_to_bilinear_weight(vx), michael@0: wb); michael@0: vx += unit_x; michael@0: *dst++ = d; michael@0: } michael@0: } michael@0: michael@0: #endif michael@0: michael@0: FAST_BILINEAR_MAINLOOP_COMMON (565_565_cover_SRC, michael@0: scaled_bilinear_scanline_565_565_SRC, NULL, michael@0: uint16_t, uint32_t, uint16_t, michael@0: COVER, FLAG_NONE) michael@0: FAST_BILINEAR_MAINLOOP_COMMON (565_565_pad_SRC, michael@0: scaled_bilinear_scanline_565_565_SRC, NULL, michael@0: uint16_t, uint32_t, uint16_t, michael@0: PAD, FLAG_NONE) michael@0: FAST_BILINEAR_MAINLOOP_COMMON (565_565_none_SRC, michael@0: scaled_bilinear_scanline_565_565_SRC, NULL, michael@0: uint16_t, uint32_t, uint16_t, michael@0: NONE, FLAG_NONE) michael@0: FAST_BILINEAR_MAINLOOP_COMMON (565_565_normal_SRC, michael@0: scaled_bilinear_scanline_565_565_SRC, NULL, michael@0: uint16_t, uint32_t, uint16_t, michael@0: NORMAL, FLAG_NONE) michael@0: michael@0: FAST_BILINEAR_MAINLOOP_COMMON (8888_565_cover_OVER, michael@0: scaled_bilinear_scanline_8888_565_OVER, NULL, michael@0: uint32_t, uint32_t, uint16_t, michael@0: COVER, FLAG_NONE) michael@0: FAST_BILINEAR_MAINLOOP_COMMON (8888_565_pad_OVER, michael@0: scaled_bilinear_scanline_8888_565_OVER, NULL, michael@0: uint32_t, uint32_t, uint16_t, michael@0: PAD, FLAG_NONE) michael@0: FAST_BILINEAR_MAINLOOP_COMMON (8888_565_none_OVER, michael@0: scaled_bilinear_scanline_8888_565_OVER, NULL, michael@0: uint32_t, uint32_t, uint16_t, michael@0: NONE, FLAG_NONE) michael@0: FAST_BILINEAR_MAINLOOP_COMMON (8888_565_normal_OVER, michael@0: scaled_bilinear_scanline_8888_565_OVER, NULL, michael@0: uint32_t, uint32_t, uint16_t, michael@0: NORMAL, FLAG_NONE) michael@0: michael@0: FAST_BILINEAR_MAINLOOP_COMMON (8888_8888_cover_OVER, michael@0: scaled_bilinear_scanline_8888_8888_OVER, NULL, michael@0: uint32_t, uint32_t, uint32_t, michael@0: COVER, FLAG_NONE) michael@0: FAST_BILINEAR_MAINLOOP_COMMON (8888_8888_pad_OVER, michael@0: scaled_bilinear_scanline_8888_8888_OVER, NULL, michael@0: uint32_t, uint32_t, uint32_t, michael@0: PAD, FLAG_NONE) michael@0: FAST_BILINEAR_MAINLOOP_COMMON (8888_8888_none_OVER, michael@0: scaled_bilinear_scanline_8888_8888_OVER, NULL, michael@0: uint32_t, uint32_t, uint32_t, michael@0: NONE, FLAG_NONE) michael@0: FAST_BILINEAR_MAINLOOP_COMMON (8888_8888_normal_OVER, michael@0: scaled_bilinear_scanline_8888_8888_OVER, NULL, michael@0: uint32_t, uint32_t, uint32_t, michael@0: NORMAL, FLAG_NONE) michael@0: michael@0: #define REPEAT_MIN_WIDTH 32 michael@0: michael@0: static void michael@0: fast_composite_tiled_repeat (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: pixman_composite_func_t func; michael@0: pixman_format_code_t mask_format; michael@0: uint32_t src_flags, mask_flags; michael@0: int32_t sx, sy; michael@0: int32_t width_remain; michael@0: int32_t num_pixels; michael@0: int32_t src_width; michael@0: int32_t i, j; michael@0: pixman_image_t extended_src_image; michael@0: uint32_t extended_src[REPEAT_MIN_WIDTH * 2]; michael@0: pixman_bool_t need_src_extension; michael@0: uint32_t *src_line; michael@0: int32_t src_stride; michael@0: int32_t src_bpp; michael@0: pixman_composite_info_t info2 = *info; michael@0: michael@0: src_flags = (info->src_flags & ~FAST_PATH_NORMAL_REPEAT) | michael@0: FAST_PATH_SAMPLES_COVER_CLIP_NEAREST; michael@0: michael@0: if (mask_image) michael@0: { michael@0: mask_format = mask_image->common.extended_format_code; michael@0: mask_flags = info->mask_flags; michael@0: } michael@0: else michael@0: { michael@0: mask_format = PIXMAN_null; michael@0: mask_flags = FAST_PATH_IS_OPAQUE; michael@0: } michael@0: michael@0: _pixman_implementation_lookup_composite ( michael@0: imp->toplevel, info->op, michael@0: src_image->common.extended_format_code, src_flags, michael@0: mask_format, mask_flags, michael@0: dest_image->common.extended_format_code, info->dest_flags, michael@0: &imp, &func); michael@0: michael@0: src_bpp = PIXMAN_FORMAT_BPP (src_image->bits.format); michael@0: michael@0: if (src_image->bits.width < REPEAT_MIN_WIDTH && michael@0: (src_bpp == 32 || src_bpp == 16 || src_bpp == 8) && michael@0: !src_image->bits.indexed) michael@0: { michael@0: sx = src_x; michael@0: sx = MOD (sx, src_image->bits.width); michael@0: sx += width; michael@0: src_width = 0; michael@0: michael@0: while (src_width < REPEAT_MIN_WIDTH && src_width <= sx) michael@0: src_width += src_image->bits.width; michael@0: michael@0: src_stride = (src_width * (src_bpp >> 3) + 3) / (int) sizeof (uint32_t); michael@0: michael@0: /* Initialize/validate stack-allocated temporary image */ michael@0: _pixman_bits_image_init (&extended_src_image, src_image->bits.format, michael@0: src_width, 1, &extended_src[0], src_stride, michael@0: FALSE); michael@0: _pixman_image_validate (&extended_src_image); michael@0: michael@0: info2.src_image = &extended_src_image; michael@0: need_src_extension = TRUE; michael@0: } michael@0: else michael@0: { michael@0: src_width = src_image->bits.width; michael@0: need_src_extension = FALSE; michael@0: } michael@0: michael@0: sx = src_x; michael@0: sy = src_y; michael@0: michael@0: while (--height >= 0) michael@0: { michael@0: sx = MOD (sx, src_width); michael@0: sy = MOD (sy, src_image->bits.height); michael@0: michael@0: if (need_src_extension) michael@0: { michael@0: if (src_bpp == 32) michael@0: { michael@0: PIXMAN_IMAGE_GET_LINE (src_image, 0, sy, uint32_t, src_stride, src_line, 1); michael@0: michael@0: for (i = 0; i < src_width; ) michael@0: { michael@0: for (j = 0; j < src_image->bits.width; j++, i++) michael@0: extended_src[i] = src_line[j]; michael@0: } michael@0: } michael@0: else if (src_bpp == 16) michael@0: { michael@0: uint16_t *src_line_16; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (src_image, 0, sy, uint16_t, src_stride, michael@0: src_line_16, 1); michael@0: src_line = (uint32_t*)src_line_16; michael@0: michael@0: for (i = 0; i < src_width; ) michael@0: { michael@0: for (j = 0; j < src_image->bits.width; j++, i++) michael@0: ((uint16_t*)extended_src)[i] = ((uint16_t*)src_line)[j]; michael@0: } michael@0: } michael@0: else if (src_bpp == 8) michael@0: { michael@0: uint8_t *src_line_8; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (src_image, 0, sy, uint8_t, src_stride, michael@0: src_line_8, 1); michael@0: src_line = (uint32_t*)src_line_8; michael@0: michael@0: for (i = 0; i < src_width; ) michael@0: { michael@0: for (j = 0; j < src_image->bits.width; j++, i++) michael@0: ((uint8_t*)extended_src)[i] = ((uint8_t*)src_line)[j]; michael@0: } michael@0: } michael@0: michael@0: info2.src_y = 0; michael@0: } michael@0: else michael@0: { michael@0: info2.src_y = sy; michael@0: } michael@0: michael@0: width_remain = width; michael@0: michael@0: while (width_remain > 0) michael@0: { michael@0: num_pixels = src_width - sx; michael@0: michael@0: if (num_pixels > width_remain) michael@0: num_pixels = width_remain; michael@0: michael@0: info2.src_x = sx; michael@0: info2.width = num_pixels; michael@0: info2.height = 1; michael@0: michael@0: func (imp, &info2); michael@0: michael@0: width_remain -= num_pixels; michael@0: info2.mask_x += num_pixels; michael@0: info2.dest_x += num_pixels; michael@0: sx = 0; michael@0: } michael@0: michael@0: sx = src_x; michael@0: sy++; michael@0: info2.mask_x = info->mask_x; michael@0: info2.mask_y++; michael@0: info2.dest_x = info->dest_x; michael@0: info2.dest_y++; michael@0: } michael@0: michael@0: if (need_src_extension) michael@0: _pixman_image_fini (&extended_src_image); michael@0: } michael@0: michael@0: /* Use more unrolling for src_0565_0565 because it is typically CPU bound */ michael@0: static force_inline void michael@0: scaled_nearest_scanline_565_565_SRC (uint16_t * dst, michael@0: const uint16_t * src, michael@0: int32_t w, michael@0: pixman_fixed_t vx, michael@0: pixman_fixed_t unit_x, michael@0: pixman_fixed_t max_vx, michael@0: pixman_bool_t fully_transparent_src) michael@0: { michael@0: uint16_t tmp1, tmp2, tmp3, tmp4; michael@0: while ((w -= 4) >= 0) michael@0: { michael@0: tmp1 = *(src + pixman_fixed_to_int (vx)); michael@0: vx += unit_x; michael@0: tmp2 = *(src + pixman_fixed_to_int (vx)); michael@0: vx += unit_x; michael@0: tmp3 = *(src + pixman_fixed_to_int (vx)); michael@0: vx += unit_x; michael@0: tmp4 = *(src + pixman_fixed_to_int (vx)); michael@0: vx += unit_x; michael@0: *dst++ = tmp1; michael@0: *dst++ = tmp2; michael@0: *dst++ = tmp3; michael@0: *dst++ = tmp4; michael@0: } michael@0: if (w & 2) michael@0: { michael@0: tmp1 = *(src + pixman_fixed_to_int (vx)); michael@0: vx += unit_x; michael@0: tmp2 = *(src + pixman_fixed_to_int (vx)); michael@0: vx += unit_x; michael@0: *dst++ = tmp1; michael@0: *dst++ = tmp2; michael@0: } michael@0: if (w & 1) michael@0: *dst = *(src + pixman_fixed_to_int (vx)); michael@0: } michael@0: michael@0: FAST_NEAREST_MAINLOOP (565_565_cover_SRC, michael@0: scaled_nearest_scanline_565_565_SRC, michael@0: uint16_t, uint16_t, COVER) michael@0: FAST_NEAREST_MAINLOOP (565_565_none_SRC, michael@0: scaled_nearest_scanline_565_565_SRC, michael@0: uint16_t, uint16_t, NONE) michael@0: FAST_NEAREST_MAINLOOP (565_565_pad_SRC, michael@0: scaled_nearest_scanline_565_565_SRC, michael@0: uint16_t, uint16_t, PAD) michael@0: michael@0: static force_inline uint32_t michael@0: fetch_nearest (pixman_repeat_t src_repeat, michael@0: pixman_format_code_t format, michael@0: uint32_t *src, int x, int src_width) michael@0: { michael@0: if (repeat (src_repeat, &x, src_width)) michael@0: { michael@0: if (format == PIXMAN_x8r8g8b8 || format == PIXMAN_x8b8g8r8) michael@0: return *(src + x) | 0xff000000; michael@0: else michael@0: return *(src + x); michael@0: } michael@0: else michael@0: { michael@0: return 0; michael@0: } michael@0: } michael@0: michael@0: static force_inline void michael@0: combine_over (uint32_t s, uint32_t *dst) michael@0: { michael@0: if (s) michael@0: { michael@0: uint8_t ia = 0xff - (s >> 24); michael@0: michael@0: if (ia) michael@0: UN8x4_MUL_UN8_ADD_UN8x4 (*dst, ia, s); michael@0: else michael@0: *dst = s; michael@0: } michael@0: } michael@0: michael@0: static force_inline void michael@0: combine_src (uint32_t s, uint32_t *dst) michael@0: { michael@0: *dst = s; michael@0: } michael@0: michael@0: static void michael@0: fast_composite_scaled_nearest (pixman_implementation_t *imp, michael@0: pixman_composite_info_t *info) michael@0: { michael@0: PIXMAN_COMPOSITE_ARGS (info); michael@0: uint32_t *dst_line; michael@0: uint32_t *src_line; michael@0: int dst_stride, src_stride; michael@0: int src_width, src_height; michael@0: pixman_repeat_t src_repeat; michael@0: pixman_fixed_t unit_x, unit_y; michael@0: pixman_format_code_t src_format; michael@0: pixman_vector_t v; michael@0: pixman_fixed_t vy; michael@0: michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, uint32_t, dst_stride, dst_line, 1); michael@0: /* pass in 0 instead of src_x and src_y because src_x and src_y need to be michael@0: * transformed from destination space to source space michael@0: */ michael@0: PIXMAN_IMAGE_GET_LINE (src_image, 0, 0, uint32_t, src_stride, src_line, 1); michael@0: michael@0: /* reference point is the center of the pixel */ michael@0: v.vector[0] = pixman_int_to_fixed (src_x) + pixman_fixed_1 / 2; michael@0: v.vector[1] = pixman_int_to_fixed (src_y) + pixman_fixed_1 / 2; michael@0: v.vector[2] = pixman_fixed_1; michael@0: michael@0: if (!pixman_transform_point_3d (src_image->common.transform, &v)) michael@0: return; michael@0: michael@0: unit_x = src_image->common.transform->matrix[0][0]; michael@0: unit_y = src_image->common.transform->matrix[1][1]; michael@0: michael@0: /* Round down to closest integer, ensuring that 0.5 rounds to 0, not 1 */ michael@0: v.vector[0] -= pixman_fixed_e; michael@0: v.vector[1] -= pixman_fixed_e; michael@0: michael@0: src_height = src_image->bits.height; michael@0: src_width = src_image->bits.width; michael@0: src_repeat = src_image->common.repeat; michael@0: src_format = src_image->bits.format; michael@0: michael@0: vy = v.vector[1]; michael@0: while (height--) michael@0: { michael@0: pixman_fixed_t vx = v.vector[0]; michael@0: int y = pixman_fixed_to_int (vy); michael@0: uint32_t *dst = dst_line; michael@0: michael@0: dst_line += dst_stride; michael@0: michael@0: /* adjust the y location by a unit vector in the y direction michael@0: * this is equivalent to transforming y+1 of the destination point to source space */ michael@0: vy += unit_y; michael@0: michael@0: if (!repeat (src_repeat, &y, src_height)) michael@0: { michael@0: if (op == PIXMAN_OP_SRC) michael@0: memset (dst, 0, sizeof (*dst) * width); michael@0: } michael@0: else michael@0: { michael@0: int w = width; michael@0: michael@0: uint32_t *src = src_line + y * src_stride; michael@0: michael@0: while (w >= 2) michael@0: { michael@0: uint32_t s1, s2; michael@0: int x1, x2; michael@0: michael@0: x1 = pixman_fixed_to_int (vx); michael@0: vx += unit_x; michael@0: michael@0: x2 = pixman_fixed_to_int (vx); michael@0: vx += unit_x; michael@0: michael@0: w -= 2; michael@0: michael@0: s1 = fetch_nearest (src_repeat, src_format, src, x1, src_width); michael@0: s2 = fetch_nearest (src_repeat, src_format, src, x2, src_width); michael@0: michael@0: if (op == PIXMAN_OP_OVER) michael@0: { michael@0: combine_over (s1, dst++); michael@0: combine_over (s2, dst++); michael@0: } michael@0: else michael@0: { michael@0: combine_src (s1, dst++); michael@0: combine_src (s2, dst++); michael@0: } michael@0: } michael@0: michael@0: while (w--) michael@0: { michael@0: uint32_t s; michael@0: int x; michael@0: michael@0: x = pixman_fixed_to_int (vx); michael@0: vx += unit_x; michael@0: michael@0: s = fetch_nearest (src_repeat, src_format, src, x, src_width); michael@0: michael@0: if (op == PIXMAN_OP_OVER) michael@0: combine_over (s, dst++); michael@0: else michael@0: combine_src (s, dst++); michael@0: } michael@0: } michael@0: } michael@0: } michael@0: michael@0: #define CACHE_LINE_SIZE 64 michael@0: michael@0: #define FAST_SIMPLE_ROTATE(suffix, pix_type) \ michael@0: \ michael@0: static void \ michael@0: blt_rotated_90_trivial_##suffix (pix_type *dst, \ michael@0: int dst_stride, \ michael@0: const pix_type *src, \ michael@0: int src_stride, \ michael@0: int w, \ michael@0: int h) \ michael@0: { \ michael@0: int x, y; \ michael@0: for (y = 0; y < h; y++) \ michael@0: { \ michael@0: const pix_type *s = src + (h - y - 1); \ michael@0: pix_type *d = dst + dst_stride * y; \ michael@0: for (x = 0; x < w; x++) \ michael@0: { \ michael@0: *d++ = *s; \ michael@0: s += src_stride; \ michael@0: } \ michael@0: } \ michael@0: } \ michael@0: \ michael@0: static void \ michael@0: blt_rotated_270_trivial_##suffix (pix_type *dst, \ michael@0: int dst_stride, \ michael@0: const pix_type *src, \ michael@0: int src_stride, \ michael@0: int w, \ michael@0: int h) \ michael@0: { \ michael@0: int x, y; \ michael@0: for (y = 0; y < h; y++) \ michael@0: { \ michael@0: const pix_type *s = src + src_stride * (w - 1) + y; \ michael@0: pix_type *d = dst + dst_stride * y; \ michael@0: for (x = 0; x < w; x++) \ michael@0: { \ michael@0: *d++ = *s; \ michael@0: s -= src_stride; \ michael@0: } \ michael@0: } \ michael@0: } \ michael@0: \ michael@0: static void \ michael@0: blt_rotated_90_##suffix (pix_type *dst, \ michael@0: int dst_stride, \ michael@0: const pix_type *src, \ michael@0: int src_stride, \ michael@0: int W, \ michael@0: int H) \ michael@0: { \ michael@0: int x; \ michael@0: int leading_pixels = 0, trailing_pixels = 0; \ michael@0: const int TILE_SIZE = CACHE_LINE_SIZE / sizeof(pix_type); \ michael@0: \ michael@0: /* \ michael@0: * split processing into handling destination as TILE_SIZExH cache line \ michael@0: * aligned vertical stripes (optimistically assuming that destination \ michael@0: * stride is a multiple of cache line, if not - it will be just a bit \ michael@0: * slower) \ michael@0: */ \ michael@0: \ michael@0: if ((uintptr_t)dst & (CACHE_LINE_SIZE - 1)) \ michael@0: { \ michael@0: leading_pixels = TILE_SIZE - (((uintptr_t)dst & \ michael@0: (CACHE_LINE_SIZE - 1)) / sizeof(pix_type)); \ michael@0: if (leading_pixels > W) \ michael@0: leading_pixels = W; \ michael@0: \ michael@0: /* unaligned leading part NxH (where N < TILE_SIZE) */ \ michael@0: blt_rotated_90_trivial_##suffix ( \ michael@0: dst, \ michael@0: dst_stride, \ michael@0: src, \ michael@0: src_stride, \ michael@0: leading_pixels, \ michael@0: H); \ michael@0: \ michael@0: dst += leading_pixels; \ michael@0: src += leading_pixels * src_stride; \ michael@0: W -= leading_pixels; \ michael@0: } \ michael@0: \ michael@0: if ((uintptr_t)(dst + W) & (CACHE_LINE_SIZE - 1)) \ michael@0: { \ michael@0: trailing_pixels = (((uintptr_t)(dst + W) & \ michael@0: (CACHE_LINE_SIZE - 1)) / sizeof(pix_type)); \ michael@0: if (trailing_pixels > W) \ michael@0: trailing_pixels = W; \ michael@0: W -= trailing_pixels; \ michael@0: } \ michael@0: \ michael@0: for (x = 0; x < W; x += TILE_SIZE) \ michael@0: { \ michael@0: /* aligned middle part TILE_SIZExH */ \ michael@0: blt_rotated_90_trivial_##suffix ( \ michael@0: dst + x, \ michael@0: dst_stride, \ michael@0: src + src_stride * x, \ michael@0: src_stride, \ michael@0: TILE_SIZE, \ michael@0: H); \ michael@0: } \ michael@0: \ michael@0: if (trailing_pixels) \ michael@0: { \ michael@0: /* unaligned trailing part NxH (where N < TILE_SIZE) */ \ michael@0: blt_rotated_90_trivial_##suffix ( \ michael@0: dst + W, \ michael@0: dst_stride, \ michael@0: src + W * src_stride, \ michael@0: src_stride, \ michael@0: trailing_pixels, \ michael@0: H); \ michael@0: } \ michael@0: } \ michael@0: \ michael@0: static void \ michael@0: blt_rotated_270_##suffix (pix_type *dst, \ michael@0: int dst_stride, \ michael@0: const pix_type *src, \ michael@0: int src_stride, \ michael@0: int W, \ michael@0: int H) \ michael@0: { \ michael@0: int x; \ michael@0: int leading_pixels = 0, trailing_pixels = 0; \ michael@0: const int TILE_SIZE = CACHE_LINE_SIZE / sizeof(pix_type); \ michael@0: \ michael@0: /* \ michael@0: * split processing into handling destination as TILE_SIZExH cache line \ michael@0: * aligned vertical stripes (optimistically assuming that destination \ michael@0: * stride is a multiple of cache line, if not - it will be just a bit \ michael@0: * slower) \ michael@0: */ \ michael@0: \ michael@0: if ((uintptr_t)dst & (CACHE_LINE_SIZE - 1)) \ michael@0: { \ michael@0: leading_pixels = TILE_SIZE - (((uintptr_t)dst & \ michael@0: (CACHE_LINE_SIZE - 1)) / sizeof(pix_type)); \ michael@0: if (leading_pixels > W) \ michael@0: leading_pixels = W; \ michael@0: \ michael@0: /* unaligned leading part NxH (where N < TILE_SIZE) */ \ michael@0: blt_rotated_270_trivial_##suffix ( \ michael@0: dst, \ michael@0: dst_stride, \ michael@0: src + src_stride * (W - leading_pixels), \ michael@0: src_stride, \ michael@0: leading_pixels, \ michael@0: H); \ michael@0: \ michael@0: dst += leading_pixels; \ michael@0: W -= leading_pixels; \ michael@0: } \ michael@0: \ michael@0: if ((uintptr_t)(dst + W) & (CACHE_LINE_SIZE - 1)) \ michael@0: { \ michael@0: trailing_pixels = (((uintptr_t)(dst + W) & \ michael@0: (CACHE_LINE_SIZE - 1)) / sizeof(pix_type)); \ michael@0: if (trailing_pixels > W) \ michael@0: trailing_pixels = W; \ michael@0: W -= trailing_pixels; \ michael@0: src += trailing_pixels * src_stride; \ michael@0: } \ michael@0: \ michael@0: for (x = 0; x < W; x += TILE_SIZE) \ michael@0: { \ michael@0: /* aligned middle part TILE_SIZExH */ \ michael@0: blt_rotated_270_trivial_##suffix ( \ michael@0: dst + x, \ michael@0: dst_stride, \ michael@0: src + src_stride * (W - x - TILE_SIZE), \ michael@0: src_stride, \ michael@0: TILE_SIZE, \ michael@0: H); \ michael@0: } \ michael@0: \ michael@0: if (trailing_pixels) \ michael@0: { \ michael@0: /* unaligned trailing part NxH (where N < TILE_SIZE) */ \ michael@0: blt_rotated_270_trivial_##suffix ( \ michael@0: dst + W, \ michael@0: dst_stride, \ michael@0: src - trailing_pixels * src_stride, \ michael@0: src_stride, \ michael@0: trailing_pixels, \ michael@0: H); \ michael@0: } \ michael@0: } \ michael@0: \ michael@0: static void \ michael@0: fast_composite_rotate_90_##suffix (pixman_implementation_t *imp, \ michael@0: pixman_composite_info_t *info) \ michael@0: { \ michael@0: PIXMAN_COMPOSITE_ARGS (info); \ michael@0: pix_type *dst_line; \ michael@0: pix_type *src_line; \ michael@0: int dst_stride, src_stride; \ michael@0: int src_x_t, src_y_t; \ michael@0: \ michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, pix_type, \ michael@0: dst_stride, dst_line, 1); \ michael@0: src_x_t = -src_y + pixman_fixed_to_int ( \ michael@0: src_image->common.transform->matrix[0][2] + \ michael@0: pixman_fixed_1 / 2 - pixman_fixed_e) - height;\ michael@0: src_y_t = src_x + pixman_fixed_to_int ( \ michael@0: src_image->common.transform->matrix[1][2] + \ michael@0: pixman_fixed_1 / 2 - pixman_fixed_e); \ michael@0: PIXMAN_IMAGE_GET_LINE (src_image, src_x_t, src_y_t, pix_type, \ michael@0: src_stride, src_line, 1); \ michael@0: blt_rotated_90_##suffix (dst_line, dst_stride, src_line, src_stride, \ michael@0: width, height); \ michael@0: } \ michael@0: \ michael@0: static void \ michael@0: fast_composite_rotate_270_##suffix (pixman_implementation_t *imp, \ michael@0: pixman_composite_info_t *info) \ michael@0: { \ michael@0: PIXMAN_COMPOSITE_ARGS (info); \ michael@0: pix_type *dst_line; \ michael@0: pix_type *src_line; \ michael@0: int dst_stride, src_stride; \ michael@0: int src_x_t, src_y_t; \ michael@0: \ michael@0: PIXMAN_IMAGE_GET_LINE (dest_image, dest_x, dest_y, pix_type, \ michael@0: dst_stride, dst_line, 1); \ michael@0: src_x_t = src_y + pixman_fixed_to_int ( \ michael@0: src_image->common.transform->matrix[0][2] + \ michael@0: pixman_fixed_1 / 2 - pixman_fixed_e); \ michael@0: src_y_t = -src_x + pixman_fixed_to_int ( \ michael@0: src_image->common.transform->matrix[1][2] + \ michael@0: pixman_fixed_1 / 2 - pixman_fixed_e) - width; \ michael@0: PIXMAN_IMAGE_GET_LINE (src_image, src_x_t, src_y_t, pix_type, \ michael@0: src_stride, src_line, 1); \ michael@0: blt_rotated_270_##suffix (dst_line, dst_stride, src_line, src_stride, \ michael@0: width, height); \ michael@0: } michael@0: michael@0: FAST_SIMPLE_ROTATE (8, uint8_t) michael@0: FAST_SIMPLE_ROTATE (565, uint16_t) michael@0: FAST_SIMPLE_ROTATE (8888, uint32_t) michael@0: michael@0: static const pixman_fast_path_t c_fast_paths[] = michael@0: { michael@0: PIXMAN_STD_FAST_PATH (OVER, solid, a8, r5g6b5, fast_composite_over_n_8_0565), michael@0: PIXMAN_STD_FAST_PATH (OVER, solid, a8, b5g6r5, fast_composite_over_n_8_0565), michael@0: PIXMAN_STD_FAST_PATH (OVER, solid, a8, r8g8b8, fast_composite_over_n_8_0888), michael@0: PIXMAN_STD_FAST_PATH (OVER, solid, a8, b8g8r8, fast_composite_over_n_8_0888), michael@0: PIXMAN_STD_FAST_PATH (OVER, solid, a8, a8r8g8b8, fast_composite_over_n_8_8888), michael@0: PIXMAN_STD_FAST_PATH (OVER, solid, a8, x8r8g8b8, fast_composite_over_n_8_8888), michael@0: PIXMAN_STD_FAST_PATH (OVER, solid, a8, a8b8g8r8, fast_composite_over_n_8_8888), michael@0: PIXMAN_STD_FAST_PATH (OVER, solid, a8, x8b8g8r8, fast_composite_over_n_8_8888), michael@0: PIXMAN_STD_FAST_PATH (OVER, solid, a1, a8r8g8b8, fast_composite_over_n_1_8888), michael@0: PIXMAN_STD_FAST_PATH (OVER, solid, a1, x8r8g8b8, fast_composite_over_n_1_8888), michael@0: PIXMAN_STD_FAST_PATH (OVER, solid, a1, a8b8g8r8, fast_composite_over_n_1_8888), michael@0: PIXMAN_STD_FAST_PATH (OVER, solid, a1, x8b8g8r8, fast_composite_over_n_1_8888), michael@0: PIXMAN_STD_FAST_PATH (OVER, solid, a1, r5g6b5, fast_composite_over_n_1_0565), michael@0: PIXMAN_STD_FAST_PATH (OVER, solid, a1, b5g6r5, fast_composite_over_n_1_0565), michael@0: PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8r8g8b8, a8r8g8b8, fast_composite_over_n_8888_8888_ca), michael@0: PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8r8g8b8, x8r8g8b8, fast_composite_over_n_8888_8888_ca), michael@0: PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8r8g8b8, r5g6b5, fast_composite_over_n_8888_0565_ca), michael@0: PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8b8g8r8, a8b8g8r8, fast_composite_over_n_8888_8888_ca), michael@0: PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8b8g8r8, x8b8g8r8, fast_composite_over_n_8888_8888_ca), michael@0: PIXMAN_STD_FAST_PATH_CA (OVER, solid, a8b8g8r8, b5g6r5, fast_composite_over_n_8888_0565_ca), michael@0: PIXMAN_STD_FAST_PATH (OVER, x8r8g8b8, a8, x8r8g8b8, fast_composite_over_x888_8_8888), michael@0: PIXMAN_STD_FAST_PATH (OVER, x8r8g8b8, a8, a8r8g8b8, fast_composite_over_x888_8_8888), michael@0: PIXMAN_STD_FAST_PATH (OVER, x8b8g8r8, a8, x8b8g8r8, fast_composite_over_x888_8_8888), michael@0: PIXMAN_STD_FAST_PATH (OVER, x8b8g8r8, a8, a8b8g8r8, fast_composite_over_x888_8_8888), michael@0: PIXMAN_STD_FAST_PATH (OVER, a8r8g8b8, null, a8r8g8b8, fast_composite_over_8888_8888), michael@0: PIXMAN_STD_FAST_PATH (OVER, a8r8g8b8, null, x8r8g8b8, fast_composite_over_8888_8888), michael@0: PIXMAN_STD_FAST_PATH (OVER, a8r8g8b8, null, r5g6b5, fast_composite_over_8888_0565), michael@0: PIXMAN_STD_FAST_PATH (OVER, a8b8g8r8, null, a8b8g8r8, fast_composite_over_8888_8888), michael@0: PIXMAN_STD_FAST_PATH (OVER, a8b8g8r8, null, x8b8g8r8, fast_composite_over_8888_8888), michael@0: PIXMAN_STD_FAST_PATH (OVER, a8b8g8r8, null, b5g6r5, fast_composite_over_8888_0565), michael@0: PIXMAN_STD_FAST_PATH (ADD, r5g6b5, null, r5g6b5, fast_composite_add_0565_0565), michael@0: PIXMAN_STD_FAST_PATH (ADD, b5g6r5, null, b5g6r5, fast_composite_add_0565_0565), michael@0: PIXMAN_STD_FAST_PATH (ADD, a8r8g8b8, null, a8r8g8b8, fast_composite_add_8888_8888), michael@0: PIXMAN_STD_FAST_PATH (ADD, a8b8g8r8, null, a8b8g8r8, fast_composite_add_8888_8888), michael@0: PIXMAN_STD_FAST_PATH (ADD, a8, null, a8, fast_composite_add_8_8), michael@0: PIXMAN_STD_FAST_PATH (ADD, a1, null, a1, fast_composite_add_1_1), michael@0: PIXMAN_STD_FAST_PATH_CA (ADD, solid, a8r8g8b8, a8r8g8b8, fast_composite_add_n_8888_8888_ca), michael@0: PIXMAN_STD_FAST_PATH (ADD, solid, a8, a8, fast_composite_add_n_8_8), michael@0: PIXMAN_STD_FAST_PATH (SRC, solid, null, a8r8g8b8, fast_composite_solid_fill), michael@0: PIXMAN_STD_FAST_PATH (SRC, solid, null, x8r8g8b8, fast_composite_solid_fill), michael@0: PIXMAN_STD_FAST_PATH (SRC, solid, null, a8b8g8r8, fast_composite_solid_fill), michael@0: PIXMAN_STD_FAST_PATH (SRC, solid, null, x8b8g8r8, fast_composite_solid_fill), michael@0: PIXMAN_STD_FAST_PATH (SRC, solid, null, a1, fast_composite_solid_fill), michael@0: PIXMAN_STD_FAST_PATH (SRC, solid, null, a8, fast_composite_solid_fill), michael@0: PIXMAN_STD_FAST_PATH (SRC, solid, null, r5g6b5, fast_composite_solid_fill), michael@0: PIXMAN_STD_FAST_PATH (SRC, x8r8g8b8, null, a8r8g8b8, fast_composite_src_x888_8888), michael@0: PIXMAN_STD_FAST_PATH (SRC, x8b8g8r8, null, a8b8g8r8, fast_composite_src_x888_8888), michael@0: PIXMAN_STD_FAST_PATH (SRC, a8r8g8b8, null, x8r8g8b8, fast_composite_src_memcpy), michael@0: PIXMAN_STD_FAST_PATH (SRC, a8r8g8b8, null, a8r8g8b8, fast_composite_src_memcpy), michael@0: PIXMAN_STD_FAST_PATH (SRC, x8r8g8b8, null, x8r8g8b8, fast_composite_src_memcpy), michael@0: PIXMAN_STD_FAST_PATH (SRC, a8b8g8r8, null, x8b8g8r8, fast_composite_src_memcpy), michael@0: PIXMAN_STD_FAST_PATH (SRC, a8b8g8r8, null, a8b8g8r8, fast_composite_src_memcpy), michael@0: PIXMAN_STD_FAST_PATH (SRC, x8b8g8r8, null, x8b8g8r8, fast_composite_src_memcpy), michael@0: PIXMAN_STD_FAST_PATH (SRC, b8g8r8a8, null, b8g8r8x8, fast_composite_src_memcpy), michael@0: PIXMAN_STD_FAST_PATH (SRC, b8g8r8a8, null, b8g8r8a8, fast_composite_src_memcpy), michael@0: PIXMAN_STD_FAST_PATH (SRC, b8g8r8x8, null, b8g8r8x8, fast_composite_src_memcpy), michael@0: PIXMAN_STD_FAST_PATH (SRC, r5g6b5, null, r5g6b5, fast_composite_src_memcpy), michael@0: PIXMAN_STD_FAST_PATH (SRC, b5g6r5, null, b5g6r5, fast_composite_src_memcpy), michael@0: PIXMAN_STD_FAST_PATH (SRC, r8g8b8, null, r8g8b8, fast_composite_src_memcpy), michael@0: PIXMAN_STD_FAST_PATH (SRC, b8g8r8, null, b8g8r8, fast_composite_src_memcpy), michael@0: PIXMAN_STD_FAST_PATH (SRC, x1r5g5b5, null, x1r5g5b5, fast_composite_src_memcpy), michael@0: PIXMAN_STD_FAST_PATH (SRC, a1r5g5b5, null, x1r5g5b5, fast_composite_src_memcpy), michael@0: PIXMAN_STD_FAST_PATH (SRC, a8, null, a8, fast_composite_src_memcpy), michael@0: PIXMAN_STD_FAST_PATH (IN, a8, null, a8, fast_composite_in_8_8), michael@0: PIXMAN_STD_FAST_PATH (IN, solid, a8, a8, fast_composite_in_n_8_8), michael@0: michael@0: SIMPLE_NEAREST_FAST_PATH (SRC, x8r8g8b8, x8r8g8b8, 8888_8888), michael@0: SIMPLE_NEAREST_FAST_PATH (SRC, a8r8g8b8, x8r8g8b8, 8888_8888), michael@0: SIMPLE_NEAREST_FAST_PATH (SRC, x8b8g8r8, x8b8g8r8, 8888_8888), michael@0: SIMPLE_NEAREST_FAST_PATH (SRC, a8b8g8r8, x8b8g8r8, 8888_8888), michael@0: michael@0: SIMPLE_NEAREST_FAST_PATH (SRC, a8r8g8b8, a8r8g8b8, 8888_8888), michael@0: SIMPLE_NEAREST_FAST_PATH (SRC, a8b8g8r8, a8b8g8r8, 8888_8888), michael@0: michael@0: SIMPLE_NEAREST_FAST_PATH (SRC, x8r8g8b8, r5g6b5, 8888_565), michael@0: SIMPLE_NEAREST_FAST_PATH (SRC, a8r8g8b8, r5g6b5, 8888_565), michael@0: michael@0: SIMPLE_NEAREST_FAST_PATH (SRC, r5g6b5, r5g6b5, 565_565), michael@0: michael@0: SIMPLE_NEAREST_FAST_PATH_COVER (SRC, x8r8g8b8, a8r8g8b8, x888_8888), michael@0: SIMPLE_NEAREST_FAST_PATH_COVER (SRC, x8b8g8r8, a8b8g8r8, x888_8888), michael@0: SIMPLE_NEAREST_FAST_PATH_PAD (SRC, x8r8g8b8, a8r8g8b8, x888_8888), michael@0: SIMPLE_NEAREST_FAST_PATH_PAD (SRC, x8b8g8r8, a8b8g8r8, x888_8888), michael@0: SIMPLE_NEAREST_FAST_PATH_NORMAL (SRC, x8r8g8b8, a8r8g8b8, x888_8888), michael@0: SIMPLE_NEAREST_FAST_PATH_NORMAL (SRC, x8b8g8r8, a8b8g8r8, x888_8888), michael@0: michael@0: SIMPLE_NEAREST_FAST_PATH (OVER, a8r8g8b8, x8r8g8b8, 8888_8888), michael@0: SIMPLE_NEAREST_FAST_PATH (OVER, a8b8g8r8, x8b8g8r8, 8888_8888), michael@0: SIMPLE_NEAREST_FAST_PATH (OVER, a8r8g8b8, a8r8g8b8, 8888_8888), michael@0: SIMPLE_NEAREST_FAST_PATH (OVER, a8b8g8r8, a8b8g8r8, 8888_8888), michael@0: michael@0: SIMPLE_NEAREST_FAST_PATH (OVER, a8r8g8b8, r5g6b5, 8888_565), michael@0: michael@0: #define NEAREST_FAST_PATH(op,s,d) \ michael@0: { PIXMAN_OP_ ## op, \ michael@0: PIXMAN_ ## s, SCALED_NEAREST_FLAGS, \ michael@0: PIXMAN_null, 0, \ michael@0: PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \ michael@0: fast_composite_scaled_nearest, \ michael@0: } michael@0: michael@0: NEAREST_FAST_PATH (SRC, x8r8g8b8, x8r8g8b8), michael@0: NEAREST_FAST_PATH (SRC, a8r8g8b8, x8r8g8b8), michael@0: NEAREST_FAST_PATH (SRC, x8b8g8r8, x8b8g8r8), michael@0: NEAREST_FAST_PATH (SRC, a8b8g8r8, x8b8g8r8), michael@0: michael@0: NEAREST_FAST_PATH (SRC, x8r8g8b8, a8r8g8b8), michael@0: NEAREST_FAST_PATH (SRC, a8r8g8b8, a8r8g8b8), michael@0: NEAREST_FAST_PATH (SRC, x8b8g8r8, a8b8g8r8), michael@0: NEAREST_FAST_PATH (SRC, a8b8g8r8, a8b8g8r8), michael@0: michael@0: NEAREST_FAST_PATH (OVER, x8r8g8b8, x8r8g8b8), michael@0: NEAREST_FAST_PATH (OVER, a8r8g8b8, x8r8g8b8), michael@0: NEAREST_FAST_PATH (OVER, x8b8g8r8, x8b8g8r8), michael@0: NEAREST_FAST_PATH (OVER, a8b8g8r8, x8b8g8r8), michael@0: michael@0: NEAREST_FAST_PATH (OVER, x8r8g8b8, a8r8g8b8), michael@0: NEAREST_FAST_PATH (OVER, a8r8g8b8, a8r8g8b8), michael@0: NEAREST_FAST_PATH (OVER, x8b8g8r8, a8b8g8r8), michael@0: NEAREST_FAST_PATH (OVER, a8b8g8r8, a8b8g8r8), michael@0: michael@0: #define SIMPLE_ROTATE_FLAGS(angle) \ michael@0: (FAST_PATH_ROTATE_ ## angle ## _TRANSFORM | \ michael@0: FAST_PATH_NEAREST_FILTER | \ michael@0: FAST_PATH_SAMPLES_COVER_CLIP_NEAREST | \ michael@0: FAST_PATH_STANDARD_FLAGS) michael@0: michael@0: #define SIMPLE_ROTATE_FAST_PATH(op,s,d,suffix) \ michael@0: { PIXMAN_OP_ ## op, \ michael@0: PIXMAN_ ## s, SIMPLE_ROTATE_FLAGS (90), \ michael@0: PIXMAN_null, 0, \ michael@0: PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \ michael@0: fast_composite_rotate_90_##suffix, \ michael@0: }, \ michael@0: { PIXMAN_OP_ ## op, \ michael@0: PIXMAN_ ## s, SIMPLE_ROTATE_FLAGS (270), \ michael@0: PIXMAN_null, 0, \ michael@0: PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \ michael@0: fast_composite_rotate_270_##suffix, \ michael@0: } michael@0: michael@0: SIMPLE_ROTATE_FAST_PATH (SRC, a8r8g8b8, a8r8g8b8, 8888), michael@0: SIMPLE_ROTATE_FAST_PATH (SRC, a8r8g8b8, x8r8g8b8, 8888), michael@0: SIMPLE_ROTATE_FAST_PATH (SRC, x8r8g8b8, x8r8g8b8, 8888), michael@0: SIMPLE_ROTATE_FAST_PATH (SRC, r5g6b5, r5g6b5, 565), michael@0: SIMPLE_ROTATE_FAST_PATH (SRC, a8, a8, 8), michael@0: michael@0: /* Simple repeat fast path entry. */ michael@0: { PIXMAN_OP_any, michael@0: PIXMAN_any, michael@0: (FAST_PATH_STANDARD_FLAGS | FAST_PATH_ID_TRANSFORM | FAST_PATH_BITS_IMAGE | michael@0: FAST_PATH_NORMAL_REPEAT), michael@0: PIXMAN_any, 0, michael@0: PIXMAN_any, FAST_PATH_STD_DEST_FLAGS, michael@0: fast_composite_tiled_repeat michael@0: }, michael@0: michael@0: SIMPLE_BILINEAR_FAST_PATH (SRC, r5g6b5, r5g6b5, 565_565), michael@0: SIMPLE_BILINEAR_FAST_PATH (OVER, a8r8g8b8, r5g6b5, 8888_565), michael@0: SIMPLE_BILINEAR_FAST_PATH (OVER, a8r8g8b8, a8r8g8b8, 8888_8888), michael@0: michael@0: { PIXMAN_OP_NONE }, michael@0: }; michael@0: michael@0: #ifdef WORDS_BIGENDIAN michael@0: #define A1_FILL_MASK(n, offs) (((1U << (n)) - 1) << (32 - (offs) - (n))) michael@0: #else michael@0: #define A1_FILL_MASK(n, offs) (((1U << (n)) - 1) << (offs)) michael@0: #endif michael@0: michael@0: static force_inline void michael@0: pixman_fill1_line (uint32_t *dst, int offs, int width, int v) michael@0: { michael@0: if (offs) michael@0: { michael@0: int leading_pixels = 32 - offs; michael@0: if (leading_pixels >= width) michael@0: { michael@0: if (v) michael@0: *dst |= A1_FILL_MASK (width, offs); michael@0: else michael@0: *dst &= ~A1_FILL_MASK (width, offs); michael@0: return; michael@0: } michael@0: else michael@0: { michael@0: if (v) michael@0: *dst++ |= A1_FILL_MASK (leading_pixels, offs); michael@0: else michael@0: *dst++ &= ~A1_FILL_MASK (leading_pixels, offs); michael@0: width -= leading_pixels; michael@0: } michael@0: } michael@0: while (width >= 32) michael@0: { michael@0: if (v) michael@0: *dst++ = 0xFFFFFFFF; michael@0: else michael@0: *dst++ = 0; michael@0: width -= 32; michael@0: } michael@0: if (width > 0) michael@0: { michael@0: if (v) michael@0: *dst |= A1_FILL_MASK (width, 0); michael@0: else michael@0: *dst &= ~A1_FILL_MASK (width, 0); michael@0: } michael@0: } michael@0: michael@0: static void michael@0: pixman_fill1 (uint32_t *bits, michael@0: int stride, michael@0: int x, michael@0: int y, michael@0: int width, michael@0: int height, michael@0: uint32_t filler) michael@0: { michael@0: uint32_t *dst = bits + y * stride + (x >> 5); michael@0: int offs = x & 31; michael@0: michael@0: if (filler & 1) michael@0: { michael@0: while (height--) michael@0: { michael@0: pixman_fill1_line (dst, offs, width, 1); michael@0: dst += stride; michael@0: } michael@0: } michael@0: else michael@0: { michael@0: while (height--) michael@0: { michael@0: pixman_fill1_line (dst, offs, width, 0); michael@0: dst += stride; michael@0: } michael@0: } michael@0: } michael@0: michael@0: static void michael@0: pixman_fill8 (uint32_t *bits, michael@0: int stride, michael@0: int x, michael@0: int y, michael@0: int width, michael@0: int height, michael@0: uint32_t filler) michael@0: { michael@0: int byte_stride = stride * (int) sizeof (uint32_t); michael@0: uint8_t *dst = (uint8_t *) bits; michael@0: uint8_t v = filler & 0xff; michael@0: int i; michael@0: michael@0: dst = dst + y * byte_stride + x; michael@0: michael@0: while (height--) michael@0: { michael@0: for (i = 0; i < width; ++i) michael@0: dst[i] = v; michael@0: michael@0: dst += byte_stride; michael@0: } michael@0: } michael@0: michael@0: static void michael@0: pixman_fill16 (uint32_t *bits, michael@0: int stride, michael@0: int x, michael@0: int y, michael@0: int width, michael@0: int height, michael@0: uint32_t filler) michael@0: { michael@0: int short_stride = michael@0: (stride * (int)sizeof (uint32_t)) / (int)sizeof (uint16_t); michael@0: uint16_t *dst = (uint16_t *)bits; michael@0: uint16_t v = filler & 0xffff; michael@0: int i; michael@0: michael@0: dst = dst + y * short_stride + x; michael@0: michael@0: while (height--) michael@0: { michael@0: for (i = 0; i < width; ++i) michael@0: dst[i] = v; michael@0: michael@0: dst += short_stride; michael@0: } michael@0: } michael@0: michael@0: static void michael@0: pixman_fill32 (uint32_t *bits, michael@0: int stride, michael@0: int x, michael@0: int y, michael@0: int width, michael@0: int height, michael@0: uint32_t filler) michael@0: { michael@0: int i; michael@0: michael@0: bits = bits + y * stride + x; michael@0: michael@0: while (height--) michael@0: { michael@0: for (i = 0; i < width; ++i) michael@0: bits[i] = filler; michael@0: michael@0: bits += stride; michael@0: } michael@0: } michael@0: michael@0: static pixman_bool_t michael@0: fast_path_fill (pixman_implementation_t *imp, michael@0: uint32_t * bits, michael@0: int stride, michael@0: int bpp, michael@0: int x, michael@0: int y, michael@0: int width, michael@0: int height, michael@0: uint32_t filler) michael@0: { michael@0: switch (bpp) michael@0: { michael@0: case 1: michael@0: pixman_fill1 (bits, stride, x, y, width, height, filler); michael@0: break; michael@0: michael@0: case 8: michael@0: pixman_fill8 (bits, stride, x, y, width, height, filler); michael@0: break; michael@0: michael@0: case 16: michael@0: pixman_fill16 (bits, stride, x, y, width, height, filler); michael@0: break; michael@0: michael@0: case 32: michael@0: pixman_fill32 (bits, stride, x, y, width, height, filler); michael@0: break; michael@0: michael@0: default: michael@0: return FALSE; michael@0: } michael@0: michael@0: return TRUE; michael@0: } michael@0: michael@0: /*****************************************************************************/ michael@0: michael@0: static uint32_t * michael@0: fast_fetch_r5g6b5 (pixman_iter_t *iter, const uint32_t *mask) michael@0: { michael@0: int32_t w = iter->width; michael@0: uint32_t *dst = iter->buffer; michael@0: const uint16_t *src = (const uint16_t *)iter->bits; michael@0: michael@0: iter->bits += iter->stride; michael@0: michael@0: /* Align the source buffer at 4 bytes boundary */ michael@0: if (w > 0 && ((uintptr_t)src & 3)) michael@0: { michael@0: *dst++ = convert_0565_to_8888 (*src++); michael@0: w--; michael@0: } michael@0: /* Process two pixels per iteration */ michael@0: while ((w -= 2) >= 0) michael@0: { michael@0: uint32_t sr, sb, sg, t0, t1; michael@0: uint32_t s = *(const uint32_t *)src; michael@0: src += 2; michael@0: sr = (s >> 8) & 0x00F800F8; michael@0: sb = (s << 3) & 0x00F800F8; michael@0: sg = (s >> 3) & 0x00FC00FC; michael@0: sr |= sr >> 5; michael@0: sb |= sb >> 5; michael@0: sg |= sg >> 6; michael@0: t0 = ((sr << 16) & 0x00FF0000) | ((sg << 8) & 0x0000FF00) | michael@0: (sb & 0xFF) | 0xFF000000; michael@0: t1 = (sr & 0x00FF0000) | ((sg >> 8) & 0x0000FF00) | michael@0: (sb >> 16) | 0xFF000000; michael@0: #ifdef WORDS_BIGENDIAN michael@0: *dst++ = t1; michael@0: *dst++ = t0; michael@0: #else michael@0: *dst++ = t0; michael@0: *dst++ = t1; michael@0: #endif michael@0: } michael@0: if (w & 1) michael@0: { michael@0: *dst = convert_0565_to_8888 (*src); michael@0: } michael@0: michael@0: return iter->buffer; michael@0: } michael@0: michael@0: static uint32_t * michael@0: fast_dest_fetch_noop (pixman_iter_t *iter, const uint32_t *mask) michael@0: { michael@0: iter->bits += iter->stride; michael@0: return iter->buffer; michael@0: } michael@0: michael@0: /* Helper function for a workaround, which tries to ensure that 0x1F001F michael@0: * constant is always allocated in a register on RISC architectures. michael@0: */ michael@0: static force_inline uint32_t michael@0: convert_8888_to_0565_workaround (uint32_t s, uint32_t x1F001F) michael@0: { michael@0: uint32_t a, b; michael@0: a = (s >> 3) & x1F001F; michael@0: b = s & 0xFC00; michael@0: a |= a >> 5; michael@0: a |= b >> 5; michael@0: return a; michael@0: } michael@0: michael@0: static void michael@0: fast_write_back_r5g6b5 (pixman_iter_t *iter) michael@0: { michael@0: int32_t w = iter->width; michael@0: uint16_t *dst = (uint16_t *)(iter->bits - iter->stride); michael@0: const uint32_t *src = iter->buffer; michael@0: /* Workaround to ensure that x1F001F variable is allocated in a register */ michael@0: static volatile uint32_t volatile_x1F001F = 0x1F001F; michael@0: uint32_t x1F001F = volatile_x1F001F; michael@0: michael@0: while ((w -= 4) >= 0) michael@0: { michael@0: uint32_t s1 = *src++; michael@0: uint32_t s2 = *src++; michael@0: uint32_t s3 = *src++; michael@0: uint32_t s4 = *src++; michael@0: *dst++ = convert_8888_to_0565_workaround (s1, x1F001F); michael@0: *dst++ = convert_8888_to_0565_workaround (s2, x1F001F); michael@0: *dst++ = convert_8888_to_0565_workaround (s3, x1F001F); michael@0: *dst++ = convert_8888_to_0565_workaround (s4, x1F001F); michael@0: } michael@0: if (w & 2) michael@0: { michael@0: *dst++ = convert_8888_to_0565_workaround (*src++, x1F001F); michael@0: *dst++ = convert_8888_to_0565_workaround (*src++, x1F001F); michael@0: } michael@0: if (w & 1) michael@0: { michael@0: *dst = convert_8888_to_0565_workaround (*src, x1F001F); michael@0: } michael@0: } michael@0: michael@0: typedef struct michael@0: { michael@0: pixman_format_code_t format; michael@0: pixman_iter_get_scanline_t get_scanline; michael@0: pixman_iter_write_back_t write_back; michael@0: } fetcher_info_t; michael@0: michael@0: static const fetcher_info_t fetchers[] = michael@0: { michael@0: { PIXMAN_r5g6b5, fast_fetch_r5g6b5, fast_write_back_r5g6b5 }, michael@0: { PIXMAN_null } michael@0: }; michael@0: michael@0: static pixman_bool_t michael@0: fast_src_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter) michael@0: { michael@0: pixman_image_t *image = iter->image; michael@0: michael@0: #define FLAGS \ michael@0: (FAST_PATH_STANDARD_FLAGS | FAST_PATH_ID_TRANSFORM | \ michael@0: FAST_PATH_BITS_IMAGE | FAST_PATH_SAMPLES_COVER_CLIP_NEAREST) michael@0: michael@0: if (iter->iter_flags & ITER_16) michael@0: return FALSE; michael@0: michael@0: if ((iter->iter_flags & ITER_NARROW) && michael@0: (iter->image_flags & FLAGS) == FLAGS) michael@0: { michael@0: const fetcher_info_t *f; michael@0: michael@0: for (f = &fetchers[0]; f->format != PIXMAN_null; f++) michael@0: { michael@0: if (image->common.extended_format_code == f->format) michael@0: { michael@0: uint8_t *b = (uint8_t *)image->bits.bits; michael@0: int s = image->bits.rowstride * 4; michael@0: michael@0: iter->bits = b + s * iter->y + iter->x * PIXMAN_FORMAT_BPP (f->format) / 8; michael@0: iter->stride = s; michael@0: michael@0: iter->get_scanline = f->get_scanline; michael@0: return TRUE; michael@0: } michael@0: } michael@0: } michael@0: michael@0: return FALSE; michael@0: } michael@0: michael@0: static pixman_bool_t michael@0: fast_dest_iter_init (pixman_implementation_t *imp, pixman_iter_t *iter) michael@0: { michael@0: pixman_image_t *image = iter->image; michael@0: michael@0: if (iter->iter_flags & ITER_16) michael@0: return FALSE; michael@0: michael@0: if ((iter->iter_flags & ITER_NARROW) && michael@0: (iter->image_flags & FAST_PATH_STD_DEST_FLAGS) == FAST_PATH_STD_DEST_FLAGS) michael@0: { michael@0: const fetcher_info_t *f; michael@0: michael@0: for (f = &fetchers[0]; f->format != PIXMAN_null; f++) michael@0: { michael@0: if (image->common.extended_format_code == f->format) michael@0: { michael@0: uint8_t *b = (uint8_t *)image->bits.bits; michael@0: int s = image->bits.rowstride * 4; michael@0: michael@0: iter->bits = b + s * iter->y + iter->x * PIXMAN_FORMAT_BPP (f->format) / 8; michael@0: iter->stride = s; michael@0: michael@0: if ((iter->iter_flags & (ITER_IGNORE_RGB | ITER_IGNORE_ALPHA)) == michael@0: (ITER_IGNORE_RGB | ITER_IGNORE_ALPHA)) michael@0: { michael@0: iter->get_scanline = fast_dest_fetch_noop; michael@0: } michael@0: else michael@0: { michael@0: iter->get_scanline = f->get_scanline; michael@0: } michael@0: iter->write_back = f->write_back; michael@0: return TRUE; michael@0: } michael@0: } michael@0: } michael@0: return FALSE; michael@0: } michael@0: michael@0: michael@0: pixman_implementation_t * michael@0: _pixman_implementation_create_fast_path (pixman_implementation_t *fallback) michael@0: { michael@0: pixman_implementation_t *imp = _pixman_implementation_create (fallback, c_fast_paths); michael@0: michael@0: imp->fill = fast_path_fill; michael@0: imp->src_iter_init = fast_src_iter_init; michael@0: imp->dest_iter_init = fast_dest_iter_init; michael@0: michael@0: return imp; michael@0: }