e_comp_screen: move evas code from e_comp_wl to e_comp_screen
authorSooChan Lim <sc1.lim@samsung.com>
Tue, 10 Dec 2024 11:21:28 +0000 (20:21 +0900)
committerJunseok Kim <juns.kim@samsung.com>
Fri, 13 Dec 2024 05:15:52 +0000 (14:15 +0900)
Change-Id: I81b3212e63955015004edce4e21a36e10dabc5f1

src/bin/compmgr/e_comp.c
src/bin/compmgr/e_comp_intern.h
src/bin/e_comp_screen.c
src/bin/e_comp_screen_intern.h
src/bin/e_main.c
src/bin/server/e_comp_wl.c
src/bin/server/e_comp_wl_intern.h
src/include/e_comp_wl.h

index ff235f2dd0017f931fb5792aa14918c1b9105408..53d9b3fb4d88f1f77b60049ca09580ef425db15d 100644 (file)
@@ -410,14 +410,6 @@ e_comp_shutdown(void)
    return 1;
 }
 
-EINTERN void
-e_comp_deferred_job(void)
-{
-   e_main_ts_begin("\tE_Comp_Wl_Deferred");
-   e_comp_wl_deferred_job();
-   e_main_ts_end("\tE_Comp_Wl_Deferred Done");
-}
-
 E_API void
 e_comp_render_queue(void)
 {
index e129876fa1d4d0bc9f3d9705c4dfb471f2985f6a..f4baa2ec2fbdcd662b97dab600356221da25b907 100644 (file)
@@ -11,7 +11,6 @@ EINTERN E_Comp       *e_comp_new(void);
 EINTERN E_Comp       *e_comp_get(void);
 
 EINTERN int           e_comp_internal_save(void);
-EINTERN void          e_comp_deferred_job(void);
 EINTERN void          e_comp_client_post_update_add(E_Client *ec);
 EINTERN void          e_comp_util_wins_print(void);
 EINTERN void          e_comp_ignore_win_add(E_Pixmap_Type type, Ecore_Window win);
index d09ff04135b52138c2fe0a569df7ba7d6e57c78a..4ebb9428485634e6e37191e0d12f0b2aec02b782 100644 (file)
 #include <tizen-extension-server-protocol.h>
 #include <tbm_bufmgr_internal.h>
 #include <gbm.h>
+#include <Evas_GL.h>
 
 #define PATH "/org/enlightenment/wm"
 #define IFACE "org.enlightenment.wm.screen_rotation"
 
+typedef struct _E_Comp_Wl_Evas_Gl E_Comp_Wl_Evas_Gl;
+
+struct _E_Comp_Wl_Evas_Gl
+{
+   Evas_GL *gl;
+   Evas_GL_Config *glcfg;
+   Evas_GL_Context *glctx;
+   Evas_GL_Surface *glsfc;
+   Evas_GL_API *glapi;
+};
+
 static Eina_List *g_policy_zones;
 
 static Ecore_Event_Handler *dbus_init_done_handler;
@@ -56,6 +68,104 @@ enum
 static void _e_comp_screen_e_screens_setup(E_Comp_Screen *e_comp_screen, int rw, int rh);
 static void _e_comp_screen_screen_policy_update(void);
 
+static void
+_e_comp_screen_gl_shutdown(E_Comp_Screen *e_comp_screen)
+{
+   if (!e_comp_screen->evas_gl) return;
+
+   if (e_comp_screen->evas_gl->glapi->evasglUnbindWaylandDisplay)
+     e_comp_screen->evas_gl->glapi->evasglUnbindWaylandDisplay(e_comp_screen->evas_gl->gl, e_comp_screen->wl_display);
+
+   evas_gl_make_current(e_comp_screen->evas_gl->gl, NULL, NULL);
+   evas_gl_context_destroy(e_comp_screen->evas_gl->gl, e_comp_screen->evas_gl->glctx);
+   evas_gl_surface_destroy(e_comp_screen->evas_gl->gl, e_comp_screen->evas_gl->glsfc);
+   evas_gl_free(e_comp_screen->evas_gl->gl);
+
+   E_FREE(e_comp_screen->evas_gl);
+}
+
+static void
+_e_comp_screen_gl_init(E_Comp_Screen *e_comp_screen)
+{
+   Evas *evas = NULL;
+   Evas_GL *evasgl = NULL;
+   Evas_GL_API *glapi = NULL;
+   Evas_GL_Context *ctx = NULL;
+   Evas_GL_Surface *sfc = NULL;
+   Evas_GL_Config *cfg = NULL;
+   Eina_Bool res;
+   E_Comp_Wl_Evas_Gl *evas_gl = NULL;
+   E_Comp *comp;
+
+   evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
+   EINA_SAFETY_ON_NULL_RETURN(evas_gl);
+
+   /* create dummy evas gl to bind wayland display of enlightenment to egl display */
+   e_main_ts_begin("\tE_Comp_Wl_GL Init");
+
+   /* if wl_drm module doesn't call e_comp_canvas_init yet,
+    * then we should get evas from ecore_evas.
+    */
+   comp = e_comp_get();
+   if (comp->evas)
+     evas = comp->evas;
+   else
+     evas = ecore_evas_get(comp->ee);
+
+   evasgl = evas_gl_new(evas);
+   EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
+
+   glapi = evas_gl_api_get(evasgl);
+   EINA_SAFETY_ON_NULL_GOTO(glapi, err);
+
+   if (!glapi->evasglBindWaylandDisplay)
+     {
+        evas_gl_free(evasgl);
+        free(evas_gl);
+        comp->gl = 1;
+        e_main_ts_end("\tE_Comp_Wl_GL Init Done");
+        return;
+     }
+
+   cfg = evas_gl_config_new();
+   EINA_SAFETY_ON_NULL_GOTO(cfg, err);
+
+   sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
+   EINA_SAFETY_ON_NULL_GOTO(sfc, err);
+
+   ctx = evas_gl_context_create(evasgl, NULL);
+   EINA_SAFETY_ON_NULL_GOTO(ctx, err);
+
+   res = evas_gl_make_current(evasgl, sfc, ctx);
+   EINA_SAFETY_ON_FALSE_GOTO(res, err);
+
+   res = glapi->evasglBindWaylandDisplay(evasgl, e_comp_screen->wl_display);
+   EINA_SAFETY_ON_FALSE_GOTO(res, err);
+
+   evas_gl_config_free(cfg);
+
+   evas_gl->gl = evasgl;
+   evas_gl->glapi = glapi;
+   evas_gl->glsfc = sfc;
+   evas_gl->glctx = ctx;
+
+   e_comp_screen->evas_gl = evas_gl;
+
+   /* for native surface */
+   comp->gl = 1;
+
+   e_main_ts_end("\tE_Comp_Wl_GL Init Done");
+
+   return;
+
+err:
+   evas_gl_config_free(cfg);
+   evas_gl_make_current(evasgl, NULL, NULL);
+   evas_gl_context_destroy(evasgl, ctx);
+   evas_gl_surface_destroy(evasgl, sfc);
+   evas_gl_free(evasgl);
+   free(evas_gl);
+}
 
 static Eldbus_Message *
 _e_comp_screen_dbus_get_cb(const Eldbus_Service_Interface *iface, const Eldbus_Message *msg)
@@ -867,6 +977,12 @@ e_comp_screen_init()
      }
    e_main_ts_end("\tE_Server Init Done");
 
