[evas_gl_thread] separates wl_egl_xxX API calls into threads. 94/139494/6
authorJoogab Yun <joogab.yun@samsung.com>
Tue, 27 Jun 2017 04:55:13 +0000 (13:55 +0900)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Wed, 19 Jul 2017 06:54:50 +0000 (06:54 +0000)
Change-Id: I39401708477d682b4ca16735cc6e66e1f036da89

src/lib/evas/common/evas_thread_render.c
src/modules/evas/engines/gl_common/evas_gl_thread_egl.c
src/modules/evas/engines/gl_common/evas_gl_thread_egl.h
src/modules/evas/engines/wayland_egl/Evas_Engine_Wayland_Egl.h
src/modules/evas/engines/wayland_egl/evas_wl_main.c

index 1f473cc..ee3ca4f 100644 (file)
@@ -333,7 +333,7 @@ evas_threads_sw_init(void)
 fail_on_software_thread_init:
   eina_threads_shutdown();
 fail_on_eina_thread_init:
-  return --evas_threads_gl_init_count;
+  return --evas_threads_sw_init_count;
 }
 
 EAPI int
index 21125b2..74d7e2d 100644 (file)
@@ -611,6 +611,61 @@ eglQueryWaylandBuffer_thread_cmd(EGLDisplay dpy, void *buffer, EGLint attribute,
    return thread_data.return_value;
 }
 
+typedef struct
+{
+   void *win;
+   int w, h;
+   int rot, info_rot, window_rotation;
+   int info_edges;
+   WL_EGL_RECONFIG func_reconfig;
+} Evas_Thread_Command_eglWindowReconfig;
+
+static void
+_gl_thread_eglWindowReconfig(void *data)
+{
+  Evas_Thread_Command_eglWindowReconfig *thread_data = data;
+
+  /* set outbuf rotation -> it is screen rotation */
+  if (thread_data->func_reconfig)
+    thread_data->func_reconfig(thread_data->win, thread_data->w, thread_data->h, thread_data->rot, thread_data->info_rot,
+                               thread_data->window_rotation, thread_data->info_edges);
+
+}
+
+
+
+EAPI void
+eglWindowReconfig_thread_cmd(void *win, int w, int h, int rot, int info_rot,
+                             int window_rotation, int info_edges, WL_EGL_RECONFIG fn_wl_egl_reconfig)
+{
+   if (!evas_gl_thread_enabled())
+     {
+       if (fn_wl_egl_reconfig)
+         fn_wl_egl_reconfig(win, w, h, rot, info_rot, window_rotation, info_edges);
+       return;
+     }
+
+   Evas_Thread_Command_eglWindowReconfig thread_data_local;
+   Evas_Thread_Command_eglWindowReconfig *thread_data = &thread_data_local;
+
+   int thread_mode = EVAS_GL_THREAD_MODE_FINISH;
+
+   thread_data->win = win;
+   thread_data->w = w;
+   thread_data->h = h;
+   thread_data->rot = rot;
+   thread_data->info_rot = info_rot;
+   thread_data->window_rotation = window_rotation;
+   thread_data->info_edges = info_edges;
+   thread_data->func_reconfig = fn_wl_egl_reconfig;
+
+
+   evas_gl_thread_cmd_enqueue(EVAS_GL_THREAD_TYPE_GL,
+                              _gl_thread_eglWindowReconfig,
+                              thread_data,
+                              thread_mode);
+
+}
 
 
 /***** EVAS GL *****/
@@ -984,6 +1039,8 @@ void       (*eglQueryWaylandBuffer_orig_evas_set)(void *func);
 void      *(*eglQueryWaylandBuffer_orig_evas_get)();
 EGLBoolean (*eglQueryWaylandBuffer_thread_cmd)(EGLDisplay dpy, void *buffer, EGLint attribute, EGLint *value);
 
+void (*eglWindowReconfig_thread_cmd)(void *win, int w, int h, int rot, int info_rot, int window_rotation, int info_edges, WL_EGL_RECONFIG fn_wl_egl_reconfig);
+
 
 /***** EVAS GL *****/
 
@@ -1035,6 +1092,8 @@ void _egl_thread_link_init()
    LINK2GENERIC(eglQueryWaylandBuffer_orig_evas_get);
    LINK2GENERIC(eglQueryWaylandBuffer_thread_cmd);
 
+   LINK2GENERIC(eglWindowReconfig_thread_cmd);
+
    /***** EVAS GL *****/
 
    LINK2GENERIC(eglGetError_evgl_thread_cmd);
index e70dba8..4341334 100644 (file)
@@ -5,6 +5,9 @@
 
 #include <EGL/egl.h>
 
+
+typedef void (*WL_EGL_RECONFIG)(void *win, int w, int h, int rot, int info_rot, int window_rotation, int info_edges);
+
 #ifdef EVAS_GL_RENDER_THREAD_COMPILE_FOR_GL_GENERIC
 
 
@@ -67,6 +70,8 @@ EAPI void       eglGetProcAddress_orig_evas_set(void *func);
 EAPI void      *eglGetProcAddress_orig_evas_get();
 EAPI void      *eglGetProcAddress_thread_cmd(char const * procname);
 
