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;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
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;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
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
|
|
|
|
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_SCALE_SMOOTH
|
|
|
|
#ifdef BUILD_C
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI void
|
2002-11-13 21:38:10 -08:00
|
|
|
evas_common_scale_rgba_mipmap_down_2x2_c(DATA32 *src, DATA32 *dst, int src_w, int src_h)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
int x, y, dst_w, dst_h;
|
|
|
|
DATA32 *src_ptr, *src_ptr2, *dst_ptr;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
dst_w = src_w >> 1;
|
|
|
|
dst_h = src_h >> 1;
|
|
|
|
|
|
|
|
if (dst_w < 1) dst_w = 1;
|
|
|
|
if (dst_h < 1) dst_h = 1;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
src_ptr = src;
|
|
|
|
src_ptr2 = src + src_w;
|
|
|
|
dst_ptr = dst;
|
|
|
|
for (y = 0; y < dst_h; y++)
|
|
|
|
{
|
|
|
|
src_ptr = src + (y * src_w * 2);
|
|
|
|
src_ptr2 = src_ptr + src_w;
|
|
|
|
for (x = 0; x < dst_w; x++)
|
|
|
|
{
|
|
|
|
R_VAL(dst_ptr) = (R_VAL(src_ptr) + R_VAL(src_ptr + 1) + R_VAL(src_ptr2) + R_VAL(src_ptr2 + 1)) >> 2;
|
|
|
|
G_VAL(dst_ptr) = (G_VAL(src_ptr) + G_VAL(src_ptr + 1) + G_VAL(src_ptr2) + G_VAL(src_ptr2 + 1)) >> 2;
|
|
|
|
B_VAL(dst_ptr) = (B_VAL(src_ptr) + B_VAL(src_ptr + 1) + B_VAL(src_ptr2) + B_VAL(src_ptr2 + 1)) >> 2;
|
|
|
|
A_VAL(dst_ptr) = (A_VAL(src_ptr) + A_VAL(src_ptr + 1) + A_VAL(src_ptr2) + A_VAL(src_ptr2 + 1)) >> 2;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
src_ptr+=2;
|
|
|
|
src_ptr2+=2;
|
|
|
|
dst_ptr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef BUILD_SCALE_SMOOTH
|
|
|
|
#ifdef BUILD_C
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI void
|
2002-11-13 21:38:10 -08:00
|
|
|
evas_common_scale_rgba_mipmap_down_2x1_c(DATA32 *src, DATA32 *dst, int src_w, int src_h)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
int x, y, dst_w, dst_h;
|
|
|
|
DATA32 *src_ptr, *dst_ptr;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
dst_w = src_w >> 1;
|
|
|
|
dst_h = src_h >> 1;
|
|
|
|
|
|
|
|
if (dst_w < 1) dst_w = 1;
|
|
|
|
if (dst_h < 1) dst_h = 1;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
src_ptr = src;
|
|
|
|
dst_ptr = dst;
|
|
|
|
for (y = 0; y < dst_h; y++)
|
|
|
|
{
|
|
|
|
src_ptr = src + (y * src_w * 2);
|
|
|
|
for (x = 0; x < dst_w; x++)
|
|
|
|
{
|
|
|
|
R_VAL(dst_ptr) = (R_VAL(src_ptr) + R_VAL(src_ptr + 1)) >> 1;
|
|
|
|
G_VAL(dst_ptr) = (G_VAL(src_ptr) + G_VAL(src_ptr + 1)) >> 1;
|
|
|
|
B_VAL(dst_ptr) = (B_VAL(src_ptr) + B_VAL(src_ptr + 1)) >> 1;
|
|
|
|
A_VAL(dst_ptr) = (A_VAL(src_ptr) + A_VAL(src_ptr + 1)) >> 1;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
src_ptr+=2;
|
|
|
|
dst_ptr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef BUILD_SCALE_SMOOTH
|
|
|
|
#ifdef BUILD_C
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI void
|
2002-11-13 21:38:10 -08:00
|
|
|
evas_common_scale_rgba_mipmap_down_1x2_c(DATA32 *src, DATA32 *dst, int src_w, int src_h)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
int x, y, dst_w, dst_h;
|
|
|
|
DATA32 *src_ptr, *src_ptr2, *dst_ptr;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
dst_w = src_w >> 1;
|
|
|
|
dst_h = src_h >> 1;
|
|
|
|
|
|
|
|
if (dst_w < 1) dst_w = 1;
|
|
|
|
if (dst_h < 1) dst_h = 1;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
src_ptr = src;
|
|
|
|
dst_ptr = dst;
|
|
|
|
for (y = 0; y < dst_h; y++)
|
|
|
|
{
|
|
|
|
src_ptr = src + (y * src_w * 2);
|
|
|
|
src_ptr2 = src_ptr + src_w;
|
|
|
|
for (x = 0; x < dst_w; x++)
|
|
|
|
{
|
|
|
|
R_VAL(dst_ptr) = (R_VAL(src_ptr) + R_VAL(src_ptr2)) >> 1;
|
|
|
|
G_VAL(dst_ptr) = (G_VAL(src_ptr) + G_VAL(src_ptr2)) >> 1;
|
|
|
|
B_VAL(dst_ptr) = (B_VAL(src_ptr) + B_VAL(src_ptr2)) >> 1;
|
|
|
|
A_VAL(dst_ptr) = (A_VAL(src_ptr) + A_VAL(src_ptr2)) >> 1;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
src_ptr+=2;
|
|
|
|
src_ptr2+=2;
|
|
|
|
dst_ptr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef BUILD_SCALE_SMOOTH
|
|
|
|
#ifdef BUILD_C
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI void
|
2002-11-13 21:38:10 -08:00
|
|
|
evas_common_scale_rgb_mipmap_down_2x2_c(DATA32 *src, DATA32 *dst, int src_w, int src_h)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
int x, y, dst_w, dst_h;
|
|
|
|
DATA32 *src_ptr, *src_ptr2, *dst_ptr;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
dst_w = src_w >> 1;
|
|
|
|
dst_h = src_h >> 1;
|
|
|
|
|
|
|
|
if (dst_w < 1) dst_w = 1;
|
|
|
|
if (dst_h < 1) dst_h = 1;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
src_ptr = src;
|
|
|
|
src_ptr2 = src + src_w;
|
|
|
|
dst_ptr = dst;
|
|
|
|
for (y = 0; y < dst_h; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < dst_w; x++)
|
|
|
|
{
|
|
|
|
R_VAL(dst_ptr) = (R_VAL(src_ptr) + R_VAL(src_ptr + 1) + R_VAL(src_ptr2) + R_VAL(src_ptr2 + 1)) >> 2;
|
|
|
|
G_VAL(dst_ptr) = (G_VAL(src_ptr) + G_VAL(src_ptr + 1) + G_VAL(src_ptr2) + G_VAL(src_ptr2 + 1)) >> 2;
|
|
|
|
B_VAL(dst_ptr) = (B_VAL(src_ptr) + B_VAL(src_ptr + 1) + B_VAL(src_ptr2) + B_VAL(src_ptr2 + 1)) >> 2;
|
|
|
|
A_VAL(dst_ptr) = 0xff;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
src_ptr+=2;
|
|
|
|
src_ptr2+=2;
|
|
|
|
dst_ptr++;
|
|
|
|
}
|
|
|
|
src_ptr += src_w;
|
|
|
|
src_ptr2 += src_w;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef BUILD_SCALE_SMOOTH
|
|
|
|
#ifdef BUILD_C
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI void
|
2002-11-13 21:38:10 -08:00
|
|
|
evas_common_scale_rgb_mipmap_down_2x1_c(DATA32 *src, DATA32 *dst, int src_w, int src_h)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
int x, y, dst_w, dst_h;
|
|
|
|
DATA32 *src_ptr, *dst_ptr;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
dst_w = src_w >> 1;
|
|
|
|
dst_h = src_h >> 1;
|
|
|
|
|
|
|
|
if (dst_w < 1) dst_w = 1;
|
|
|
|
if (dst_h < 1) dst_h = 1;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
src_ptr = src;
|
|
|
|
dst_ptr = dst;
|
|
|
|
for (y = 0; y < dst_h; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < dst_w; x++)
|
|
|
|
{
|
|
|
|
R_VAL(dst_ptr) = (R_VAL(src_ptr) + R_VAL(src_ptr + 1)) >> 1;
|
|
|
|
G_VAL(dst_ptr) = (G_VAL(src_ptr) + G_VAL(src_ptr + 1)) >> 1;
|
|
|
|
B_VAL(dst_ptr) = (B_VAL(src_ptr) + B_VAL(src_ptr + 1)) >> 1;
|
|
|
|
A_VAL(dst_ptr) = 0xff;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
src_ptr+=2;
|
|
|
|
dst_ptr++;
|
|
|
|
}
|
|
|
|
src_ptr += src_w;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef BUILD_SCALE_SMOOTH
|
|
|
|
#ifdef BUILD_C
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI void
|
2002-11-13 21:38:10 -08:00
|
|
|
evas_common_scale_rgb_mipmap_down_1x2_c(DATA32 *src, DATA32 *dst, int src_w, int src_h)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
int x, y, dst_w, dst_h;
|
|
|
|
DATA32 *src_ptr, *src_ptr2, *dst_ptr;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
dst_w = src_w >> 1;
|
|
|
|
dst_h = src_h >> 1;
|
|
|
|
|
|
|
|
if (dst_w < 1) dst_w = 1;
|
|
|
|
if (dst_h < 1) dst_h = 1;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
src_ptr = src;
|
|
|
|
src_ptr2 = src + src_w;
|
|
|
|
dst_ptr = dst;
|
|
|
|
for (y = 0; y < dst_h; y++)
|
|
|
|
{
|
|
|
|
for (x = 0; x < dst_w; x++)
|
|
|
|
{
|
|
|
|
R_VAL(dst_ptr) = (R_VAL(src_ptr) + R_VAL(src_ptr2)) >> 1;
|
|
|
|
G_VAL(dst_ptr) = (G_VAL(src_ptr) + G_VAL(src_ptr2)) >> 1;
|
|
|
|
B_VAL(dst_ptr) = (B_VAL(src_ptr) + B_VAL(src_ptr2)) >> 1;
|
|
|
|
A_VAL(dst_ptr) = 0xff;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
src_ptr+=2;
|
|
|
|
src_ptr2+=2;
|
|
|
|
dst_ptr++;
|
|
|
|
}
|
|
|
|
src_ptr += src_w;
|
|
|
|
src_ptr2 += src_w;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef BUILD_SCALE_SMOOTH
|
|
|
|
#ifdef BUILD_MMX
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI void
|
2002-11-13 21:38:10 -08:00
|
|
|
evas_common_scale_rgba_mipmap_down_2x2_mmx(DATA32 *src, DATA32 *dst, int src_w, int src_h)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
int x, y, dst_w, dst_h;
|
|
|
|
DATA32 *src_ptr, *src_ptr2, *dst_ptr;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
dst_w = src_w >> 1;
|
|
|
|
dst_h = src_h >> 1;
|
|
|
|
|
|
|
|
if (dst_w < 1) dst_w = 1;
|
|
|
|
if (dst_h < 1) dst_h = 1;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2010-07-31 00:13:21 -07:00
|
|
|
/* NB: Dead assignments (reassigned to different values below)
|
2002-11-08 00:02:15 -08:00
|
|
|
src_ptr = src;
|
|
|
|
src_ptr2 = src + src_w;
|
2010-07-31 00:13:21 -07:00
|
|
|
*/
|
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
dst_ptr = dst;
|
|
|
|
for (y = 0; y < dst_h; y++)
|
|
|
|
{
|
|
|
|
src_ptr = src + (y * src_w * 2);
|
|
|
|
src_ptr2 = src_ptr + src_w;
|
|
|
|
for (x = 0; x < dst_w; x++)
|
|
|
|
{
|
|
|
|
punpcklbw_m2r(src_ptr[0], mm0);
|
|
|
|
punpcklbw_m2r(src_ptr[1], mm1);
|
|
|
|
punpcklbw_m2r(src_ptr2[0], mm2);
|
|
|
|
punpcklbw_m2r(src_ptr2[1], mm3);
|
|
|
|
psrlw_i2r(8, mm0);
|
|
|
|
psrlw_i2r(8, mm1);
|
|
|
|
psrlw_i2r(8, mm2);
|
|
|
|
psrlw_i2r(8, mm3);
|
|
|
|
paddw_r2r(mm1, mm0);
|
|
|
|
paddw_r2r(mm2, mm0);
|
|
|
|
paddw_r2r(mm3, mm0);
|
|
|
|
psrlw_i2r(2, mm0);
|
|
|
|
packuswb_r2r(mm0, mm0);
|
|
|
|
movd_r2m(mm0, dst_ptr[0]);
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
src_ptr+=2;
|
|
|
|
src_ptr2+=2;
|
|
|
|
dst_ptr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef BUILD_SCALE_SMOOTH
|
|
|
|
#ifdef BUILD_MMX
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI void
|
2002-11-13 21:38:10 -08:00
|
|
|
evas_common_scale_rgba_mipmap_down_2x1_mmx(DATA32 *src, DATA32 *dst, int src_w, int src_h)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
int x, y, dst_w, dst_h;
|
|
|
|
DATA32 *src_ptr, *dst_ptr;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
dst_w = src_w >> 1;
|
|
|
|
dst_h = src_h >> 1;
|
|
|
|
|
|
|
|
if (dst_w < 1) dst_w = 1;
|
|
|
|
if (dst_h < 1) dst_h = 1;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
src_ptr = src;
|
|
|
|
dst_ptr = dst;
|
|
|
|
for (y = 0; y < dst_h; y++)
|
|
|
|
{
|
|
|
|
src_ptr = src + (y * src_w * 2);
|
|
|
|
for (x = 0; x < dst_w; x++)
|
|
|
|
{
|
|
|
|
punpcklbw_m2r(src_ptr[0], mm0);
|
|
|
|
punpcklbw_m2r(src_ptr[1], mm1);
|
|
|
|
psrlw_i2r(8, mm0);
|
|
|
|
psrlw_i2r(8, mm1);
|
|
|
|
paddw_r2r(mm1, mm0);
|
|
|
|
psrlw_i2r(1, mm0);
|
|
|
|
packuswb_r2r(mm0, mm0);
|
|
|
|
movd_r2m(mm0, dst_ptr[0]);
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
src_ptr+=2;
|
|
|
|
dst_ptr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef BUILD_SCALE_SMOOTH
|
|
|
|
#ifdef BUILD_MMX
|
2006-09-06 00:33:40 -07:00
|
|
|
EAPI void
|
2002-11-13 21:38:10 -08:00
|
|
|
evas_common_scale_rgba_mipmap_down_1x2_mmx(DATA32 *src, DATA32 *dst, int src_w, int src_h)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
|
|
|
int x, y, dst_w, dst_h;
|
|
|
|
DATA32 *src_ptr, *src_ptr2, *dst_ptr;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
dst_w = src_w >> 1;
|
|
|
|
dst_h = src_h >> 1;
|
|
|
|
|
|
|
|
if (dst_w < 1) dst_w = 1;
|
|
|
|
if (dst_h < 1) dst_h = 1;
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2010-07-30 23:12:39 -07:00
|
|
|
/* NB: Dead assignment (gets reassigned later) */
|
|
|
|
// src_ptr = src;
|
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
src_ptr2 = src + src_w;
|
|
|
|
dst_ptr = dst;
|
|
|
|
for (y = 0; y < dst_h; y++)
|
|
|
|
{
|
|
|
|
src_ptr = src + (y * src_w * 2);
|
|
|
|
src_ptr2 = src_ptr + src_w;
|
|
|
|
for (x = 0; x < dst_w; x++)
|
|
|
|
{
|
|
|
|
punpcklbw_m2r(src_ptr[0], mm0);
|
|
|
|
punpcklbw_m2r(src_ptr2[0], mm1);
|
|
|
|
psrlw_i2r(8, mm0);
|
|
|
|
psrlw_i2r(8, mm1);
|
|
|
|
paddw_r2r(mm1, mm0);
|
|
|
|
psrlw_i2r(1, mm0);
|
|
|
|
packuswb_r2r(mm0, mm0);
|
|
|
|
movd_r2m(mm0, dst_ptr[0]);
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
src_ptr+=2;
|
|
|
|
src_ptr2+=2;
|
|
|
|
dst_ptr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef BUILD_SCALE_SMOOTH
|
|
|
|
# ifdef BUILD_MMX
|
|
|
|
# undef SCALE_FUNC
|
2002-11-13 21:38:10 -08:00
|
|
|
# define SCALE_FUNC evas_common_scale_rgba_in_to_out_clip_smooth_mmx
|
2002-11-08 00:02:15 -08:00
|
|
|
# undef SCALE_USING_MMX
|
|
|
|
# define SCALE_USING_MMX
|
|
|
|
# include "evas_scale_smooth_scaler.c"
|
|
|
|
# endif
|
|
|
|
# ifdef BUILD_C
|
|
|
|
# undef SCALE_FUNC
|
2002-11-13 21:38:10 -08:00
|
|
|
# define SCALE_FUNC evas_common_scale_rgba_in_to_out_clip_smooth_c
|
2002-11-08 00:02:15 -08:00
|
|
|
# undef SCALE_USING_MMX
|
|
|
|
# include "evas_scale_smooth_scaler.c"
|
|
|
|
# endif
|
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,
|
2002-11-08 00:02:15 -08:00
|
|
|
RGBA_Draw_Context *dc,
|
2005-05-21 19:49:50 -07:00
|
|
|
int src_region_x, int src_region_y,
|
|
|
|
int src_region_w, int src_region_h,
|
|
|
|
int dst_region_x, int dst_region_y,
|
2002-11-08 00:02:15 -08:00
|
|
|
int dst_region_w, int dst_region_h)
|
|
|
|
{
|
|
|
|
# ifdef BUILD_MMX
|
|
|
|
int mmx, sse, sse2;
|
2005-05-21 19:49:50 -07:00
|
|
|
# endif
|
2007-04-04 02:55:40 -07:00
|
|
|
Cutout_Rects *rects;
|
|
|
|
Cutout_Rect *r;
|
|
|
|
int c, cx, cy, cw, ch;
|
|
|
|
int i;
|
2002-11-08 00:02:15 -08:00
|
|
|
/* handle cutouts here! */
|
2005-05-21 19:49:50 -07:00
|
|
|
|
2002-11-08 00:02:15 -08:00
|
|
|
if ((dst_region_w <= 0) || (dst_region_h <= 0)) return;
|
2008-04-11 17:32:30 -07:00
|
|
|
if (!(RECTS_INTERSECT(dst_region_x, dst_region_y, dst_region_w, dst_region_h, 0, 0, dst->cache_entry.w, dst->cache_entry.h)))
|
2002-11-08 00:02:15 -08:00
|
|
|
return;
|
|
|
|
# ifdef BUILD_MMX
|
2002-11-13 21:38:10 -08:00
|
|
|
evas_common_cpu_can_do(&mmx, &sse, &sse2);
|
2005-05-21 19:49:50 -07:00
|
|
|
# endif
|
2002-11-08 00:02:15 -08:00
|
|
|
/* no cutouts - cut right to the chase */
|
|
|
|
if (!dc->cutout.rects)
|
|
|
|
{
|
|
|
|
# ifdef BUILD_MMX
|
|
|
|
if (mmx)
|
2005-05-21 19:49:50 -07:00
|
|
|
evas_common_scale_rgba_in_to_out_clip_smooth_mmx(src, dst, dc,
|
|
|
|
src_region_x, src_region_y,
|
2002-11-08 00:02:15 -08:00
|
|
|
src_region_w, src_region_h,
|
|
|
|
dst_region_x, dst_region_y,
|
|
|
|
dst_region_w, dst_region_h);
|
|
|
|
else
|
|
|
|
# endif
|
|
|
|
# ifdef BUILD_C
|
2005-05-21 19:49:50 -07:00
|
|
|
evas_common_scale_rgba_in_to_out_clip_smooth_c(src, dst, dc,
|
|
|
|
src_region_x, src_region_y,
|
2002-11-08 00:02:15 -08:00
|
|
|
src_region_w, src_region_h,
|
|
|
|
dst_region_x, dst_region_y,
|
|
|
|
dst_region_w, dst_region_h);
|
2005-05-21 19:49:50 -07:00
|
|
|
# endif
|
2002-11-08 00:02:15 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* save out clip info */
|
|
|
|
c = dc->clip.use; cx = dc->clip.x; cy = dc->clip.y; cw = dc->clip.w; ch = dc->clip.h;
|
2008-04-11 17:32:30 -07:00
|
|
|
evas_common_draw_context_clip_clip(dc, 0, 0, dst->cache_entry.w, dst->cache_entry.h);
|
2002-11-13 21:38:10 -08:00
|
|
|
evas_common_draw_context_clip_clip(dc, dst_region_x, dst_region_y, dst_region_w, dst_region_h);
|
2002-11-08 00:02:15 -08:00
|
|
|
/* our clip is 0 size.. abort */
|
|
|
|
if ((dc->clip.w <= 0) || (dc->clip.h <= 0))
|
|
|
|
{
|
|
|
|
dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch;
|
|
|
|
return;
|
|
|
|
}
|
2002-11-13 21:38:10 -08:00
|
|
|
rects = evas_common_draw_context_apply_cutouts(dc);
|
2007-04-04 02:55:40 -07:00
|
|
|
for (i = 0; i < rects->active; ++i)
|
2002-11-08 00:02:15 -08:00
|
|
|
{
|
2007-04-04 02:55:40 -07:00
|
|
|
r = rects->rects + i;
|
2002-11-13 21:38:10 -08:00
|
|
|
evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h);
|
2002-11-08 00:02:15 -08:00
|
|
|
# ifdef BUILD_MMX
|
|
|
|
if (mmx)
|
2005-05-21 19:49:50 -07:00
|
|
|
evas_common_scale_rgba_in_to_out_clip_smooth_mmx(src, dst, dc,
|
|
|
|
src_region_x, src_region_y,
|
2002-11-08 00:02:15 -08:00
|
|
|
src_region_w, src_region_h,
|
|
|
|
dst_region_x, dst_region_y,
|
|
|
|
dst_region_w, dst_region_h);
|
|
|
|
else
|
|
|
|
# endif
|
|
|
|
# ifdef BUILD_C
|
2005-05-21 19:49:50 -07:00
|
|
|
evas_common_scale_rgba_in_to_out_clip_smooth_c(src, dst, dc,
|
|
|
|
src_region_x, src_region_y,
|
2002-11-08 00:02:15 -08:00
|
|
|
src_region_w, src_region_h,
|
|
|
|
dst_region_x, dst_region_y,
|
|
|
|
dst_region_w, dst_region_h);
|
2005-05-21 19:49:50 -07:00
|
|
|
# endif
|
2002-11-08 00:02:15 -08:00
|
|
|
}
|
2007-04-04 02:55:40 -07:00
|
|
|
evas_common_draw_context_apply_clear_cutouts(rects);
|
2002-11-08 00:02:15 -08:00
|
|
|
/* restore clip info */
|
|
|
|
dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch;
|
|
|
|
}
|
|
|
|
#endif
|