e_comp_wl: get inverse coords using reverse evas_map 35/224635/1
authorjeon <jhyuni.kang@samsung.com>
Wed, 12 Feb 2020 05:27:21 +0000 (14:27 +0900)
committerjeon <jhyuni.kang@samsung.com>
Wed, 12 Feb 2020 05:27:21 +0000 (14:27 +0900)
Change-Id: Ic9f06b3f0f0b243abc198b081f34568cb0e25205

src/bin/e_comp_wl.c

index bd39105..64f9ec4 100644 (file)
@@ -454,10 +454,9 @@ EINTERN void
 e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my)
 {
    const Evas_Map *map;
-   int map_c;
-   int min_x = 0, min_y = 0, max_x = 0, max_y = 0;
-   int map_x = 0, map_y = 0;
-   double diff_w, diff_h;
+   Evas_Map *map2;
+   int map_c = 0, map_x = 0, map_y = 0;
+   double inv_x = 0.0, inv_y = 0.0;
 
    EINA_SAFETY_ON_NULL_RETURN(ec);
 
@@ -471,29 +470,24 @@ e_comp_wl_map_inv_coord_get(E_Client *ec, int x, int y, int *mx, int *my)
         return;
      }
 
+   map2 = evas_map_new(map_c);
+
+   evas_map_point_coord_set(map2, 0, ec->x, ec->y, 0);
+   evas_map_point_coord_set(map2, 1, ec->x + ec->w, ec->y, 0);
+   evas_map_point_coord_set(map2, 2, ec->x + ec->w, ec->y + ec->h, 0);
+   evas_map_point_coord_set(map2, 3, ec->x, ec->y + ec->h, 0);
+
    for (int i = 0; i < map_c; i++)
      {
         evas_map_point_coord_get(map, i, &map_x, &map_y, NULL);
-        if (i == 0)
-          {
-             min_x = max_x = map_x;
-             min_y = max_y = map_y;
-          }
-        else
-          {
-             if (min_x > map_x) min_x = map_x;
-             else if (max_x < map_x) max_x = map_x;
-
-             if (min_y > map_y) min_y = map_y;
-             else if (max_y < map_y) max_y = map_y;
-          }
+        evas_map_point_image_uv_set(map2, i, map_x, map_y);
      }
+   evas_map_coords_get(map2, (double)x, (double)y, &inv_x, &inv_y, 0);
 
-   diff_w = (double)(max_x - min_x) / (double)ec->w;
-   diff_h = (double)(max_y - min_y) / (double)ec->h;
+   *mx = (int)inv_x;
+   *my = (int)inv_y;
 
-   *mx = (int)(x * diff_w);
-   *my = (int)(y * diff_h);
+   evas_map_free(map2);
 }
 
 static void