subsurface: Add and use a function for getting position 20/260620/4
authorSeunghun Lee <shiin.lee@samsung.com>
Thu, 24 Jun 2021 07:37:37 +0000 (16:37 +0900)
committerSeunghun Lee <shiin.lee@samsung.com>
Wed, 30 Jun 2021 05:36:36 +0000 (14:36 +0900)
This lets us be able to get position of sub-surface without accessing
the data of sub-surface by calling e_comp_wl_subsurface_position_get().

Change-Id: I930893a326990fb3991152dfb56e13a469f3be14

src/bin/e_client.c
src/bin/e_comp_wl.c
src/bin/e_comp_wl_rsm.c
src/bin/e_comp_wl_subsurface.c
src/bin/e_comp_wl_subsurface.h
src/bin/e_comp_wl_viewport.c
src/bin/video/iface/e_video_hwc.c

index 79ec5a9c6112dff9c79cd10eee0dc5d655fc675e..a16a85eed834d7f0a72b4f2889c3010b00b200ad 100644 (file)
@@ -3152,18 +3152,16 @@ static void
 _e_client_transform_sub_apply(E_Client *ec, E_Client *epc, double zoom)
 {
    E_Comp_Wl_Client_Data *cdata = e_client_cdata_get(ec);
-   E_Comp_Wl_Subsurf_Data *sdata = cdata->sub.data;
    E_Client *subc;
    Eina_List *l;
    int px = 0, py = 0;
-   int ox, oy, ow, oh;
+   int ox = 0, oy = 0, ow, oh;
    int mx, my, mw, mh;
    E_Map *map;
 
-   EINA_SAFETY_ON_NULL_RETURN(sdata);
+   EINA_SAFETY_ON_FALSE_RETURN(e_comp_wl_subsurface_check(ec));
 
-   ox = sdata->position.x;
-   oy = sdata->position.y;
+   e_comp_wl_subsurface_position_get(ec, &ox, &oy);
    ow = cdata->width_from_viewport;
    oh = cdata->height_from_viewport;
 
index 4cd98a28fbd64e0ec29c1080dd9930ea1f56bbc5..e721f5d460d9de1dd1e0ecc5a4696aab3fcb78d8 100644 (file)
@@ -413,11 +413,12 @@ 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;
    int x1, y1, x2, y2, x, y;
-   int dx, dy;
+   int dx = 0, dy = 0;
    Eina_Bool zoom_animating = EINA_FALSE;
 
    if (!ec || !ec->comp_data || e_object_is_del(E_OBJECT(ec))) return;
@@ -430,18 +431,17 @@ e_comp_wl_map_apply(E_Client *ec)
        (!cdata->viewport_transform))
      return;
 
