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: #ifndef PIXMAN_FAST_PATH_H__ michael@0: #define PIXMAN_FAST_PATH_H__ michael@0: michael@0: #include "pixman-private.h" michael@0: michael@0: #define PIXMAN_REPEAT_COVER -1 michael@0: michael@0: static force_inline pixman_bool_t michael@0: repeat (pixman_repeat_t repeat, int *c, int size) michael@0: { michael@0: if (repeat == PIXMAN_REPEAT_NONE) michael@0: { michael@0: if (*c < 0 || *c >= size) michael@0: return FALSE; michael@0: } michael@0: else if (repeat == PIXMAN_REPEAT_NORMAL) michael@0: { michael@0: while (*c >= size) michael@0: *c -= size; michael@0: while (*c < 0) michael@0: *c += size; michael@0: } michael@0: else if (repeat == PIXMAN_REPEAT_PAD) michael@0: { michael@0: *c = CLIP (*c, 0, size - 1); michael@0: } michael@0: else /* REFLECT */ michael@0: { michael@0: *c = MOD (*c, size * 2); michael@0: if (*c >= size) michael@0: *c = size * 2 - *c - 1; michael@0: } michael@0: return TRUE; michael@0: } michael@0: michael@0: /* michael@0: * For each scanline fetched from source image with PAD repeat: michael@0: * - calculate how many pixels need to be padded on the left side michael@0: * - calculate how many pixels need to be padded on the right side michael@0: * - update width to only count pixels which are fetched from the image michael@0: * All this information is returned via 'width', 'left_pad', 'right_pad' michael@0: * arguments. The code is assuming that 'unit_x' is positive. michael@0: * michael@0: * Note: 64-bit math is used in order to avoid potential overflows, which michael@0: * is probably excessive in many cases. This particular function michael@0: * may need its own correctness test and performance tuning. michael@0: */ michael@0: static force_inline void michael@0: pad_repeat_get_scanline_bounds (int32_t source_image_width, michael@0: pixman_fixed_t vx, michael@0: pixman_fixed_t unit_x, michael@0: int32_t * width, michael@0: int32_t * left_pad, michael@0: int32_t * right_pad) michael@0: { michael@0: int64_t max_vx = (int64_t) source_image_width << 16; michael@0: int64_t tmp; michael@0: if (vx < 0) michael@0: { michael@0: tmp = ((int64_t) unit_x - 1 - vx) / unit_x; michael@0: if (tmp > *width) michael@0: { michael@0: *left_pad = *width; michael@0: *width = 0; michael@0: } michael@0: else michael@0: { michael@0: *left_pad = (int32_t) tmp; michael@0: *width -= (int32_t) tmp; michael@0: } michael@0: } michael@0: else michael@0: { michael@0: *left_pad = 0; michael@0: } michael@0: tmp = ((int64_t) unit_x - 1 - vx + max_vx) / unit_x - *left_pad; michael@0: if (tmp < 0) michael@0: { michael@0: *right_pad = *width; michael@0: *width = 0; michael@0: } michael@0: else if (tmp >= *width) michael@0: { michael@0: *right_pad = 0; michael@0: } michael@0: else michael@0: { michael@0: *right_pad = *width - (int32_t) tmp; michael@0: *width = (int32_t) tmp; michael@0: } michael@0: } michael@0: michael@0: /* A macroified version of specialized nearest scalers for some michael@0: * common 8888 and 565 formats. It supports SRC and OVER ops. michael@0: * michael@0: * There are two repeat versions, one that handles repeat normal, michael@0: * and one without repeat handling that only works if the src region michael@0: * used is completely covered by the pre-repeated source samples. michael@0: * michael@0: * The loops are unrolled to process two pixels per iteration for better michael@0: * performance on most CPU architectures (superscalar processors michael@0: * can issue several operations simultaneously, other processors can hide michael@0: * instructions latencies by pipelining operations). Unrolling more michael@0: * does not make much sense because the compiler will start running out michael@0: * of spare registers soon. michael@0: */ michael@0: michael@0: #define GET_8888_ALPHA(s) ((s) >> 24) michael@0: /* This is not actually used since we don't have an OVER with michael@0: 565 source, but it is needed to build. */ michael@0: #define GET_0565_ALPHA(s) 0xff michael@0: michael@0: #define FAST_NEAREST_SCANLINE(scanline_func_name, SRC_FORMAT, DST_FORMAT, \ michael@0: src_type_t, dst_type_t, OP, repeat_mode) \ michael@0: static force_inline void \ michael@0: scanline_func_name (dst_type_t *dst, \ michael@0: const src_type_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: uint32_t d; \ michael@0: src_type_t s1, s2; \ michael@0: uint8_t a1, a2; \ michael@0: int x1, x2; \ michael@0: \ michael@0: if (PIXMAN_OP_ ## OP == PIXMAN_OP_OVER && fully_transparent_src) \ michael@0: return; \ michael@0: \ michael@0: if (PIXMAN_OP_ ## OP != PIXMAN_OP_SRC && PIXMAN_OP_ ## OP != PIXMAN_OP_OVER) \ michael@0: abort(); \ michael@0: \ michael@0: while ((w -= 2) >= 0) \ michael@0: { \ michael@0: x1 = vx >> 16; \ michael@0: vx += unit_x; \ michael@0: if (PIXMAN_REPEAT_ ## repeat_mode == PIXMAN_REPEAT_NORMAL) \ michael@0: { \ michael@0: /* This works because we know that unit_x is positive */ \ michael@0: while (vx >= max_vx) \ michael@0: vx -= max_vx; \ michael@0: } \ michael@0: s1 = src[x1]; \ michael@0: \ michael@0: x2 = vx >> 16; \ michael@0: vx += unit_x; \ michael@0: if (PIXMAN_REPEAT_ ## repeat_mode == PIXMAN_REPEAT_NORMAL) \ michael@0: { \ michael@0: /* This works because we know that unit_x is positive */ \ michael@0: while (vx >= max_vx) \ michael@0: vx -= max_vx; \ michael@0: } \ michael@0: s2 = src[x2]; \ michael@0: \ michael@0: if (PIXMAN_OP_ ## OP == PIXMAN_OP_OVER) \ michael@0: { \ michael@0: a1 = GET_ ## SRC_FORMAT ## _ALPHA(s1); \ michael@0: a2 = GET_ ## SRC_FORMAT ## _ALPHA(s2); \ michael@0: \ michael@0: if (a1 == 0xff) \ michael@0: { \ michael@0: *dst = CONVERT_ ## SRC_FORMAT ## _TO_ ## DST_FORMAT (s1); \ michael@0: } \ michael@0: else if (s1) \ michael@0: { \ michael@0: d = CONVERT_ ## DST_FORMAT ## _TO_8888 (*dst); \ michael@0: s1 = CONVERT_ ## SRC_FORMAT ## _TO_8888 (s1); \ michael@0: a1 ^= 0xff; \ michael@0: UN8x4_MUL_UN8_ADD_UN8x4 (d, a1, s1); \ michael@0: *dst = CONVERT_8888_TO_ ## DST_FORMAT (d); \ michael@0: } \ michael@0: dst++; \ michael@0: \ michael@0: if (a2 == 0xff) \ michael@0: { \ michael@0: *dst = CONVERT_ ## SRC_FORMAT ## _TO_ ## DST_FORMAT (s2); \ michael@0: } \ michael@0: else if (s2) \ michael@0: { \ michael@0: d = CONVERT_## DST_FORMAT ## _TO_8888 (*dst); \ michael@0: s2 = CONVERT_## SRC_FORMAT ## _TO_8888 (s2); \ michael@0: a2 ^= 0xff; \ michael@0: UN8x4_MUL_UN8_ADD_UN8x4 (d, a2, s2); \ michael@0: *dst = CONVERT_8888_TO_ ## DST_FORMAT (d); \ michael@0: } \ michael@0: dst++; \ michael@0: } \ michael@0: else /* PIXMAN_OP_SRC */ \ michael@0: { \ michael@0: *dst++ = CONVERT_ ## SRC_FORMAT ## _TO_ ## DST_FORMAT (s1); \ michael@0: *dst++ = CONVERT_ ## SRC_FORMAT ## _TO_ ## DST_FORMAT (s2); \ michael@0: } \ michael@0: } \ michael@0: \ michael@0: if (w & 1) \ michael@0: { \ michael@0: x1 = vx >> 16; \ michael@0: s1 = src[x1]; \ michael@0: \ michael@0: if (PIXMAN_OP_ ## OP == PIXMAN_OP_OVER) \ michael@0: { \ michael@0: a1 = GET_ ## SRC_FORMAT ## _ALPHA(s1); \ michael@0: \ michael@0: if (a1 == 0xff) \ michael@0: { \ michael@0: *dst = CONVERT_ ## SRC_FORMAT ## _TO_ ## DST_FORMAT (s1); \ michael@0: } \ michael@0: else if (s1) \ michael@0: { \ michael@0: d = CONVERT_## DST_FORMAT ## _TO_8888 (*dst); \ michael@0: s1 = CONVERT_ ## SRC_FORMAT ## _TO_8888 (s1); \ michael@0: a1 ^= 0xff; \ michael@0: UN8x4_MUL_UN8_ADD_UN8x4 (d, a1, s1); \ michael@0: *dst = CONVERT_8888_TO_ ## DST_FORMAT (d); \ michael@0: } \ michael@0: dst++; \ michael@0: } \ michael@0: else /* PIXMAN_OP_SRC */ \ michael@0: { \ michael@0: *dst++ = CONVERT_ ## SRC_FORMAT ## _TO_ ## DST_FORMAT (s1); \ michael@0: } \ michael@0: } \ michael@0: } michael@0: michael@0: #define FAST_NEAREST_MAINLOOP_INT(scale_func_name, scanline_func, src_type_t, mask_type_t, \ michael@0: dst_type_t, repeat_mode, have_mask, mask_is_solid) \ michael@0: static void \ michael@0: fast_composite_scaled_nearest ## scale_func_name (pixman_implementation_t *imp, \ michael@0: pixman_op_t op, \ michael@0: pixman_image_t * src_image, \ michael@0: pixman_image_t * mask_image, \ michael@0: pixman_image_t * dst_image, \ michael@0: int32_t src_x, \ michael@0: int32_t src_y, \ michael@0: int32_t mask_x, \ michael@0: int32_t mask_y, \ michael@0: int32_t dst_x, \ michael@0: int32_t dst_y, \ michael@0: int32_t width, \ michael@0: int32_t height) \ michael@0: { \ michael@0: dst_type_t *dst_line; \ michael@0: mask_type_t *mask_line; \ michael@0: src_type_t *src_first_line; \ michael@0: int y; \ michael@0: pixman_fixed_t max_vx = INT32_MAX; /* suppress uninitialized variable warning */ \ michael@0: pixman_fixed_t max_vy; \ michael@0: pixman_vector_t v; \ michael@0: pixman_fixed_t vx, vy; \ michael@0: pixman_fixed_t unit_x, unit_y; \ michael@0: int32_t left_pad, right_pad; \ michael@0: \ michael@0: src_type_t *src; \ michael@0: dst_type_t *dst; \ michael@0: mask_type_t solid_mask; \ michael@0: const mask_type_t *mask = &solid_mask; \ michael@0: int src_stride, mask_stride, dst_stride; \ michael@0: \ michael@0: PIXMAN_IMAGE_GET_LINE (dst_image, dst_x, dst_y, dst_type_t, dst_stride, dst_line, 1); \ michael@0: if (have_mask) \ michael@0: { \ michael@0: if (mask_is_solid) \ michael@0: solid_mask = _pixman_image_get_solid (imp, mask_image, dst_image->bits.format); \ michael@0: else \ michael@0: PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, mask_type_t, \ michael@0: mask_stride, mask_line, 1); \ michael@0: } \ 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: PIXMAN_IMAGE_GET_LINE (src_image, 0, 0, src_type_t, src_stride, src_first_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: vx = v.vector[0]; \ michael@0: vy = v.vector[1]; \ michael@0: \ michael@0: if (PIXMAN_REPEAT_ ## repeat_mode == PIXMAN_REPEAT_NORMAL) \ michael@0: { \ michael@0: /* Clamp repeating positions inside the actual samples */ \ michael@0: max_vx = src_image->bits.width << 16; \ michael@0: max_vy = src_image->bits.height << 16; \ michael@0: \ michael@0: repeat (PIXMAN_REPEAT_NORMAL, &vx, max_vx); \ michael@0: repeat (PIXMAN_REPEAT_NORMAL, &vy, max_vy); \ michael@0: } \ michael@0: \ michael@0: if (PIXMAN_REPEAT_ ## repeat_mode == PIXMAN_REPEAT_PAD || \ michael@0: PIXMAN_REPEAT_ ## repeat_mode == PIXMAN_REPEAT_NONE) \ michael@0: { \ michael@0: pad_repeat_get_scanline_bounds (src_image->bits.width, vx, unit_x, \ michael@0: &width, &left_pad, &right_pad); \ michael@0: vx += left_pad * unit_x; \ michael@0: } \ michael@0: \ michael@0: while (--height >= 0) \ michael@0: { \ michael@0: dst = dst_line; \ michael@0: dst_line += dst_stride; \ michael@0: if (have_mask && !mask_is_solid) \ michael@0: { \ michael@0: mask = mask_line; \ michael@0: mask_line += mask_stride; \ michael@0: } \ michael@0: \ michael@0: y = vy >> 16; \ michael@0: vy += unit_y; \ michael@0: if (PIXMAN_REPEAT_ ## repeat_mode == PIXMAN_REPEAT_NORMAL) \ michael@0: repeat (PIXMAN_REPEAT_NORMAL, &vy, max_vy); \ michael@0: if (PIXMAN_REPEAT_ ## repeat_mode == PIXMAN_REPEAT_PAD) \ michael@0: { \ michael@0: repeat (PIXMAN_REPEAT_PAD, &y, src_image->bits.height); \ michael@0: src = src_first_line + src_stride * y; \ michael@0: if (left_pad > 0) \ michael@0: { \ michael@0: scanline_func (mask, dst, src, left_pad, 0, 0, 0, FALSE); \ michael@0: } \ michael@0: if (width > 0) \ michael@0: { \ michael@0: scanline_func (mask + (mask_is_solid ? 0 : left_pad), \ michael@0: dst + left_pad, src, width, vx, unit_x, 0, FALSE); \ michael@0: } \ michael@0: if (right_pad > 0) \ michael@0: { \ michael@0: scanline_func (mask + (mask_is_solid ? 0 : left_pad + width), \ michael@0: dst + left_pad + width, src + src_image->bits.width - 1, \ michael@0: right_pad, 0, 0, 0, FALSE); \ michael@0: } \ michael@0: } \ michael@0: else if (PIXMAN_REPEAT_ ## repeat_mode == PIXMAN_REPEAT_NONE) \ michael@0: { \ michael@0: static const src_type_t zero[1] = { 0 }; \ michael@0: if (y < 0 || y >= src_image->bits.height) \ michael@0: { \ michael@0: scanline_func (mask, dst, zero, left_pad + width + right_pad, 0, 0, 0, TRUE); \ michael@0: continue; \ michael@0: } \ michael@0: src = src_first_line + src_stride * y; \ michael@0: if (left_pad > 0) \ michael@0: { \ michael@0: scanline_func (mask, dst, zero, left_pad, 0, 0, 0, TRUE); \ michael@0: } \ michael@0: if (width > 0) \ michael@0: { \ michael@0: scanline_func (mask + (mask_is_solid ? 0 : left_pad), \ michael@0: dst + left_pad, src, width, vx, unit_x, 0, FALSE); \ michael@0: } \ michael@0: if (right_pad > 0) \ michael@0: { \ michael@0: scanline_func (mask + (mask_is_solid ? 0 : left_pad + width), \ michael@0: dst + left_pad + width, zero, right_pad, 0, 0, 0, TRUE); \ michael@0: } \ michael@0: } \ michael@0: else \ michael@0: { \ michael@0: src = src_first_line + src_stride * y; \ michael@0: scanline_func (mask, dst, src, width, vx, unit_x, max_vx, FALSE); \ michael@0: } \ michael@0: } \ michael@0: } michael@0: michael@0: /* A workaround for old sun studio, see: https://bugs.freedesktop.org/show_bug.cgi?id=32764 */ michael@0: #define FAST_NEAREST_MAINLOOP_COMMON(scale_func_name, scanline_func, src_type_t, mask_type_t, \ michael@0: dst_type_t, repeat_mode, have_mask, mask_is_solid) \ michael@0: FAST_NEAREST_MAINLOOP_INT(_ ## scale_func_name, scanline_func, src_type_t, mask_type_t, \ michael@0: dst_type_t, repeat_mode, have_mask, mask_is_solid) michael@0: michael@0: #define FAST_NEAREST_MAINLOOP_NOMASK(scale_func_name, scanline_func, src_type_t, dst_type_t, \ michael@0: repeat_mode) \ michael@0: static force_inline void \ michael@0: scanline_func##scale_func_name##_wrapper ( \ michael@0: const uint8_t *mask, \ michael@0: dst_type_t *dst, \ michael@0: const src_type_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: scanline_func (dst, src, w, vx, unit_x, max_vx, fully_transparent_src); \ michael@0: } \ michael@0: FAST_NEAREST_MAINLOOP_INT (scale_func_name, scanline_func##scale_func_name##_wrapper, \ michael@0: src_type_t, uint8_t, dst_type_t, repeat_mode, FALSE, FALSE) michael@0: michael@0: #define FAST_NEAREST_MAINLOOP(scale_func_name, scanline_func, src_type_t, dst_type_t, \ michael@0: repeat_mode) \ michael@0: FAST_NEAREST_MAINLOOP_NOMASK(_ ## scale_func_name, scanline_func, src_type_t, \ michael@0: dst_type_t, repeat_mode) michael@0: michael@0: #define FAST_NEAREST(scale_func_name, SRC_FORMAT, DST_FORMAT, \ michael@0: src_type_t, dst_type_t, OP, repeat_mode) \ michael@0: FAST_NEAREST_SCANLINE(scaled_nearest_scanline_ ## scale_func_name ## _ ## OP, \ michael@0: SRC_FORMAT, DST_FORMAT, src_type_t, dst_type_t, \ michael@0: OP, repeat_mode) \ michael@0: FAST_NEAREST_MAINLOOP_NOMASK(_ ## scale_func_name ## _ ## OP, \ michael@0: scaled_nearest_scanline_ ## scale_func_name ## _ ## OP, \ michael@0: src_type_t, dst_type_t, repeat_mode) michael@0: michael@0: michael@0: #define SCALED_NEAREST_FLAGS \ michael@0: (FAST_PATH_SCALE_TRANSFORM | \ michael@0: FAST_PATH_NO_ALPHA_MAP | \ michael@0: FAST_PATH_NEAREST_FILTER | \ michael@0: FAST_PATH_NO_ACCESSORS | \ michael@0: FAST_PATH_NARROW_FORMAT) michael@0: michael@0: #define SIMPLE_NEAREST_FAST_PATH_NORMAL(op,s,d,func) \ michael@0: { PIXMAN_OP_ ## op, \ michael@0: PIXMAN_ ## s, \ michael@0: (SCALED_NEAREST_FLAGS | \ michael@0: FAST_PATH_NORMAL_REPEAT | \ michael@0: FAST_PATH_X_UNIT_POSITIVE), \ michael@0: PIXMAN_null, 0, \ michael@0: PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \ michael@0: fast_composite_scaled_nearest_ ## func ## _normal ## _ ## op, \ michael@0: } michael@0: michael@0: #define SIMPLE_NEAREST_FAST_PATH_PAD(op,s,d,func) \ michael@0: { PIXMAN_OP_ ## op, \ michael@0: PIXMAN_ ## s, \ michael@0: (SCALED_NEAREST_FLAGS | \ michael@0: FAST_PATH_PAD_REPEAT | \ michael@0: FAST_PATH_X_UNIT_POSITIVE), \ michael@0: PIXMAN_null, 0, \ michael@0: PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \ michael@0: fast_composite_scaled_nearest_ ## func ## _pad ## _ ## op, \ michael@0: } michael@0: michael@0: #define SIMPLE_NEAREST_FAST_PATH_NONE(op,s,d,func) \ michael@0: { PIXMAN_OP_ ## op, \ michael@0: PIXMAN_ ## s, \ michael@0: (SCALED_NEAREST_FLAGS | \ michael@0: FAST_PATH_NONE_REPEAT | \ michael@0: FAST_PATH_X_UNIT_POSITIVE), \ michael@0: PIXMAN_null, 0, \ michael@0: PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \ michael@0: fast_composite_scaled_nearest_ ## func ## _none ## _ ## op, \ michael@0: } michael@0: michael@0: #define SIMPLE_NEAREST_FAST_PATH_COVER(op,s,d,func) \ michael@0: { PIXMAN_OP_ ## op, \ michael@0: PIXMAN_ ## s, \ michael@0: SCALED_NEAREST_FLAGS | FAST_PATH_SAMPLES_COVER_CLIP, \ michael@0: PIXMAN_null, 0, \ michael@0: PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \ michael@0: fast_composite_scaled_nearest_ ## func ## _cover ## _ ## op, \ michael@0: } michael@0: michael@0: #define SIMPLE_NEAREST_A8_MASK_FAST_PATH_NORMAL(op,s,d,func) \ michael@0: { PIXMAN_OP_ ## op, \ michael@0: PIXMAN_ ## s, \ michael@0: (SCALED_NEAREST_FLAGS | \ michael@0: FAST_PATH_NORMAL_REPEAT | \ michael@0: FAST_PATH_X_UNIT_POSITIVE), \ michael@0: PIXMAN_a8, MASK_FLAGS (a8, FAST_PATH_UNIFIED_ALPHA), \ michael@0: PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \ michael@0: fast_composite_scaled_nearest_ ## func ## _normal ## _ ## op, \ michael@0: } michael@0: michael@0: #define SIMPLE_NEAREST_A8_MASK_FAST_PATH_PAD(op,s,d,func) \ michael@0: { PIXMAN_OP_ ## op, \ michael@0: PIXMAN_ ## s, \ michael@0: (SCALED_NEAREST_FLAGS | \ michael@0: FAST_PATH_PAD_REPEAT | \ michael@0: FAST_PATH_X_UNIT_POSITIVE), \ michael@0: PIXMAN_a8, MASK_FLAGS (a8, FAST_PATH_UNIFIED_ALPHA), \ michael@0: PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \ michael@0: fast_composite_scaled_nearest_ ## func ## _pad ## _ ## op, \ michael@0: } michael@0: michael@0: #define SIMPLE_NEAREST_A8_MASK_FAST_PATH_NONE(op,s,d,func) \ michael@0: { PIXMAN_OP_ ## op, \ michael@0: PIXMAN_ ## s, \ michael@0: (SCALED_NEAREST_FLAGS | \ michael@0: FAST_PATH_NONE_REPEAT | \ michael@0: FAST_PATH_X_UNIT_POSITIVE), \ michael@0: PIXMAN_a8, MASK_FLAGS (a8, FAST_PATH_UNIFIED_ALPHA), \ michael@0: PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \ michael@0: fast_composite_scaled_nearest_ ## func ## _none ## _ ## op, \ michael@0: } michael@0: michael@0: #define SIMPLE_NEAREST_A8_MASK_FAST_PATH_COVER(op,s,d,func) \ michael@0: { PIXMAN_OP_ ## op, \ michael@0: PIXMAN_ ## s, \ michael@0: SCALED_NEAREST_FLAGS | FAST_PATH_SAMPLES_COVER_CLIP, \ michael@0: PIXMAN_a8, MASK_FLAGS (a8, FAST_PATH_UNIFIED_ALPHA), \ michael@0: PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \ michael@0: fast_composite_scaled_nearest_ ## func ## _cover ## _ ## op, \ michael@0: } michael@0: michael@0: #define SIMPLE_NEAREST_SOLID_MASK_FAST_PATH_NORMAL(op,s,d,func) \ michael@0: { PIXMAN_OP_ ## op, \ michael@0: PIXMAN_ ## s, \ michael@0: (SCALED_NEAREST_FLAGS | \ michael@0: FAST_PATH_NORMAL_REPEAT | \ michael@0: FAST_PATH_X_UNIT_POSITIVE), \ michael@0: PIXMAN_solid, MASK_FLAGS (solid, FAST_PATH_UNIFIED_ALPHA), \ michael@0: PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \ michael@0: fast_composite_scaled_nearest_ ## func ## _normal ## _ ## op, \ michael@0: } michael@0: michael@0: #define SIMPLE_NEAREST_SOLID_MASK_FAST_PATH_PAD(op,s,d,func) \ michael@0: { PIXMAN_OP_ ## op, \ michael@0: PIXMAN_ ## s, \ michael@0: (SCALED_NEAREST_FLAGS | \ michael@0: FAST_PATH_PAD_REPEAT | \ michael@0: FAST_PATH_X_UNIT_POSITIVE), \ michael@0: PIXMAN_solid, MASK_FLAGS (solid, FAST_PATH_UNIFIED_ALPHA), \ michael@0: PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \ michael@0: fast_composite_scaled_nearest_ ## func ## _pad ## _ ## op, \ michael@0: } michael@0: michael@0: #define SIMPLE_NEAREST_SOLID_MASK_FAST_PATH_NONE(op,s,d,func) \ michael@0: { PIXMAN_OP_ ## op, \ michael@0: PIXMAN_ ## s, \ michael@0: (SCALED_NEAREST_FLAGS | \ michael@0: FAST_PATH_NONE_REPEAT | \ michael@0: FAST_PATH_X_UNIT_POSITIVE), \ michael@0: PIXMAN_solid, MASK_FLAGS (solid, FAST_PATH_UNIFIED_ALPHA), \ michael@0: PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \ michael@0: fast_composite_scaled_nearest_ ## func ## _none ## _ ## op, \ michael@0: } michael@0: michael@0: #define SIMPLE_NEAREST_SOLID_MASK_FAST_PATH_COVER(op,s,d,func) \ michael@0: { PIXMAN_OP_ ## op, \ michael@0: PIXMAN_ ## s, \ michael@0: SCALED_NEAREST_FLAGS | FAST_PATH_SAMPLES_COVER_CLIP, \ michael@0: PIXMAN_solid, MASK_FLAGS (solid, FAST_PATH_UNIFIED_ALPHA), \ michael@0: PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \ michael@0: fast_composite_scaled_nearest_ ## func ## _cover ## _ ## op, \ michael@0: } michael@0: michael@0: /* Prefer the use of 'cover' variant, because it is faster */ michael@0: #define SIMPLE_NEAREST_FAST_PATH(op,s,d,func) \ michael@0: SIMPLE_NEAREST_FAST_PATH_COVER (op,s,d,func), \ michael@0: SIMPLE_NEAREST_FAST_PATH_NONE (op,s,d,func), \ michael@0: SIMPLE_NEAREST_FAST_PATH_PAD (op,s,d,func), \ michael@0: SIMPLE_NEAREST_FAST_PATH_NORMAL (op,s,d,func) michael@0: michael@0: #define SIMPLE_NEAREST_A8_MASK_FAST_PATH(op,s,d,func) \ michael@0: SIMPLE_NEAREST_A8_MASK_FAST_PATH_COVER (op,s,d,func), \ michael@0: SIMPLE_NEAREST_A8_MASK_FAST_PATH_NONE (op,s,d,func), \ michael@0: SIMPLE_NEAREST_A8_MASK_FAST_PATH_PAD (op,s,d,func) michael@0: michael@0: #define SIMPLE_NEAREST_SOLID_MASK_FAST_PATH(op,s,d,func) \ michael@0: SIMPLE_NEAREST_SOLID_MASK_FAST_PATH_COVER (op,s,d,func), \ michael@0: SIMPLE_NEAREST_SOLID_MASK_FAST_PATH_NONE (op,s,d,func), \ michael@0: SIMPLE_NEAREST_SOLID_MASK_FAST_PATH_PAD (op,s,d,func) michael@0: michael@0: /*****************************************************************************/ michael@0: michael@0: /* michael@0: * Identify 5 zones in each scanline for bilinear scaling. Depending on michael@0: * whether 2 pixels to be interpolated are fetched from the image itself, michael@0: * from the padding area around it or from both image and padding area. michael@0: */ michael@0: static force_inline void michael@0: bilinear_pad_repeat_get_scanline_bounds (int32_t source_image_width, michael@0: pixman_fixed_t vx, michael@0: pixman_fixed_t unit_x, michael@0: int32_t * left_pad, michael@0: int32_t * left_tz, michael@0: int32_t * width, michael@0: int32_t * right_tz, michael@0: int32_t * right_pad) michael@0: { michael@0: int width1 = *width, left_pad1, right_pad1; michael@0: int width2 = *width, left_pad2, right_pad2; michael@0: michael@0: pad_repeat_get_scanline_bounds (source_image_width, vx, unit_x, michael@0: &width1, &left_pad1, &right_pad1); michael@0: pad_repeat_get_scanline_bounds (source_image_width, vx + pixman_fixed_1, michael@0: unit_x, &width2, &left_pad2, &right_pad2); michael@0: michael@0: *left_pad = left_pad2; michael@0: *left_tz = left_pad1 - left_pad2; michael@0: *right_tz = right_pad2 - right_pad1; michael@0: *right_pad = right_pad1; michael@0: *width -= *left_pad + *left_tz + *right_tz + *right_pad; michael@0: } michael@0: michael@0: /* michael@0: * Main loop template for single pass bilinear scaling. It needs to be michael@0: * provided with 'scanline_func' which should do the compositing operation. michael@0: * The needed function has the following prototype: michael@0: * michael@0: * scanline_func (dst_type_t * dst, michael@0: * const mask_type_ * mask, michael@0: * const src_type_t * src_top, michael@0: * const src_type_t * src_bottom, michael@0: * int32_t width, michael@0: * int weight_top, michael@0: * int weight_bottom, 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: * Where: michael@0: * dst - destination scanline buffer for storing results michael@0: * mask - mask buffer (or single value for solid mask) michael@0: * src_top, src_bottom - two source scanlines michael@0: * width - number of pixels to process michael@0: * weight_top - weight of the top row for interpolation michael@0: * weight_bottom - weight of the bottom row for interpolation michael@0: * vx - initial position for fetching the first pair of michael@0: * pixels from the source buffer michael@0: * unit_x - position increment needed to move to the next pair michael@0: * of pixels michael@0: * max_vx - image size as a fixed point value, can be used for michael@0: * implementing NORMAL repeat (when it is supported) michael@0: * zero_src - boolean hint variable, which is set to TRUE when michael@0: * all source pixels are fetched from zero padding michael@0: * zone for NONE repeat michael@0: * michael@0: * Note: normally the sum of 'weight_top' and 'weight_bottom' is equal to 256, michael@0: * but sometimes it may be less than that for NONE repeat when handling michael@0: * fuzzy antialiased top or bottom image edges. Also both top and michael@0: * bottom weight variables are guaranteed to have value in 0-255 michael@0: * range and can fit into unsigned byte or be used with 8-bit SIMD michael@0: * multiplication instructions. michael@0: */ michael@0: #define FAST_BILINEAR_MAINLOOP_INT(scale_func_name, scanline_func, src_type_t, mask_type_t, \ michael@0: dst_type_t, repeat_mode, have_mask, mask_is_solid) \ michael@0: static void \ michael@0: fast_composite_scaled_bilinear ## scale_func_name (pixman_implementation_t *imp, \ michael@0: pixman_op_t op, \ michael@0: pixman_image_t * src_image, \ michael@0: pixman_image_t * mask_image, \ michael@0: pixman_image_t * dst_image, \ michael@0: int32_t src_x, \ michael@0: int32_t src_y, \ michael@0: int32_t mask_x, \ michael@0: int32_t mask_y, \ michael@0: int32_t dst_x, \ michael@0: int32_t dst_y, \ michael@0: int32_t width, \ michael@0: int32_t height) \ michael@0: { \ michael@0: dst_type_t *dst_line; \ michael@0: mask_type_t *mask_line; \ michael@0: src_type_t *src_first_line; \ michael@0: int y1, y2; \ michael@0: pixman_fixed_t max_vx = INT32_MAX; /* suppress uninitialized variable warning */ \ michael@0: pixman_vector_t v; \ michael@0: pixman_fixed_t vx, vy; \ michael@0: pixman_fixed_t unit_x, unit_y; \ michael@0: int32_t left_pad, left_tz, right_tz, right_pad; \ michael@0: \ michael@0: dst_type_t *dst; \ michael@0: mask_type_t solid_mask; \ michael@0: const mask_type_t *mask = &solid_mask; \ michael@0: int src_stride, mask_stride, dst_stride; \ michael@0: \ michael@0: PIXMAN_IMAGE_GET_LINE (dst_image, dst_x, dst_y, dst_type_t, dst_stride, dst_line, 1); \ michael@0: if (have_mask) \ michael@0: { \ michael@0: if (mask_is_solid) \ michael@0: { \ michael@0: solid_mask = _pixman_image_get_solid (imp, mask_image, dst_image->bits.format); \ michael@0: mask_stride = 0; \ michael@0: } \ michael@0: else \ michael@0: { \ michael@0: PIXMAN_IMAGE_GET_LINE (mask_image, mask_x, mask_y, mask_type_t, \ michael@0: mask_stride, mask_line, 1); \ michael@0: } \ michael@0: } \ 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: PIXMAN_IMAGE_GET_LINE (src_image, 0, 0, src_type_t, src_stride, src_first_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: v.vector[0] -= pixman_fixed_1 / 2; \ michael@0: v.vector[1] -= pixman_fixed_1 / 2; \ michael@0: \ michael@0: vy = v.vector[1]; \ michael@0: \ michael@0: if (PIXMAN_REPEAT_ ## repeat_mode == PIXMAN_REPEAT_PAD || \ michael@0: PIXMAN_REPEAT_ ## repeat_mode == PIXMAN_REPEAT_NONE) \ michael@0: { \ michael@0: bilinear_pad_repeat_get_scanline_bounds (src_image->bits.width, v.vector[0], unit_x, \ michael@0: &left_pad, &left_tz, &width, &right_tz, &right_pad); \ michael@0: if (PIXMAN_REPEAT_ ## repeat_mode == PIXMAN_REPEAT_PAD) \ michael@0: { \ michael@0: /* PAD repeat does not need special handling for 'transition zones' and */ \ michael@0: /* they can be combined with 'padding zones' safely */ \ michael@0: left_pad += left_tz; \ michael@0: right_pad += right_tz; \ michael@0: left_tz = right_tz = 0; \ michael@0: } \ michael@0: v.vector[0] += left_pad * unit_x; \ michael@0: } \ michael@0: \ michael@0: while (--height >= 0) \ michael@0: { \ michael@0: int weight1, weight2; \ michael@0: dst = dst_line; \ michael@0: dst_line += dst_stride; \ michael@0: vx = v.vector[0]; \ michael@0: if (have_mask && !mask_is_solid) \ michael@0: { \ michael@0: mask = mask_line; \ michael@0: mask_line += mask_stride; \ michael@0: } \ michael@0: \ michael@0: y1 = pixman_fixed_to_int (vy); \ michael@0: weight2 = (vy >> 8) & 0xff; \ michael@0: if (weight2) \ michael@0: { \ michael@0: /* normal case, both row weights are in 0-255 range and fit unsigned byte */ \ michael@0: y2 = y1 + 1; \ michael@0: weight1 = 256 - weight2; \ michael@0: } \ michael@0: else \ michael@0: { \ michael@0: /* set both top and bottom row to the same scanline, and weights to 128+128 */ \ michael@0: y2 = y1; \ michael@0: weight1 = weight2 = 128; \ michael@0: } \ michael@0: vy += unit_y; \ michael@0: if (PIXMAN_REPEAT_ ## repeat_mode == PIXMAN_REPEAT_PAD) \ michael@0: { \ michael@0: src_type_t *src1, *src2; \ michael@0: src_type_t buf1[2]; \ michael@0: src_type_t buf2[2]; \ michael@0: repeat (PIXMAN_REPEAT_PAD, &y1, src_image->bits.height); \ michael@0: repeat (PIXMAN_REPEAT_PAD, &y2, src_image->bits.height); \ michael@0: src1 = src_first_line + src_stride * y1; \ michael@0: src2 = src_first_line + src_stride * y2; \ michael@0: \ michael@0: if (left_pad > 0) \ michael@0: { \ michael@0: buf1[0] = buf1[1] = src1[0]; \ michael@0: buf2[0] = buf2[1] = src2[0]; \ michael@0: scanline_func (dst, mask, \ michael@0: buf1, buf2, left_pad, weight1, weight2, 0, 0, 0, FALSE); \ michael@0: dst += left_pad; \ michael@0: if (have_mask && !mask_is_solid) \ michael@0: mask += left_pad; \ michael@0: } \ michael@0: if (width > 0) \ michael@0: { \ michael@0: scanline_func (dst, mask, \ michael@0: src1, src2, width, weight1, weight2, vx, unit_x, 0, FALSE); \ michael@0: dst += width; \ michael@0: if (have_mask && !mask_is_solid) \ michael@0: mask += width; \ michael@0: } \ michael@0: if (right_pad > 0) \ michael@0: { \ michael@0: buf1[0] = buf1[1] = src1[src_image->bits.width - 1]; \ michael@0: buf2[0] = buf2[1] = src2[src_image->bits.width - 1]; \ michael@0: scanline_func (dst, mask, \ michael@0: buf1, buf2, right_pad, weight1, weight2, 0, 0, 0, FALSE); \ michael@0: } \ michael@0: } \ michael@0: else if (PIXMAN_REPEAT_ ## repeat_mode == PIXMAN_REPEAT_NONE) \ michael@0: { \ michael@0: src_type_t *src1, *src2; \ michael@0: src_type_t buf1[2]; \ michael@0: src_type_t buf2[2]; \ michael@0: /* handle top/bottom zero padding by just setting weights to 0 if needed */ \ michael@0: if (y1 < 0) \ michael@0: { \ michael@0: weight1 = 0; \ michael@0: y1 = 0; \ michael@0: } \ michael@0: if (y1 >= src_image->bits.height) \ michael@0: { \ michael@0: weight1 = 0; \ michael@0: y1 = src_image->bits.height - 1; \ michael@0: } \ michael@0: if (y2 < 0) \ michael@0: { \ michael@0: weight2 = 0; \ michael@0: y2 = 0; \ michael@0: } \ michael@0: if (y2 >= src_image->bits.height) \ michael@0: { \ michael@0: weight2 = 0; \ michael@0: y2 = src_image->bits.height - 1; \ michael@0: } \ michael@0: src1 = src_first_line + src_stride * y1; \ michael@0: src2 = src_first_line + src_stride * y2; \ michael@0: \ michael@0: if (left_pad > 0) \ michael@0: { \ michael@0: buf1[0] = buf1[1] = 0; \ michael@0: buf2[0] = buf2[1] = 0; \ michael@0: scanline_func (dst, mask, \ michael@0: buf1, buf2, left_pad, weight1, weight2, 0, 0, 0, TRUE); \ michael@0: dst += left_pad; \ michael@0: if (have_mask && !mask_is_solid) \ michael@0: mask += left_pad; \ michael@0: } \ michael@0: if (left_tz > 0) \ michael@0: { \ michael@0: buf1[0] = 0; \ michael@0: buf1[1] = src1[0]; \ michael@0: buf2[0] = 0; \ michael@0: buf2[1] = src2[0]; \ michael@0: scanline_func (dst, mask, \ michael@0: buf1, buf2, left_tz, weight1, weight2, \ michael@0: pixman_fixed_frac (vx), unit_x, 0, FALSE); \ michael@0: dst += left_tz; \ michael@0: if (have_mask && !mask_is_solid) \ michael@0: mask += left_tz; \ michael@0: vx += left_tz * unit_x; \ michael@0: } \ michael@0: if (width > 0) \ michael@0: { \ michael@0: scanline_func (dst, mask, \ michael@0: src1, src2, width, weight1, weight2, vx, unit_x, 0, FALSE); \ michael@0: dst += width; \ michael@0: if (have_mask && !mask_is_solid) \ michael@0: mask += width; \ michael@0: vx += width * unit_x; \ michael@0: } \ michael@0: if (right_tz > 0) \ michael@0: { \ michael@0: buf1[0] = src1[src_image->bits.width - 1]; \ michael@0: buf1[1] = 0; \ michael@0: buf2[0] = src2[src_image->bits.width - 1]; \ michael@0: buf2[1] = 0; \ michael@0: scanline_func (dst, mask, \ michael@0: buf1, buf2, right_tz, weight1, weight2, \ michael@0: pixman_fixed_frac (vx), unit_x, 0, FALSE); \ michael@0: dst += right_tz; \ michael@0: if (have_mask && !mask_is_solid) \ michael@0: mask += right_tz; \ michael@0: } \ michael@0: if (right_pad > 0) \ michael@0: { \ michael@0: buf1[0] = buf1[1] = 0; \ michael@0: buf2[0] = buf2[1] = 0; \ michael@0: scanline_func (dst, mask, \ michael@0: buf1, buf2, right_pad, weight1, weight2, 0, 0, 0, TRUE); \ michael@0: } \ michael@0: } \ michael@0: else \ michael@0: { \ michael@0: scanline_func (dst, mask, src_first_line + src_stride * y1, \ michael@0: src_first_line + src_stride * y2, width, \ michael@0: weight1, weight2, vx, unit_x, max_vx, FALSE); \ michael@0: } \ michael@0: } \ michael@0: } michael@0: michael@0: /* A workaround for old sun studio, see: https://bugs.freedesktop.org/show_bug.cgi?id=32764 */ michael@0: #define FAST_BILINEAR_MAINLOOP_COMMON(scale_func_name, scanline_func, src_type_t, mask_type_t, \ michael@0: dst_type_t, repeat_mode, have_mask, mask_is_solid) \ michael@0: FAST_BILINEAR_MAINLOOP_INT(_ ## scale_func_name, scanline_func, src_type_t, mask_type_t,\ michael@0: dst_type_t, repeat_mode, have_mask, mask_is_solid) michael@0: michael@0: #define SCALED_BILINEAR_FLAGS \ michael@0: (FAST_PATH_SCALE_TRANSFORM | \ michael@0: FAST_PATH_NO_ALPHA_MAP | \ michael@0: FAST_PATH_BILINEAR_FILTER | \ michael@0: FAST_PATH_NO_ACCESSORS | \ michael@0: FAST_PATH_NARROW_FORMAT) michael@0: michael@0: #define SIMPLE_BILINEAR_FAST_PATH_PAD(op,s,d,func) \ michael@0: { PIXMAN_OP_ ## op, \ michael@0: PIXMAN_ ## s, \ michael@0: (SCALED_BILINEAR_FLAGS | \ michael@0: FAST_PATH_PAD_REPEAT | \ michael@0: FAST_PATH_X_UNIT_POSITIVE), \ michael@0: PIXMAN_null, 0, \ michael@0: PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \ michael@0: fast_composite_scaled_bilinear_ ## func ## _pad ## _ ## op, \ michael@0: } michael@0: michael@0: #define SIMPLE_BILINEAR_FAST_PATH_NONE(op,s,d,func) \ michael@0: { PIXMAN_OP_ ## op, \ michael@0: PIXMAN_ ## s, \ michael@0: (SCALED_BILINEAR_FLAGS | \ michael@0: FAST_PATH_NONE_REPEAT | \ michael@0: FAST_PATH_X_UNIT_POSITIVE), \ michael@0: PIXMAN_null, 0, \ michael@0: PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \ michael@0: fast_composite_scaled_bilinear_ ## func ## _none ## _ ## op, \ michael@0: } michael@0: michael@0: #define SIMPLE_BILINEAR_FAST_PATH_COVER(op,s,d,func) \ michael@0: { PIXMAN_OP_ ## op, \ michael@0: PIXMAN_ ## s, \ michael@0: SCALED_BILINEAR_FLAGS | FAST_PATH_SAMPLES_COVER_CLIP, \ michael@0: PIXMAN_null, 0, \ michael@0: PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \ michael@0: fast_composite_scaled_bilinear_ ## func ## _cover ## _ ## op, \ michael@0: } michael@0: michael@0: #define SIMPLE_BILINEAR_A8_MASK_FAST_PATH_PAD(op,s,d,func) \ michael@0: { PIXMAN_OP_ ## op, \ michael@0: PIXMAN_ ## s, \ michael@0: (SCALED_BILINEAR_FLAGS | \ michael@0: FAST_PATH_PAD_REPEAT | \ michael@0: FAST_PATH_X_UNIT_POSITIVE), \ michael@0: PIXMAN_a8, MASK_FLAGS (a8, FAST_PATH_UNIFIED_ALPHA), \ michael@0: PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \ michael@0: fast_composite_scaled_bilinear_ ## func ## _pad ## _ ## op, \ michael@0: } michael@0: michael@0: #define SIMPLE_BILINEAR_A8_MASK_FAST_PATH_NONE(op,s,d,func) \ michael@0: { PIXMAN_OP_ ## op, \ michael@0: PIXMAN_ ## s, \ michael@0: (SCALED_BILINEAR_FLAGS | \ michael@0: FAST_PATH_NONE_REPEAT | \ michael@0: FAST_PATH_X_UNIT_POSITIVE), \ michael@0: PIXMAN_a8, MASK_FLAGS (a8, FAST_PATH_UNIFIED_ALPHA), \ michael@0: PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \ michael@0: fast_composite_scaled_bilinear_ ## func ## _none ## _ ## op, \ michael@0: } michael@0: michael@0: #define SIMPLE_BILINEAR_A8_MASK_FAST_PATH_COVER(op,s,d,func) \ michael@0: { PIXMAN_OP_ ## op, \ michael@0: PIXMAN_ ## s, \ michael@0: SCALED_BILINEAR_FLAGS | FAST_PATH_SAMPLES_COVER_CLIP, \ michael@0: PIXMAN_a8, MASK_FLAGS (a8, FAST_PATH_UNIFIED_ALPHA), \ michael@0: PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \ michael@0: fast_composite_scaled_bilinear_ ## func ## _cover ## _ ## op, \ michael@0: } michael@0: michael@0: #define SIMPLE_BILINEAR_SOLID_MASK_FAST_PATH_PAD(op,s,d,func) \ michael@0: { PIXMAN_OP_ ## op, \ michael@0: PIXMAN_ ## s, \ michael@0: (SCALED_BILINEAR_FLAGS | \ michael@0: FAST_PATH_PAD_REPEAT | \ michael@0: FAST_PATH_X_UNIT_POSITIVE), \ michael@0: PIXMAN_solid, MASK_FLAGS (solid, FAST_PATH_UNIFIED_ALPHA), \ michael@0: PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \ michael@0: fast_composite_scaled_bilinear_ ## func ## _pad ## _ ## op, \ michael@0: } michael@0: michael@0: #define SIMPLE_BILINEAR_SOLID_MASK_FAST_PATH_NONE(op,s,d,func) \ michael@0: { PIXMAN_OP_ ## op, \ michael@0: PIXMAN_ ## s, \ michael@0: (SCALED_BILINEAR_FLAGS | \ michael@0: FAST_PATH_NONE_REPEAT | \ michael@0: FAST_PATH_X_UNIT_POSITIVE), \ michael@0: PIXMAN_solid, MASK_FLAGS (solid, FAST_PATH_UNIFIED_ALPHA), \ michael@0: PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \ michael@0: fast_composite_scaled_bilinear_ ## func ## _none ## _ ## op, \ michael@0: } michael@0: michael@0: #define SIMPLE_BILINEAR_SOLID_MASK_FAST_PATH_COVER(op,s,d,func) \ michael@0: { PIXMAN_OP_ ## op, \ michael@0: PIXMAN_ ## s, \ michael@0: SCALED_BILINEAR_FLAGS | FAST_PATH_SAMPLES_COVER_CLIP, \ michael@0: PIXMAN_solid, MASK_FLAGS (solid, FAST_PATH_UNIFIED_ALPHA), \ michael@0: PIXMAN_ ## d, FAST_PATH_STD_DEST_FLAGS, \ michael@0: fast_composite_scaled_bilinear_ ## func ## _cover ## _ ## op, \ michael@0: } michael@0: michael@0: /* Prefer the use of 'cover' variant, because it is faster */ michael@0: #define SIMPLE_BILINEAR_FAST_PATH(op,s,d,func) \ michael@0: SIMPLE_BILINEAR_FAST_PATH_COVER (op,s,d,func), \ michael@0: SIMPLE_BILINEAR_FAST_PATH_NONE (op,s,d,func), \ michael@0: SIMPLE_BILINEAR_FAST_PATH_PAD (op,s,d,func) michael@0: michael@0: #define SIMPLE_BILINEAR_A8_MASK_FAST_PATH(op,s,d,func) \ michael@0: SIMPLE_BILINEAR_A8_MASK_FAST_PATH_COVER (op,s,d,func), \ michael@0: SIMPLE_BILINEAR_A8_MASK_FAST_PATH_NONE (op,s,d,func), \ michael@0: SIMPLE_BILINEAR_A8_MASK_FAST_PATH_PAD (op,s,d,func) michael@0: michael@0: #define SIMPLE_BILINEAR_SOLID_MASK_FAST_PATH(op,s,d,func) \ michael@0: SIMPLE_BILINEAR_SOLID_MASK_FAST_PATH_COVER (op,s,d,func), \ michael@0: SIMPLE_BILINEAR_SOLID_MASK_FAST_PATH_NONE (op,s,d,func), \ michael@0: SIMPLE_BILINEAR_SOLID_MASK_FAST_PATH_PAD (op,s,d,func) michael@0: michael@0: #endif