oh dear... way too many warnings. added a whole bunch of fixme's too
for later. SVN revision: 58740
This commit is contained in:
parent
549cc252cc
commit
1eaba59607
|
@ -1,10 +1,8 @@
|
|||
/*
|
||||
* Filter implementation for evas
|
||||
*/
|
||||
|
||||
#include <stddef.h> // offsetof
|
||||
|
||||
|
||||
#include "evas_common.h"
|
||||
#include "evas_private.h"
|
||||
|
||||
|
@ -16,32 +14,37 @@
|
|||
# define BUILD_NEON0 0
|
||||
#endif
|
||||
|
||||
typedef struct Evas_Filter_Info_Blur {
|
||||
typedef struct Evas_Filter_Info_Blur
|
||||
{
|
||||
double quality;
|
||||
int radius;
|
||||
} Evas_Filter_Info_Blur;
|
||||
|
||||
typedef struct Evas_Filter_Info_GreyScale {
|
||||
typedef struct Evas_Filter_Info_GreyScale
|
||||
{
|
||||
double r,g,b;
|
||||
} Evas_Filter_Info_GreyScale;
|
||||
typedef struct Evas_Filter_Info_Brightness {
|
||||
|
||||
typedef struct Evas_Filter_Info_Brightness
|
||||
{
|
||||
double adjust;
|
||||
} Evas_Filter_Info_Brightness;
|
||||
typedef struct Evas_Filter_Info_Contrast {
|
||||
|
||||
typedef struct Evas_Filter_Info_Contrast
|
||||
{
|
||||
double adjust;
|
||||
} Evas_Filter_Info_Contrast;
|
||||
|
||||
|
||||
typedef int (*Filter_Size_FN)(Evas_Filter_Info *,int,int,int*,int*,Eina_Bool);
|
||||
typedef uint8_t *(*Key_FN)(const Evas_Filter_Info *, uint32_t *);
|
||||
|
||||
struct fieldinfo {
|
||||
struct fieldinfo
|
||||
{
|
||||
const char *field;
|
||||
int type;
|
||||
size_t offset;
|
||||
};
|
||||
|
||||
|
||||
struct filterinfo
|
||||
{
|
||||
Evas_Software_Filter_Fn filter;
|
||||
|
@ -51,7 +54,8 @@ struct filterinfo
|
|||
Eina_Bool alwaysalpha;
|
||||
};
|
||||
|
||||
enum {
|
||||
enum
|
||||
{
|
||||
TYPE_INT,
|
||||
TYPE_FLOAT
|
||||
};
|
||||
|
@ -88,13 +92,15 @@ struct filterinfo filterinfo[] =
|
|||
};
|
||||
|
||||
|
||||
static struct fieldinfo blurfields[] = {
|
||||
static struct fieldinfo blurfields[] =
|
||||
{
|
||||
{ "quality", TYPE_FLOAT, offsetof(Evas_Filter_Info_Blur, quality) },
|
||||
{ "radius", TYPE_INT, offsetof(Evas_Filter_Info_Blur, radius) },
|
||||
{ NULL, 0, 0 },
|
||||
};
|
||||
|
||||
static struct fieldinfo greyfields[] = {
|
||||
static struct fieldinfo greyfields[] =
|
||||
{
|
||||
{ "red", TYPE_FLOAT, offsetof(Evas_Filter_Info_GreyScale, r) },
|
||||
{ "green", TYPE_FLOAT, offsetof(Evas_Filter_Info_GreyScale, g) },
|
||||
{ "blue", TYPE_FLOAT, offsetof(Evas_Filter_Info_GreyScale, b) },
|
||||
|
@ -104,17 +110,17 @@ static struct fieldinfo greyfields[] = {
|
|||
{ "all", TYPE_FLOAT, offsetof(Evas_Filter_Info_GreyScale, b) },
|
||||
{ NULL, 0, 0 },
|
||||
};
|
||||
static struct fieldinfo brightnessfields[] = {
|
||||
static struct fieldinfo brightnessfields[] =
|
||||
{
|
||||
{ "adjust", TYPE_FLOAT, offsetof(Evas_Filter_Info_Brightness, adjust) },
|
||||
{ NULL, 0, 0 },
|
||||
};
|
||||
static struct fieldinfo contrastfields[] = {
|
||||
static struct fieldinfo contrastfields[] =
|
||||
{
|
||||
{ "adjust", TYPE_FLOAT, offsetof(Evas_Filter_Info_Contrast, adjust) },
|
||||
{ NULL, 0, 0 },
|
||||
};
|
||||
|
||||
|
||||
|
||||
static struct fieldinfo *filterfields[] =
|
||||
{
|
||||
NULL,
|
||||
|
@ -126,10 +132,8 @@ static struct fieldinfo *filterfields[] =
|
|||
contrastfields,
|
||||
};
|
||||
|
||||
|
||||
static Evas_Filter_Info *filter_alloc(Evas_Object *o);
|
||||
|
||||
|
||||
/**
|
||||
* Set the filter mode for an object.
|
||||
*
|
||||
|
@ -148,6 +152,8 @@ EAPI Eina_Bool
|
|||
evas_object_filter_mode_set(Evas_Object *o, Evas_Filter_Mode mode)
|
||||
{
|
||||
Evas_Filter_Info *info;
|
||||
|
||||
// FIXME: do real magic check
|
||||
if (!o) return EINA_FALSE; /* nash: do Magic check */
|
||||
|
||||
if (mode != EVAS_FILTER_MODE_OBJECT && mode != EVAS_FILTER_MODE_BELOW)
|
||||
|
@ -178,6 +184,7 @@ evas_object_filter_mode_set(Evas_Object *o, Evas_Filter_Mode mode)
|
|||
EAPI Evas_Filter_Mode
|
||||
evas_object_filter_mode_get(Evas_Object *o)
|
||||
{
|
||||
// FIXME: do real magic check
|
||||
if (!o) return EVAS_FILTER_MODE_OBJECT; /* nash magic */
|
||||
if (!o->filter) filter_alloc(o);
|
||||
if (!o->filter) return EVAS_FILTER_MODE_OBJECT;
|
||||
|
@ -206,12 +213,12 @@ evas_object_filter_set(Evas_Object *o, Evas_Filter filter)
|
|||
Evas_Filter_Info *info;
|
||||
struct filterinfo *finfo;
|
||||
|
||||
|
||||
// FIXME: do real magic check
|
||||
if (!o) return EINA_FALSE; /* nash: magic */
|
||||
|
||||
/* force filter to be signed: else gcc complains, but enums may always be
|
||||
* signed */
|
||||
if ((int)filter < (int)EVAS_FILTER_NONE || filter > EVAS_FILTER_LAST)
|
||||
if (((int)filter < (int)EVAS_FILTER_NONE) || (filter > EVAS_FILTER_LAST))
|
||||
return EINA_FALSE;
|
||||
|
||||
if (!o->filter) filter_alloc(o);
|
||||
|
@ -233,6 +240,7 @@ evas_object_filter_set(Evas_Object *o, Evas_Filter filter)
|
|||
}
|
||||
info->datalen = finfo->datasize;
|
||||
if (finfo->datasize)
|
||||
// FIXME: hande calloc fail
|
||||
info->data = calloc(1,finfo->datasize);
|
||||
else
|
||||
info->data = NULL;
|
||||
|
@ -251,8 +259,8 @@ evas_object_filter_set(Evas_Object *o, Evas_Filter filter)
|
|||
EAPI Evas_Filter
|
||||
evas_object_filter_get(Evas_Object *o)
|
||||
{
|
||||
// FIXME: do real magic check
|
||||
if (!o || !o->filter) return EVAS_FILTER_NONE;
|
||||
|
||||
return o->filter->filter;
|
||||
}
|
||||
|
||||
|
@ -280,7 +288,7 @@ evas_object_filter_param_set_int(Evas_Object *o, const char *param, int val)
|
|||
Eina_Bool found;
|
||||
int i;
|
||||
|
||||
|
||||
// FIXME: do real magic check
|
||||
if (!o || !o->filter || !o->filter->data) return EINA_FALSE;
|
||||
|
||||
fields = filterfields[o->filter->filter];
|
||||
|
@ -290,7 +298,7 @@ evas_object_filter_param_set_int(Evas_Object *o, const char *param, int val)
|
|||
|
||||
for (i = 0; fields[i].field; i++)
|
||||
{
|
||||
if (strcmp(fields[i].field, param) == 0)
|
||||
if (!strcmp(fields[i].field, param))
|
||||
{
|
||||
if (fields[i].type != TYPE_INT) continue;
|
||||
*(int *)(data + fields[i].offset) = val;
|
||||
|
@ -299,7 +307,6 @@ evas_object_filter_param_set_int(Evas_Object *o, const char *param, int val)
|
|||
found = EINA_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
|
@ -325,6 +332,7 @@ evas_object_filter_param_get_int(Evas_Object *o, const char *param)
|
|||
int val;
|
||||
int i;
|
||||
|
||||
// FIXME: do real magic check
|
||||
if (!o || !o->filter || !o->filter->data) return -1;
|
||||
|
||||
fields = blurfields;
|
||||
|
@ -332,7 +340,7 @@ evas_object_filter_param_get_int(Evas_Object *o, const char *param)
|
|||
|
||||
for (i = 0; fields[i].field; i++)
|
||||
{
|
||||
if (strcmp(fields[i].field, param) == 0)
|
||||
if (!strcmp(fields[i].field, param))
|
||||
{
|
||||
if (fields[i].type != TYPE_INT) continue;
|
||||
val = *(int *)(data + fields[i].offset);
|
||||
|
@ -344,15 +352,17 @@ evas_object_filter_param_get_int(Evas_Object *o, const char *param)
|
|||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
evas_object_filter_param_set_str(Evas_Object *o, const char *param,
|
||||
const char *val)
|
||||
evas_object_filter_param_set_str(Evas_Object *o __UNUSED__,
|
||||
const char *param __UNUSED__,
|
||||
const char *val __UNUSED__)
|
||||
{
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
evas_object_filter_param_set_obj(Evas_Object *o, const char *param,
|
||||
Evas_Object *val)
|
||||
evas_object_filter_param_set_obj(Evas_Object *o __UNUSED__,
|
||||
const char *param __UNUSED__,
|
||||
Evas_Object *val __UNUSED__)
|
||||
{
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
@ -376,6 +386,7 @@ evas_object_filter_param_set_float(Evas_Object *o, const char *param,
|
|||
int i;
|
||||
Eina_Bool rv;
|
||||
|
||||
// FIXME: do real magic check
|
||||
if (!o || !o->filter || !o->filter->data) return EINA_FALSE;
|
||||
|
||||
rv = EINA_FALSE;
|
||||
|
@ -384,7 +395,7 @@ evas_object_filter_param_set_float(Evas_Object *o, const char *param,
|
|||
|
||||
for (i = 0; fields[i].field; i++)
|
||||
{
|
||||
if (strcmp(fields[i].field, param) == 0)
|
||||
if (!strcmp(fields[i].field, param))
|
||||
{
|
||||
if (fields[i].type != TYPE_FLOAT) continue;
|
||||
*(double *)(data + fields[i].offset) = val;
|
||||
|
@ -446,38 +457,34 @@ evas_filter_key_get(const Evas_Filter_Info *info, uint32_t *lenp)
|
|||
struct filterinfo *finfo;
|
||||
uint8_t *key;
|
||||
int len;
|
||||
|
||||
if (!info) return NULL;
|
||||
|
||||
finfo = filterinfo + info->filter;
|
||||
|
||||
if (finfo->keyfn)
|
||||
return finfo->keyfn(info, lenp);
|
||||
if (finfo->keyfn) return finfo->keyfn(info, lenp);
|
||||
|
||||
len = 1 + finfo->datasize;
|
||||
key = malloc(len);
|
||||
if (finfo->datasize) memcpy(key, info->data, finfo->datasize);
|
||||
key[finfo->datasize] = info->filter;
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
blur_size_get(Evas_Filter_Info *info, int inw, int inh, int *outw, int *outh,
|
||||
Eina_Bool inv){
|
||||
Evas_Filter_Info_Blur *blur;
|
||||
|
||||
blur = info->data;
|
||||
blur_size_get(Evas_Filter_Info *info, int inw, int inh, int *outw, int *outh, Eina_Bool inv)
|
||||
{
|
||||
Evas_Filter_Info_Blur *blur = info->data;
|
||||
|
||||
if (inv)
|
||||
{
|
||||
if (outw) *outw = MAX(inw - blur->radius * 2, 0);
|
||||
if (outh) *outh = MAX(inh - blur->radius * 2, 0);
|
||||
if (outw) *outw = MAX(inw - (blur->radius * 2), 0);
|
||||
if (outh) *outh = MAX(inh - (blur->radius * 2), 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (outw) *outw = inw + blur->radius * 2;
|
||||
if (outh) *outh = inh + blur->radius * 2;
|
||||
if (outw) *outw = inw + (blur->radius * 2);
|
||||
if (outh) *outh = inh + (blur->radius * 2);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -504,6 +511,7 @@ gaussian_key_get(const Evas_Filter_Info *info, uint32_t *lenp)
|
|||
blur = info->data;
|
||||
|
||||
if (lenp) *lenp = 4;
|
||||
// FIXME: handle malloc fail
|
||||
key = malloc(4);
|
||||
key[0] = EVAS_FILTER_BLUR;
|
||||
key[1] = blur->quality * 255;
|
||||
|
@ -513,16 +521,12 @@ gaussian_key_get(const Evas_Filter_Info *info, uint32_t *lenp)
|
|||
return key;
|
||||
}
|
||||
|
||||
|
||||
Evas_Software_Filter_Fn
|
||||
evas_filter_software_get(Evas_Filter_Info *info)
|
||||
{
|
||||
return filterinfo[info->filter].filter;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Private calls
|
||||
*/
|
||||
|
@ -547,6 +551,7 @@ filter_alloc(Evas_Object *o)
|
|||
* Software implementations
|
||||
*/
|
||||
|
||||
// FIXME we have R_VAL/G_VAL...A_VAL for this
|
||||
#define alpha(x) (((x) >> 24) )
|
||||
#define red(x) (((x) >> 16) & 0xff)
|
||||
#define green(x) (((x) >> 8) & 0xff)
|
||||
|
@ -573,7 +578,7 @@ const uint32_t *gaussian_row_get(int row, int *npoints, uint32_t *weight);
|
|||
const uint64_t *gaussian_row_get64(int row, int *npoints, uint64_t *weight);
|
||||
const double *gaussian_row_getd(int row, int *npoints, double *weight);
|
||||
|
||||
|
||||
// FIXME: why not static?
|
||||
Eina_Bool
|
||||
gaussian_filter(Evas_Filter_Info *filter, RGBA_Image *src, RGBA_Image *dst)
|
||||
{
|
||||
|
@ -587,14 +592,16 @@ gaussian_filter(Evas_Filter_Info *filter, RGBA_Image *src, RGBA_Image *dst)
|
|||
|
||||
blur = filter->data;
|
||||
|
||||
printf("Gaussian filter\n");
|
||||
/* Use 64 bit version if we are going to overflow */
|
||||
if (blur->radius > 508){ /** too big for doubles: Bail out */
|
||||
if (blur->radius > 508) /** too big for doubles: Bail out */
|
||||
return EINA_FALSE;
|
||||
} else if (blur->radius > 28){
|
||||
else if (blur->radius > 28)
|
||||
{
|
||||
filter_v = gaussian_filter_vd;
|
||||
filter_h = gaussian_filter_hd;
|
||||
} else if (blur->radius > 12){
|
||||
}
|
||||
else if (blur->radius > 12)
|
||||
{
|
||||
filter_v = gaussian_filter_v64;
|
||||
filter_h = gaussian_filter_h64;
|
||||
}
|
||||
|
@ -613,9 +620,9 @@ gaussian_filter(Evas_Filter_Info *filter, RGBA_Image *src, RGBA_Image *dst)
|
|||
tmp = malloc(nw * h * sizeof(uint32_t));
|
||||
|
||||
for (i = 0; i < h; i++)
|
||||
filter_h(blur->radius,in + i*w,w,tmp + i*nw);
|
||||
filter_h(blur->radius,in + (i * w), w, tmp + (i * nw));
|
||||
|
||||
for (i = 0 ; i < nw ; i ++)
|
||||
for (i = 0; i < (int)nw; i++)
|
||||
filter_v(blur->radius,tmp + i, h, nw, out + i);
|
||||
|
||||
free(tmp);
|
||||
|
@ -623,8 +630,10 @@ gaussian_filter(Evas_Filter_Info *filter, RGBA_Image *src, RGBA_Image *dst)
|
|||
}
|
||||
|
||||
/* Blur only horizontally */
|
||||
// FIXME: why not static?
|
||||
int
|
||||
gaussian_filter_h(int rad, uint32_t *in, int w, uint32_t *out){
|
||||
gaussian_filter_h(int rad, uint32_t *in, int w, uint32_t *out)
|
||||
{
|
||||
const uint32_t *points;
|
||||
int npoints;
|
||||
uint32_t weight;
|
||||
|
@ -633,27 +642,31 @@ gaussian_filter_h(int rad, uint32_t *in, int w, uint32_t *out){
|
|||
|
||||
/* Get twice the radius: even rows have 1 element */
|
||||
points = gaussian_row_get(rad * 2, &npoints, &weight);
|
||||
|
||||
for (i = -rad ; i < w + rad; i ++){
|
||||
for (i = -rad; i < (w + rad); i++)
|
||||
{
|
||||
r = g = b = a = 0;
|
||||
for (k = -rad ; k <= rad ; k ++){
|
||||
for (k = -rad; k <= rad; k++)
|
||||
{
|
||||
if ((k + i) < 0) continue;
|
||||
if ((k + i) >= w) continue;
|
||||
all(+=, a, r, g, b, points[k + rad], in[k + i]);
|
||||
}
|
||||
*(out) = (wavg(a,weight) << 24) |
|
||||
// FIXME: use ARGB_JOIN
|
||||
*(out) =
|
||||
(wavg(a, weight) << 24) |
|
||||
(wavg(r, weight) << 16) |
|
||||
(wavg(g, weight) << 8) |
|
||||
(wavg(b, weight));
|
||||
out++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Blur only horizontally */
|
||||
// FIXME: why not static?
|
||||
int
|
||||
gaussian_filter_hd(int rad, uint32_t *in, int w, uint32_t *out){
|
||||
gaussian_filter_hd(int rad, uint32_t *in, int w, uint32_t *out)
|
||||
{
|
||||
const double *points;
|
||||
int npoints;
|
||||
double weight;
|
||||
|
@ -662,28 +675,32 @@ gaussian_filter_hd(int rad, uint32_t *in, int w, uint32_t *out){
|
|||
|
||||
/* Get twice the radius: even rows have 1 element */
|
||||
points = gaussian_row_getd(rad * 2, &npoints, &weight);
|
||||
|
||||
for (i = -rad ; i < w + rad; i ++){
|
||||
for (i = -rad; i < (w + rad); i++)
|
||||
{
|
||||
r = g = b = a = 0;
|
||||
for (k = -rad ; k <= rad ; k ++){
|
||||
for (k = -rad; k <= rad; k++)
|
||||
{
|
||||
if ((k + i) < 0) continue;
|
||||
if ((k + i) >= w) continue;
|
||||
all(+=, a, r, g, b, points[k + rad], in[k + i]);
|
||||
}
|
||||
*(out) = (wavgd(a,weight) << 24) |
|
||||
// FIXME: use ARGB_JOIN
|
||||
*(out) =
|
||||
(wavgd(a, weight) << 24) |
|
||||
(wavgd(r, weight) << 16) |
|
||||
(wavgd(g, weight) << 8) |
|
||||
(wavgd(b, weight));
|
||||
out++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Blur only horizontally */
|
||||
// FIXME: why not static?
|
||||
int
|
||||
gaussian_filter_h64(int rad, uint32_t *in, int w, uint32_t *out){
|
||||
gaussian_filter_h64(int rad, uint32_t *in, int w, uint32_t *out)
|
||||
{
|
||||
const uint64_t *points;
|
||||
int npoints;
|
||||
uint64_t weight;
|
||||
|
@ -692,7 +709,6 @@ gaussian_filter_h64(int rad, uint32_t *in, int w, uint32_t *out){
|
|||
|
||||
/* Get twice the radius: even rows have 1 element */
|
||||
points = gaussian_row_get64(rad * 2, &npoints, &weight);
|
||||
|
||||
for (i = -rad ; i < w + rad; i ++){
|
||||
r = g = b = a = 0;
|
||||
for (k = -rad ; k <= rad ; k ++){
|
||||
|
@ -700,20 +716,21 @@ gaussian_filter_h64(int rad, uint32_t *in, int w, uint32_t *out){
|
|||
if ((k + i) >= w) continue;
|
||||
all(+=, a, r, g, b, points[k + rad], in[k + i]);
|
||||
}
|
||||
*(out) = (wavg(a,weight) << 24) |
|
||||
// FIXME: use ARGB_JOIN
|
||||
*(out) =
|
||||
(wavg(a, weight) << 24) |
|
||||
(wavg(r, weight) << 16) |
|
||||
(wavg(g, weight) << 8) |
|
||||
(wavg(b, weight));
|
||||
out++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// FIXME: why not static?
|
||||
int
|
||||
gaussian_filter_v(int rad, uint32_t *in, int h, int skip, uint32_t *out){
|
||||
gaussian_filter_v(int rad, uint32_t *in, int h, int skip, uint32_t *out)
|
||||
{
|
||||
const uint32_t *points;
|
||||
int npoints;
|
||||
uint32_t weight;
|
||||
|
@ -723,29 +740,32 @@ gaussian_filter_v(int rad, uint32_t *in, int h, int skip, uint32_t *out){
|
|||
/* Get twice the radius: even rows have 1 element */
|
||||
points = gaussian_row_get(rad * 2, &npoints, &weight);
|
||||
weight = 0;
|
||||
for (i = 0 ; i < npoints ; i ++)
|
||||
weight += points[i];
|
||||
for (i = 0; i < npoints; i++) weight += points[i];
|
||||
|
||||
for (i = -rad ; i < h + rad; i ++){
|
||||
for (i = -rad; i < (h + rad); i++)
|
||||
{
|
||||
r = g = b = a = 0;
|
||||
for (k = -rad ; k <= rad ; k ++){
|
||||
for (k = -rad; k <= rad; k++)
|
||||
{
|
||||
if ((k + i) < 0) continue;
|
||||
if ((k + i) >= h) continue;
|
||||
all(+=, a, r, g, b, points[k + rad],
|
||||
in[skip * (k + i)]);
|
||||
all(+=, a, r, g, b, points[k + rad], in[skip * (k + i)]);
|
||||
}
|
||||
*(out) = (wavg(a,weight) << 24) |
|
||||
// FIXME: use ARGB_JOIN
|
||||
*(out) =
|
||||
(wavg(a, weight) << 24) |
|
||||
(wavg(r, weight) << 16) |
|
||||
(wavg(g, weight) << 8) |
|
||||
(wavg(b, weight));
|
||||
out += skip;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// FIXME: why not static?
|
||||
int
|
||||
gaussian_filter_v64(int rad, uint32_t *in, int h, int skip, uint32_t *out){
|
||||
gaussian_filter_v64(int rad, uint32_t *in, int h, int skip, uint32_t *out)
|
||||
{
|
||||
const uint64_t *points;
|
||||
int npoints;
|
||||
uint64_t weight;
|
||||
|
@ -755,30 +775,32 @@ gaussian_filter_v64(int rad, uint32_t *in, int h, int skip, uint32_t *out){
|
|||
/* Get twice the radius: even rows have 1 element */
|
||||
points = gaussian_row_get64(rad * 2, &npoints, &weight);
|
||||
weight = 0;
|
||||
for (i = 0 ; i < npoints ; i ++)
|
||||
weight += points[i];
|
||||
for (i = 0; i < npoints; i++) weight += points[i];
|
||||
|
||||
for (i = -rad ; i < h + rad; i ++){
|
||||
for (i = -rad; i < (h + rad); i++)
|
||||
{
|
||||
r = g = b = a = 0;
|
||||
for (k = -rad ; k <= rad ; k ++){
|
||||
for (k = -rad ; k <= rad ; k++)
|
||||
{
|
||||
if ((k + i) < 0) continue;
|
||||
if ((k + i) >= h) continue;
|
||||
all(+=, a, r, g, b, points[k + rad],
|
||||
in[skip * (k + i)]);
|
||||
all(+=, a, r, g, b, points[k + rad], in[skip * (k + i)]);
|
||||
}
|
||||
*(out) = (wavg(a,weight) << 24) |
|
||||
// FIXME: use ARGB_JOIN
|
||||
*(out) =
|
||||
(wavg(a, weight) << 24) |
|
||||
(wavg(r, weight) << 16) |
|
||||
(wavg(g, weight) << 8) |
|
||||
(wavg(b, weight));
|
||||
out += skip;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// FIXME: why not static?
|
||||
int
|
||||
gaussian_filter_vd(int rad, uint32_t *in, int h, int skip, uint32_t *out){
|
||||
gaussian_filter_vd(int rad, uint32_t *in, int h, int skip, uint32_t *out)
|
||||
{
|
||||
const double *points;
|
||||
int npoints;
|
||||
double weight;
|
||||
|
@ -788,30 +810,32 @@ gaussian_filter_vd(int rad, uint32_t *in, int h, int skip, uint32_t *out){
|
|||
/* Get twice the radius: even rows have 1 element */
|
||||
points = gaussian_row_getd(rad * 2, &npoints, &weight);
|
||||
weight = 0;
|
||||
for (i = 0 ; i < npoints ; i ++)
|
||||
weight += points[i];
|
||||
for (i = 0 ; i < npoints ; i ++) weight += points[i];
|
||||
|
||||
for (i = -rad ; i < h + rad; i ++){
|
||||
for (i = -rad ; i < h + rad; i ++)
|
||||
{
|
||||
r = g = b = a = 0;
|
||||
for (k = -rad ; k <= rad ; k ++){
|
||||
for (k = -rad ; k <= rad ; k ++)
|
||||
{
|
||||
if ((k + i) < 0) continue;
|
||||
if ((k + i) >= h) continue;
|
||||
all(+=, a, r, g, b, points[k + rad],
|
||||
in[skip * (k + i)]);
|
||||
all(+=, a, r, g, b, points[k + rad], in[skip * (k + i)]);
|
||||
}
|
||||
*(out) = (wavgd(a,weight) << 24) |
|
||||
// FIXME: use ARGB_JOIN
|
||||
*(out) =
|
||||
(wavgd(a, weight) << 24) |
|
||||
(wavgd(r, weight) << 16) |
|
||||
(wavgd(g, weight) << 8) |
|
||||
(wavgd(b, weight));
|
||||
out += skip;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// FIXME: why not static?
|
||||
const uint32_t *
|
||||
gaussian_row_get(int row, int *npoints, uint32_t *weight){
|
||||
gaussian_row_get(int row, int *npoints, uint32_t *weight)
|
||||
{
|
||||
static uint32_t *points = NULL;
|
||||
static int last = -1;
|
||||
static uint32_t lastweight = -1;
|
||||
|
@ -821,36 +845,37 @@ gaussian_row_get(int row, int *npoints, uint32_t *weight){
|
|||
|
||||
if (npoints) *npoints = row + 1;
|
||||
|
||||
if (last == row){
|
||||
if (last == row)
|
||||
{
|
||||
if (weight) *weight = lastweight;
|
||||
return points;
|
||||
}
|
||||
if (points) free(points);
|
||||
|
||||
points = malloc((row + 1) * sizeof(uint32_t));
|
||||
if (!points){
|
||||
if (!points)
|
||||
{
|
||||
last = -1;
|
||||
return NULL;
|
||||
}
|
||||
last = row;
|
||||
|
||||
|
||||
c = 1;
|
||||
for (k = 0 ; k <= row ; k ++){
|
||||
for (k = 0; k <= row; k++)
|
||||
{
|
||||
points[k] = c;
|
||||
c = c * (row - k) / (k + 1);
|
||||
}
|
||||
|
||||
for (k = 0, lastweight = 0 ; k <= row ; k ++)
|
||||
lastweight += points[k];
|
||||
|
||||
for (k = 0, lastweight = 0; k <= row; k++) lastweight += points[k];
|
||||
if (weight) *weight = lastweight;
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
// FIXME: why not static?
|
||||
const uint64_t *
|
||||
gaussian_row_get64(int row, int *npoints, uint64_t *weight){
|
||||
gaussian_row_get64(int row, int *npoints, uint64_t *weight)
|
||||
{
|
||||
static uint64_t *points = NULL;
|
||||
static int last = -1;
|
||||
static uint64_t lastweight = -1;
|
||||
|
@ -860,35 +885,38 @@ gaussian_row_get64(int row, int *npoints, uint64_t *weight){
|
|||
if (row < 0) return NULL;
|
||||
|
||||
if (npoints) *npoints = row + 1;
|
||||
if (last == row){
|
||||
if (last == row)
|
||||
{
|
||||
if (weight) *weight = lastweight;
|
||||
return points;
|
||||
}
|
||||
if (points) free(points);
|
||||
|
||||
points = malloc((row + 1) * sizeof(uint64_t));
|
||||
if (!points){
|
||||
if (!points)
|
||||
{
|
||||
last = -1;
|
||||
return NULL;
|
||||
}
|
||||
last = row;
|
||||
|
||||
|
||||
c = 1;
|
||||
for (k = 0 ; k <= row ; k ++){
|
||||
for (k = 0; k <= row; k++)
|
||||
{
|
||||
points[k] = c;
|
||||
c = c * (row - k) / (k + 1);
|
||||
}
|
||||
|
||||
for (k = 0, lastweight = 0 ; k <= row ; k ++)
|
||||
lastweight += points[k];
|
||||
|
||||
for (k = 0, lastweight = 0; k <= row; k ++) lastweight += points[k];
|
||||
if (weight) *weight = lastweight;
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
// FIXME: why not static?
|
||||
const double *
|
||||
gaussian_row_getd(int row, int *npoints, double *weight){
|
||||
gaussian_row_getd(int row, int *npoints, double *weight)
|
||||
{
|
||||
static double *points = NULL;
|
||||
static int last = -1;
|
||||
static double lastweight = -1;
|
||||
|
@ -897,14 +925,16 @@ gaussian_row_getd(int row, int *npoints, double *weight){
|
|||
|
||||
if (row < 0) return NULL;
|
||||
|
||||
if (last == row){
|
||||
if (last == row)
|
||||
{
|
||||
if (weight) *weight = lastweight;
|
||||
return points;
|
||||
}
|
||||
|
||||
if (points) free(points);
|
||||
points = malloc((row + 1) * sizeof(double));
|
||||
if (!points){
|
||||
if (!points)
|
||||
{
|
||||
last = -1;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -913,21 +943,18 @@ gaussian_row_getd(int row, int *npoints, double *weight){
|
|||
if (npoints) *npoints = row + 1;
|
||||
|
||||
c = 1;
|
||||
for (k = 0 ; k <= row ; k ++){
|
||||
for (k = 0; k <= row; k++)
|
||||
{
|
||||
points[k] = c;
|
||||
c = c * (row - k) / (k + 1);
|
||||
}
|
||||
|
||||
for (k = 0, lastweight = 0 ; k <= row ; k ++)
|
||||
lastweight += points[k];
|
||||
|
||||
for (k = 0, lastweight = 0; k <= row; k++) lastweight += points[k];
|
||||
if (weight) *weight = lastweight;
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static Eina_Bool
|
||||
negation_filter(Evas_Filter_Info *info, RGBA_Image *src, RGBA_Image *dst)
|
||||
{
|
||||
|
@ -936,6 +963,7 @@ negation_filter(Evas_Filter_Info *info, RGBA_Image *src, RGBA_Image *dst)
|
|||
int w,h;
|
||||
uint32_t mask,a;
|
||||
|
||||
// FIXME: dont call if img has alpha
|
||||
if (BUILD_NEON0 && evas_common_cpu_has_feature(CPU_FEATURE_NEON))
|
||||
return negation_filter_neon(info, src, dst);
|
||||
|
||||
|
@ -952,12 +980,12 @@ negation_filter(Evas_Filter_Info *info, RGBA_Image *src, RGBA_Image *dst)
|
|||
{
|
||||
a = (*in >> 24) & 0xff;
|
||||
mask = a | (a << 8) | (a << 16);
|
||||
// FIXME: use *out = ARGB_JOIN(a, r, g, b);
|
||||
*out = (mask - (*in & 0xffffff)) | (a << 24);
|
||||
out++;
|
||||
in++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -965,6 +993,7 @@ negation_filter(Evas_Filter_Info *info, RGBA_Image *src, RGBA_Image *dst)
|
|||
{
|
||||
for (j = 0; j < w; j++)
|
||||
{
|
||||
// FIXME: use *out = ARGB_JOIN(a, r, g, b);
|
||||
*out = ~(*in & ~0xff000000) | ((*in) & 0xff000000);
|
||||
out++;
|
||||
in++;
|
||||
|
@ -982,7 +1011,7 @@ negation_filter_neon(Evas_Filter_Info *info, RGBA_Image *src, RGBA_Image *dst)
|
|||
|
||||
if (src->cache_entry.flags.alpha)
|
||||
{
|
||||
|
||||
// FIXME: not implemented
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1028,20 +1057,13 @@ negation_filter_neon(Evas_Filter_Info *info, RGBA_Image *src, RGBA_Image *dst)
|
|||
);
|
||||
#undef AP
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
return EINA_TRUE;
|
||||
info = NULL; src = NULL; dst = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static Eina_Bool
|
||||
sepia_filter(Evas_Filter_Info *info, RGBA_Image *src, RGBA_Image *dst)
|
||||
sepia_filter(Evas_Filter_Info *info __UNUSED__, RGBA_Image *src, RGBA_Image *dst)
|
||||
{
|
||||
uint32_t *in, *out;
|
||||
int i, j;
|
||||
|
@ -1060,12 +1082,13 @@ sepia_filter(Evas_Filter_Info *info, RGBA_Image *src, RGBA_Image *dst)
|
|||
r = R_VAL(in);
|
||||
g = G_VAL(in);
|
||||
b = B_VAL(in);
|
||||
nr = ((uint32_t)((r * .393) + (g *.769) + (b * .189)));
|
||||
ng = ((uint32_t)((r * .349) + (g *.686) + (b * .168)));
|
||||
nb = ((uint32_t)((r * .272) + (g *.534) + (b * .131)));
|
||||
nr = ((uint32_t)((r * 0.393) + (g * 0.769) + (b * 0.189)));
|
||||
ng = ((uint32_t)((r * 0.349) + (g * 0.686) + (b * 0.168)));
|
||||
nb = ((uint32_t)((r * 0.272) + (g * 0.534) + (b * 0.131)));
|
||||
if (nr > 255) nr = 255;
|
||||
if (ng > 255) ng = 255;
|
||||
if (nb > 255) nb = 255;
|
||||
// FIXME: use *out = ARGB_JOIN(a, r, g, b);
|
||||
*out = (*in & 0xff000000) | (nr << 16) | (ng << 8) | nb;
|
||||
out++;
|
||||
in++;
|
||||
|
@ -1075,8 +1098,9 @@ sepia_filter(Evas_Filter_Info *info, RGBA_Image *src, RGBA_Image *dst)
|
|||
return EINA_TRUE;
|
||||
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
greyscale_filter(Evas_Filter_Info *info, RGBA_Image *src, RGBA_Image *dst)
|
||||
greyscale_filter(Evas_Filter_Info *info __UNUSED__, RGBA_Image *src, RGBA_Image *dst)
|
||||
{
|
||||
uint32_t *in, *out;
|
||||
int i, j;
|
||||
|
@ -1099,8 +1123,9 @@ greyscale_filter(Evas_Filter_Info *info, RGBA_Image *src, RGBA_Image *dst)
|
|||
r = R_VAL(in);
|
||||
g = G_VAL(in);
|
||||
b = B_VAL(in);
|
||||
cur = r * 0.3 + g * 0.59 + b * 0.11;
|
||||
cur = (r * 0.3) + (g * 0.59) + (b * 0.11);
|
||||
cur |= cur << 16;
|
||||
// FIXME: use *out = ARGB_JOIN(a, r, g, b);
|
||||
*out = (a << 24) | cur | (cur << 8);
|
||||
out++;
|
||||
in++;
|
||||
|
@ -1118,6 +1143,7 @@ greyscale_filter(Evas_Filter_Info *info, RGBA_Image *src, RGBA_Image *dst)
|
|||
b = B_VAL(in);
|
||||
cur = r * 0.3 + g * 0.59 + b * 0.11;
|
||||
cur |= cur << 16;
|
||||
// FIXME: use *out = ARGB_JOIN(a, r, g, b);
|
||||
*out = 0xff000000 | cur | (cur << 8);
|
||||
out++;
|
||||
in++;
|
||||
|
@ -1128,7 +1154,7 @@ greyscale_filter(Evas_Filter_Info *info, RGBA_Image *src, RGBA_Image *dst)
|
|||
}
|
||||
|
||||
static Eina_Bool
|
||||
brightness_filter(Evas_Filter_Info *info, RGBA_Image *src, RGBA_Image *dst)
|
||||
brightness_filter(Evas_Filter_Info *info __UNUSED__, RGBA_Image *src, RGBA_Image *dst)
|
||||
{
|
||||
uint32_t *in, *out;
|
||||
int i, j;
|
||||
|
@ -1143,6 +1169,7 @@ brightness_filter(Evas_Filter_Info *info, RGBA_Image *src, RGBA_Image *dst)
|
|||
{
|
||||
for (j = 0; j < w; j++)
|
||||
{
|
||||
// FIXME: not even implemented
|
||||
out++;
|
||||
in++;
|
||||
}
|
||||
|
@ -1152,8 +1179,9 @@ brightness_filter(Evas_Filter_Info *info, RGBA_Image *src, RGBA_Image *dst)
|
|||
return EINA_TRUE;
|
||||
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
contrast_filter(Evas_Filter_Info *info, RGBA_Image *src, RGBA_Image *dst)
|
||||
contrast_filter(Evas_Filter_Info *info __UNUSED__, RGBA_Image *src, RGBA_Image *dst)
|
||||
{
|
||||
uint32_t *in, *out;
|
||||
int i, j;
|
||||
|
@ -1168,6 +1196,7 @@ contrast_filter(Evas_Filter_Info *info, RGBA_Image *src, RGBA_Image *dst)
|
|||
{
|
||||
for (j = 0; j < w; j++)
|
||||
{
|
||||
// FIXME: not even implemented
|
||||
out++;
|
||||
in++;
|
||||
}
|
||||
|
@ -1177,9 +1206,4 @@ contrast_filter(Evas_Filter_Info *info, RGBA_Image *src, RGBA_Image *dst)
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/
|
||||
|
|
Loading…
Reference in New Issue