Replace e_comp_wl_subsurface APIs with e_subsurface 33/313433/1
authorSeunghun Lee <shiin.lee@samsung.com>
Thu, 30 May 2024 01:50:54 +0000 (10:50 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Wed, 26 Jun 2024 00:34:33 +0000 (09:34 +0900)
Change-Id: Id8c77c5282f29ff99ff3130201d3e92aedf3f08b

src/bin/displaymgr/video/e_video_hwc.c
src/bin/server/e_comp_wl.c
src/bin/server/e_comp_wl_subsurface.c
src/bin/server/e_comp_wl_subsurface_intern.h
src/bin/server/e_compositor.c
src/bin/server/e_compositor_intern.h

index e4b6bb1..9754116 100644 (file)
@@ -10,6 +10,7 @@
 #include "e_util_video_intern.h"
 #include "e_video_debug_intern.h"
 #include "e_client_intern.h"
+#include "e_compositor_intern.h"
 
 #include <wayland-tbm-server.h>
 
@@ -1452,8 +1453,13 @@ _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_Subsurface *subsurface;
+
    if (e_comp_wl_subsurface_check(ec))
-     e_comp_wl_subsurface_global_coord_get(ec, &out->x, &out->y);
+     {
+        subsurface = e_subsurface_from_ec(ec);
+        e_subsurface_coord_get(subsurface, &out->x, &out->y);
+     }
    else
      {
         out->x = ec->x;
index 7eb0991..2b9b69b 100644 (file)
@@ -560,6 +560,7 @@ e_comp_wl_map_apply(E_Client *ec)
    E_Comp_Wl_Buffer_Viewport *vp;
    E_Comp_Wl_Subsurf_Data *sdata;
    E_Comp_Wl_Client_Data *cdata;
+   E_Subsurface *subsurface;
    int x1, y1, x2, y2, x, y;
    int dx = 0, dy = 0;
    Eina_Bool zoom_animating = EINA_FALSE;
@@ -576,7 +577,8 @@ e_comp_wl_map_apply(E_Client *ec)
 
    if (e_comp_wl_subsurface_check(ec))
      {
-        e_comp_wl_subsurface_global_coord_get(ec, &dx, &dy);
+        subsurface = e_subsurface_from_ec(ec);
+        e_subsurface_coord_get(subsurface, &dx, &dy);
 
         sdata = ec->comp_data->sub.data;
         if (sdata->remote_surface.offscreen_parent)
@@ -596,16 +598,20 @@ e_comp_wl_map_apply(E_Client *ec)
                   break;
                }
           }
+
+        evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
+        if (x != dx || y != dy)
+          e_subsurface_view_position_set(subsurface, dx, dy);
      }
    else
      {
         dx = ec->x;
         dy = ec->y;
-     }
 
-   evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
-   if (x != dx || y != dy)
-     evas_object_move(ec->frame, dx, dy);
+        evas_object_geometry_get(ec->frame, &x, &y, NULL, NULL);
+        if (x != dx || y != dy)
+          evas_object_move(ec->frame, dx, dy);
+     }
 
    if (!cdata->viewport_transform)
      {
@@ -774,7 +780,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 = 0 , y = 0;
+   E_Subsurface *subsurface;
 
    if (!(ec = data)) return;
    if (e_object_is_del(E_OBJECT(ec))) return;
@@ -782,8 +788,8 @@ _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_global_coord_get(subc, &x, &y);
-        evas_object_move(subc->frame, x, y);
+        subsurface = e_subsurface_from_ec(subc);
+        e_subsurface_view_reposition(subsurface);
 
         E_Comp_Wl_Client_Data *cdata = subc->comp_data;
         if (cdata->viewport_transform)
@@ -793,8 +799,8 @@ _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_global_coord_get(subc, &x, &y);
-        evas_object_move(subc->frame, x, y);
+        subsurface = e_subsurface_from_ec(subc);
+        e_subsurface_view_reposition(subsurface);
 
         E_Comp_Wl_Client_Data *cdata = subc->comp_data;
         if (cdata->viewport_transform)
@@ -5462,6 +5468,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_Subsurface *subsurface;
+
    if (!out)
      return;
 
@@ -5469,7 +5477,10 @@ _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_global_coord_get(ec, &out->x, &out->y);
+     {
+        subsurface = e_subsurface_from_ec(ec);
+        e_subsurface_coord_get(subsurface, &out->x, &out->y);
+     }
    else
      {
         out->x = ec->x;
index 8774475..f0eed38 100644 (file)
@@ -696,46 +696,6 @@ 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_Client *parent;
-   E_Comp_Wl_Subsurf_Data *sdata;
-   int ret_x = 0, ret_y = 0;
-
-   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);
-
-   while (1)
-     {
-        ret_x += sdata->position.x;
-        ret_y += sdata->position.y;
-
-        parent = sdata->parent;
-        if (!parent)
-          break;
-
-        sdata = _e_comp_wl_subsurface_data_get(parent);
-        if (!sdata)
-          {
-             ret_x += parent->x;
-             ret_y += parent->y;
-             break;
-          }
-   }
-
-   if (x)
-     *x = ret_x;
-   if (y)
-     *y = ret_y;
-
-   return EINA_TRUE;
-}
-
 static E_Comp_Wl_Subsurf_Data *
 _e_comp_wl_subsurface_data_get(E_Client *ec)
 {
index 88acc87..e396e37 100644 (file)
@@ -33,6 +33,5 @@ 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 d0b0962..652204b 100644 (file)
@@ -10,6 +10,7 @@
 #include "e_client_video_intern.h"
 #include "e_client_intern.h"
 
+#include <assert.h>
 #include <libds/compositor.h>
 #include <libds/subcompositor.h>
 #include <libds/types/ds_surface.h>
@@ -51,9 +52,21 @@ struct _E_Surface
      } events;
 };
 
