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.



SVN revision: 63978
This commit is contained in:
Carsten Haitzler 2011-10-11 06:06:11 +00:00
parent 0bfb70e48e
commit 914a08e206
3 changed files with 16 additions and 14 deletions

View File

@ -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++)
{

View File

@ -2,6 +2,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <math.h>
#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;

View File

@ -1,5 +1,6 @@
#include "evas_common.h"
#include "evas_private.h"
#include <math.h>
// 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;