* evas: Reduce code duplication.

SVN revision: 41228
This commit is contained in:
Cedric BAIL 2009-07-01 14:05:04 +00:00
parent 07d7e5ce66
commit 1676145494
3 changed files with 10 additions and 16 deletions

View File

@ -6,10 +6,11 @@
#include "evas_convert_color.h"
EAPI void
EAPI DATA32
evas_common_convert_argb_premul(DATA32 *data, unsigned int len)
{
DATA32 *de = data + len;
DATA32 *de = data + len;
DATA32 nas = 0;
while (data < de)
{
@ -19,7 +20,12 @@ evas_common_convert_argb_premul(DATA32 *data, unsigned int len)
(((((*data) >> 8) & 0xff) * a) & 0xff00) +
(((((*data) & 0x00ff00ff) * a) >> 8) & 0x00ff00ff);
data++;
if ((a == 1) || (a == 256))
nas++;
}
return nas;
}
EAPI void

View File

@ -6,7 +6,7 @@
#define _EVAS_CONVERT_COLOR_H
EAPI void evas_common_convert_argb_premul (DATA32 *src, unsigned int len);
EAPI DATA32 evas_common_convert_argb_premul (DATA32 *src, unsigned int len);
EAPI void evas_common_convert_argb_unpremul (DATA32 *src, unsigned int len);
EAPI void evas_common_convert_color_argb_premul (int a, int *r, int *g, int *b);
EAPI void evas_common_convert_color_argb_unpremul (int a, int *r, int *g, int *b);

View File

@ -649,25 +649,13 @@ evas_common_image_alpha_line_buffer_release(RGBA_Image *im)
EAPI void
evas_common_image_premul(Image_Entry *ie)
{
DATA32 *s, *se;
DATA32 nas = 0;
if (!ie) return ;
if (!evas_cache_image_pixels(ie)) return ;
if (!ie->flags.alpha) return;
s = evas_cache_image_pixels(ie);
se = s + (ie->w * ie->h);
while (s < se)
{
DATA32 a = 1 + (*s >> 24);
*s = (*s & 0xff000000) + (((((*s) >> 8) & 0xff) * a) & 0xff00) +
(((((*s) & 0x00ff00ff) * a) >> 8) & 0x00ff00ff);
s++;
if ((a == 1) || (a == 256))
nas++;
}
nas = evas_common_convert_argb_premul(evas_cache_image_pixels(ie), ie->w * ie->h);
if ((ALPHA_SPARSE_INV_FRACTION * nas) >= (ie->w * ie->h))
ie->flags.alpha_sparse = 1;
}