+typedef struct
+{
+   E_Client *ec;
+   E_Subsurface *subsurface;
+
+   struct
+     {
+        struct wl_signal reposition;
+     } events;
+} E_Subsurface_View;
+
 struct _E_Subsurface
 {
    E_Comp_Wl_Subsurf_Data base;
+   E_Subsurface_View view;
 
    E_Surface *surface;
    struct ds_subsurface *ds_subsurface;
@@ -102,7 +115,6 @@ static E_Subsurface *_e_subsurface_from_ds_subsurface(struct ds_subsurface *ds_s
 static void _e_subsurface_destroy(E_Subsurface *sub);
 static void _e_subsurface_commit(E_Subsurface *sub);
 static void _e_subsurface_place_below_parent(E_Subsurface *sub);
-static void _e_subsurface_position_update(E_Subsurface *sub);
 static void _e_subsurface_cb_destroy(struct wl_listener *listener, void *data);
 static void _e_subsurface_cb_cached(struct wl_listener *listener, void *data);
 static void _e_subsurface_cb_sync_precommit(struct wl_listener *listener, void *data);
@@ -477,6 +489,16 @@ e_subsurface_from_surface(E_Surface *surface)
    return _e_subsurface_from_surface(surface);
 }
 
+EINTERN E_Subsurface *
+e_subsurface_from_ec(E_Client *ec)
+{
+   E_Subsurface *subsurface;
+
+   assert(ec->comp_data->sub.data);
+
+   return wl_container_of(ec->comp_data->sub.data, subsurface, base);
+}
+
 EINTERN Eina_Bool
 e_subsurface_position_set(E_Subsurface *subsurface, int x, int y)
 {
@@ -1312,6 +1334,20 @@ _e_surface_cb_new_subsurface(struct wl_listener *listener, void *data)
      }
 }
 
+static void
+_e_subsurface_view_init(E_Subsurface_View *view, E_Subsurface *subsurface)
+{
+   int x, y;
+
+   view->subsurface = subsurface;
+   view->ec = subsurface->surface->ec;
+
+   wl_signal_init(&view->events.reposition);
+
+   e_subsurface_coord_get(subsurface, &x, &y);
+   evas_object_move(view->ec->frame, x, y);   
+}
+
 static E_Subsurface *
 _e_subsurface_create(struct ds_subsurface *ds_subsurface, E_Surface *parent_surface)
 {
@@ -1384,7 +1420,7 @@ _e_subsurface_create(struct ds_subsurface *ds_subsurface, E_Surface *parent_surf
                                     epc,
                                     offscreen_parent);
 
-   _e_subsurface_position_update(sub);
+   _e_subsurface_view_init(&sub->view, sub);
 
    ELOGF("SUBSURFACE", "Create: parent(%p)", surface->ec, epc);
 
@@ -1486,16 +1522,6 @@ _e_subsurface_commit(E_Subsurface *sub)
 }
 
 static void
