efl_ui_win: Added frontbuffer mode. 08/289208/3
authorMichal Szczecinski <m.szczecinsk@partner.samsung.com>
Thu, 2 Mar 2023 13:24:16 +0000 (14:24 +0100)
committerMichal Szczecinski <m.szczecinsk@partner.samsung.com>
Fri, 3 Mar 2023 07:33:54 +0000 (08:33 +0100)
Introduced new API:
- elm_win_use_frontbuffer_set(Evas_Object *obj, Eina_Bool
  use_frontbuffer) : setter of internal option.
- Eina_Bool elm_win_use_frontbuffer_get(Evas_Object *obj):
  getter of internal option.
- elm_win_frontbuffer_add()

When use_frontbuffer mode is set wayland engine uses frontbuffer
rendering mode on specified window.

Usage example:

   win = efl_add_ref(EFL_UI_WIN_CLASS, NULL,
                efl_ui_win_name_set(efl_added, "win-example"),
                efl_text_set(efl_added, "Elm_Win Example"),
                elm_win_use_frontbuffer_set(efl_added, EINA_TRUE));

   or:

   win = elm_win_frontbuffer_add(NULL, "win-example", "win-example", ELM_WIN_BASIC);

Change-Id: Ia1b06841f7ced23991d275ac09002bb89efa4fd2

src/lib/ecore_evas/Ecore_Evas.h
src/lib/elementary/efl_ui_win.c
src/lib/elementary/efl_ui_win.eo
src/lib/elementary/elm_win_legacy.h
src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
src/modules/evas/engines/wayland_common/Evas_Engine_Wayland.h
src/modules/evas/engines/wayland_egl/evas_engine.h
src/modules/evas/engines/wayland_egl/evas_wl_main.c

index 9f5681d..79d203f 100755 (executable)
@@ -148,7 +148,10 @@ typedef enum _Ecore_Evas_Engine_Type
 #define ECORE_EVAS_OPT_GL_DEPTH     4
 #define ECORE_EVAS_OPT_GL_STENCIL   5
 #define ECORE_EVAS_OPT_GL_MSAA      6
-#define ECORE_EVAS_OPT_LAST         7
+//TIZEN_ONLY(20230302): Added frontbuffer API
+#define ECORE_EVAS_OPT_FRONTBUFFER  7
+//
+#define ECORE_EVAS_OPT_LAST         8
 
 #define ECORE_EVAS_SWAP_MODE_AUTO   0
 #define ECORE_EVAS_SWAP_MODE_FULL   1
index 77ce9d4..ebc3257 100644 (file)
@@ -224,6 +224,9 @@ struct _Efl_Ui_Win_Data
    Eina_Stringshare *name;
    Eina_Stringshare *accel_pref;
 
+   //TIZEN_ONLY(20230302): Added frontbuffer API
+   Eina_Bool use_frontbuffer;
+
    Eina_Future *finalize_future;
 
    Evas_Object *main_menu;
@@ -6437,6 +6440,13 @@ _elm_win_finalize_internal(Eo *obj, Efl_Ui_Win_Data *sd, const char *name, Efl_U
                   opt[opt_i++] = ECORE_EVAS_OPT_GL_MSAA;
                   opt[opt_i++] = gl_msaa;
                }
+             //TIZEN_ONLY(20230302): Added frontbuffer API
+             if (sd->use_frontbuffer)
+               {
+                  opt[opt_i++] = ECORE_EVAS_OPT_FRONTBUFFER;
+                  opt[opt_i++] = 1;
+               }
+             //
              opt[opt_i] = 0;
 
              if (!strcmp(enginelist[i], ELM_SOFTWARE_X11))
@@ -7129,6 +7139,25 @@ _efl_ui_win_accel_preference_get(const Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *pd)
    return pd->accel_pref;
 }
 
