From: raster Date: Tue, 11 Oct 2011 06:06:11 +0000 (+0000) Subject: use lround() for map coord rounding to avoid silly things like X-Git-Tag: accepted/2.0/20130306.225542~195^2~88 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c1847f83c4502e4c73de830f7d922c27f7ffe291;p=profile%2Fivi%2Fevas.git use lround() for map coord rounding to avoid silly things like 15.999999999999999998 rounding down to 15... whihc leads to sometimes... odd off-by-1 expected results. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/evas@63978 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- diff --git a/src/lib/canvas/evas_map.c b/src/lib/canvas/evas_map.c index 28a9592..930c0f5 100644 --- a/src/lib/canvas/evas_map.c +++ b/src/lib/canvas/evas_map.c @@ -81,10 +81,10 @@ _evas_map_calc_map_geometry(Evas_Object *obj) p = obj->cur.map->points; p_end = p + obj->cur.map->count; - x1 = p->x; - x2 = p->x; - y1 = p->y; - y2 = p->y; + x1 = lround(p->x); + x2 = lround(p->x); + y1 = lround(p->y); + y2 = lround(p->y); p++; for (; p < p_end; p++) { diff --git a/src/lib/canvas/evas_object_image.c b/src/lib/canvas/evas_object_image.c index e976a3f..561b3da 100644 --- a/src/lib/canvas/evas_object_image.c +++ b/src/lib/canvas/evas_object_image.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "evas_common.h" #include "evas_private.h" @@ -2887,14 +2888,14 @@ evas_object_image_render(Evas_Object *obj, void *output, void *context, void *su // draw geom +x +y for (; p < p_end; p++, pt++) { - pt->x = (p->x + (double)x) * FP1; - pt->y = (p->y + (double)y) * FP1; - pt->z = (p->z) * FP1; + pt->x = (lround(p->x) + x) * FP1; + pt->y = (lround(p->y) + y) * FP1; + pt->z = (lround(p->z) ) * FP1; pt->fx = p->px; pt->fy = p->py; pt->fz = p->z; - pt->u = ((p->u * imagew) / uvw) * FP1; - pt->v = ((p->v * imageh) / uvh) * FP1; + pt->u = ((lround(p->u) * imagew) / uvw) * FP1; + pt->v = ((lround(p->v) * imageh) / uvh) * FP1; if (pt->u < 0) pt->u = 0; else if (pt->u > (imagew * FP1)) pt->u = (imagew * FP1); if (pt->v < 0) pt->v = 0; diff --git a/src/lib/canvas/evas_render.c b/src/lib/canvas/evas_render.c index 12f5f2c..ebb9ecf 100644 --- a/src/lib/canvas/evas_render.c +++ b/src/lib/canvas/evas_render.c @@ -1,5 +1,6 @@ #include "evas_common.h" #include "evas_private.h" +#include // debug rendering /* #define REND_DGB 1 */ @@ -911,14 +912,14 @@ evas_render_mapped(Evas *e, Evas_Object *obj, void *context, void *surface, pt = pts; for (; p < p_end; p++, pt++) { - pt->x = (p->x + (double)off_x) * FP1; - pt->y = (p->y + (double)off_y) * FP1; - pt->z = (p->z) * FP1; + pt->x = (lround(p->x) + off_x) * FP1; + pt->y = (lround(p->y) + off_y) * FP1; + pt->z = (lround(p->z) ) * FP1; pt->fx = p->px; pt->fy = p->py; pt->fz = p->z; - pt->u = p->u * FP1; - pt->v = p->v * FP1; + pt->u = lround(p->u) * FP1; + pt->v = lround(p->v) * FP1; if (pt->u < 0) pt->u = 0; else if (pt->u > (sw * FP1)) pt->u = (sw * FP1); if (pt->v < 0) pt->v = 0;