-_e_subsurface_position_update(E_Subsurface *sub)
-{
-   E_Client *ec = sub->surface->ec;
-   int x, y;
-
-   if (e_comp_wl_subsurface_global_coord_get(ec, &x, &y))
-     evas_object_move(ec->frame, x, y);
-}
-
-static void
 _e_subsurface_place_below_parent(E_Subsurface *sub)
 {
    struct ds_subsurface *ds_subsurface = sub->ds_subsurface;
@@ -1609,7 +1635,7 @@ _e_subsurface_cb_request_move(struct wl_listener *listener, void *data)
    sub->base.position.x = ds_subsurface->current.x;
    sub->base.position.y = ds_subsurface->current.y;
 
-   _e_subsurface_position_update(sub);
+   e_subsurface_view_reposition(sub);
 }
 
 static void
@@ -1726,4 +1752,65 @@ e_subsurface_desync_precommit_listener_add(E_Subsurface *subsurface, struct wl_l
 {
    EINA_SAFETY_ON_NULL_RETURN(subsurface);
    wl_signal_add(&subsurface->events.desync_precommit, listener);
-}
\ No newline at end of file
+}
+
+EINTERN void
+e_subsurface_coord_get(E_Subsurface *subsurface, int *x, int *y)
+{
+   E_Subsurface *iter = subsurface;
+   E_Client *parent;
+   int ret_x = 0, ret_y = 0;
+
+   while (1)
+     {
+        ret_x += iter->base.position.x;
+        ret_y += iter->base.position.y;
+
+        parent = iter->base.parent;
+        if (!parent)
+          break;
+
+        if (parent->comp_data && parent->comp_data->sub.data)
+          {
+             iter = wl_container_of(parent->comp_data->sub.data, iter, base);
+          }
+        else
+          {
+             ret_x += parent->x;
+             ret_y += parent->y;
+             break;
+          }
+     }
+
+   if (x)
+     *x = ret_x;
+   if (y)
+     *y = ret_y;
+}
+
+EINTERN void
+e_subsurface_view_reposition_listener_add(E_Subsurface *subsurface, struct wl_listener *listener)
+{
+   E_Subsurface_View *view = &subsurface->view;
+
+   wl_signal_add(&view->events.reposition, listener);
+}
+
+EINTERN void
+e_subsurface_view_position_set(E_Subsurface *subsurface, int x, int y)
+{
+   E_Subsurface_View *view = &subsurface->view;
+
+   evas_object_move(view->ec->frame, x, y);
+
+   wl_signal_emit(&view->events.reposition, subsurface);
+}
+
+EINTERN void
+e_subsurface_view_reposition(E_Subsurface *subsurface)
+{
+   int x, y;
+
+   e_subsurface_coord_get(subsurface, &x, &y);
+   e_subsurface_view_position_set(subsurface, x, y);
+}
index 7bfc445..22f41c5 100644 (file)
@@ -28,10 +28,15 @@ EINTERN Eina_Bool e_surface_viewport_changed_get(E_Surface *surface);
 
 EINTERN E_Subsurface *e_subsurface_from_resource(struct wl_resource *resource);
 EINTERN E_Subsurface *e_subsurface_from_surface(E_Surface *surface);
+EINTERN E_Subsurface *e_subsurface_from_ec(E_Client *ec);
 EINTERN Eina_Bool e_subsurface_position_set(E_Subsurface *subsurface, int x, int y);
 EINTERN void e_subsurface_destroy_listener_add(E_Subsurface *subsurface, struct wl_listener *listener);
 EINTERN void e_subsurface_cached_listener_add(E_Subsurface *subsurface, struct wl_listener *listener);
 EINTERN void e_subsurface_sync_commit_pre_listener_add(E_Subsurface *subsurface, struct wl_listener *listener);
 EINTERN void e_subsurface_desync_commit_pre_listener_add(E_Subsurface *subsurface, struct wl_listener *listener);
 
+EINTERN void e_subsurface_view_reposition_listener_add(E_Subsurface *subsurface, struct wl_listener *listener);
+EINTERN void e_subsurface_view_position_set(E_Subsurface *subsurface, int x, int y);
+EINTERN void e_subsurface_view_reposition(E_Subsurface *subsurface);
+
 #endif