e_comp_wl_subsurface: Do not resize the below_obj for optimizing gpu memory 07/266507/1
authorChangyeon Lee <cyeon.lee@samsung.com>
Thu, 7 Oct 2021 05:26:30 +0000 (14:26 +0900)
committerDoyoun Kang <doyoun.kang@samsung.com>
Sat, 13 Nov 2021 04:20:49 +0000 (13:20 +0900)
before this patch, the below_obj is resized according to size of object of ec.
in normal scenario, the below_obj does not use extra gpu memory.
but the below object use extra gpu memory when evas_map is applied to
the below_obj.
(size of extra gpu memory is same size of the below obj)
this patch is for optimizing gpu memory.
the below_obj is resized by 1x1 when it is created and evas_map is applied
with size of object of ec.
it makes the below obj always use extra gpu memory for 1x1 size.

Change-Id: Ied098c06b0cd153bc1218155ae385c2848a9d4be

src/bin/e_client.c
src/bin/e_comp_wl.h
src/bin/e_comp_wl_subsurface.c

index aae90bbe1cc2ac3a371d5f828a96c1065106a408..8dc3c69c9343cc20b100a651ae0a89b4706071de 100644 (file)
@@ -3810,22 +3810,11 @@ _e_client_transform_core_check_change(E_Client *ec)
    int w = 0;
    int h = 0;
    Eina_Bool check = EINA_FALSE;
-   E_Comp_Wl_Client_Data *cdata;
    if (!ec) return EINA_FALSE;
 
    if (ec->frame)
      evas_object_geometry_get(ec->frame, 0, 0, &w, &h);
 