+//TIZEN_ONLY(20230302): Added frontbuffer API
+EOLIAN static void
+_efl_ui_win_use_frontbuffer_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *pd, Eina_Bool use_frontbuffer)
+{
+   if (efl_finalized_get(obj))
+     {
+        ERR("This function is only allowed during construction.");
+        return;
+     }
+   pd->use_frontbuffer = use_frontbuffer;
+}
+
+EOLIAN static Eina_Bool
+_efl_ui_win_use_frontbuffer_get(const Eo *obj, Efl_Ui_Win_Data *pd)
+{
+   return pd->use_frontbuffer;
+}
+//
+
 EOLIAN static void
 _efl_ui_win_win_role_set(Eo *obj EINA_UNUSED, Efl_Ui_Win_Data *sd, const char *role)
 {
@@ -11353,6 +11382,20 @@ elm_win_util_dialog_add(Evas_Object *parent, const char *name, const char *title
    return win;
 }
 
+EAPI Evas_Object *
+elm_win_frontbuffer_add(Evas_Object *parent, const char *name, const char *title, Elm_Win_Type type)
+{
+   Evas_Object *win = NULL;
+
+   win = elm_legacy_add(EFL_UI_WIN_LEGACY_CLASS, parent,
+                        efl_text_set(efl_added, title),
+                        efl_ui_win_name_set(efl_added, name),
+                        efl_ui_win_type_set(efl_added, (Elm_Win_Type)type),
+                        efl_ui_win_use_frontbuffer_set(efl_added, EINA_TRUE));
+
+   _elm_win_standard_init(win);
+   return win;
+}
 
 EAPI void
 elm_win_keyboard_mode_set(Evas_Object *obj, Elm_Win_Keyboard_Mode mode)
@@ -11533,6 +11576,20 @@ elm_win_accel_preference_get(const Evas_Object *obj)
    return efl_ui_win_accel_preference_get(obj);
 }
 
+//TIZEN_ONLY(20230302): Added frontbuffer API
+EAPI const void
+elm_win_use_frontbuffer_set(Evas_Object *obj, Eina_Bool use_frontbuffer)
+{
+   return efl_ui_win_use_frontbuffer_set(obj, use_frontbuffer);
+}
+
+EAPI const Eina_Bool
+elm_win_use_frontbuffer_get(const Evas_Object *obj)
+{
+   return efl_ui_win_use_frontbuffer_get(obj);
+}
+//
+
 EAPI void
 elm_win_alpha_set(Evas_Object *obj, Eina_Bool alpha)
 {
index b31002d..b19111e 100644 (file)
@@ -533,6 +533,26 @@ class Efl.Ui.Win extends Efl.Ui.Widget implements Efl.Canvas.Scene, Efl.Access.W
          get {
          }
       }
