From: Hosang Kim Date: Thu, 13 Jul 2023 09:28:24 +0000 (+0900) Subject: evas_map: add calibrating coordinates when origin is changed. X-Git-Tag: accepted/tizen/unified/20230719.170100^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=088b7a81cebea00780ed8c3066245f3bf6c1bb99;p=platform%2Fupstream%2Fefl.git evas_map: add calibrating coordinates when origin is changed. Change-Id: I632aa74b4ccb1fad32159643b865f197b12d9bc2 --- diff --git a/src/lib/evas/canvas/evas_map.c b/src/lib/evas/canvas/evas_map.c index 973d10f..350627f 100644 --- a/src/lib/evas/canvas/evas_map.c +++ b/src/lib/evas/canvas/evas_map.c @@ -267,11 +267,12 @@ evas_map_coords_get(const Evas_Map *m, double x, double y, // FIXME: need to handle grab mode and extrapolate coords outside map if (grab && !inside) return EINA_FALSE; - int i, j, edges, edge[m->count][2]; + int i, j, edges, edgesx, edge[m->count][2], edgex[m->count][2]; Eina_Bool douv = EINA_FALSE; double xe[2]; double u[2] = { 0.0, 0.0 }; double v[2] = { 0.0, 0.0 }; + double xc = 0.0, yc = 0.0; /* if (grab) @@ -290,6 +291,7 @@ evas_map_coords_get(const Evas_Map *m, double x, double y, } */ edges = EINA_FALSE; + edgesx = EINA_FALSE; for (i = 0; i < m->count; i++) { j = (i + 1) % m->count; @@ -305,7 +307,25 @@ evas_map_coords_get(const Evas_Map *m, double x, double y, edge[edges][1] = i; edges++; } + if ((m->points[i].x <= x) && (m->points[j].x > x)) + { + edgex[edgesx][0] = i; + edgex[edgesx][1] = j; + edgesx++; + } + else if ((m->points[j].x <= x) && (m->points[i].x > x)) + { + edgex[edgesx][0] = j; + edgex[edgesx][1] = i; + edgesx++; + } } + if (edges > 1) { + if (edge[0][1] < edge[0][0]) xc = -1.0; + } + if (edgesx > 1) { + if (edgex[0][1] < edgex[0][0]) yc = -1.0; + } if ((mx) || (my)) douv = EINA_TRUE; for (i = 0; i < (edges - 1); i+= 2) { @@ -376,11 +396,11 @@ evas_map_coords_get(const Evas_Map *m, double x, double y, if (douv) { if (mx) - *mx = u[0] + (((x - xe[0]) * (u[1] - u[0])) / - (xe[1] - xe[0])); + *mx = u[0] + xc + (((x - xe[0]) * (u[1] - u[0])) / + (xe[1] - xe[0])); if (my) - *my = v[0] + (((x - xe[0]) * (v[1] - v[0])) / - (xe[1] - xe[0])); + *my = v[0] + yc + (((x - xe[0]) * (v[1] - v[0])) / + (xe[1] - xe[0])); } return EINA_TRUE; }