+EAPI void       eglWindowReconfig_thread_cmd(void *win, int w, int h, int rot, int info_rot, int window_rotation, int info_edges, WL_EGL_RECONFIG fn_wl_egl_reconfig);
+
 /***** EVAS GL *****/
 
 /* EGL 1.4 Referencing to Thread Local Storage */
@@ -113,6 +118,7 @@ extern EGLBoolean (*eglSetDamageRegion_thread_cmd)(EGLDisplay dpy, EGLSurface su
 extern void       (*eglQueryWaylandBuffer_orig_evas_set)(void *func);
 extern void      *(*eglQueryWaylandBuffer_orig_evas_get)();
 extern EGLBoolean (*eglQueryWaylandBuffer_thread_cmd)(EGLDisplay dpy, void *buffer, EGLint attribute, EGLint *value);
+extern void       (*eglWindowReconfig_thread_cmd)(void *win, int w, int h, int rot, int info_rot, int window_rotation, int info_edges, WL_EGL_RECONFIG fn_wl_egl_reconfig);
 
 
 /***** EVAS GL *****/
index 6767e1c..6617b85 100644 (file)
@@ -51,7 +51,7 @@ struct _Evas_Engine_Info_Wayland_Egl
    int           stencil_bits;
    int           msaa_bits;
 
-   int window_rotation;
+   int           window_rotation;
 };
 
 #endif
index e9a9687..acfa20a 100644 (file)
@@ -525,7 +525,45 @@ eng_window_resurf(Outbuf *gw)
    gw->surf = EINA_TRUE;
 }
 
-void 
+void
+_wl_egl_window_reconfig(void *win, int w, int h, int rot, int info_rot, int window_rotation, int info_edges)
+{
+
+  int aw, ah, dx = 0, dy = 0;
+
+  if ((info_rot == 90) || (info_rot == 270))
+    wl_egl_window_get_attached_size(win, &ah, &aw);
+  else
+    wl_egl_window_get_attached_size(win, &aw, &ah);
+
+  if (info_edges & 4) // resize from left
+    {
+       if ((info_rot == 90) || (info_rot == 270))
+         dx = ah - h;
+       else
+         dx = aw - w;
+    }
+
+  if (info_edges & 1) // resize from top
+    {
+       if ((info_rot == 90) || (info_rot == 270))
+         dy = aw - w;
+       else
+         dy = ah - h;
+    }
+
+  /* set outbuf rotation -> it is screen rotation */
+  wl_egl_window_set_buffer_transform(win, rot / 90);
+  wl_egl_window_set_window_transform(win, window_rotation / 90);
+
+  if ((info_rot == 90) || (info_rot == 270))
+    wl_egl_window_resize(win, h, w, dx, dy);
+  else
+    wl_egl_window_resize(win, w, h, dx, dy);
+}
+
+
+void
 eng_outbuf_reconfigure(Outbuf *ob, int w, int h, int rot, Outbuf_Depth depth EINA_UNUSED)
 {
    ob->w = w;
@@ -537,55 +575,18 @@ eng_outbuf_reconfigure(Outbuf *ob, int w, int h, int rot, Outbuf_Depth depth EIN
    glsym_evas_gl_common_context_resize(ob->gl_context, w, h, ob->rot,1);
 
    if (ob->win)
-     {
-        int aw, ah, dx = 0, dy = 0;
-
-        if ((ob->info->info.rotation == 90) || (ob->info->info.rotation == 270))
-          wl_egl_window_get_attached_size(ob->win, &ah, &aw);
-        else
-          wl_egl_window_get_attached_size(ob->win, &aw, &ah);
-
-        if (ob->info->info.edges & 4) // resize from left
-          {
-             if ((ob->info->info.rotation == 90) || (ob->info->info.rotation == 270))
-               dx = ah - h;
-             else
-               dx = aw - w;
-          }
-
-        if (ob->info->info.edges & 1) // resize from top
-          {
-             if ((ob->info->info.rotation == 90) || (ob->info->info.rotation == 270))
-               dy = aw - w;
-             else
-               dy = ah - h;
-          }
-
-        /* buffer_transform: screen rotation + window rotation
-         * window_transform: window rotation only
-         * We have to let the display server know the window rotation value
-         * because the display server needs to calcuate the screen rotation value
-         * from buffer_transform value.
-         */
-        wl_egl_window_set_buffer_transform(ob->win, ob->info->info.rotation / 90);
-        wl_egl_window_set_window_transform(ob->win, ob->info->window_rotation / 90);
-
-        if ((ob->info->info.rotation == 90) || (ob->info->info.rotation == 270))
-          wl_egl_window_resize(ob->win, h, w, dx, dy);
-        else
-          wl_egl_window_resize(ob->win, w, h, dx, dy);
-
-
-     }
+        eglWindowReconfig_thread_cmd(ob->win, w, h,  ob->rot, ob->info->info.rotation,
+                                     ob->info->window_rotation, ob->info->info.edges,
+                                     _wl_egl_window_reconfig);
 }
 
-int 
+int
 eng_outbuf_rotation_get(Outbuf *ob)
 {
    return ob->rot;
 }
 
-Render_Engine_Swap_Mode 
+Render_Engine_Swap_Mode
 eng_outbuf_swap_mode_get(Outbuf *ob)
 {
    if ((ob->swap_mode == MODE_AUTO) && (extn_have_buffer_age))