e_output: change pp zoom touch rect cal method 54/156854/3
authorJunkyeong Kim <jk0430.kim@samsung.com>
Fri, 20 Oct 2017 07:38:10 +0000 (16:38 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Thu, 26 Oct 2017 07:33:40 +0000 (07:33 +0000)
fix pp zoom center x, y origin coordinate error.

Change-Id: I6c819c3f8d7d561de99698e20a26f54bbccc6d7e
Signed-off-by: Junkyeong Kim <jk0430.kim@samsung.com>
src/bin/e_output.c
src/bin/e_output.h

index d3b4b2a9fc3ab33fff0c055204e7dbca8da626bb..85baa31a9c87bde665564cec64a91255e748de62 100644 (file)
@@ -93,97 +93,69 @@ static int
 _e_output_zoom_get_angle(E_Output *output)
 {
    E_Client *ec = NULL;
-   int angle = 0;
    int ec_angle = 0;
 
    ec = _e_output_zoom_top_visible_ec_get();
    if (ec)
      ec_angle = ec->e.state.rot.ang.curr;
 
-   angle = (ec_angle + output->config.rotation) % 360;
-
-   return angle;
+   return ec_angle;
 }
 
 static void
-_e_output_zoom_coordinate_cal_with_angle(E_Output *output, int angle)
+_e_output_zoom_raw_xy_get(E_Output *output, int *x, int *y)
 {
-   int x, y;
-   int w, h;
+   int w = 0, h = 0;
 
-   if (angle == 0 || angle == 180)
-     {
-        w = output->config.geom.w;
-        h = output->config.geom.h;
-     }
-   else
-     {
-        w = output->config.geom.h;
-        h = output->config.geom.w;
-     }
+   e_output_size_get(output, &w, &h);
+
+   if (w <= 0 || h <= 0)
+     return;
 
-   if (angle == output->zoom_conf.init_angle)
+   if ((output->zoom_conf.init_screen_rotation == 0) || (output->zoom_conf.init_screen_rotation == 180))
      {
-        if (angle == 0)
+        if (output->zoom_conf.current_screen_rotation == 0)
           {
-             output->zoom_conf.adjusted_cx = output->zoom_conf.init_cx;
-             output->zoom_conf.adjusted_cy = output->zoom_conf.init_cy;
+             *x = output->zoom_conf.init_cx;
+             *y = output->zoom_conf.init_cy;
           }
-        else if (angle == 90)
+        else if (output->zoom_conf.current_screen_rotation == 90)
           {
-             output->zoom_conf.adjusted_cx = output->zoom_conf.init_cy;
-             output->zoom_conf.adjusted_cy = w - output->zoom_conf.init_cx - 1;
+             *x = (float)w / h * output->zoom_conf.init_cy;
+             *y = h - (float)h / w * output->zoom_conf.init_cx - 1;
           }
-        else if (angle == 180)
+        else if (output->zoom_conf.current_screen_rotation == 180)
           {
-             output->zoom_conf.adjusted_cx = w - output->zoom_conf.init_cx - 1;
-             output->zoom_conf.adjusted_cy = h - output->zoom_conf.init_cy - 1;
+             *x = w - output->zoom_conf.init_cx - 1;
+             *y = h - output->zoom_conf.init_cy - 1;
           }
-        else /* angle == 270 */
+        else /* output->zoom_conf.current_screen_rotation == 270 */
           {
-             output->zoom_conf.adjusted_cx = h - output->zoom_conf.init_cy - 1;
-             output->zoom_conf.adjusted_cy = output->zoom_conf.init_cx;
+             *x = w - (float)w / h * output->zoom_conf.init_cy - 1;
+             *y = (float)h / w * output->zoom_conf.init_cx;
           }
      }
-   else
+   else /* (output->zoom_conf.init_screen_rotation == 90) || (output->zoom_conf.init_screen_rotation == 270) */
      {
-        if ((angle % 180) == (output->zoom_conf.init_angle % 180)) /* 180 changed from init, don't have to cal ratio */
-          {
-             x = output->zoom_conf.init_cx;
-             y = output->zoom_conf.init_cy;
-          }
-        else /* 90 or 270 changed from init, need ratio cal*/
-          {
-             if (angle == 90 || angle == 270)
-               {
-                  x = (float)output->config.geom.h / output->config.geom.w * output->zoom_conf.init_cx;
-                  y = (float)output->config.geom.w / output->config.geom.h * output->zoom_conf.init_cy;
-               }
-             else /* 0 or 180 */
-               {
-                  x = (float)output->config.geom.w / output->config.geom.h * output->zoom_conf.init_cx;
-                  y = (float)output->config.geom.h / output->config.geom.w * output->zoom_conf.init_cy;
-               }
-          }
-        if (angle == 0)
+        if (output->zoom_conf.current_screen_rotation == 0)
           {
-             output->zoom_conf.adjusted_cx = x;
-             output->zoom_conf.adjusted_cy = y;
+             *x = (float)w / h * output->zoom_conf.init_cx;
+             *y = (float)h / w * output->zoom_conf.init_cy;
           }
-        else if (angle == 90)
+        else if (output->zoom_conf.current_screen_rotation == 90)
           {
-             output->zoom_conf.adjusted_cx = y;
-             output->zoom_conf.adjusted_cy = w - x - 1;
+             *x = output->zoom_conf.init_cy;
+             *y = h - output->zoom_conf.init_cx - 1;
           }
-        else if (angle == 180)
+        else if (output->zoom_conf.current_screen_rotation == 180)
           {
-             output->zoom_conf.adjusted_cx = w - x - 1;
-             output->zoom_conf.adjusted_cy = h - y - 1;
+             *x = w - (float)w / h * output->zoom_conf.init_cx - 1;
+             *y = h - (float)h / w * output->zoom_conf.init_cy - 1;
           }
-        else /* angle == 270 */
+        else /* output->zoom_conf.current_screen_rotation == 270 */
           {
-             output->zoom_conf.adjusted_cx = h - y - 1;
-             output->zoom_conf.adjusted_cy = x;
+             *x = w - output->zoom_conf.init_cy - 1;
+             *y = output->zoom_conf.init_cx;
           }
      }
 }
@@ -220,6 +192,39 @@ _e_output_zoom_scaled_rect_get(int out_w, int out_h, double zoomx, double zoomy,
    rect->y = (int)(dy / zoomy);
 }
 
+static void
+_e_output_zoom_coordinate_cal(E_Output *output)
+{
+   int x = 0, y = 0;
+   int w = 0, h = 0;
+   int zoomx = 0, zoomy = 0;
+   int rotation_diff = 0;
+
+   rotation_diff = (360 + output->zoom_conf.current_screen_rotation - output->zoom_conf.init_screen_rotation) % 360;
+
+   e_output_size_get(output, &w, &h);
+
+   _e_output_zoom_raw_xy_get(output, &x, &y);
+
+   output->zoom_conf.adjusted_cx = x;
+   output->zoom_conf.adjusted_cy = y;
+
+   if (rotation_diff == 90 || rotation_diff == 270)
+     {
+        zoomx = output->zoom_conf.zoomy;
+        zoomy = output->zoom_conf.zoomx;
+     }
+   else
+     {
+        zoomx = output->zoom_conf.zoomx;
+        zoomy = output->zoom_conf.zoomy;
+     }
+
+   /* get the scaled rect */
+   _e_output_zoom_scaled_rect_get(w, h, zoomx, zoomy, x, y,
+                                  &output->zoom_conf.rect);
+}
+
 static Eina_Bool
 _e_output_zoom_touch_transform(E_Output *output, Eina_Bool set)
 {
@@ -244,8 +249,8 @@ _e_output_zoom_touch_transform(E_Output *output, Eina_Bool set)
 
    if (set)
      ret = e_input_device_touch_transformation_set(dev,
-                                                     output->zoom_conf.rect.x, output->zoom_conf.rect.y,
-                                                     output->zoom_conf.rect.w, output->zoom_conf.rect.h);
+                                                     output->zoom_conf.rect_touch.x, output->zoom_conf.rect_touch.y,
+                                                     output->zoom_conf.rect_touch.w, output->zoom_conf.rect_touch.h);
    else
      {
         e_output_size_get(output, &w, &h);
@@ -356,6 +361,82 @@ _e_output_render_update(E_Output *output)
    e_output_render(output);
 }
 
+static E_Client *
+_e_output_top_visible_ec_get()
+{
+   E_Client *ec;
+   Evas_Object *o;
+   E_Comp_Wl_Client_Data *cdata;
+
+   for (o = evas_object_top_get(e_comp->evas); o; o = evas_object_below_get(o))
+     {
+        ec = evas_object_data_get(o, "E_Client");
+
+        /* check e_client and skip e_clients not intersects with zone */
+        if (!ec) continue;
+        if (e_object_is_del(E_OBJECT(ec))) continue;
+        if (e_client_util_ignored_get(ec)) continue;
+        if (ec->iconic) continue;
+        if (ec->visible == 0) continue;
+        if (!(ec->visibility.obscured == 0 || ec->visibility.obscured == 1)) continue;
+        if (!ec->frame) continue;
+        if (!evas_object_visible_get(ec->frame)) continue;
+        /* if ec is subsurface, skip this */
+        cdata = (E_Comp_Wl_Client_Data *)ec->comp_data;
+        if (cdata && cdata->sub.data) continue;
+
+        return ec;
+     }
+
+   return NULL;
+}
+
+static int
+_e_output_top_ec_angle_get(void)
+{
+   E_Client *ec = NULL;
+
+   ec = _e_output_top_visible_ec_get();
+   if (ec)
+     return ec->e.state.rot.ang.curr;
+
+   return 0;
+}
+
+static void
+_e_output_zoom_touch_rect_get(E_Output *output)
+{
+   int x = 0, y = 0;
+   int w = 0, h = 0;
+   int zoomx = 0, zoomy = 0;
+   int rotation_diff = 0;
+
+   rotation_diff = (360 + output->zoom_conf.current_screen_rotation - output->zoom_conf.init_screen_rotation) % 360;
+
+   if (output->zoom_conf.current_screen_rotation == 0 || output->zoom_conf.current_screen_rotation == 180)
+     e_output_size_get(output, &w, &h);
+   else
+     e_output_size_get(output, &h, &w);
+
+   if ((rotation_diff == 90) || (rotation_diff == 270))
+     {
+        x = (float)h / w * output->zoom_conf.init_cx;
+        y = (float)w / h * output->zoom_conf.init_cy;
+        zoomx = output->zoom_conf.zoomy;
+        zoomy = output->zoom_conf.zoomx;
+     }
+   else
+     {
+        x = output->zoom_conf.init_cx;
+        y = output->zoom_conf.init_cy;
+        zoomx = output->zoom_conf.zoomx;
+        zoomy = output->zoom_conf.zoomy;
+     }
+
+   _e_output_zoom_scaled_rect_get(w, h, zoomx, zoomy, x, y,
+                                  &output->zoom_conf.rect_touch);
+}
+
 static void
 _e_output_zoom_rotate(E_Output *output)
 {
@@ -367,11 +448,9 @@ _e_output_zoom_rotate(E_Output *output)
 
    e_output_size_get(output, &w, &h);
 
-   _e_output_zoom_coordinate_cal_with_angle(output, output->zoom_conf.current_angle);
+   _e_output_zoom_coordinate_cal(output);
+   _e_output_zoom_touch_rect_get(output);
 
-   /* get the scaled rect */
-   _e_output_zoom_scaled_rect_get(w, h, output->zoom_conf.zoomx, output->zoom_conf.zoomy,
-                                  output->zoom_conf.adjusted_cx, output->zoom_conf.adjusted_cy, &output->zoom_conf.rect);
    DBG("zoom_rect rotate(x:%d,y:%d) (w:%d,h:%d)",
        output->zoom_conf.rect.x, output->zoom_conf.rect.y, output->zoom_conf.rect.w, output->zoom_conf.rect.h);
 
@@ -397,9 +476,11 @@ _e_output_zoom_rotating_check(E_Output *output)
    int angle = 0;
 
    angle = _e_output_zoom_get_angle(output);
-   if (output->zoom_conf.current_angle != angle)
+   if ((output->zoom_conf.current_angle != angle) ||
+      (output->zoom_conf.current_screen_rotation != output->config.rotation))
      {
         output->zoom_conf.current_angle = angle;
+        output->zoom_conf.current_screen_rotation = output->config.rotation;
         _e_output_zoom_rotate(output);
      }
 }
@@ -704,48 +785,6 @@ _e_output_aligned_width_get(tbm_surface_h tsurface)
    return aligned_width;
 }
 
