forked from enlightenment/efl
some nasty hackery to get affine transform mapping to be "pixel
perfect" with 90 degree rotations. i really should have actually special cased them, for for now i made the generic routine try and punt out the right numbers. SVN revision: 63986
This commit is contained in:
parent
2cf202ff51
commit
b531487495
|
@ -82,10 +82,10 @@ _limit(Span *s, int c1, int c2, int nocol)
|
||||||
static void
|
static void
|
||||||
_calc_spans(RGBA_Map_Point *p, Line *spans, int ystart, int yend, int cx, int cy __UNUSED__, int cw, int ch __UNUSED__)
|
_calc_spans(RGBA_Map_Point *p, Line *spans, int ystart, int yend, int cx, int cy __UNUSED__, int cw, int ch __UNUSED__)
|
||||||
{
|
{
|
||||||
int i, y, yp;
|
int i, y, yp, yy;
|
||||||
int py[4];
|
int py[4];
|
||||||
int edge[4][4], edge_num, swapped, order[4];
|
int edge[4][4], edge_num, swapped, order[4];
|
||||||
FPc uv[4][2], u, v, x, h, t;
|
FPc uv[4][2], u, v, x, h, t, uu, vv;
|
||||||
DATA32 col[4];
|
DATA32 col[4];
|
||||||
|
|
||||||
#if 1 // maybe faster on x86?
|
#if 1 // maybe faster on x86?
|
||||||
|
@ -169,7 +169,7 @@ _calc_spans(RGBA_Map_Point *p, Line *spans, int ystart, int yend, int cx, int cy
|
||||||
|
|
||||||
h = (p[e2].y - p[e1].y) >> FP; // height of edge
|
h = (p[e2].y - p[e1].y) >> FP; // height of edge
|
||||||
if (h < 1) h = 1;
|
if (h < 1) h = 1;
|
||||||
t = (((y << FP) + (FP1 - 1)) - p[e1].y) >> FP;
|
t = (((y << FP) + (FP1 / 2) - 1) - p[e1].y) >> FP;
|
||||||
x = p[e2].x - p[e1].x;
|
x = p[e2].x - p[e1].x;
|
||||||
x = p[e1].x + ((x * t) / h);
|
x = p[e1].x + ((x * t) / h);
|
||||||
|
|
||||||
|
@ -220,10 +220,42 @@ _calc_spans(RGBA_Map_Point *p, Line *spans, int ystart, int yend, int cx, int cy
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
u = p[e2].u - p[e1].u;
|
u = p[e2].u - p[e1].u;
|
||||||
u = p[e1].u + ((u * t) / h);
|
uu = u >> FP;
|
||||||
|
if (uu < 0) uu = -uu;
|
||||||
|
if (uu == h)
|
||||||
|
{
|
||||||
|
yy = ((y << FP) - p[e1].y) >> FP;
|
||||||
|
if (u > 0)
|
||||||
|
u = p[e1].u + (yy << FP);
|
||||||
|
else
|
||||||
|
u = p[e1].u - (yy << FP) - (FP1 - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (u >= 0)
|
||||||
|
u = p[e1].u + ((u * t) / h);
|
||||||
|
else
|
||||||
|
u = p[e1].u + (((u * t) - (FP1 / 2)) / h);
|
||||||
|
}
|
||||||
|
|
||||||
v = p[e2].v - p[e1].v;
|
v = p[e2].v - p[e1].v;
|
||||||
v = p[e1].v + ((v * t) / h);
|
vv = v >> FP;
|
||||||
|
if (vv < 0) vv = -vv;
|
||||||
|
if (vv == h)
|
||||||
|
{
|
||||||
|
yy = ((y << FP) - p[e1].y) >> FP;
|
||||||
|
if (v > 0)
|
||||||
|
v = p[e1].v + (yy << FP);
|
||||||
|
else
|
||||||
|
v = p[e1].v - (yy << FP) - (FP1 - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (v >= 0)
|
||||||
|
v = p[e1].v + ((v * t) / h);
|
||||||
|
else
|
||||||
|
v = p[e1].v + (((v * t) - (FP1 / 2)) / h);
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: 3d accuracy for color too
|
// FIXME: 3d accuracy for color too
|
||||||
t256 = (t << 8) / h; // maybe * 255?
|
t256 = (t << 8) / h; // maybe * 255?
|
||||||
|
|
|
@ -40,16 +40,16 @@
|
||||||
ww = w;
|
ww = w;
|
||||||
u = span->u[0] << FPI;
|
u = span->u[0] << FPI;
|
||||||
if (u < 0) u = 0;
|
if (u < 0) u = 0;
|
||||||
else if (u >= swp) u = swp - 1;
|
else if (u > swp) u = swp;
|
||||||
v = span->v[0] << FPI;
|
v = span->v[0] << FPI;
|
||||||
if (v < 0) v = 0;
|
if (v < 0) v = 0;
|
||||||
else if (v >= shp) v = shp - 1;
|
else if (v > shp) v = shp;
|
||||||
ue = span->u[1] << FPI;
|
ue = span->u[1] << FPI;
|
||||||
if (ue < 0) ue = 0;
|
if (ue < 0) ue = 0;
|
||||||
else if (ue >= swp) ue = swp - 1;
|
else if (ue > swp) ue = swp;
|
||||||
ve = span->v[1] << FPI;
|
ve = span->v[1] << FPI;
|
||||||
if (ve < 0) ve = 0;
|
if (ve < 0) ve = 0;
|
||||||
else if (ve >= shp) ve = shp - 1;
|
else if (ve > shp) ve = shp;
|
||||||
ud = (ue - u) / w;
|
ud = (ue - u) / w;
|
||||||
vd = (ve - v) / w;
|
vd = (ve - v) / w;
|
||||||
tl = (long long)ud * (w << FP);
|
tl = (long long)ud * (w << FP);
|
||||||
|
@ -61,10 +61,14 @@
|
||||||
tl = tl / dv;
|
tl = tl / dv;
|
||||||
vd = tl;
|
vd = tl;
|
||||||
v -= (vd * (span->o1 - (span->x1 << FP))) / FP1;
|
v -= (vd * (span->o1 - (span->x1 << FP))) / FP1;
|
||||||
|
|
||||||
if (ud < 0) u -= 1;
|
if (ud < 0) u += ud;
|
||||||
if (vd < 0) v -= 1;
|
if (vd < 0) v += vd;
|
||||||
|
if (u < 0) u = 0;
|
||||||
|
else if (u >= swp) u = swp - 1;
|
||||||
|
if (v < 0) v = 0;
|
||||||
|
else if (v >= shp) v = shp - 1;
|
||||||
|
|
||||||
if (direct)
|
if (direct)
|
||||||
d = dst->image.data + (y * dst->cache_entry.w) + x;
|
d = dst->image.data + (y * dst->cache_entry.w) + x;
|
||||||
else
|
else
|
||||||
|
@ -146,23 +150,30 @@
|
||||||
ww = w;
|
ww = w;
|
||||||
u = span->u[0] << FPI;
|
u = span->u[0] << FPI;
|
||||||
if (u < 0) u = 0;
|
if (u < 0) u = 0;
|
||||||
else if (u >= swp) u = swp - 1;
|
else if (u > swp) u = swp;
|
||||||
v = span->v[0] << FPI;
|
v = span->v[0] << FPI;
|
||||||
if (v < 0) v = 0;
|
if (v < 0) v = 0;
|
||||||
else if (v >= shp) v = shp - 1;
|
else if (v > shp) v = shp;
|
||||||
ue = span->u[1] << FPI;
|
ue = span->u[1] << FPI;
|
||||||
if (ue < 0) ue = 0;
|
if (ue < 0) ue = 0;
|
||||||
else if (ue >= swp) ue = swp - 1;
|
else if (ue > swp) ue = swp;
|
||||||
ve = span->v[1] << FPI;
|
ve = span->v[1] << FPI;
|
||||||
if (ve < 0) ve = 0;
|
if (ve < 0) ve = 0;
|
||||||
else if (ve >= shp) ve = shp - 1;
|
else if (ve > shp) ve = shp;
|
||||||
ud = (ue - u) / w;
|
ud = (ue - u) / w;
|
||||||
vd = (ve - v) / w;
|
vd = (ve - v) / w;
|
||||||
if (direct)
|
if (direct)
|
||||||
d = dst->image.data + (y * dst->cache_entry.w) + x;
|
d = dst->image.data + (y * dst->cache_entry.w) + x;
|
||||||
else
|
else
|
||||||
d = buf;
|
d = buf;
|
||||||
|
|
||||||
|
if (ud < 0) u += ud;
|
||||||
|
if (vd < 0) v += vd;
|
||||||
|
if (u < 0) u = 0;
|
||||||
|
else if (u >= swp) u = swp - 1;
|
||||||
|
if (v < 0) v = 0;
|
||||||
|
else if (v >= shp) v = shp - 1;
|
||||||
|
|
||||||
#undef SMOOTH
|
#undef SMOOTH
|
||||||
#ifdef COLMUL
|
#ifdef COLMUL
|
||||||
c1 = span->col[0]; // col
|
c1 = span->col[0]; // col
|
||||||
|
|
Loading…
Reference in New Issue