+   comp_wl = e_comp_wl_get();
+   e_comp_screen->wl_display = comp_wl->wl.disp;
+
+   if (e_comp_gl_get())
+     _e_comp_screen_gl_init(e_comp_screen);
+
    /* e_comp_screen_setup */
    if (!_e_comp_screen_screen_policy_setup())
      {
@@ -876,7 +992,6 @@ e_comp_screen_init()
 
    /* pointer */
    e_input_device_pointer_xy_get(NULL, &ptr_x, &ptr_y);
-   comp_wl = e_comp_wl_get();
    comp_wl->ptr.x = wl_fixed_from_int(ptr_x);
    comp_wl->ptr.y = wl_fixed_from_int(ptr_y);
 
@@ -944,6 +1059,8 @@ e_comp_screen_shutdown()
    E_Comp_Screen *e_comp_screen = e_comp_screen_get();
    if (!e_comp_screen) return;
 
+   _e_comp_screen_gl_shutdown(e_comp_screen);
+
    if (e_comp_screen_iface)
      {
         eldbus_service_interface_unregister(e_comp_screen_iface);
index 958eaf6b5922b426cc394e4eff6bce4ac9708a42..371176eb5b587b5c6213242fd70674f551801e57 100644 (file)
@@ -8,6 +8,7 @@
 #include <Eldbus.h>
 
 typedef struct _E_Screen        E_Screen;
+typedef struct _E_Comp_Wl_Evas_Gl E_Comp_Wl_Evas_Gl;
 
 struct _E_Comp_Screen
 {
@@ -39,6 +40,9 @@ struct _E_Comp_Screen
    Eina_Bool  pp_enabled;
    Eina_List *available_pp_formats;
 
+   E_Comp_Wl_Evas_Gl *evas_gl;
+   void *wl_display;
+
    int fd;
    Ecore_Fd_Handler *hdlr;
 };
index 761c20e00cb01f5dadbfdc869b451da0e8399a01..b8e79175b0456c096467eebd6a737c569b42a3d3 100644 (file)
@@ -293,11 +293,6 @@ _e_main_subsystem_defer(void *data EINA_UNUSED)
    TRACE_DS_END();
    TRACE_DS_BEGIN(MAIN:DEFERRED COMP JOB);
 
-   /* try to do deferred job of any subsystems*/
-   TSB("[DEFERRED] Compositor's deferred job");
-   e_comp_deferred_job();
-   TSE("[DEFERRED] Compositor's deferred job Done");
-
    if (e_config->use_e_policy)
      {
         TSB("[DEFERRED] E_Policy's deferred job");
index 68dd0fe07c1e0ab55f42f9276edcd86d318a2cdb..f76f49bf88e053860e3238b53e973aa8374da51f 100644 (file)
@@ -56,7 +56,6 @@
 #include <glib.h>
 #include <libds/log.h>
 #include <libds/single_pixel_buffer_v1.h>
-#include <Evas_GL.h>
 
  #include <ctype.h>
  #include <sys/resource.h>
@@ -93,15 +92,6 @@ typedef struct _E_Comp_Wl_Key_Data
    Ecore_Device *dev;
 } E_Comp_Wl_Key_Data;
 
-struct _E_Comp_Wl_Evas_Gl
-{
-   Evas_GL *gl;
-   Evas_GL_Config *glcfg;
-   Evas_GL_Context *glctx;
-   Evas_GL_Surface *glsfc;
-   Evas_GL_API *glapi;
-};
-
 static Eina_List *handlers = NULL;
 static E_Client *cursor_timer_ec = NULL;
 static Eina_Bool need_send_released = EINA_FALSE;
@@ -3585,97 +3575,6 @@ send_info:
    _e_comp_wl_output_info_send(output, resource, pid, res_w, res_h);
 }
 
-static void
-_e_comp_wl_gl_init(E_Comp_Wl_Data *comp_wl)
-{
-   Evas *evas = NULL;
-   Evas_GL *evasgl = NULL;
-   Evas_GL_API *glapi = NULL;
-   Evas_GL_Context *ctx = NULL;
-   Evas_GL_Surface *sfc = NULL;
-   Evas_GL_Config *cfg = NULL;
-   Eina_Bool res;
-   E_Comp_Wl_Evas_Gl *evas_gl = NULL;
-   E_Comp *comp;
-
-   if (!e_comp_gl_get()) return;
-
-   evas_gl = E_NEW(E_Comp_Wl_Evas_Gl, 1);
-   EINA_SAFETY_ON_NULL_RETURN(evas_gl);
-
-   /* create dummy evas gl to bind wayland display of enlightenment to egl display */
-   e_main_ts_begin("\tE_Comp_Wl_GL Init");
-
-   /* if wl_drm module doesn't call e_comp_canvas_init yet,
-    * then we should get evas from ecore_evas.
-    */
-   comp = e_comp_get();
-   if (comp->evas)
-     evas = comp->evas;
-   else
-     evas = ecore_evas_get(comp->ee);
-
-   evasgl = evas_gl_new(evas);
-   EINA_SAFETY_ON_NULL_GOTO(evasgl, err);
-
-   glapi = evas_gl_api_get(evasgl);
-   EINA_SAFETY_ON_NULL_GOTO(glapi, err);
-
-   if (!glapi->evasglBindWaylandDisplay)
-     {
-        evas_gl_free(evasgl);
-        free(evas_gl);
-        comp->gl = 1;
-        e_main_ts_end("\tE_Comp_Wl_GL Init Done");
-        return;
-     }
-
-   cfg = evas_gl_config_new();
-   EINA_SAFETY_ON_NULL_GOTO(cfg, err);
-
-   sfc = evas_gl_surface_create(evasgl, cfg, 1, 1);
-   EINA_SAFETY_ON_NULL_GOTO(sfc, err);
-
-   ctx = evas_gl_context_create(evasgl, NULL);
-   EINA_SAFETY_ON_NULL_GOTO(ctx, err);
-
-   res = evas_gl_make_current(evasgl, sfc, ctx);
-   EINA_SAFETY_ON_FALSE_GOTO(res, err);
-
-   res = glapi->evasglBindWaylandDisplay(evasgl, comp_wl->wl.disp);
-   EINA_SAFETY_ON_FALSE_GOTO(res, err);
-
-   evas_gl_config_free(cfg);
-
-   evas_gl->gl = evasgl;
-   evas_gl->glapi = glapi;
-   evas_gl->glsfc = sfc;
-   evas_gl->glctx = ctx;
-
-   comp_wl->evas_gl = evas_gl;
-
-   /* for native surface */
-   comp->gl = 1;
-
-   e_main_ts_end("\tE_Comp_Wl_GL Init Done");
-
-   return;
-
-err:
-   evas_gl_config_free(cfg);
-   evas_gl_make_current(evasgl, NULL, NULL);
-   evas_gl_context_destroy(evasgl, ctx);
-   evas_gl_surface_destroy(evasgl, sfc);
-   evas_gl_free(evasgl);
-   free(evas_gl);
-}
-
-static Eina_Bool
-_e_comp_wl_gl_idle(void *data)
-{
-   return ECORE_CALLBACK_CANCEL;
-}
-
 static void
 _e_comp_wl_cb_client_created(struct wl_listener *listener, void *data)
 {
@@ -3785,10 +3684,6 @@ _e_comp_wl_display_create(void)
    comp_data->client_created.notify = _e_comp_wl_cb_client_created;
    wl_display_add_client_created_listener(comp_data->base.wl.disp, &comp_data->client_created);
 
-   // TODO: this function has to move to compmgr module
-   if (e_comp_gl_get())
-     _e_comp_wl_gl_init(comp_wl);
-
    /* create a listener for wayland main loop events */
    comp_wl->fd_hdlr =
      ecore_main_fd_handler_add(fd, (ECORE_FD_READ | ECORE_FD_ERROR),
@@ -3813,22 +3708,6 @@ disp_err:
    return NULL;
 }
 
-static void
-_e_comp_wl_gl_shutdown(E_Comp_Wl_Data *comp_wl)
-{
-   if (!comp_wl->evas_gl) return;
-
-   if (comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay)
-     comp_wl->evas_gl->glapi->evasglUnbindWaylandDisplay(comp_wl->evas_gl->gl, comp_wl->wl.disp);
-
-   evas_gl_make_current(comp_wl->evas_gl->gl, NULL, NULL);
-   evas_gl_context_destroy(comp_wl->evas_gl->gl, comp_wl->evas_gl->glctx);
-   evas_gl_surface_destroy(comp_wl->evas_gl->gl, comp_wl->evas_gl->glsfc);
-   evas_gl_free(comp_wl->evas_gl->gl);
-
-   E_FREE(comp_wl->evas_gl);
-}
-
 static void
 _e_comp_wl_cb_input_thread_start(void *data, const char *device_name)
 {
@@ -3914,12 +3793,6 @@ e_comp_wl_init(void)
    return comp_wl;
 }
 
-EINTERN void
-e_comp_wl_deferred_job(void)
-{
-   ecore_idle_enterer_add(_e_comp_wl_gl_idle, NULL);
-}
-
 /* internal functions */
 EINTERN void
 e_comp_wl_shutdown(void)
@@ -3936,7 +3809,6 @@ e_comp_wl_shutdown(void)
      e_input_hook_del(input_hook);
 
    e_comp_wl_input_thread_remove_e_input_handlers();
-   _e_comp_wl_gl_shutdown(e_comp_wl);
 
    e_comp_wl_capture_shutdown();
 
index 40964f40e14686d6312cba4dfe7786175a058fd8..3340d0b0761ca5bbf344ef0274f4e1c9595029cb 100644 (file)
@@ -12,8 +12,6 @@ EINTERN E_Comp_Wl_Data *e_comp_wl_init(void);
 EINTERN void            e_comp_wl_shutdown(void);
 EINTERN E_Comp_Wl_Data *e_comp_wl_get(void);
 
-EINTERN void e_comp_wl_deferred_job(void);
-
 EINTERN void      e_comp_wl_surface_destroy(struct wl_resource *resource);
 EINTERN void      e_comp_wl_surface_attach(E_Client *ec, E_Comp_Wl_Buffer *buffer);
 EINTERN Eina_Bool e_comp_wl_surface_commit(E_Client *ec);
index 3ad5ce4ceb005da033620e353d74e3591cc3427e..b3f62b0bc86f5e42b584578aa9bc5ed6d3e2fe94 100644 (file)
@@ -58,7 +58,6 @@ typedef struct _E_Comp_Wl_Shell_Surface_Api E_Comp_Wl_Shell_Surface_Api;
 typedef struct _E_Comp_Wl_Data E_Comp_Wl_Data;
 typedef struct _E_Comp_Wl_Output E_Comp_Wl_Output;
 typedef struct _E_Comp_Wl_Intercept_Hook E_Comp_Wl_Intercept_Hook;
-typedef struct _E_Comp_Wl_Evas_Gl E_Comp_Wl_Evas_Gl;
 typedef struct _E_Comp_Wl_Pointer_Constraint E_Comp_Wl_Pointer_Constraint;
 
 typedef enum _E_Comp_Wl_Buffer_Type
@@ -397,8 +396,6 @@ struct _E_Comp_Wl_Data
    void *drag_offer;
    int drag_device_id; // Ecore_Event_Mouse_Move.multi.device
 
-   E_Comp_Wl_Evas_Gl *evas_gl;
-
    double idle_exiter_timestamp;
 };