subsurface: Add and use a function for getting global coord 28/260628/2
authorSeunghun Lee <shiin.lee@samsung.com>
Wed, 30 Jun 2021 02:52:55 +0000 (11:52 +0900)
committerSeunghun Lee <shiin.lee@samsung.com>
Wed, 30 Jun 2021 05:36:38 +0000 (14:36 +0900)
This provides a helper function for getting global coordinates of
sub-surface which is calculated by adding the coordinates of sub-surface
to the coordinates of its parent.
This is to not repeat calculation code and help with readability.

Change-Id: I46c99bbf7eb3c82e70aae1a5f0b5f7d16b2c00aa

src/bin/e_comp_wl.c
src/bin/e_comp_wl_subsurface.c
src/bin/e_comp_wl_subsurface.h
src/bin/video/iface/e_video_hwc.c

index e721f5d460d9de1dd1e0ecc5a4696aab3fcb78d8..f65e8611365e47f2c48495240d8e6412ee64b9c2 100644 (file)
@@ -413,7 +413,6 @@ e_comp_wl_topmost_parent_get(E_Client *ec)
 E_API void
 e_comp_wl_map_apply(E_Client *ec)
 {
-   E_Client *parent;
    E_Comp_Wl_Buffer_Viewport *vp;
    E_Comp_Wl_Subsurf_Data *sdata;
    E_Comp_Wl_Client_Data *cdata;
@@ -433,13 +432,7 @@ e_comp_wl_map_apply(E_Client *ec)
 
    if (e_comp_wl_subsurface_check(ec))
      {
-        e_comp_wl_subsurface_position_get(ec, &dx, &dy);
-        parent = e_comp_wl_subsurface_parent_get(ec);
-        if (parent)
-          {
-             dx += parent->x;
-             dy += parent->y;
-          }
+        e_comp_wl_subsurface_global_coord_get(ec, &dx, &dy);
 
         sdata = ec->comp_data->sub.data;
         if (sdata->remote_surface.offscreen_parent)
@@ -638,7 +631,7 @@ _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U
    E_Client *ec;
    E_Client *subc;
    Eina_List *l;
-   int x, y, sx = 0, sy = 0;
+   int x = 0 , y = 0;
 
    if (!(ec = data)) return;
    if (e_object_is_del(E_OBJECT(ec))) return;
@@ -646,9 +639,7 @@ _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U
    EINA_LIST_FOREACH(ec->comp_data->sub.list, l, subc)
      {
         if (!e_comp_wl_subsurface_check(subc)) continue;
-        e_comp_wl_subsurface_position_get(subc, &sx, &sy);
-        x = ec->x + sx;
-        y = ec->y + sy;
+        e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
         evas_object_move(subc->frame, x, y);
 
         if (subc->comp_data->scaler.viewport)
@@ -662,9 +653,7 @@ _e_comp_wl_evas_cb_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_U
    EINA_LIST_FOREACH(ec->comp_data->sub.below_list, l, subc)
      {
         if (!e_comp_wl_subsurface_check(subc)) continue;
-        e_comp_wl_subsurface_position_get(subc, &sx, &sy);
-        x = ec->x + sx;
-        y = ec->y + sy;
+        e_comp_wl_subsurface_global_coord_get(subc, &x, &y);
         evas_object_move(subc->frame, x, y);
 
         if (subc->comp_data->scaler.viewport)
@@ -6283,9 +6272,6 @@ _transform_merge_with_rotation(enum wl_output_transform transform, unsigned int
 static void
 _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
 {
-   E_Client *parent;
-   int x = 0, y = 0;
-
    if (!out)
      return;
 
@@ -6293,20 +6279,7 @@ _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
      return;
 
    if (e_comp_wl_subsurface_check(ec))
-     {
-        e_comp_wl_subsurface_position_get(ec, &x, &y);
-        parent = e_comp_wl_subsurface_parent_get(ec);
-        if (parent)
-          {
-             out->x = parent->x + x;
-             out->y = parent->y + y;
-          }
-        else
-          {
-             out->x = x;
-             out->y = y;
-          }
-     }
+     e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
    else
      {
         out->x = ec->x;
index 625a77bdf4112bd86f6b532de9cc9c1e22db0ca3..f7cdb3ca9dede5a54c4b6b2dd4180cd4a01be17a 100644 (file)
@@ -1425,6 +1425,26 @@ e_comp_wl_subsurface_position_get(E_Client *ec, int *x, int *y)
    return EINA_TRUE;
 }
 
+EINTERN Eina_Bool
+e_comp_wl_subsurface_global_coord_get(E_Client *ec, int *x, int *y)
+{
+   E_Comp_Wl_Subsurf_Data *sdata;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(ec, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(ec->comp_data, EINA_FALSE);
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(e_comp_wl_subsurface_check(ec), EINA_FALSE);
+
+   sdata = ec->comp_data->sub.data;
+   EINA_SAFETY_ON_NULL_RETURN_VAL(sdata, EINA_FALSE);
+
+   if (x)
+     *x = sdata->position.x + (sdata->parent ? sdata->parent->x : 0);
+   if (y)
+     *y = sdata->position.y + (sdata->parent ? sdata->parent->y : 0);
+
+   return EINA_TRUE;
+}
+
 static void
 _e_comp_wl_subsurface_cb_dummy_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
 {
index 8bfa3ea9c27e763bc4aae75aee14cf063eecacc0..4ec3c829209929d9b8a421bf06deb745ec95792b 100644 (file)
@@ -33,5 +33,6 @@ EINTERN Eina_Bool     e_comp_wl_subsurface_check(E_Client *ec);
 EINTERN E_Client     *e_comp_wl_subsurface_parent_get(E_Client *ec);
 EINTERN Eina_Bool     e_comp_wl_subsurface_stand_alone_mode_get(E_Client *ec);
 EINTERN Eina_Bool     e_comp_wl_subsurface_position_get(E_Client *ec, int *x, int *y);
+EINTERN Eina_Bool     e_comp_wl_subsurface_global_coord_get(E_Client *ec, int *x, int *y);
 
 #endif
index f5b7b153854f59be3ea6fbcb7d292220dc089de7..3489d40820409cdee1f2824ea315068f43dca477 100644 (file)
@@ -1412,24 +1412,8 @@ _e_video_hwc_geometry_input_rect_get_with_viewport(tbm_surface_h tbm_surf, E_Com
 static void
 _e_video_hwc_geometry_output_rect_get(E_Client *ec, Eina_Rectangle *out)
 {
-   E_Client *parent;
-   int sx = 0, sy = 0;
-
    if (e_comp_wl_subsurface_check(ec))
-     {
-        e_comp_wl_subsurface_position_get(ec, &sx, &sy);
-        parent = e_comp_wl_subsurface_parent_get(ec);
-        if (parent)
-          {
-             out->x = parent->x + sx;
-             out->y = parent->y + sy;
-          }
-        else
-          {
-             out->x = sx;
-             out->y = sy;
-          }
-     }
+     e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
    else
      {
         out->x = ec->x;