diff -r e4d67989cc36 -r 47c74d1534e1 genericopenlibs/liboil/src/composite_s.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/genericopenlibs/liboil/src/composite_s.c Fri Apr 16 16:46:38 2010 +0300 @@ -0,0 +1,763 @@ +/* + * LIBOIL - Library of Optimized Inner Loops + * Copyright (c) 2003,2004 David A. Schleef + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +//Portions Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include "liboil/liboilcolorspace.h" +#include +#include + +#ifdef __SYMBIAN32__ +#ifdef __ARMCC__ +#pragma diag_remark 186 +#endif//__ARMCC__ +#endif//__SYMBIAN32__ + +#define COMPOSITE_OVER(d,s,m) ((d) + (s) - oil_muldiv_255((d),(m))) +#define COMPOSITE_ADD(d,s) oil_clamp_255((d) + (s)) +#define COMPOSITE_IN(s,m) oil_muldiv_255((s),(m)) + +/** + * SECTION:liboilfuncs-pixel + * @title: Pixel Operations + * @short_description: Operations on pixels + * + * Pixels are 4-element arrays of type uint8_t. The elements, in + * memory order, represent the alpha, red, green, and blue + * components respectively. The color components are premultiplied + * with the alpha component. Liboil functions represent pixels + * as the type uint32_t. + * + * The compositing operators IN, OVER, and ADD are defined the same + * as cairo. + * + */ +static void +handle_param (OilParameter *p) +{ + int n; + + if (p->src_data) { + if (p->type == OIL_TYPE_u32p) { + uint32_t *ptr; + ptr = (uint32_t *)oil_param_get_source_data (p); + n = p->post_n; + oil_random_argb (ptr, n); + } + if (p->type == OIL_TYPE_u8p) { + uint8_t *ptr; + ptr = (uint8_t *)oil_param_get_source_data (p); + n = p->post_n; + oil_random_alpha (ptr, n); + } + } +} + +static void +composite_test (OilTest *test) +{ + handle_param(&test->params[OIL_ARG_SRC1]); + handle_param(&test->params[OIL_ARG_SRC2]); + handle_param(&test->params[OIL_ARG_INPLACE1]); +} + +/** + * oil_composite_in_argb: + * @d_n: DEST + * @s1_n: SRC + * @s2_n: MASK + * @n: number of elements + * + * Performs the compositing operation DEST = SRC IN MASK. + */ +OIL_DEFINE_CLASS_FULL (composite_in_argb, + "uint32_t *d_n, uint32_t *s1_n, uint8_t *s2_n, int n", + composite_test); +/** + * oil_composite_in_argb_const_src: + * @d_n: DEST + * @s1_1: SRC + * @s2_n: MASK + * @n: number of elements + * + * Performs the compositing operation DEST = SRC IN MASK, for a constant + * SRC. + */ +OIL_DEFINE_CLASS_FULL (composite_in_argb_const_src, + "uint32_t *d_n, uint32_t *s1_1, uint8_t *s2_n, int n", + composite_test); +/** + * oil_composite_in_argb_const_mask: + * @d_n: DEST + * @s1_n: SRC + * @s2_1: MASK + * @n: number of elements + * + * Performs the compositing operation DEST = SRC IN MASK, for a constant + * MASK. + */ +OIL_DEFINE_CLASS_FULL (composite_in_argb_const_mask, + "uint32_t *d_n, uint32_t *s1_n, uint8_t *s2_1, int n", + composite_test); +/** + * oil_composite_over_argb: + * @i_n: DEST + * @s1_n: SRC + * @n: number of elements + * + * Performs the compositing operation DEST = SRC OVER DEST. + */ +OIL_DEFINE_CLASS_FULL (composite_over_argb, + "uint32_t *i_n, uint32_t *s1_n, int n", + composite_test); +/** + * oil_composite_over_argb_const_src: + * @i_n: DEST + * @s1_1: SRC + * @n: number of elements + * + * Performs the compositing operation DEST = SRC OVER DEST, for a + * constant SRC. + */ +OIL_DEFINE_CLASS_FULL (composite_over_argb_const_src, + "uint32_t *i_n, uint32_t *s1_1, int n", + composite_test); +/** + * oil_composite_add_argb: + * @i_n: DEST + * @s1_n: SRC + * @n: number of elements + * + * Performs the compositing operation DEST = SRC ADD DEST. + */ +OIL_DEFINE_CLASS_FULL (composite_add_argb, + "uint32_t *i_n, uint32_t *s1_n, int n", + composite_test); +/** + * oil_composite_add_argb_const_src: + * @i_n: DEST + * @s1_1: SRC + * @n: number of elements + * + * Performs the compositing operation DEST = SRC ADD DEST, for a + * constant SRC. + */ +OIL_DEFINE_CLASS_FULL (composite_add_argb_const_src, + "uint32_t *i_n, uint32_t *s1_1, int n", + composite_test); +/** + * oil_composite_in_over_argb: + * @i_n: DEST + * @s1_n: SRC + * @s2_n: MASK + * @n: number of elements + * + * Performs the compositing operation DEST = (SRC IN MASK) OVER DEST. + */ +OIL_DEFINE_CLASS_FULL (composite_in_over_argb, + "uint32_t *i_n, uint32_t *s1_n, uint8_t *s2_n, int n", + composite_test); +/** + * oil_composite_in_over_argb_const_src: + * @i_n: DEST + * @s1_1: SRC + * @s2_n: MASK + * @n: number of elements + * + * Performs the compositing operation DEST = (SRC IN MASK) OVER DEST, + * for a constant SRC. + */ +OIL_DEFINE_CLASS_FULL (composite_in_over_argb_const_src, + "uint32_t *i_n, uint32_t *s1_1, uint8_t *s2_n, int n", + composite_test); +/** + * oil_composite_in_over_argb_const_mask: + * @i_n: DEST + * @s1_n: SRC + * @s2_1: MASK + * @n: number of elements + * + * Performs the compositing operation DEST = (SRC IN MASK) OVER DEST, + * for a constant MASK. + */ +OIL_DEFINE_CLASS_FULL (composite_in_over_argb_const_mask, + "uint32_t *i_n, uint32_t *s1_n, uint8_t *s2_1, int n", + composite_test); +/** + * oil_composite_over_u8: + * @i_n: DEST + * @s1_n: SRC + * @n: number of elements + * + * Performs the compositing operation DEST = SRC OVER DEST. + */ +OIL_DEFINE_CLASS_FULL (composite_over_u8, + "uint8_t *i_n, uint8_t *s1_n, int n", + composite_test); +/** + * oil_composite_add_u8: + * @i_n: DEST + * @s1_n: SRC + * @n: number of elements + * + * Performs the compositing operation DEST = SRC ADD DEST. + */ +OIL_DEFINE_CLASS_FULL (composite_add_u8, + "uint8_t *i_n, uint8_t *s1_n, int n", + composite_test); +/** + * oil_composite_add_u8_const_src: + * @i_n: DEST + * @s1_1: SRC + * @n: number of elements + * + * Performs the compositing operation DEST = SRC ADD DEST. + */ +OIL_DEFINE_CLASS_FULL (composite_add_u8_const_src, + "uint8_t *i_n, uint8_t *s1_1, int n", + composite_test); + +static void +composite_in_argb_ref (uint32_t *dest, const uint32_t *src, const uint8_t *mask, int n) +{ + int i; + + for(i=0;ifunc; + } +#endif + +#ifdef __SYMBIAN32__ + +EXPORT_C void** _oil_function_class_ptr_composite_in_argb_const_src () { + oil_function_class_ptr_composite_in_argb_const_src = __oil_function_class_composite_in_argb_const_src(); + return &oil_function_class_ptr_composite_in_argb_const_src->func; + } +#endif + +#ifdef __SYMBIAN32__ + +EXPORT_C void** _oil_function_class_ptr_composite_in_argb_const_mask () { + oil_function_class_ptr_composite_in_argb_const_mask = __oil_function_class_composite_in_argb_const_mask(); + return &oil_function_class_ptr_composite_in_argb_const_mask->func; + } +#endif + +#ifdef __SYMBIAN32__ + +EXPORT_C void** _oil_function_class_ptr_composite_over_argb () { + oil_function_class_ptr_composite_over_argb = __oil_function_class_composite_over_argb(); + return &oil_function_class_ptr_composite_over_argb->func; + } +#endif + +#ifdef __SYMBIAN32__ + +EXPORT_C void** _oil_function_class_ptr_composite_over_argb_const_src () { + oil_function_class_ptr_composite_over_argb_const_src = __oil_function_class_composite_over_argb_const_src(); + return &oil_function_class_ptr_composite_over_argb_const_src->func; + } +#endif + +#ifdef __SYMBIAN32__ + +EXPORT_C void** _oil_function_class_ptr_composite_add_argb () { + oil_function_class_ptr_composite_add_argb = __oil_function_class_composite_add_argb(); + return &oil_function_class_ptr_composite_add_argb->func; + } +#endif + +#ifdef __SYMBIAN32__ + +EXPORT_C void** _oil_function_class_ptr_composite_add_argb_const_src () { + oil_function_class_ptr_composite_add_argb_const_src = __oil_function_class_composite_add_argb_const_src(); + return &oil_function_class_ptr_composite_add_argb_const_src->func; + } +#endif + +#ifdef __SYMBIAN32__ + +EXPORT_C void** _oil_function_class_ptr_composite_in_over_argb () { + oil_function_class_ptr_composite_in_over_argb = __oil_function_class_composite_in_over_argb(); + return &oil_function_class_ptr_composite_in_over_argb->func; + } +#endif + +#ifdef __SYMBIAN32__ + +EXPORT_C void** _oil_function_class_ptr_composite_in_over_argb_const_src () { + oil_function_class_ptr_composite_in_over_argb_const_src = __oil_function_class_composite_in_over_argb_const_src(); + return &oil_function_class_ptr_composite_in_over_argb_const_src->func; + } +#endif + +#ifdef __SYMBIAN32__ + +EXPORT_C void** _oil_function_class_ptr_composite_in_over_argb_const_mask () { + oil_function_class_ptr_composite_in_over_argb_const_mask = __oil_function_class_composite_in_over_argb_const_mask(); + return &oil_function_class_ptr_composite_in_over_argb_const_mask->func; + } +#endif + +#ifdef __SYMBIAN32__ + +EXPORT_C void** _oil_function_class_ptr_composite_over_u8 () { + oil_function_class_ptr_composite_over_u8 = __oil_function_class_composite_over_u8(); + return &oil_function_class_ptr_composite_over_u8->func; + } +#endif + +#ifdef __SYMBIAN32__ + +EXPORT_C void** _oil_function_class_ptr_composite_add_u8 () { + oil_function_class_ptr_composite_add_u8 = __oil_function_class_composite_add_u8(); + return &oil_function_class_ptr_composite_add_u8->func; + } +#endif + +#ifdef __SYMBIAN32__ + +EXPORT_C void** _oil_function_class_ptr_composite_add_u8_const_src () { + oil_function_class_ptr_composite_add_u8_const_src = __oil_function_class_composite_add_u8_const_src(); + return &oil_function_class_ptr_composite_add_u8_const_src->func; + } +#endif +