speedup scaling down....... but i cant seem to get any speedup for up scaling

SVN revision: 2367
This commit is contained in:
Carsten Haitzler 2000-03-28 22:25:45 +00:00
parent 87146f0a33
commit 0780bd87ac
2 changed files with 845 additions and 810 deletions

View File

@ -1,10 +1,16 @@
#include "common.h" #include "common.h"
#include <X11/Xlib.h>
#include "colormod.h"
#include "image.h"
#include "blend.h"
#include "scale.h" #include "scale.h"
/*
#define R_VAL(x) (((x) & 0x000000ff)) #define R_VAL(x) (((x) & 0x000000ff))
#define G_VAL(x) (((x) & 0x0000ff00) >> 8) #define G_VAL(x) (((x) & 0x0000ff00) >> 8)
#define B_VAL(x) (((x) & 0x00ff0000) >> 16) #define B_VAL(x) (((x) & 0x00ff0000) >> 16)
#define A_VAL(x) (((x) & 0xff000000) >> 24) #define A_VAL(x) (((x) & 0xff000000) >> 24)
*/
#define RGBA_COMPOSE(r, g, b, a) ((a) << 24) | ((b) << 16) | ((g) << 8) | (r) #define RGBA_COMPOSE(r, g, b, a) ((a) << 24) | ((b) << 16) | ((g) << 8) | (r)
#define INV_XAP (255 - xapoints[x]) #define INV_XAP (255 - xapoints[x])
#define XAP (xapoints[x]) #define XAP (xapoints[x])
@ -222,30 +228,30 @@ __imlib_ScaleAARGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
{ {
int r = 0, g = 0, b = 0, a = 0; int r = 0, g = 0, b = 0, a = 0;
int rr = 0, gg = 0, bb = 0, aa = 0; int rr = 0, gg = 0, bb = 0, aa = 0;
DATA32 pix; DATA32 *pix;
if (YAP > 0) if (YAP > 0)
{ {
if (XAP > 0) if (XAP > 0)
{ {
ssptr = ypoints[dyy + y]; ssptr = ypoints[dyy + y];
pix = ssptr[xpoints[x]]; pix = &ssptr[xpoints[x]];
r = R_VAL(pix) * INV_XAP; r = R_VAL(pix) * INV_XAP;
g = G_VAL(pix) * INV_XAP; g = G_VAL(pix) * INV_XAP;
b = B_VAL(pix) * INV_XAP; b = B_VAL(pix) * INV_XAP;
a = A_VAL(pix) * INV_XAP; a = A_VAL(pix) * INV_XAP;
pix = ssptr[xpoints[x] + 1]; pix = &ssptr[xpoints[x] + 1];
r += R_VAL(pix) * XAP; r += R_VAL(pix) * XAP;
g += G_VAL(pix) * XAP; g += G_VAL(pix) * XAP;
b += B_VAL(pix) * XAP; b += B_VAL(pix) * XAP;
a += A_VAL(pix) * XAP; a += A_VAL(pix) * XAP;
ssptr += sow; ssptr += sow;
pix = ssptr[xpoints[x]]; pix = &ssptr[xpoints[x]];
rr = R_VAL(pix) * INV_XAP; rr = R_VAL(pix) * INV_XAP;
gg = G_VAL(pix) * INV_XAP; gg = G_VAL(pix) * INV_XAP;
bb = B_VAL(pix) * INV_XAP; bb = B_VAL(pix) * INV_XAP;
aa = A_VAL(pix) * INV_XAP; aa = A_VAL(pix) * INV_XAP;
pix = ssptr[xpoints[x] + 1]; pix = &ssptr[xpoints[x] + 1];
rr += R_VAL(pix) * XAP; rr += R_VAL(pix) * XAP;
gg += G_VAL(pix) * XAP; gg += G_VAL(pix) * XAP;
bb += B_VAL(pix) * XAP; bb += B_VAL(pix) * XAP;
@ -254,19 +260,18 @@ __imlib_ScaleAARGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
g = ((gg * YAP) + (g * INV_YAP)) >> 16; g = ((gg * YAP) + (g * INV_YAP)) >> 16;
b = ((bb * YAP) + (b * INV_YAP)) >> 16; b = ((bb * YAP) + (b * INV_YAP)) >> 16;
a = ((aa * YAP) + (a * INV_YAP)) >> 16; a = ((aa * YAP) + (a * INV_YAP)) >> 16;
pix = RGBA_COMPOSE(r, g, b, a); *dptr++ = RGBA_COMPOSE(r, g, b, a);
*dptr++ = pix;
} }
else else
{ {
ssptr = ypoints[dyy + y]; ssptr = ypoints[dyy + y];
pix = ssptr[xpoints[x]]; pix = &ssptr[xpoints[x]];
r = R_VAL(pix) * INV_YAP; r = R_VAL(pix) * INV_YAP;
g = G_VAL(pix) * INV_YAP; g = G_VAL(pix) * INV_YAP;
b = B_VAL(pix) * INV_YAP; b = B_VAL(pix) * INV_YAP;
a = A_VAL(pix) * INV_YAP; a = A_VAL(pix) * INV_YAP;
ssptr += sow; ssptr += sow;
pix = ssptr[xpoints[x]]; pix = &ssptr[xpoints[x]];
r += R_VAL(pix) * YAP; r += R_VAL(pix) * YAP;
g += G_VAL(pix) * YAP; g += G_VAL(pix) * YAP;
b += B_VAL(pix) * YAP; b += B_VAL(pix) * YAP;
@ -275,8 +280,7 @@ __imlib_ScaleAARGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
g >>= 8; g >>= 8;
b >>= 8; b >>= 8;
a >>= 8; a >>= 8;
pix = RGBA_COMPOSE(r, g, b, a); *dptr++ = RGBA_COMPOSE(r, g, b, a);
*dptr++ = pix;
} }
} }
else else
@ -284,12 +288,12 @@ __imlib_ScaleAARGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
if (XAP > 0) if (XAP > 0)
{ {
ssptr = ypoints[dyy + y]; ssptr = ypoints[dyy + y];
pix = ssptr[xpoints[x]]; pix = &ssptr[xpoints[x]];
r = R_VAL(pix) * INV_XAP; r = R_VAL(pix) * INV_XAP;
g = G_VAL(pix) * INV_XAP; g = G_VAL(pix) * INV_XAP;
b = B_VAL(pix) * INV_XAP; b = B_VAL(pix) * INV_XAP;
a = A_VAL(pix) * INV_XAP; a = A_VAL(pix) * INV_XAP;
pix = ssptr[xpoints[x] + 1]; pix = &ssptr[xpoints[x] + 1];
r += R_VAL(pix) * XAP; r += R_VAL(pix) * XAP;
g += G_VAL(pix) * XAP; g += G_VAL(pix) * XAP;
b += B_VAL(pix) * XAP; b += B_VAL(pix) * XAP;
@ -298,8 +302,7 @@ __imlib_ScaleAARGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
g >>= 8; g >>= 8;
b >>= 8; b >>= 8;
a >>= 8; a >>= 8;
pix = RGBA_COMPOSE(r, g, b, a); *dptr++ = RGBA_COMPOSE(r, g, b, a);
*dptr++ = pix;
} }
else else
*dptr++ = sptr[xpoints[x] ]; *dptr++ = sptr[xpoints[x] ];
@ -321,7 +324,7 @@ __imlib_ScaleAARGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
int r = 0, g = 0, b = 0, a = 0; int r = 0, g = 0, b = 0, a = 0;
int rr = 0, gg = 0, bb = 0, aa = 0; int rr = 0, gg = 0, bb = 0, aa = 0;
int count; int count;
DATA32 pix; DATA32 *pix;
if (XAP > 0) if (XAP > 0)
{ {
@ -330,7 +333,7 @@ __imlib_ScaleAARGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
for (j = 0; j < YAP; j++) for (j = 0; j < YAP; j++)
{ {
ssptr = ypoints[dyy + y] + (j * sow); ssptr = ypoints[dyy + y] + (j * sow);
pix = ssptr[xpoints[x]]; pix = &ssptr[xpoints[x]];
r += R_VAL(pix); r += R_VAL(pix);
g += G_VAL(pix); g += G_VAL(pix);
b += B_VAL(pix); b += B_VAL(pix);
@ -344,7 +347,7 @@ __imlib_ScaleAARGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
for (j = 0; j < YAP; j++) for (j = 0; j < YAP; j++)
{ {
ssptr = ypoints[dyy + y] + (j * sow); ssptr = ypoints[dyy + y] + (j * sow);
pix = ssptr[xpoints[x] + 1]; pix = &ssptr[xpoints[x] + 1];
rr += R_VAL(pix); rr += R_VAL(pix);
gg += G_VAL(pix); gg += G_VAL(pix);
bb += B_VAL(pix); bb += B_VAL(pix);
@ -355,18 +358,17 @@ __imlib_ScaleAARGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
g = (g + ((gg * XAP) / count)) >> 8; g = (g + ((gg * XAP) / count)) >> 8;
b = (b + ((bb * XAP) / count)) >> 8; b = (b + ((bb * XAP) / count)) >> 8;
a = (a + ((aa * XAP) / count)) >> 8; a = (a + ((aa * XAP) / count)) >> 8;
pix = RGBA_COMPOSE(r, g, b, a); *dptr++ = RGBA_COMPOSE(r, g, b, a);
*dptr++ = pix;
} }
else else
{ {
ssptr = ypoints[dyy + y]; ssptr = ypoints[dyy + y];
pix = ssptr[xpoints[x]]; pix = &ssptr[xpoints[x]];
r = R_VAL(pix) * INV_XAP; r = R_VAL(pix) * INV_XAP;
g = G_VAL(pix) * INV_XAP; g = G_VAL(pix) * INV_XAP;
b = B_VAL(pix) * INV_XAP; b = B_VAL(pix) * INV_XAP;
a = A_VAL(pix) * INV_XAP; a = A_VAL(pix) * INV_XAP;
pix = ssptr[xpoints[x] + 1]; pix = &ssptr[xpoints[x] + 1];
r += R_VAL(pix) * XAP; r += R_VAL(pix) * XAP;
g += G_VAL(pix) * XAP; g += G_VAL(pix) * XAP;
b += B_VAL(pix) * XAP; b += B_VAL(pix) * XAP;
@ -375,8 +377,7 @@ __imlib_ScaleAARGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
g >>= 8; g >>= 8;
b >>= 8; b >>= 8;
a >>= 8; a >>= 8;
pix = RGBA_COMPOSE(r, g, b, a); *dptr++ = RGBA_COMPOSE(r, g, b, a);
*dptr++ = pix;
} }
} }
else else
@ -386,7 +387,7 @@ __imlib_ScaleAARGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
for (j = 0; j < YAP; j++) for (j = 0; j < YAP; j++)
{ {
ssptr = ypoints[dyy + y] + (j *sow); ssptr = ypoints[dyy + y] + (j *sow);
pix = ssptr[xpoints[x]]; pix = &ssptr[xpoints[x]];
r += R_VAL(pix); r += R_VAL(pix);
g += G_VAL(pix); g += G_VAL(pix);
b += B_VAL(pix); b += B_VAL(pix);
@ -397,8 +398,7 @@ __imlib_ScaleAARGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
g /= count; g /= count;
b /= count; b /= count;
a /= count; a /= count;
pix = RGBA_COMPOSE(r, g, b, a); *dptr++ = RGBA_COMPOSE(r, g, b, a);
*dptr++ = pix;
} }
else else
*dptr++ = sptr[xpoints[x]]; *dptr++ = sptr[xpoints[x]];
@ -420,7 +420,7 @@ __imlib_ScaleAARGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
int r = 0, g = 0, b = 0, a = 0; int r = 0, g = 0, b = 0, a = 0;
int rr = 0, gg = 0, bb = 0, aa = 0; int rr = 0, gg = 0, bb = 0, aa = 0;
int count; int count;
DATA32 pix; DATA32 *pix;
if (YAP > 0) if (YAP > 0)
{ {
@ -429,7 +429,7 @@ __imlib_ScaleAARGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
ssptr = ypoints[dyy + y]; ssptr = ypoints[dyy + y];
for (i = 0; i < XAP; i++) for (i = 0; i < XAP; i++)
{ {
pix = ssptr[xpoints[x] + i]; pix = &ssptr[xpoints[x] + i];
r += R_VAL(pix); r += R_VAL(pix);
g += G_VAL(pix); g += G_VAL(pix);
b += B_VAL(pix); b += B_VAL(pix);
@ -443,7 +443,7 @@ __imlib_ScaleAARGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
ssptr = ypoints[dyy + y] + sow; ssptr = ypoints[dyy + y] + sow;
for (i = 0; i < XAP; i++) for (i = 0; i < XAP; i++)
{ {
pix = ssptr[xpoints[x] + i]; pix = &ssptr[xpoints[x] + i];
rr += R_VAL(pix); rr += R_VAL(pix);
gg += G_VAL(pix); gg += G_VAL(pix);
bb += B_VAL(pix); bb += B_VAL(pix);
@ -454,19 +454,18 @@ __imlib_ScaleAARGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
g = (g + ((gg * YAP) / count)) >> 8; g = (g + ((gg * YAP) / count)) >> 8;
b = (b + ((bb * YAP) / count)) >> 8; b = (b + ((bb * YAP) / count)) >> 8;
a = (a + ((aa * YAP) / count)) >> 8; a = (a + ((aa * YAP) / count)) >> 8;
pix = RGBA_COMPOSE(r, g, b, a); *dptr++ = RGBA_COMPOSE(r, g, b, a);
*dptr++ = pix;
} }
else else
{ {
ssptr = ypoints[dyy + y]; ssptr = ypoints[dyy + y];
pix = ssptr[xpoints[x]]; pix = &ssptr[xpoints[x]];
r = R_VAL(pix) * INV_YAP; r = R_VAL(pix) * INV_YAP;
g = G_VAL(pix) * INV_YAP; g = G_VAL(pix) * INV_YAP;
b = B_VAL(pix) * INV_YAP; b = B_VAL(pix) * INV_YAP;
a = A_VAL(pix) * INV_YAP; a = A_VAL(pix) * INV_YAP;
ssptr += sow; ssptr += sow;
pix = ssptr[xpoints[x]]; pix = &ssptr[xpoints[x]];
r += R_VAL(pix) * YAP; r += R_VAL(pix) * YAP;
g += G_VAL(pix) * YAP; g += G_VAL(pix) * YAP;
b += B_VAL(pix) * YAP; b += B_VAL(pix) * YAP;
@ -475,8 +474,7 @@ __imlib_ScaleAARGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
g >>= 8; g >>= 8;
b >>= 8; b >>= 8;
a >>= 8; a >>= 8;
pix = RGBA_COMPOSE(r, g, b, a); *dptr++ = RGBA_COMPOSE(r, g, b, a);
*dptr++ = pix;
} }
} }
else else
@ -486,7 +484,7 @@ __imlib_ScaleAARGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
ssptr = ypoints[dyy + y]; ssptr = ypoints[dyy + y];
for (i = 0; i < XAP; i++) for (i = 0; i < XAP; i++)
{ {
pix = ssptr[xpoints[x] + i]; pix = &ssptr[xpoints[x] + i];
r += R_VAL(pix); r += R_VAL(pix);
g += G_VAL(pix); g += G_VAL(pix);
b += B_VAL(pix); b += B_VAL(pix);
@ -497,8 +495,7 @@ __imlib_ScaleAARGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
g /= count; g /= count;
b /= count; b /= count;
a /= count; a /= count;
pix = RGBA_COMPOSE(r, g, b, a); *dptr++ = RGBA_COMPOSE(r, g, b, a);
*dptr++ = pix;
} }
else else
*dptr++ = sptr[xpoints[x]]; *dptr++ = sptr[xpoints[x]];
@ -519,7 +516,7 @@ __imlib_ScaleAARGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
{ {
int r = 0, g = 0, b = 0, a = 0; int r = 0, g = 0, b = 0, a = 0;
int count; int count;
DATA32 pix; DATA32 *pix;
if ((XAP > 1) || (YAP > 1)) if ((XAP > 1) || (YAP > 1))
{ {
@ -528,7 +525,7 @@ __imlib_ScaleAARGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
ssptr = ypoints[dyy + y] + (j * sow); ssptr = ypoints[dyy + y] + (j * sow);
for (i = 0; i < XAP; i++) for (i = 0; i < XAP; i++)
{ {
pix = ssptr[xpoints[x] + i]; pix = &ssptr[xpoints[x] + i];
r += R_VAL(pix); r += R_VAL(pix);
g += G_VAL(pix); g += G_VAL(pix);
b += B_VAL(pix); b += B_VAL(pix);
@ -540,8 +537,7 @@ __imlib_ScaleAARGBA(DATA32 **ypoints, int *xpoints, DATA32 *dest,
g /= count; g /= count;
b /= count; b /= count;
a /= count; a /= count;
pix = RGBA_COMPOSE(r, g, b, a); *dptr++ = RGBA_COMPOSE(r, g, b, a);
*dptr++ = pix;
} }
else else
*dptr++ = sptr[xpoints[x]]; *dptr++ = sptr[xpoints[x]];
@ -573,53 +569,51 @@ __imlib_ScaleAARGB(DATA32 **ypoints, int *xpoints, DATA32 *dest,
{ {
int r = 0, g = 0, b = 0; int r = 0, g = 0, b = 0;
int rr = 0, gg = 0, bb = 0; int rr = 0, gg = 0, bb = 0;
DATA32 pix; DATA32 *pix;
if (YAP > 0) if (YAP > 0)
{ {
if (XAP > 0) if (XAP > 0)
{ {
ssptr = ypoints[dyy + y]; ssptr = ypoints[dyy + y];
pix = ssptr[xpoints[x]]; pix = &ssptr[xpoints[x]];
r = R_VAL(pix) * INV_XAP; r = R_VAL(pix) * INV_XAP;
g = G_VAL(pix) * INV_XAP; g = G_VAL(pix) * INV_XAP;
b = B_VAL(pix) * INV_XAP; b = B_VAL(pix) * INV_XAP;
pix = ssptr[xpoints[x] + 1]; pix = &ssptr[xpoints[x] + 1];
r += R_VAL(pix) * XAP; r += R_VAL(pix) * XAP;
g += G_VAL(pix) * XAP; g += G_VAL(pix) * XAP;
b += B_VAL(pix) * XAP; b += B_VAL(pix) * XAP;
ssptr += sow; ssptr += sow;
pix = ssptr[xpoints[x]]; pix = &ssptr[xpoints[x]];
rr = R_VAL(pix) * INV_XAP; rr = R_VAL(pix) * INV_XAP;
gg = G_VAL(pix) * INV_XAP; gg = G_VAL(pix) * INV_XAP;
bb = B_VAL(pix) * INV_XAP; bb = B_VAL(pix) * INV_XAP;
pix = ssptr[xpoints[x] + 1]; pix = &ssptr[xpoints[x] + 1];
rr += R_VAL(pix) * XAP; rr += R_VAL(pix) * XAP;
gg += G_VAL(pix) * XAP; gg += G_VAL(pix) * XAP;
bb += B_VAL(pix) * XAP; bb += B_VAL(pix) * XAP;
r = ((rr * YAP) + (r * INV_YAP)) >> 16; r = ((rr * YAP) + (r * INV_YAP)) >> 16;
g = ((gg * YAP) + (g * INV_YAP)) >> 16; g = ((gg * YAP) + (g * INV_YAP)) >> 16;
b = ((bb * YAP) + (b * INV_YAP)) >> 16; b = ((bb * YAP) + (b * INV_YAP)) >> 16;
pix = RGBA_COMPOSE(r, g, b, 0xff); *dptr++ = RGBA_COMPOSE(r, g, b, 0xff);
*dptr++ = pix;
} }
else else
{ {
ssptr = ypoints[dyy + y]; ssptr = ypoints[dyy + y];
pix = ssptr[xpoints[x]]; pix = &ssptr[xpoints[x]];
r = R_VAL(pix) * INV_YAP; r = R_VAL(pix) * INV_YAP;
g = G_VAL(pix) * INV_YAP; g = G_VAL(pix) * INV_YAP;
b = B_VAL(pix) * INV_YAP; b = B_VAL(pix) * INV_YAP;
ssptr += sow; ssptr += sow;
pix = ssptr[xpoints[x]]; pix = &ssptr[xpoints[x]];
r += R_VAL(pix) * YAP; r += R_VAL(pix) * YAP;
g += G_VAL(pix) * YAP; g += G_VAL(pix) * YAP;
b += B_VAL(pix) * YAP; b += B_VAL(pix) * YAP;
r >>= 8; r >>= 8;
g >>= 8; g >>= 8;
b >>= 8; b >>= 8;
pix = RGBA_COMPOSE(r, g, b, 0xff); *dptr++ = RGBA_COMPOSE(r, g, b, 0xff);
*dptr++ = pix;
} }
} }
else else
@ -627,19 +621,18 @@ __imlib_ScaleAARGB(DATA32 **ypoints, int *xpoints, DATA32 *dest,
if (XAP > 0) if (XAP > 0)
{ {
ssptr = ypoints[dyy + y]; ssptr = ypoints[dyy + y];
pix = ssptr[xpoints[x]]; pix = &ssptr[xpoints[x]];
r = R_VAL(pix) * INV_XAP; r = R_VAL(pix) * INV_XAP;
g = G_VAL(pix) * INV_XAP; g = G_VAL(pix) * INV_XAP;
b = B_VAL(pix) * INV_XAP; b = B_VAL(pix) * INV_XAP;
pix = ssptr[xpoints[x] + 1]; pix = &ssptr[xpoints[x] + 1];
r += R_VAL(pix) * XAP; r += R_VAL(pix) * XAP;
g += G_VAL(pix) * XAP; g += G_VAL(pix) * XAP;
b += B_VAL(pix) * XAP; b += B_VAL(pix) * XAP;
r >>= 8; r >>= 8;
g >>= 8; g >>= 8;
b >>= 8; b >>= 8;
pix = RGBA_COMPOSE(r, g, b, 0xff); *dptr++ = RGBA_COMPOSE(r, g, b, 0xff);
*dptr++ = pix;
} }
else else
*dptr++ = sptr[xpoints[x] ]; *dptr++ = sptr[xpoints[x] ];
@ -661,7 +654,7 @@ __imlib_ScaleAARGB(DATA32 **ypoints, int *xpoints, DATA32 *dest,
int r = 0, g = 0, b = 0; int r = 0, g = 0, b = 0;
int rr = 0, gg = 0, bb = 0; int rr = 0, gg = 0, bb = 0;
int count; int count;
DATA32 pix; DATA32 *pix;
if (XAP > 0) if (XAP > 0)
{ {
@ -670,7 +663,7 @@ __imlib_ScaleAARGB(DATA32 **ypoints, int *xpoints, DATA32 *dest,
for (j = 0; j < YAP; j++) for (j = 0; j < YAP; j++)
{ {
ssptr = ypoints[dyy + y] + (j * sow); ssptr = ypoints[dyy + y] + (j * sow);
pix = ssptr[xpoints[x]]; pix = &ssptr[xpoints[x]];
r += R_VAL(pix); r += R_VAL(pix);
g += G_VAL(pix); g += G_VAL(pix);
b += B_VAL(pix); b += B_VAL(pix);
@ -682,7 +675,7 @@ __imlib_ScaleAARGB(DATA32 **ypoints, int *xpoints, DATA32 *dest,
for (j = 0; j < YAP; j++) for (j = 0; j < YAP; j++)
{ {
ssptr = ypoints[dyy + y] + (j * sow); ssptr = ypoints[dyy + y] + (j * sow);
pix = ssptr[xpoints[x] + 1]; pix = &ssptr[xpoints[x] + 1];
rr += R_VAL(pix); rr += R_VAL(pix);
gg += G_VAL(pix); gg += G_VAL(pix);
bb += B_VAL(pix); bb += B_VAL(pix);
@ -691,25 +684,23 @@ __imlib_ScaleAARGB(DATA32 **ypoints, int *xpoints, DATA32 *dest,
r = (r + ((rr * XAP) / count)) >> 8; r = (r + ((rr * XAP) / count)) >> 8;
g = (g + ((gg * XAP) / count)) >> 8; g = (g + ((gg * XAP) / count)) >> 8;
b = (b + ((bb * XAP) / count)) >> 8; b = (b + ((bb * XAP) / count)) >> 8;
pix = RGBA_COMPOSE(r, g, b, 0xff); *dptr++ = RGBA_COMPOSE(r, g, b, 0xff);
*dptr++ = pix;
} }
else else
{ {
ssptr = ypoints[dyy + y]; ssptr = ypoints[dyy + y];
pix = ssptr[xpoints[x]]; pix = &ssptr[xpoints[x]];
r = R_VAL(pix) * INV_XAP; r = R_VAL(pix) * INV_XAP;
g = G_VAL(pix) * INV_XAP; g = G_VAL(pix) * INV_XAP;
b = B_VAL(pix) * INV_XAP; b = B_VAL(pix) * INV_XAP;
pix = ssptr[xpoints[x] + 1]; pix = &ssptr[xpoints[x] + 1];
r += R_VAL(pix) * XAP; r += R_VAL(pix) * XAP;
g += G_VAL(pix) * XAP; g += G_VAL(pix) * XAP;
b += B_VAL(pix) * XAP; b += B_VAL(pix) * XAP;
r >>= 8; r >>= 8;
g >>= 8; g >>= 8;
b >>= 8; b >>= 8;
pix = RGBA_COMPOSE(r, g, b, 0xff); *dptr++ = RGBA_COMPOSE(r, g, b, 0xff);
*dptr++ = pix;
} }
} }
else else
@ -719,7 +710,7 @@ __imlib_ScaleAARGB(DATA32 **ypoints, int *xpoints, DATA32 *dest,
for (j = 0; j < YAP; j++) for (j = 0; j < YAP; j++)
{ {
ssptr = ypoints[dyy + y] + (j *sow); ssptr = ypoints[dyy + y] + (j *sow);
pix = ssptr[xpoints[x]]; pix = &ssptr[xpoints[x]];
r += R_VAL(pix); r += R_VAL(pix);
g += G_VAL(pix); g += G_VAL(pix);
b += B_VAL(pix); b += B_VAL(pix);
@ -728,8 +719,7 @@ __imlib_ScaleAARGB(DATA32 **ypoints, int *xpoints, DATA32 *dest,
r /= count; r /= count;
g /= count; g /= count;
b /= count; b /= count;
pix = RGBA_COMPOSE(r, g, b, 0xff); *dptr++ = RGBA_COMPOSE(r, g, b, 0xff);
*dptr++ = pix;
} }
else else
*dptr++ = sptr[xpoints[x]]; *dptr++ = sptr[xpoints[x]];
@ -751,7 +741,7 @@ __imlib_ScaleAARGB(DATA32 **ypoints, int *xpoints, DATA32 *dest,
int r = 0, g = 0, b = 0; int r = 0, g = 0, b = 0;
int rr = 0, gg = 0, bb = 0; int rr = 0, gg = 0, bb = 0;
int count; int count;
DATA32 pix; DATA32 *pix;
if (YAP > 0) if (YAP > 0)
{ {
@ -760,7 +750,7 @@ __imlib_ScaleAARGB(DATA32 **ypoints, int *xpoints, DATA32 *dest,
ssptr = ypoints[dyy + y]; ssptr = ypoints[dyy + y];
for (i = 0; i < XAP; i++) for (i = 0; i < XAP; i++)
{ {
pix = ssptr[xpoints[x] + i]; pix = &ssptr[xpoints[x] + i];
r += R_VAL(pix); r += R_VAL(pix);
g += G_VAL(pix); g += G_VAL(pix);
b += B_VAL(pix); b += B_VAL(pix);
@ -772,7 +762,7 @@ __imlib_ScaleAARGB(DATA32 **ypoints, int *xpoints, DATA32 *dest,
ssptr = ypoints[dyy + y] + sow; ssptr = ypoints[dyy + y] + sow;
for (i = 0; i < XAP; i++) for (i = 0; i < XAP; i++)
{ {
pix = ssptr[xpoints[x] + i]; pix = &ssptr[xpoints[x] + i];
rr += R_VAL(pix); rr += R_VAL(pix);
gg += G_VAL(pix); gg += G_VAL(pix);
bb += B_VAL(pix); bb += B_VAL(pix);
@ -781,26 +771,24 @@ __imlib_ScaleAARGB(DATA32 **ypoints, int *xpoints, DATA32 *dest,
r = (r + ((rr * YAP) / count)) >> 8; r = (r + ((rr * YAP) / count)) >> 8;
g = (g + ((gg * YAP) / count)) >> 8; g = (g + ((gg * YAP) / count)) >> 8;
b = (b + ((bb * YAP) / count)) >> 8; b = (b + ((bb * YAP) / count)) >> 8;
pix = RGBA_COMPOSE(r, g, b, 0xff); *dptr++ = RGBA_COMPOSE(r, g, b, 0xff);
*dptr++ = pix;
} }
else else
{ {
ssptr = ypoints[dyy + y]; ssptr = ypoints[dyy + y];
pix = ssptr[xpoints[x]]; pix = &ssptr[xpoints[x]];
r = R_VAL(pix) * INV_YAP; r = R_VAL(pix) * INV_YAP;
g = G_VAL(pix) * INV_YAP; g = G_VAL(pix) * INV_YAP;
b = B_VAL(pix) * INV_YAP; b = B_VAL(pix) * INV_YAP;
ssptr += sow; ssptr += sow;
pix = ssptr[xpoints[x]]; pix = &ssptr[xpoints[x]];
r += R_VAL(pix) * YAP; r += R_VAL(pix) * YAP;
g += G_VAL(pix) * YAP; g += G_VAL(pix) * YAP;
b += B_VAL(pix) * YAP; b += B_VAL(pix) * YAP;
r >>= 8; r >>= 8;
g >>= 8; g >>= 8;
b >>= 8; b >>= 8;
pix = RGBA_COMPOSE(r, g, b, 0xff); *dptr++ = RGBA_COMPOSE(r, g, b, 0xff);
*dptr++ = pix;
} }
} }
else else
@ -810,7 +798,7 @@ __imlib_ScaleAARGB(DATA32 **ypoints, int *xpoints, DATA32 *dest,
ssptr = ypoints[dyy + y]; ssptr = ypoints[dyy + y];
for (i = 0; i < XAP; i++) for (i = 0; i < XAP; i++)
{ {
pix = ssptr[xpoints[x] + i]; pix = &ssptr[xpoints[x] + i];
r += R_VAL(pix); r += R_VAL(pix);
g += G_VAL(pix); g += G_VAL(pix);
b += B_VAL(pix); b += B_VAL(pix);
@ -819,8 +807,7 @@ __imlib_ScaleAARGB(DATA32 **ypoints, int *xpoints, DATA32 *dest,
r /= count; r /= count;
g /= count; g /= count;
b /= count; b /= count;
pix = RGBA_COMPOSE(r, g, b, 0xff); *dptr++ = RGBA_COMPOSE(r, g, b, 0xff);
*dptr++ = pix;
} }
else else
*dptr++ = sptr[xpoints[x]]; *dptr++ = sptr[xpoints[x]];
@ -828,9 +815,15 @@ __imlib_ScaleAARGB(DATA32 **ypoints, int *xpoints, DATA32 *dest,
} }
} }
} }
/* fully optimized (i think) - onyl change of algorithm can help */
/* if we're scaling down horizontally & vertically */ /* if we're scaling down horizontally & vertically */
else else
{ {
int count;
DATA32 *pix;
int r, g, b;
int xp, xap, yap;
/* go through every scanline in the output buffer */ /* go through every scanline in the output buffer */
for (y = 0; y < dh; y++) for (y = 0; y < dh; y++)
{ {
@ -839,29 +832,27 @@ __imlib_ScaleAARGB(DATA32 **ypoints, int *xpoints, DATA32 *dest,
sptr = ypoints[dyy + y]; sptr = ypoints[dyy + y];
for (x = dxx; x < end; x++) for (x = dxx; x < end; x++)
{ {
int r = 0, g = 0, b = 0;
int count;
DATA32 pix;
if ((XAP > 1) || (YAP > 1)) if ((XAP > 1) || (YAP > 1))
{ {
for (i = 0, j = 0; j < YAP; j++) r = 0; g = 0; b = 0; count = 0;
xp = xpoints[x];
ssptr = ypoints[dyy + y];
for (j = 0; j < YAP; j++)
{ {
ssptr = ypoints[dyy + y] + (j * sow);
for (i = 0; i < XAP; i++) for (i = 0; i < XAP; i++)
{ {
pix = ssptr[xpoints[x] + i]; pix = &ssptr[xp + i];
r += R_VAL(pix); r += R_VAL(pix);
g += G_VAL(pix); g += G_VAL(pix);
b += B_VAL(pix); b += B_VAL(pix);
} }
count += i;
ssptr += sow;
} }
count = (i * j); R_VAL(dptr) = r / count;
r /= count; G_VAL(dptr) = g / count;
g /= count; B_VAL(dptr) = b / count;
b /= count; dptr++;
pix = RGBA_COMPOSE(r, g, b, 0xff);
*dptr++ = pix;
} }
else else
*dptr++ = sptr[xpoints[x]]; *dptr++ = sptr[xpoints[x]];

View File

@ -72,6 +72,7 @@ int main (int argc, char **argv)
int blendtest = 0; int blendtest = 0;
int rotate = 0; int rotate = 0;
int rottest = 0; int rottest = 0;
int scaleup = 0;
for (i = 1; i < argc; i++) for (i = 1; i < argc; i++)
{ {
@ -86,6 +87,8 @@ int main (int argc, char **argv)
interactive = 0; interactive = 0;
loop = 1; loop = 1;
} }
else if (!strcmp(argv[i], "-up"))
scaleup = 1;
else if (!strcmp(argv[i], "-blend")) else if (!strcmp(argv[i], "-blend"))
blend = 1; blend = 1;
else if (!strcmp(argv[i], "-blendtest")) else if (!strcmp(argv[i], "-blendtest"))
@ -165,6 +168,9 @@ int main (int argc, char **argv)
{ {
if (!root) if (!root)
{ {
if (scaleup)
XResizeWindow(disp, win, w * 4, h * 4);
else
XResizeWindow(disp, win, w, h); XResizeWindow(disp, win, w, h);
XMapWindow(disp, win); XMapWindow(disp, win);
} }
@ -178,9 +184,6 @@ int main (int argc, char **argv)
XSync(disp, False); XSync(disp, False);
} }
printf("rend\n"); printf("rend\n");
gettimeofday(&timev,NULL);
sec1=(int)timev.tv_sec; /* and stores it so we can time outselves */
usec1=(int)timev.tv_usec; /* we will use this to vary speed of rot */
if (!blendtest) if (!blendtest)
{ {
@ -196,15 +199,57 @@ int main (int argc, char **argv)
imlib_context_set_operation(IMLIB_OP_COPY); imlib_context_set_operation(IMLIB_OP_COPY);
imlib_context_set_image(im); imlib_context_set_image(im);
gettimeofday(&timev,NULL);
sec1=(int)timev.tv_sec; /* and stores it so we can time outselves */
usec1=(int)timev.tv_usec; /* we will use this to vary speed of rot */
if (loop) if (loop)
{
if (scaleup)
{
for (i = 0; i < w * 3; i+= 8)
{
if (!blendtest)
imlib_render_image_on_drawable_at_size(0, 0,
w + i, (((w + i) * h) / w));
else
{
Imlib_Image im_tmp;
im_tmp = imlib_create_cropped_scaled_image(0, 0, w, h,
w + i, (((w + i) * h) / w));
if (im_tmp)
{
imlib_context_set_image(im_tmp);
imlib_free_image();
}
imlib_context_set_image(im);
}
pixels += (w - i) * (((w - i) * h) / w);
}
}
else
{ {
for (i = 0; i < w; i++) for (i = 0; i < w; i++)
{ {
if (!blendtest)
imlib_render_image_on_drawable_at_size(0, 0, imlib_render_image_on_drawable_at_size(0, 0,
w - i, (((w - i) * h) / w)); w - i, (((w - i) * h) / w));
else
{
Imlib_Image im_tmp;
im_tmp = imlib_create_cropped_scaled_image(0, 0, w, h,
w - i, (((w - i) * h) / w));
if (im_tmp)
{
imlib_context_set_image(im_tmp);
imlib_free_image();
}
imlib_context_set_image(im);
}
pixels += (w - i) * (((w - i) * h) / w); pixels += (w - i) * (((w - i) * h) / w);
} }
} }
}
else if (blendtest) else if (blendtest)
{ {
Imlib_Image im2; Imlib_Image im2;
@ -520,14 +565,13 @@ int main (int argc, char **argv)
sec2=(int)timev.tv_sec; /* and stores it so we can time outselves */ sec2=(int)timev.tv_sec; /* and stores it so we can time outselves */
usec2=(int)timev.tv_usec; /* we will use this to vary speed of rot */ usec2=(int)timev.tv_usec; /* we will use this to vary speed of rot */
printf("done\n"); printf("done\n");
i = sec2 - sec1;
j = usec2 - usec1;
while (j < 0)
{ {
i++; double t1, t2;
j += 1000000;
t1 = (double)sec1 + ((double)usec1 / 1000000);
t2 = (double)sec2 + ((double)usec2 / 1000000);
sec = t2 - t1;
} }
sec = (double)i + ((double)j / 1000000);
printf("%3.3f sec, %3.3f M pixels (%i)\n", sec, (double)pixels / 1000000, pixels); printf("%3.3f sec, %3.3f M pixels (%i)\n", sec, (double)pixels / 1000000, pixels);
printf("%3.3f Mpixels / sec\n", (double)(pixels) / (sec * 1000000)); printf("%3.3f Mpixels / sec\n", (double)(pixels) / (sec * 1000000));
return 0; return 0;