diff --git a/legacy/evas/src/lib/engines/common/evas_map_image.c b/legacy/evas/src/lib/engines/common/evas_map_image.c index 6ac74a390e..502b2dc859 100644 --- a/legacy/evas/src/lib/engines/common/evas_map_image.c +++ b/legacy/evas/src/lib/engines/common/evas_map_image.c @@ -82,10 +82,10 @@ _limit(Span *s, int c1, int c2, int nocol) static void _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 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]; #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 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[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[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[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 t256 = (t << 8) / h; // maybe * 255? diff --git a/legacy/evas/src/lib/engines/common/evas_map_image_core.c b/legacy/evas/src/lib/engines/common/evas_map_image_core.c index 632f2f145e..b9bbeb57e3 100644 --- a/legacy/evas/src/lib/engines/common/evas_map_image_core.c +++ b/legacy/evas/src/lib/engines/common/evas_map_image_core.c @@ -40,16 +40,16 @@ ww = w; u = span->u[0] << FPI; if (u < 0) u = 0; - else if (u >= swp) u = swp - 1; + else if (u > swp) u = swp; v = span->v[0] << FPI; if (v < 0) v = 0; - else if (v >= shp) v = shp - 1; + else if (v > shp) v = shp; ue = span->u[1] << FPI; if (ue < 0) ue = 0; - else if (ue >= swp) ue = swp - 1; + else if (ue > swp) ue = swp; ve = span->v[1] << FPI; if (ve < 0) ve = 0; - else if (ve >= shp) ve = shp - 1; + else if (ve > shp) ve = shp; ud = (ue - u) / w; vd = (ve - v) / w; tl = (long long)ud * (w << FP); @@ -61,10 +61,14 @@ tl = tl / dv; vd = tl; v -= (vd * (span->o1 - (span->x1 << FP))) / FP1; - - if (ud < 0) u -= 1; - if (vd < 0) v -= 1; - + + 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; + if (direct) d = dst->image.data + (y * dst->cache_entry.w) + x; else @@ -146,23 +150,30 @@ ww = w; u = span->u[0] << FPI; if (u < 0) u = 0; - else if (u >= swp) u = swp - 1; + else if (u > swp) u = swp; v = span->v[0] << FPI; if (v < 0) v = 0; - else if (v >= shp) v = shp - 1; + else if (v > shp) v = shp; ue = span->u[1] << FPI; if (ue < 0) ue = 0; - else if (ue >= swp) ue = swp - 1; + else if (ue > swp) ue = swp; ve = span->v[1] << FPI; if (ve < 0) ve = 0; - else if (ve >= shp) ve = shp - 1; + else if (ve > shp) ve = shp; ud = (ue - u) / w; vd = (ve - v) / w; if (direct) d = dst->image.data + (y * dst->cache_entry.w) + x; else 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 #ifdef COLMUL c1 = span->col[0]; // col