-static E_Client *
-_e_output_top_visible_ec_get()
-{
-   E_Client *ec;
-   Evas_Object *o;
-   E_Comp_Wl_Client_Data *cdata;
-
-   for (o = evas_object_top_get(e_comp->evas); o; o = evas_object_below_get(o))
-     {
-        ec = evas_object_data_get(o, "E_Client");
-
-        /* check e_client and skip e_clients not intersects with zone */
-        if (!ec) continue;
-        if (e_object_is_del(E_OBJECT(ec))) continue;
-        if (e_client_util_ignored_get(ec)) continue;
-        if (ec->iconic) continue;
-        if (ec->visible == 0) continue;
-        if (!(ec->visibility.obscured == 0 || ec->visibility.obscured == 1)) continue;
-        if (!ec->frame) continue;
-        if (!evas_object_visible_get(ec->frame)) continue;
-        /* if ec is subsurface, skip this */
-        cdata = (E_Comp_Wl_Client_Data *)ec->comp_data;
-        if (cdata && cdata->sub.data) continue;
-
-        return ec;
-     }
-
-   return NULL;
-}
-
-static int
-_e_output_top_ec_angle_get(void)
-{
-   E_Client *ec = NULL;
-
-   ec = _e_output_top_visible_ec_get();
-   if (ec)
-     return ec->e.state.rot.ang.curr;
-
-   return 0;
-}
-
 static E_Output_Capture *
 _e_output_tdm_stream_capture_find_data(E_Output *output, tbm_surface_h tsurface)
 {
@@ -2499,13 +2538,16 @@ e_output_zoom_set(E_Output *output, double zoomx, double zoomy, int cx, int cy)
 
    if (cx < 0 || cy < 0) return EINA_FALSE;
    if (zoomx <= 0 || zoomy <= 0) return EINA_FALSE;
-   if (angle % 180 == 0)
+
+   if (output->config.rotation % 180 == 0)
      {
-        if (cx >= w || cy >= h) return EINA_FALSE;
+        if (cx >= w || cy >= h)
+          return EINA_FALSE;
      }
    else
      {
-        if (cx >= h || cy >= w) return EINA_FALSE;
+        if (cx >= h || cy >= w)
+          return EINA_FALSE;
      }
 
    ep = e_output_fb_target_get(output);
@@ -2521,12 +2563,11 @@ e_output_zoom_set(E_Output *output, double zoomx, double zoomy, int cx, int cy)
    output->zoom_conf.init_cy = cy;
    output->zoom_conf.init_angle = angle;
    output->zoom_conf.current_angle = angle;
+   output->zoom_conf.init_screen_rotation = output->config.rotation;
+   output->zoom_conf.current_screen_rotation = output->config.rotation;
 
-   _e_output_zoom_coordinate_cal_with_angle(output, angle);
-
-   /* get the scaled rect */
-   _e_output_zoom_scaled_rect_get(w, h, output->zoom_conf.zoomx, output->zoom_conf.zoomy,
-                                  output->zoom_conf.adjusted_cx, output->zoom_conf.adjusted_cy, &output->zoom_conf.rect);
+   _e_output_zoom_coordinate_cal(output);
+   _e_output_zoom_touch_rect_get(output);
 
    if (!e_plane_zoom_set(ep, &output->zoom_conf.rect))
      {
@@ -2579,6 +2620,10 @@ e_output_zoom_unset(E_Output *output)
    output->zoom_conf.rect.y = 0;
    output->zoom_conf.rect.w = 0;
    output->zoom_conf.rect.h = 0;
+   output->zoom_conf.rect_touch.x = 0;
+   output->zoom_conf.rect_touch.y = 0;
+   output->zoom_conf.rect_touch.w = 0;
+   output->zoom_conf.rect_touch.h = 0;
 
    e_plane_zoom_unset(ep);
 
index 946072a3a3df05ba7dd217ef5353daa3168d6a33..779764b8fd3f8024255bb63e6392765f5eebb0e6 100644 (file)
@@ -85,7 +85,10 @@ struct _E_Output
       int               adjusted_cy;
       int               init_angle;
       int               current_angle;
+      int               init_screen_rotation;
+      int               current_screen_rotation;
       Eina_Rectangle    rect;
+      Eina_Rectangle    rect_touch;
       Eina_Bool         need_touch_set;
    } zoom_conf;
    Ecore_Event_Handler *touch_up_handler;