-   cdata = e_client_cdata_get(ec);
-   if ((ec->transform_core.transform_list) &&
-       (cdata && cdata->sub.below_obj))
-     {
-        E_Map *map_ = e_comp_object_map_get(cdata->sub.below_obj);
-        if (!map_)
-          check = EINA_TRUE;
-        e_map_free(map_);
-     }
-
    // check client position or size change
    if (ec->x != ec->transform_core.backup.client_x ||
        ec->y != ec->transform_core.backup.client_y ||
@@ -4045,9 +4034,6 @@ _e_client_transform_core_sub_update(E_Client *ec, E_Util_Transform_Rect_Vertex *
    cdata = e_client_cdata_get(ec);
    if (!cdata) return;
 
-   if (cdata->sub.below_obj)
-     _e_client_transform_core_vertices_apply(ec, cdata->sub.below_obj, vertices, NULL);
-
    EINA_LIST_FOREACH(cdata->sub.list, l, subc)
       e_client_transform_core_update(subc);
 
@@ -4069,9 +4055,6 @@ _e_client_transform_core_sub_update_with_zoom(E_Client *ec, E_Util_Transform_Rec
 
    ELOGF("TRANSFORM", "transform_core_sub_update_with_zoom, (zoom:%lf,%lf / coord:%d,%d)", ec, zoomx, zoomy, cx, cy);
 
-   if (cdata->sub.below_obj)
-     _e_client_transform_core_vertices_apply_with_zoom(ec, cdata->sub.below_obj, vertices, NULL, zoomx, zoomy, cx, cy);
-
    EINA_LIST_FOREACH(cdata->sub.list, l, subc)
      {
         _e_client_transform_core_update_with_zoom(subc, zoomx, zoomy, cx, cy);
@@ -7231,12 +7214,6 @@ e_client_transform_apply(E_Client *ec, double angle, double zoom, int cx, int cy
    e_client_map_set(ec, map);
    e_client_map_enable_set(ec, EINA_TRUE);
 
-   if (cdata->sub.below_obj)
-     {
-        e_comp_object_map_set(cdata->sub.below_obj, map);
-        e_comp_object_map_enable_set(cdata->sub.below_obj, EINA_TRUE);
-     }
-
    EINA_LIST_FOREACH(cdata->sub.list, l, subc)
      _e_client_transform_sub_apply(subc, ec, zoom);
    EINA_LIST_REVERSE_FOREACH(cdata->sub.below_list, l, subc)
@@ -7263,12 +7240,6 @@ e_client_transform_clear(E_Client *ec)
    e_client_map_enable_set(ec, EINA_FALSE);
    e_client_map_set(ec, NULL);
 
-   if (cdata->sub.below_obj)
-     {
-        e_comp_object_map_enable_set(cdata->sub.below_obj, EINA_FALSE);
-        e_comp_object_map_set(cdata->sub.below_obj, NULL);
-     }
-
    EINA_LIST_FOREACH(cdata->sub.list, l, subc)
      _e_client_transform_sub_apply(subc, ec, 1.0);
    EINA_LIST_REVERSE_FOREACH(cdata->sub.below_list, l, subc)
index 9c2e35bc67192c0f0fc4bcbb8338b49805643c30..45b93beeb3c31cb32d0cd666c44a31ee31275bcd 100644 (file)
@@ -395,6 +395,8 @@ struct _E_Comp_Wl_Client_Data
         Eina_List *below_list;
         Eina_List *below_list_pending;
         Evas_Object *below_obj;
+        E_Map *below_obj_map;
+        E_Client_Hook *below_obj_map_transform_hook;
 
         Eina_Bool restacking : 1;
 
index 8ef8c13a0c87b1e0dbdf85e7b5e2e09cac8966a5..d7e3a6acd7bb193dc8899d76004674bf5ccf3505 100644 (file)
@@ -103,17 +103,72 @@ _e_comp_wl_subsurface_restack(E_Client *ec)
      _e_comp_wl_subsurface_restack(subc);
 }
 
+static void
+_e_comp_wl_subsurface_bg_map_apply(E_Client *ec)
+{
+   E_Map *map = NULL, *new_map = NULL;
+   Eina_Bool enable;
+   int w, h;
+
+   if (e_object_is_del(E_OBJECT(ec))) return;
+   if (!ec->comp_data) return;
+   if (!ec->comp_data->sub.below_obj) return;
+   if (!ec->comp_data->sub.below_obj_map) return;
+
+   e_map_util_points_populate_from_object_full(ec->comp_data->sub.below_obj_map, ec->frame, 0);
+
+   evas_object_geometry_get(ec->comp_data->sub.below_obj, NULL, NULL, &w, &h);
+   e_map_point_image_uv_set(ec->comp_data->sub.below_obj_map, 0, 0, 0);
+   e_map_point_image_uv_set(ec->comp_data->sub.below_obj_map, 1, w, 0);
+   e_map_point_image_uv_set(ec->comp_data->sub.below_obj_map, 2, w, h);
+   e_map_point_image_uv_set(ec->comp_data->sub.below_obj_map, 3, 0, h);
+
+   enable = evas_object_map_enable_get(ec->frame);
+   if (enable)
+     map = e_comp_object_map_get(ec->frame);
+
+   if ((enable) && (map))
+     {
+        new_map = e_map_dup(map);
+        if (!new_map)
+          {
+             ERR("fail to dup e_map ec:%p", ec);
+             e_map_free(map);
+             return;
+          }
+
+        e_map_point_image_uv_set(new_map, 0, 0, 0);
+        e_map_point_image_uv_set(new_map, 1, w, 0);
+        e_map_point_image_uv_set(new_map, 2, w, h);
+        e_map_point_image_uv_set(new_map, 3, 0, h);
+
+        e_comp_object_map_set(ec->comp_data->sub.below_obj, new_map);
+        e_comp_object_map_enable_set(ec->comp_data->sub.below_obj, EINA_TRUE);
+        e_map_free(new_map);
+     }
+   else
+     {
+        e_comp_object_map_set(ec->comp_data->sub.below_obj, ec->comp_data->sub.below_obj_map);
+        e_comp_object_map_enable_set(ec->comp_data->sub.below_obj, EINA_TRUE);
+     }
+
+    if (map) e_map_free(map);
+}
+
 static void
 _e_comp_wl_subsurface_bg_evas_cb_resize(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
 {
    E_Client *ec;
 
    if (!(ec = data)) return;
-   if (e_object_is_del(E_OBJECT(ec))) return;
-   if (!ec->comp_data) return;
 
-   if (ec->comp_data->sub.below_obj)
-     evas_object_resize(ec->comp_data->sub.below_obj, ec->w, ec->h);
+   _e_comp_wl_subsurface_bg_map_apply(ec);
+}
+
+static void
+_e_comp_wl_subsurface_bg_cb_hook_transform_change(void *data, E_Client *ec)
+{
+   _e_comp_wl_subsurface_bg_map_apply(ec);
 }
 
 static void
@@ -127,7 +182,15 @@ _e_comp_wl_subsurface_bg_evas_cb_del(void *data, Evas *evas EINA_UNUSED, Evas_Ob
 
    ec = e_comp_object_client_get(obj);
    if ((ec) && (ec->comp_data))
-     ec->comp_data->sub.below_obj = NULL;
+     {
+        ec->comp_data->sub.below_obj = NULL;
+        if (ec->comp_data->sub.below_obj_map)
+          {
+             e_map_free(ec->comp_data->sub.below_obj_map);
+             ec->comp_data->sub.below_obj_map = NULL;
+          }
+        E_FREE_FUNC(ec->comp_data->sub.below_obj_map_transform_hook, e_client_hook_del);
+     }
 
    evas_object_event_callback_del(obj, EVAS_CALLBACK_DEL,
                                   _e_comp_wl_subsurface_bg_evas_cb_del);
@@ -169,12 +232,21 @@ static void
 _e_comp_wl_subsurface_below_obj_create(E_Client *ec)
 {
    Evas_Object *below_obj;
+   E_Map *below_obj_map;
    short layer;
 
    /* create a bg rectangle if topmost window is 24 depth window */
    below_obj = evas_object_rectangle_add(e_comp->evas);
    EINA_SAFETY_ON_NULL_RETURN(below_obj);
 
+   below_obj_map = e_map_new();
+   if (!below_obj_map)
+     {
+        ERR("Failed to new e_map ec:%p", ec);
+        evas_object_del(below_obj);
+        return;
+     }
+
    /* This object doesn't care about mouse event. And It's also
     * to avoid events of mouse on the E_Client. */
    evas_object_pass_events_set(below_obj, EINA_TRUE);
@@ -188,14 +260,22 @@ _e_comp_wl_subsurface_below_obj_create(E_Client *ec)
     */
    evas_object_color_set(below_obj, 0x00, 0x00, 0x00, 0x00);
    evas_object_move(below_obj, ec->x, ec->y);
-   evas_object_resize(below_obj, ec->w, ec->h);
+   evas_object_resize(below_obj, 1, 1);
    evas_object_name_set(below_obj, "below_bg_rectangle");
 
+   ec->comp_data->sub.below_obj = below_obj;
+
+   ec->comp_data->sub.below_obj_map = below_obj_map;
+   ec->comp_data->sub.below_obj_map_transform_hook =
+      e_client_hook_add(E_CLIENT_HOOK_TRANSFORM_CHANGE,
+                        _e_comp_wl_subsurface_bg_cb_hook_transform_change,
+                        ec);
+
+   _e_comp_wl_subsurface_bg_map_apply(ec);
+
    if (evas_object_visible_get(ec->frame))
      evas_object_show(below_obj);
 
-   ec->comp_data->sub.below_obj = below_obj;
-
    ELOGF("COMP", "         |bg_rectangle(%p) created", ec, below_obj);
 
    evas_object_event_callback_add(ec->frame, EVAS_CALLBACK_RESIZE,