os/ossrv/genericopenlibs/liboil/src/ref/rgb.c
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/liboil/src/ref/rgb.c	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,189 @@
     1.4 +/*
     1.5 + * LIBOIL - Library of Optimized Inner Loops
     1.6 + * Copyright (c) 2003,2004 David A. Schleef <ds@schleef.org>
     1.7 + * All rights reserved.
     1.8 + *
     1.9 + * Redistribution and use in source and binary forms, with or without
    1.10 + * modification, are permitted provided that the following conditions
    1.11 + * are met:
    1.12 + * 1. Redistributions of source code must retain the above copyright
    1.13 + *    notice, this list of conditions and the following disclaimer.
    1.14 + * 2. Redistributions in binary form must reproduce the above copyright
    1.15 + *    notice, this list of conditions and the following disclaimer in the
    1.16 + *    documentation and/or other materials provided with the distribution.
    1.17 + * 
    1.18 + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
    1.19 + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    1.20 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    1.21 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
    1.22 + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    1.23 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
    1.24 + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    1.25 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
    1.26 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
    1.27 + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    1.28 + * POSSIBILITY OF SUCH DAMAGE.
    1.29 + */
    1.30 +//Portions Copyright (c)  2008-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. 
    1.31 +
    1.32 +#ifdef HAVE_CONFIG_H
    1.33 +#include "config.h"
    1.34 +#endif
    1.35 +
    1.36 +#include <liboil/liboilfunction.h>
    1.37 +#include "liboil/liboilcolorspace.h"
    1.38 +
    1.39 +/**
    1.40 + * oil_rgb2bgr:
    1.41 + * @d_3xn:
    1.42 + * @s_3xn:
    1.43 + * @n:
    1.44 + *
    1.45 + * Converts arrays of 24-bit RGB pixels from RGBRGBRGB ordering to
    1.46 + * BGRBGRBGR ordering (and vice-versa).
    1.47 + */
    1.48 +OIL_DEFINE_CLASS (rgb2bgr, "uint8_t *d_3xn, uint8_t* s_3xn, int n");
    1.49 +/**
    1.50 + * oil_rgb2rgba:
    1.51 + * @d_4xn:
    1.52 + * @s_3xn:
    1.53 + * @n:
    1.54 + *
    1.55 + * Converts arrays of 24-bit RGB pixels in RGBRGBRGB memory order
    1.56 + * to 32-bit RGBA pixels in RGBARGBA order.
    1.57 + */
    1.58 +OIL_DEFINE_CLASS (rgb2rgba, "uint8_t *d_4xn, uint8_t* s_3xn, int n");
    1.59 +/**
    1.60 + * oil_rgb565_to_argb:
    1.61 + * @d:
    1.62 + * @s:
    1.63 + * @n:
    1.64 + *
    1.65 + * Converts arrays of 16-bit RGB565 pixels to 32-bit ARGB pixels.
    1.66 + */
    1.67 +OIL_DEFINE_CLASS (rgb565_to_argb, "uint32_t *d, uint16_t* s, int n");
    1.68 +
    1.69 +static void
    1.70 +rgb2bgr_ref (uint8_t *dest, const uint8_t* src, int n)
    1.71 +{
    1.72 +  int i;
    1.73 +  uint8_t tmp;
    1.74 +  
    1.75 +  for (i = 0; i < n; i++) {
    1.76 +    tmp = src[2];
    1.77 +    dest[1] = src[1];
    1.78 +    dest[2] = src[0];
    1.79 +    dest[0] = tmp;
    1.80 +    dest += 3;
    1.81 +    src += 3;
    1.82 +  }
    1.83 +}
    1.84 +
    1.85 +OIL_DEFINE_IMPL_REF (rgb2bgr_ref, rgb2bgr);
    1.86 +
    1.87 +
    1.88 +static void
    1.89 +rgb2rgba_ref (uint8_t *dest, const uint8_t* src, int n)
    1.90 +{
    1.91 +  int i;
    1.92 +  
    1.93 +  for (i = 0; i < n; i++) {
    1.94 +    dest[0] = src[0];
    1.95 +    dest[1] = src[1];
    1.96 +    dest[2] = src[2];
    1.97 +    dest[3] = 0xFF;
    1.98 +    dest += 4;
    1.99 +    src += 3;
   1.100 +  }
   1.101 +}
   1.102 +
   1.103 +OIL_DEFINE_IMPL_REF (rgb2rgba_ref, rgb2rgba);
   1.104 +
   1.105 +
   1.106 +void
   1.107 +rgb565_to_argb_ref (uint32_t *d, uint16_t* s, int n)
   1.108 +{
   1.109 +  int i;
   1.110 +  int r,g,b;
   1.111 +
   1.112 +  for (i = 0; i < n; i++) {
   1.113 +    r = (s[i] >> 8) & 0xf8;
   1.114 +    g = (s[i] >> 3) & 0xfc;
   1.115 +    b = (s[i] << 3) & 0xf8;
   1.116 +    d[i] = oil_argb(255, r | (r>>5), g | (g>>6), b | (b>>5));
   1.117 +  }
   1.118 +}
   1.119 +OIL_DEFINE_IMPL_REF (rgb565_to_argb_ref, rgb565_to_argb);
   1.120 +
   1.121 +
   1.122 +
   1.123 +#ifdef	__SYMBIAN32__
   1.124 + 
   1.125 +OilFunctionClass* __oil_function_class_rgb2bgr() {
   1.126 +		return &_oil_function_class_rgb2bgr;
   1.127 +}
   1.128 +#endif
   1.129 +
   1.130 +#ifdef	__SYMBIAN32__
   1.131 + 
   1.132 +OilFunctionClass* __oil_function_class_rgb2rgba() {
   1.133 +		return &_oil_function_class_rgb2rgba;
   1.134 +}
   1.135 +#endif
   1.136 +
   1.137 +#ifdef	__SYMBIAN32__
   1.138 + 
   1.139 +OilFunctionClass* __oil_function_class_rgb565_to_argb() {
   1.140 +		return &_oil_function_class_rgb565_to_argb;
   1.141 +}
   1.142 +#endif
   1.143 +
   1.144 +
   1.145 +
   1.146 +#ifdef	__SYMBIAN32__
   1.147 + 
   1.148 +OilFunctionImpl* __oil_function_impl_rgb2bgr_ref() {
   1.149 +		return &_oil_function_impl_rgb2bgr_ref;
   1.150 +}
   1.151 +#endif
   1.152 +
   1.153 +#ifdef	__SYMBIAN32__
   1.154 + 
   1.155 +OilFunctionImpl* __oil_function_impl_rgb2rgba_ref() {
   1.156 +		return &_oil_function_impl_rgb2rgba_ref;
   1.157 +}
   1.158 +#endif
   1.159 +
   1.160 +#ifdef	__SYMBIAN32__
   1.161 + 
   1.162 +OilFunctionImpl* __oil_function_impl_rgb565_to_argb_ref() {
   1.163 +		return &_oil_function_impl_rgb565_to_argb_ref;
   1.164 +}
   1.165 +#endif
   1.166 +
   1.167 +
   1.168 +
   1.169 +#ifdef	__SYMBIAN32__
   1.170 + 
   1.171 +EXPORT_C void** _oil_function_class_ptr_rgb2bgr ()	{
   1.172 +	oil_function_class_ptr_rgb2bgr = __oil_function_class_rgb2bgr();
   1.173 +	return &oil_function_class_ptr_rgb2bgr->func;
   1.174 +	}
   1.175 +#endif
   1.176 +
   1.177 +#ifdef	__SYMBIAN32__
   1.178 + 
   1.179 +EXPORT_C void** _oil_function_class_ptr_rgb2rgba ()	{
   1.180 +	oil_function_class_ptr_rgb2rgba = __oil_function_class_rgb2rgba();
   1.181 +	return &oil_function_class_ptr_rgb2rgba->func;
   1.182 +	}
   1.183 +#endif
   1.184 +
   1.185 +#ifdef	__SYMBIAN32__
   1.186 + 
   1.187 +EXPORT_C void** _oil_function_class_ptr_rgb565_to_argb ()	{
   1.188 +	oil_function_class_ptr_rgb565_to_argb = __oil_function_class_rgb565_to_argb();
   1.189 +	return &oil_function_class_ptr_rgb565_to_argb->func;
   1.190 +	}
   1.191 +#endif
   1.192 +