+      //TIZEN_ONLY(20220302) Add frontbuffer setter / get_container
+      @property use_frontbuffer {
+         [[The frontbuffer rendering mode used for a window
+
+           If $use_frontbuffer is true, then wayland use frontbuffer rendering mode.
+
+           //TODO: add better description ? mabye from the
+
+           Note: This property is available only for wayland
+         ]]
+         values {
+            use_frontbuffer: bool; [[$true if the window frontbuffer rendering mode is enabled,
+                                     $false otherwise.]]
+         }
+         set {
+         }
+         get {
+         }
+      }
+
       @property alpha {
          [[The alpha channel state of a window.
 
index e74fa49..1a7d8e7 100644 (file)
@@ -276,6 +276,26 @@ EAPI Evas_Object          *elm_win_util_standard_add(const char *name, const cha
 EAPI Evas_Object          *elm_win_util_dialog_add(Evas_Object *parent, const char *name, const char *title);
 
 /**
+ * Adds a window object with frontbuffer setup
+ *
+ * @param parent The parent window
+ * @param name The name of the window
+ * @param title The title for the window
+ * @param type  The type of the window
+ *
+ * This creates a window like elm_win_add() but also setup frontbuffer rendering mode if it is possible.
+ * Currently only wayland support this.
+ *
+ * @return The created object, or @c NULL on failure
+ *
+ * @see elm_win_add()
+ *
+ * @ingroup Elm_Win_Group
+ * @since 1.25
+ */
+EAPI Evas_Object          *elm_win_frontbuffer_add(Evas_Object *parent, const char *name, const char *title, Elm_Win_Type type);
+
+/**
  * @brief Sets the window's autodel state.
  *
  * When closing the window in any way outside of the program control, like
@@ -2124,6 +2144,41 @@ EAPI Elm_Win_Type elm_win_type_get(const Evas_Object *obj);
 EAPI const char *elm_win_accel_preference_get(const Evas_Object *obj);
 
 /**
+ * @brief The frontbuffer preference for this window.
+ *
+ * Note that this option may be used only in wayland
+ *
+ * @param[in] obj       The object.
+ * @param[in] Eina_Bool frontbuffer enabled value
+ *
+ * @since 1.25
+ *
+ * @ingroup Elm_Win_Group
+ */
+EAPI const void elm_win_use_frontbuffer_set(Evas_Object *obj, Eina_Bool use_frontbuffer);
+
+/**
+ * @brief The frontbuffer preference for this window.
+ *
+ * This is a constructor function and can only be called before
+ * @ref Efl.Object.finalize.
+ *
+ * Note that this option may be used only in wayland
+ *
+ * This will return the value of "use_frontbuffer" when the window was
+ * created.
+ *
+ * @param[in] obj The object.
+ *
+ * @return Eina_Bool
+ *
+ * @since 1.25
+ *
+ * @ingroup Elm_Win_Group
+ */
+EAPI const Eina_Bool elm_win_use_frontbuffer_get(const Evas_Object *obj);
+
+/**
  * @brief Set the alpha channel state of a window.
  *
  * If @c alpha is true, the alpha channel of the canvas will be enabled
index 7a8ccc1..4cc571c 100644 (file)
@@ -4156,7 +4156,7 @@ _ecore_evas_wl_common_new_internal(const char *disp_name, Ecore_Window parent, i
 
    ee->driver = engine_name;
    if (disp_name) ee->name = strdup(disp_name);
-   
+
 //TIZEN_ONLY(20171228): set default size of ecore_evas
    if (w < 1) w = 1;
    if (h < 1) h = 1;
@@ -4246,6 +4246,13 @@ _ecore_evas_wl_common_new_internal(const char *disp_name, Ecore_Window parent, i
                             op++;
                             einfo->msaa_bits = opt[op];
                          }
+                       //TIZEN_ONLY(20230301): support frontbuffer surface
+                       else if (opt[op] == ECORE_EVAS_OPT_FRONTBUFFER)
+                         {
+                            op++;
+                            einfo->use_frontbuffer = opt[op];
+                         }
+                       //
                     }
                }
 
index 23c7f02..42afa19 100755 (executable)
@@ -41,6 +41,9 @@ struct _Evas_Engine_Info_Wayland
    int stencil_bits;
    int msaa_bits;
 
+   //TIZEN_ONLY(20230301): support frontbuffer surface
+   Eina_Bool use_frontbuffer;
+
    //TIZEN_ONLY(20171115): support output transform
    int window_rotation;
 
index 9521e0f..0f68a0a 100755 (executable)
@@ -91,6 +91,9 @@ struct _Outbuf
    int stencil_bits;
    int msaa_bits;
 
+   //TIZEN_ONLY(20230302): Added frontbuffer API
+   Eina_Bool use_frontbuffer;
+
    //TIZEN_ONLY(20161121) : Support PreRotation
    int support_pre_rotation;
 
index a11c9d5..bbeef45 100755 (executable)
@@ -122,6 +122,9 @@ eng_window_new(Evas_Engine_Info_Wayland *einfo, int w, int h, Render_Output_Swap
    gw->stencil_bits = einfo->stencil_bits;
    gw->msaa_bits = einfo->msaa_bits;
 
+   //TIZEN_ONLY(20230302): Added frontbuffer API
+   gw->use_frontbuffer = einfo->use_frontbuffer;
+
 //
 //TIZEN_ONLY(20161121):Support PreRotation
    gw->support_pre_rotation = 0;
@@ -263,6 +266,11 @@ try_again:
   gw->egl_surface =
       eglCreateWindowSurface(gw->egl_disp, gw->egl_config,
                              (EGLNativeWindowType)gw->win, NULL);
+
+//TIZEN_ONLY(20230302): Added frontbuffer API
+  if (gw->use_frontbuffer)
+    wl_egl_window_tizen_set_frontbuffer_mode((EGLNativeWindowType)gw->win, 1);
+
   if (gw->egl_surface == EGL_NO_SURFACE)
     {
       ERR("eglCreateWindowSurface() fail for %p. code=%#x",