e_comp_object: make the frame object transparent when it is unredirected 07/292107/1
authorChangyeon Lee <cyeon.lee@samsung.com>
Mon, 24 Apr 2023 07:58:13 +0000 (16:58 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Thu, 27 Apr 2023 07:52:26 +0000 (16:52 +0900)
glTexImage2D is called in next render if the frame object is redirected
because it does not have native buffer and it is visible.

we makes the frame object transparent and evas does not render
the frame object.(glTexImage2D is not called)

this patch optimizes gpu memory usage.

Change-Id: I73a99ec8039d3093d7f1fad8edd40a21d951a00f

src/bin/e_comp_object.c
src/bin/e_hwc_windows.c

index 6115cf6..332692e 100644 (file)
@@ -177,6 +177,15 @@ typedef struct _E_Comp_Object
         Eina_Bool            pending_resize_set;
         int                  pending_resize_w, pending_resize_h;
      } render_update_lock;
+
+   struct
+     {
+        Eina_Bool        set;
+        int              user_r;
+        int              user_g;
+        int              user_b;
+        int              user_a;
+     } transparent;
 } E_Comp_Object;
 
 typedef struct _E_Input_Rect_Data
@@ -2782,6 +2791,23 @@ _e_comp_intercept_focus(void *data, Evas_Object *obj, Eina_Bool focus)
    evas_object_focus_set(obj, focus);
 }
 
+static void
+_e_comp_intercept_color_set(void *data, Evas_Object *obj, int r, int g, int b, int a)
+{
+   E_Comp_Object *cw = data;
+
+   if (cw->transparent.set)
+     {
+        cw->transparent.user_r = r;
+        cw->transparent.user_g = g;
+        cw->transparent.user_b = b;
+        cw->transparent.user_a = a;
+     }
+   else
+     {
+        evas_object_color_set(obj, r, g, b, a);
+     }
+}
 ////////////////////////////////////////////////////
 
 static void
@@ -3205,6 +3231,7 @@ _e_comp_smart_add(Evas_Object *obj)
    evas_object_intercept_show_callback_add(obj, _e_comp_intercept_show, cw);
    evas_object_intercept_hide_callback_add(obj, _e_comp_intercept_hide, cw);
    evas_object_intercept_focus_set_callback_add(obj, _e_comp_intercept_focus, cw);
+   evas_object_intercept_color_set_callback_add(obj, _e_comp_intercept_color_set, cw);
 
    evas_object_smart_callback_add(obj, "shading", _e_comp_smart_cb_shading, cw);
    evas_object_smart_callback_add(obj, "shaded", _e_comp_smart_cb_shaded, cw);
@@ -4744,6 +4771,56 @@ _e_comp_object_clear(E_Comp_Object *cw)
    e_comp_object_render_update_del(cw->smart_obj);
 }
 
+static Eina_Bool
+_e_comp_object_transparent_set(Evas_Object *obj, Eina_Bool set)
+{
+    int r, g, b, a;
+
+    API_ENTRY EINA_FALSE;
+
+    if (cw->transparent.set == set)
+       return EINA_TRUE;
+
+    if (set)
+      {
+         evas_object_color_get(obj, &r, &g, &b, &a);
+         evas_object_color_set(obj, 0, 0, 0, 0);
+
+         cw->transparent.user_r = r;
+         cw->transparent.user_g = g;
+         cw->transparent.user_b = b;
+         cw->transparent.user_a = a;
+
+         ELOGF("COMP", "Transparent enabled user_color(%d,%d,%d,%d)",
+               cw->ec,
+               cw->transparent.user_r,
+               cw->transparent.user_g,
+               cw->transparent.user_b,
+               cw->transparent.user_a);
+
+         cw->transparent.set = EINA_TRUE;
+      }
+    else
+      {
+         cw->transparent.set = EINA_FALSE;
+
+         evas_object_color_set(obj,
+                               cw->transparent.user_r,
+                               cw->transparent.user_g,
+                               cw->transparent.user_b,
+                               cw->transparent.user_a);
+
+         ELOGF("COMP", "Transparent disabled user_color(%d,%d,%d,%d)",
+               cw->ec,
+               cw->transparent.user_r,
+               cw->transparent.user_g,
+               cw->transparent.user_b,
+               cw->transparent.user_a);
+      }
+
+   return EINA_TRUE;
+}
+
 /* helper function to simplify toggling of redirection for display servers which support it */
 E_API void
 e_comp_object_redirected_set(Evas_Object *obj, Eina_Bool set)
@@ -4763,11 +4840,14 @@ e_comp_object_redirected_set(Evas_Object *obj, Eina_Bool set)
           e_comp_object_render_update_add(obj);
         else
           e_comp_object_damage(obj, 0, 0, cw->w, cw->h);
+
+        _e_comp_object_transparent_set(obj, EINA_FALSE);
         evas_object_smart_callback_call(obj, "redirected", NULL);
      }
    else
      {
         _e_comp_object_clear(cw);
+        _e_comp_object_transparent_set(obj, EINA_TRUE);
         evas_object_smart_callback_call(obj, "unredirected", NULL);
      }
 }
index e533669..8674aed 100644 (file)
@@ -1162,7 +1162,8 @@ _e_hwc_windows_visible_windows_list_get(E_Hwc *hwc)
 
         e_client_geometry_get(ec, &x, &y, &w, &h);
 
-        if ((!effect_client) && (!e_comp_object_color_visible_get(ec->frame)))
+        if ((!effect_client) &&
+            (e_comp_object_redirected_get(ec->frame) && !e_comp_object_color_visible_get(ec->frame)))
           {
              e_hwc_window_state_set(hwc_window, E_HWC_WINDOW_STATE_NONE, EINA_TRUE);