2002-11-08 00:02:15 -08:00
|
|
|
#include "evas_common.h"
|
2008-07-10 23:36:30 -07:00
|
|
|
#include "evas_scale_smooth.h"
|
2008-07-21 09:10:48 -07:00
|
|
|
#include "evas_blend_private.h"
|
2004-01-29 21:46:57 -08:00
|
|
|
|
2011-02-12 06:50:25 -08:00
|
|
|
#define SCALE_CALC_X_POINTS(P, SW, DW, CX, CW) \
|
|
|
|
P = alloca((CW + 1) * sizeof (int)); \
|
|
|
|
scale_calc_x_points(P, SW, DW, CX, CW);
|
2004-01-29 21:46:57 -08:00
|
|
|
|
2011-02-12 06:50:25 -08:00
|
|
|
#define SCALE_CALC_Y_POINTS(P, SRC, SW, SH, DH, CY, CH) \
|
|
|
|
P = alloca((CH + 1) * sizeof (DATA32 *)); \
|
|
|
|
scale_calc_y_points(P, SRC, SW, SH, DH, CY, CH);
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2011-02-12 06:50:25 -08:00
|
|
|
#define SCALE_CALC_A_POINTS(P, S, D, C, CC) \
|
|
|
|
P = alloca(CC * sizeof (int)); \
|
|
|
|
scale_calc_a_points(P, S, D, C, CC);
|
2009-06-15 07:34:33 -07:00
|
|
|
|
2011-02-12 06:50:25 -08:00
|
|
|
static void scale_calc_y_points(DATA32 **p, DATA32 *src, int sw, int sh, int dh, int cy, int ch);
|
|
|
|
static void scale_calc_x_points(int *p, int sw, int dw, int cx, int cw);
|
|
|
|
static void scale_calc_a_points(int *p, int s, int d, int c, int cc);
|
2009-06-15 07:34:33 -07:00
|
|
|
|
|
|
|
static void
|
2011-02-12 06:50:25 -08:00
|
|
|
scale_calc_y_points(DATA32** p, DATA32 *src, int sw, int sh, int dh, int cy, int ch)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
int i, val, inc;
|
2011-06-12 19:57:01 -07:00
|
|
|
if (sh > SCALE_SIZE_MAX) return;
|
2002-11-08 00:02:15 -08:00
|
|
|
val = 0;
|
|
|
|
inc = (sh << 16) / dh;
|
2005-05-21 19:49:50 -07:00
|
|
|
for (i = 0; i < dh; i++)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2011-02-12 06:50:25 -08:00
|
|
|
if ((i >= cy) && (i < (cy + ch)))
|
|
|
|
p[i - cy] = src + ((val >> 16) * sw);
|
2002-11-08 00:02:15 -08:00
|
|
|
val += inc;
|
|
|
|
}
|
2011-02-12 06:50:25 -08:00
|
|
|
if ((i >= cy) && (i < (cy + ch)))
|
|
|
|
p[i - cy] = p[i - cy - 1];
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2009-06-15 07:34:33 -07:00
|
|
|
static void
|
2011-02-12 06:50:25 -08:00
|
|
|
scale_calc_x_points(int *p, int sw, int dw, int cx, int cw)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
int i, val, inc;
|
2011-06-12 19:57:01 -07:00
|
|
|
if (sw > SCALE_SIZE_MAX) return;
|
2002-11-08 00:02:15 -08:00
|
|
|
val = 0;
|
|
|
|
inc = (sw << 16) / dw;
|
2005-05-21 19:49:50 -07:00
|
|
|
for (i = 0; i < dw; i++)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2011-02-12 06:50:25 -08:00
|
|
|
if ((i >= cx) && (i < (cx + cw)))
|
|
|
|
p[i - cx] = val >> 16;
|
2002-11-08 00:02:15 -08:00
|
|
|
val += inc;
|
|
|
|
}
|
2011-02-12 06:50:25 -08:00
|
|
|
if ((i >= cx) && (i < (cx + cw)))
|
|
|
|
p[i - cx] = p[i - cx - 1];
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
|
2009-06-15 07:34:33 -07:00
|
|
|
static void
|
2011-02-12 06:50:25 -08:00
|
|
|
scale_calc_a_points(int *p, int s, int d, int c, int cc)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
int i, val, inc;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2011-06-12 19:57:01 -07:00
|
|
|
if (s > SCALE_SIZE_MAX) return;
|
2002-11-08 00:02:15 -08:00
|
|
|
if (d >= s)
|
|
|
|
{
|
|
|
|
val = 0;
|
|
|
|
inc = (s << 16) / d;
|
|
|
|
for (i = 0; i < d; i++)
|
|
|
|
{
|
2011-02-12 06:50:25 -08:00
|
|
|
if ((i >= c) && (i < (c + cc)))
|
|
|
|
{
|
|
|
|
p[i - c] = (val >> 8) - ((val >> 8) & 0xffffff00);
|
|
|
|
if ((val >> 16) >= (s - 1)) p[i - c] = 0;
|
|
|
|
}
|
2002-11-08 00:02:15 -08:00
|
|
|
val += inc;
|
2005-05-21 19:49:50 -07:00
|
|
|
}
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int ap, Cp;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
val = 0;
|
|
|
|
inc = (s << 16) / d;
|
|
|
|
Cp = ((d << 14) / s) + 1;
|
|
|
|
for (i = 0; i < d; i++)
|
|
|
|
{
|
|
|
|
ap = ((0x100 - ((val >> 8) & 0xff)) * Cp) >> 8;
|
2011-02-12 06:50:25 -08:00
|
|
|
if ((i >= c) && (i < (c + cc)))
|
|
|
|
p[i - c] = ap | (Cp << 16);
|
2002-11-08 00:02:15 -08:00
|
|
|
val += inc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef BUILD_MMX
|
2012-10-15 20:15:40 -07:00
|
|
|
# undef SCALE_FUNC
|
|
|
|
# define SCALE_FUNC evas_common_scale_rgba_in_to_out_clip_smooth_mmx
|
|
|
|
# undef SCALE_USING_MMX
|
|
|
|
# define SCALE_USING_MMX
|
|
|
|
# include "evas_scale_smooth_scaler.c"
|
2002-11-08 00:02:15 -08:00
|
|
|
#endif
|
|
|
|
|
2012-10-15 20:15:40 -07:00
|
|
|
#undef SCALE_FUNC
|
|
|
|
#define SCALE_FUNC evas_common_scale_rgba_in_to_out_clip_smooth_c
|
|
|
|
#undef SCALE_USING_MMX
|
|
|
|
#include "evas_scale_smooth_scaler.c"
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI void
|
2005-05-21 19:49:50 -07:00
|
|
|
evas_common_scale_rgba_in_to_out_clip_smooth(RGBA_Image *src, RGBA_Image *dst,
|
2012-10-15 20:15:40 -07:00
|
|
|
RGBA_Draw_Context *dc,
|
|
|
|
int src_region_x, int src_region_y,
|
|
|
|
int src_region_w, int src_region_h,
|
|
|
|
int dst_region_x, int dst_region_y,
|
|
|
|
int dst_region_w, int dst_region_h)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2012-11-28 14:49:19 -08:00
|
|
|
Evas_Common_Scale_In_To_Out_Clip_Cb cb;
|
|
|
|
#ifdef BUILD_MMX
|
2002-11-08 00:02:15 -08:00
|
|
|
int mmx, sse, sse2;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-13 21:38:10 -08:00
|
|
|
evas_common_cpu_can_do(&mmx, &sse, &sse2);
|
2012-11-28 14:49:19 -08:00
|
|
|
if (mmx)
|
|
|
|
cb = evas_common_scale_rgba_in_to_out_clip_smooth_mmx;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
cb = evas_common_scale_rgba_in_to_out_clip_smooth_c;
|
|
|
|
|
|
|
|
evas_common_scale_rgba_in_to_out_clip_cb(src, dst, dc,
|
|
|
|
src_region_x, src_region_y,
|
|
|
|
src_region_w, src_region_h,
|
|
|
|
dst_region_x, dst_region_y,
|
|
|
|
dst_region_w, dst_region_h,
|
|
|
|
cb);
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
2012-07-04 02:39:23 -07:00
|
|
|
|
|
|
|
EAPI void
|
|
|
|
evas_common_scale_rgba_in_to_out_clip_smooth_do(const Cutout_Rects *reuse,
|
|
|
|
const Eina_Rectangle *clip,
|
|
|
|
RGBA_Image *src, RGBA_Image *dst,
|
|
|
|
RGBA_Draw_Context *dc,
|
|
|
|
int src_region_x, int src_region_y,
|
|
|
|
int src_region_w, int src_region_h,
|
|
|
|
int dst_region_x, int dst_region_y,
|
|
|
|
int dst_region_w, int dst_region_h)
|
|
|
|
{
|
|
|
|
# ifdef BUILD_MMX
|
|
|
|
int mmx, sse, sse2;
|
|
|
|
# endif
|
|
|
|
Eina_Rectangle area;
|
|
|
|
Cutout_Rect *r;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
# ifdef BUILD_MMX
|
|
|
|
evas_common_cpu_can_do(&mmx, &sse, &sse2);
|
|
|
|
# endif
|
|
|
|
if (!reuse)
|
|
|
|
{
|
2012-07-04 20:11:47 -07:00
|
|
|
evas_common_draw_context_clip_clip(dc, clip->x, clip->y, clip->w, clip->h);
|
2012-07-04 02:39:23 -07:00
|
|
|
# ifdef BUILD_MMX
|
|
|
|
if (mmx)
|
|
|
|
evas_common_scale_rgba_in_to_out_clip_smooth_mmx(src, dst, dc,
|
|
|
|
src_region_x, src_region_y,
|
|
|
|
src_region_w, src_region_h,
|
|
|
|
dst_region_x, dst_region_y,
|
|
|
|
dst_region_w, dst_region_h);
|
|
|
|
else
|
|
|
|
# endif
|
|
|
|
evas_common_scale_rgba_in_to_out_clip_smooth_c(src, dst, dc,
|
2012-10-15 20:15:40 -07:00
|
|
|
src_region_x, src_region_y,
|
|
|
|
src_region_w, src_region_h,
|
|
|
|
dst_region_x, dst_region_y,
|
|
|
|
dst_region_w, dst_region_h);
|
|
|
|
return;
|
2012-07-04 02:39:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < reuse->active; ++i)
|
|
|
|
{
|
|
|
|
r = reuse->rects + i;
|
|
|
|
|
|
|
|
EINA_RECTANGLE_SET(&area, r->x, r->y, r->w, r->h);
|
|
|
|
if (!eina_rectangle_intersection(&area, clip)) continue ;
|
|
|
|
evas_common_draw_context_set_clip(dc, area.x, area.y, area.w, area.h);
|
|
|
|
# ifdef BUILD_MMX
|
|
|
|
if (mmx)
|
|
|
|
evas_common_scale_rgba_in_to_out_clip_smooth_mmx(src, dst, dc,
|
|
|
|
src_region_x, src_region_y,
|
|
|
|
src_region_w, src_region_h,
|
|
|
|
dst_region_x, dst_region_y,
|
|
|
|
dst_region_w, dst_region_h);
|
|
|
|
else
|
|
|
|
# endif
|
|
|
|
evas_common_scale_rgba_in_to_out_clip_smooth_c(src, dst, dc,
|
2012-10-15 20:15:40 -07:00
|
|
|
src_region_x, src_region_y,
|
|
|
|
src_region_w, src_region_h,
|
|
|
|
dst_region_x, dst_region_y,
|
|
|
|
dst_region_w, dst_region_h);
|
2012-07-04 02:39:23 -07:00
|
|
|
}
|
|
|
|
}
|