-   sdata = ec->comp_data->sub.data;
-   if (sdata)
+   if (e_comp_wl_subsurface_check(ec))
      {
-        dx = sdata->position.x;
-        dy = sdata->position.y;
-
-        if (sdata->parent)
+        e_comp_wl_subsurface_position_get(ec, &dx, &dy);
+        parent = e_comp_wl_subsurface_parent_get(ec);
+        if (parent)
           {
-             dx += sdata->parent->x;
-             dy += sdata->parent->y;
+             dx += parent->x;
+             dy += parent->y;
           }
 
+        sdata = ec->comp_data->sub.data;
         if (sdata->remote_surface.offscreen_parent)
           {
              E_Client *offscreen_parent = sdata->remote_surface.offscreen_parent;
@@ -638,16 +638,17 @@ _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;
+   int x, y, sx = 0, sy = 0;
 
    if (!(ec = data)) return;
    if (e_object_is_del(E_OBJECT(ec))) return;
 
    EINA_LIST_FOREACH(ec->comp_data->sub.list, l, subc)
      {
-        if (!subc->comp_data || !subc->comp_data->sub.data) continue;
-        x = ec->x + subc->comp_data->sub.data->position.x;
-        y = ec->y + subc->comp_data->sub.data->position.y;
+        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;
         evas_object_move(subc->frame, x, y);
 
         if (subc->comp_data->scaler.viewport)
@@ -660,9 +661,10 @@ _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 (!subc->comp_data || !subc->comp_data->sub.data) continue;
-        x = ec->x + subc->comp_data->sub.data->position.x;
-        y = ec->y + subc->comp_data->sub.data->position.y;
+        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;
         evas_object_move(subc->frame, x, y);
 
         if (subc->comp_data->scaler.viewport)
@@ -6281,7 +6283,8 @@ _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_Comp_Wl_Subsurf_Data *sdata = NULL;
+   E_Client *parent;
+   int x = 0, y = 0;
 
    if (!out)
      return;
@@ -6289,18 +6292,19 @@ _e_comp_wl_surface_output_viewport_get(E_Client *ec, Eina_Rectangle *out)
    if (!ec->comp_data)
      return;
 
-   sdata = ec->comp_data->sub.data;
-   if (sdata)
+   if (e_comp_wl_subsurface_check(ec))
      {
-        if (sdata->parent)
+        e_comp_wl_subsurface_position_get(ec, &x, &y);
+        parent = e_comp_wl_subsurface_parent_get(ec);
+        if (parent)
           {
-             out->x = sdata->parent->x + sdata->position.x;
-             out->y = sdata->parent->y + sdata->position.y;
+             out->x = parent->x + x;
+             out->y = parent->y + y;
           }
         else
           {
-             out->x = sdata->position.x;
-             out->y = sdata->position.y;
+             out->x = x;
+             out->y = y;
           }
      }
    else
index 6ce95a94405d1f5c60a50086814dad638468c73f..de171dade572660f1e6d5ebcd259b323cf0cbc4c 100644 (file)
@@ -3106,12 +3106,12 @@ static Eina_Bool
 _e_comp_wl_remote_surface_subsurface_commit(E_Comp_Wl_Remote_Provider *parent_provider,
                                             E_Client *ec)
 {
-   E_Comp_Wl_Subsurf_Data *sdata;
    E_Comp_Wl_Remote_Surface *onscreen_parent;
    Eina_List *l;
    Eina_Rectangle *rect;
    int fx, fy, fw, fh;
    int x, y, w, h;
+   int sx = 0, sy = 0;
    Eina_Bool first_skip = EINA_TRUE;
    E_Comp_Wl_Buffer *buffer;
 
@@ -3128,17 +3128,19 @@ _e_comp_wl_remote_surface_subsurface_commit(E_Comp_Wl_Remote_Provider *parent_pr
 
    if (!evas_object_visible_get(ec->frame)) return EINA_TRUE;
 
-   sdata = ec->comp_data->sub.data;
    evas_object_geometry_get(ec->frame, &fx, &fy, &fw, &fh);
 
+   e_comp_wl_subsurface_position_get(ec, &sx, &sy);
+
    EINA_LIST_FOREACH(parent_provider->common.ec->comp_data->remote_surface.regions, l, rect)
      {
         E_Comp_Wl_Remote_Region *region;
 
         region = container_of(rect, E_Comp_Wl_Remote_Region, geometry);
 
-        x = sdata->position.x + rect->x;
-        y = sdata->position.y + rect->y;
+        x = sx + rect->x;
+        y = sy + rect->y;
+
         if (onscreen_parent->ec)
           {
              x += onscreen_parent->ec->x;
index 8fe8c828ac3a9b2a9c142e2203f7fdbfce1e0d12..625a77bdf4112bd86f6b532de9cc9c1e22db0ca3 100644 (file)
@@ -1407,6 +1407,24 @@ e_comp_wl_subsurface_resource_place_below_parent(struct wl_resource *subsurface_
    epc_cdata->sub.list_changed = EINA_TRUE;
 }
 
+EINTERN Eina_Bool
+e_comp_wl_subsurface_position_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;
+   if (y) *y = sdata->position.y;
+
+   return EINA_TRUE;
+}
+
 static void
 _e_comp_wl_subsurface_cb_dummy_destroy(struct wl_client *client EINA_UNUSED, struct wl_resource *resource)
 {
index db05f3232402803f2652829e77466d9719feb1bf..8bfa3ea9c27e763bc4aae75aee14cf063eecacc0 100644 (file)
@@ -32,5 +32,6 @@ EINTERN void          e_comp_wl_subsurface_check_below_bg_rectangle(E_Client *ec
 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);
 
 #endif
index 501457dad587af4fac5ea7953ce3115ce1788038..cb0479bbc0a805e6601f7e7816f49305ae354e1d 100644 (file)
@@ -1409,6 +1409,7 @@ _e_comp_wl_viewport_apply_destination(E_Viewport *viewport, Eina_Rectangle *rrec
    E_Comp_Wl_Buffer_Viewport *vp;
    Eina_Rectangle dst = {0,}, prect;
    Eina_Bool changed = EINA_FALSE;
+   int sx = 0, sy = 0;
 
    ec = viewport->ec;
    vp = &ec->comp_data->scaler.buffer_viewport;
@@ -1469,8 +1470,8 @@ _e_comp_wl_viewport_apply_destination(E_Viewport *viewport, Eina_Rectangle *rrec
    /* The values of below x, y, w, h are specified in the transform 0 and in the parent */
    if (ec->comp_data->sub.data)
      {
-        if (ec->comp_data->sub.data->position.x != dst.x ||
-            ec->comp_data->sub.data->position.y != dst.y)
+        e_comp_wl_subsurface_position_get(ec, &sx, &sy);
+        if ((sx != dst.x) || (sy != dst.y))
           {
              ec->comp_data->sub.data->position.x = dst.x;
              ec->comp_data->sub.data->position.y = dst.y;
index 89dbbacf91f33b86073469c94aa2991c7317e645..f5b7b153854f59be3ea6fbcb7d292220dc089de7 100644 (file)
@@ -1409,32 +1409,25 @@ _e_video_hwc_geometry_input_rect_get_with_viewport(tbm_surface_h tbm_surf, E_Com
    out->h = (ty1 <= ty2) ? ty2 - ty1 : ty1 - ty2;
 }
 
-static E_Comp_Wl_Subsurf_Data *
-_e_video_hwc_client_subsurface_data_get(E_Client *ec)
-{
-   if (ec->comp_data && ec->comp_data->sub.data)
-     return ec->comp_data->sub.data;
-
-   return NULL;
-}
-
 static void
 _e_video_hwc_geometry_output_rect_get(E_Client *ec, Eina_Rectangle *out)
 {
-   E_Comp_Wl_Subsurf_Data *sdata;
+   E_Client *parent;
+   int sx = 0, sy = 0;
 
-   sdata = _e_video_hwc_client_subsurface_data_get(ec);
-   if (sdata)
+   if (e_comp_wl_subsurface_check(ec))
      {
-        if (sdata->parent)
+        e_comp_wl_subsurface_position_get(ec, &sx, &sy);
+        parent = e_comp_wl_subsurface_parent_get(ec);
+        if (parent)
           {
-             out->x = sdata->parent->x + sdata->position.x;
-             out->y = sdata->parent->y + sdata->position.y;
+             out->x = parent->x + sx;
+             out->y = parent->y + sy;
           }
         else
           {
-             out->x = sdata->position.x;
-             out->y = sdata->position.y;
+             out->x = sx;
+             out->y = sy;
           }
      }
    else