evas-wl-egl: set depth/stencil/msaa bit to window surface 62/52462/3 accepted/tizen/mobile/20151208.123515 accepted/tizen/tv/20151208.123533 accepted/tizen/wearable/20151208.123546 submit/tizen/20151207.075741
authorDaeKwang Ryu <dkdk.ryu@samsung.com>
Mon, 23 Nov 2015 07:44:25 +0000 (16:44 +0900)
committerDaeKwang Ryu <dkdk.ryu@samsung.com>
Mon, 7 Dec 2015 05:06:11 +0000 (14:06 +0900)
This is for wayland_egl backend.

please refer https://phab.enlightenment.org/D2144

Change-Id: Ifd88dc50ef335013e33c1e123acb8a19182f5646

src/lib/ecore_evas/Ecore_Evas.h
src/lib/ecore_evas/ecore_evas.c
src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_egl.c
src/modules/evas/engines/wayland_egl/Evas_Engine_Wayland_Egl.h
src/modules/evas/engines/wayland_egl/evas_engine.c
src/modules/evas/engines/wayland_egl/evas_engine.h
src/modules/evas/engines/wayland_egl/evas_wl_main.c

index 1a035ab..56183e0 100644 (file)
@@ -149,6 +149,22 @@ typedef enum _Ecore_Evas_Object_Associate_Flags
   ECORE_EVAS_OBJECT_ASSOCIATE_DEL = 1 << 2
 } Ecore_Evas_Object_Associate_Flags;
 
+#define ECORE_EVAS_OPT_NONE         0
+#define ECORE_EVAS_OPT_INDIRECT     1
+#define ECORE_EVAS_OPT_VSYNC        2
+#define ECORE_EVAS_OPT_SWAP_MODE    3
+#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
+
+#define ECORE_EVAS_SWAP_MODE_AUTO      0
+#define ECORE_EVAS_SWAP_MODE_FULL      1
+#define ECORE_EVAS_SWAP_MODE_COPY      2
+#define ECORE_EVAS_SWAP_MODE_DOUBLE    3
+#define ECORE_EVAS_SWAP_MODE_TRIPLE    4
+#define ECORE_EVAS_SWAP_MODE_QUADRUPLE 5
+
 /* module setup/shutdown calls */
 
 EAPI int         ecore_evas_engine_type_supported_get(Ecore_Evas_Engine_Type engine);
@@ -1174,20 +1190,20 @@ EAPI Ecore_Evas     *ecore_evas_software_x11_pixmap_new(const char *disp_name, E
  */
 EAPI Ecore_X_Pixmap ecore_evas_software_x11_pixmap_get(const Ecore_Evas *ee);
 
-#define ECORE_EVAS_GL_X11_OPT_NONE         0
-#define ECORE_EVAS_GL_X11_OPT_INDIRECT     1
-#define ECORE_EVAS_GL_X11_OPT_VSYNC        2
-#define ECORE_EVAS_GL_X11_OPT_SWAP_MODE    3
-#define ECORE_EVAS_GL_X11_OPT_GL_DEPTH     4
-#define ECORE_EVAS_GL_X11_OPT_GL_STENCIL   5
-#define ECORE_EVAS_GL_X11_OPT_GL_MSAA      6
-#define ECORE_EVAS_GL_X11_OPT_LAST         7
+#define ECORE_EVAS_GL_X11_OPT_NONE         ECORE_EVAS_OPT_NONE
+#define ECORE_EVAS_GL_X11_OPT_INDIRECT     ECORE_EVAS_OPT_INDIRECT
+#define ECORE_EVAS_GL_X11_OPT_VSYNC        ECORE_EVAS_OPT_VSYNC
+#define ECORE_EVAS_GL_X11_OPT_SWAP_MODE    ECORE_EVAS_OPT_SWAP_MODE
+#define ECORE_EVAS_GL_X11_OPT_GL_DEPTH     ECORE_EVAS_OPT_GL_DEPTH
+#define ECORE_EVAS_GL_X11_OPT_GL_STENCIL   ECORE_EVAS_OPT_GL_STENCIL
+#define ECORE_EVAS_GL_X11_OPT_GL_MSAA      ECORE_EVAS_OPT_GL_MSAA
+#define ECORE_EVAS_GL_X11_OPT_LAST         ECORE_EVAS_OPT_LAST
 
-#define ECORE_EVAS_GL_X11_SWAP_MODE_AUTO   0
-#define ECORE_EVAS_GL_X11_SWAP_MODE_FULL   1
-#define ECORE_EVAS_GL_X11_SWAP_MODE_COPY   2
-#define ECORE_EVAS_GL_X11_SWAP_MODE_DOUBLE 3
-#define ECORE_EVAS_GL_X11_SWAP_MODE_TRIPLE 4
+#define ECORE_EVAS_GL_X11_SWAP_MODE_AUTO   ECORE_EVAS_SWAP_MODE_AUTO
+#define ECORE_EVAS_GL_X11_SWAP_MODE_FULL   ECORE_EVAS_SWAP_MODE_FULL
+#define ECORE_EVAS_GL_X11_SWAP_MODE_COPY   ECORE_EVAS_SWAP_MODE_COPY
+#define ECORE_EVAS_GL_X11_SWAP_MODE_DOUBLE ECORE_EVAS_SWAP_MODE_DOUBLE
+#define ECORE_EVAS_GL_X11_SWAP_MODE_TRIPLE ECORE_EVAS_SWAP_MODE_TRIPLE
 
 /**
  * @brief Create Ecore_Evas using opengl x11.
@@ -1310,6 +1326,7 @@ EAPI Ecore_DirectFB_Window *ecore_evas_directfb_window_get(const Ecore_Evas *ee)
 
 EAPI Ecore_Evas     *ecore_evas_wayland_shm_new(const char *disp_name, unsigned int parent, int x, int y, int w, int h, Eina_Bool frame);
 EAPI Ecore_Evas     *ecore_evas_wayland_egl_new(const char *disp_name, unsigned int parent, int x, int y, int w, int h, Eina_Bool frame);
+EAPI Ecore_Evas     *ecore_evas_wayland_egl_options_new(const char *disp_name, unsigned int parent, int x, int y, int w, int h, Eina_Bool frame, const int *opt);
 EAPI void            ecore_evas_wayland_resize(Ecore_Evas *ee, int location);
 EAPI void            ecore_evas_wayland_move(Ecore_Evas *ee, int x, int y);
 
index 8a2a955..f6ee321 100644 (file)
@@ -3991,6 +3991,20 @@ ecore_evas_wayland_egl_new(const char *disp_name, unsigned int parent,
    return new(disp_name, parent, x, y, w, h, frame);
 }
 
+EAPI Ecore_Evas *
+ecore_evas_wayland_egl_options_new(const char *disp_name, unsigned int parent,
+                              int x, int y, int w, int h, Eina_Bool frame, const int *opt)
+{
+   Ecore_Evas *(*new)(const char *, unsigned int, int, int, int, int, Eina_Bool, const int *);
+   Eina_Module *m = _ecore_evas_engine_load("wayland");
+   EINA_SAFETY_ON_NULL_RETURN_VAL(m, NULL);
+
+   new = eina_module_symbol_get(m, "ecore_evas_wayland_egl_options_new_internal");
+   EINA_SAFETY_ON_NULL_RETURN_VAL(new, NULL);
+
+   return new(disp_name, parent, x, y, w, h, frame, opt);
+}
+
 EAPI void
 ecore_evas_wayland_resize(Ecore_Evas *ee, int location)
 {
index c7d3d8c..8c4b49e 100644 (file)
@@ -116,8 +116,8 @@ static Ecore_Evas_Engine_Func _ecore_wl_engine_func =
 
 /* external functions */
 EAPI Ecore_Evas *
-ecore_evas_wayland_egl_new_internal(const char *disp_name, unsigned int parent,
-                                     int x, int y, int w, int h, Eina_Bool frame)
+ecore_evas_wayland_egl_options_new_internal(const char *disp_name, unsigned int parent,
+                                            int x, int y, int w, int h, Eina_Bool frame, const int *opt)
 {
    Ecore_Wl_Window *p = NULL;
    Ecore_Wl_Global *global;
@@ -254,6 +254,42 @@ ecore_evas_wayland_egl_new_internal(const char *disp_name, unsigned int parent,
 
    if ((einfo = (Evas_Engine_Info_Wayland_Egl *)evas_engine_info_get(ee->evas)))
      {
+        if (opt)
+          {
+             int op;
+
+             for (op = 0; opt[op]; op++)
+               {
+                  if (opt[op] == ECORE_EVAS_OPT_VSYNC)
+                    {
+                       op++;
+                       einfo->vsync = opt[op];
+                    }
+#ifdef EVAS_ENGINE_WAYLAND_EGL_SWAP_MODE_EXISTS
+                  else if (opt[op] == ECORE_EVAS_OPT_SWAP_MODE)
+                    {
+                       op++;
+                       einfo->swap_mode = opt[op];
+                    }
+#endif
+                  else if (opt[op] == ECORE_EVAS_OPT_GL_DEPTH)
+                    {
+                       op++;
+                       einfo->depth_bits = opt[op];
+                    }
+                  else if (opt[op] == ECORE_EVAS_OPT_GL_STENCIL)
+                    {
+                       op++;
+                       einfo->stencil_bits = opt[op];
+                    }
+                  else if (opt[op] == ECORE_EVAS_OPT_GL_MSAA)
+                    {
+                       op++;
+                       einfo->msaa_bits = opt[op];
+                    }
+               }
+          }
+
         einfo->info.display = ecore_wl_display_get();
         einfo->info.compositor = ecore_wl_compositor_get();
         einfo->info.destination_alpha = EINA_TRUE;
@@ -306,6 +342,13 @@ ecore_evas_wayland_egl_new_internal(const char *disp_name, unsigned int parent,
    return NULL;
 }
 
+EAPI Ecore_Evas *
+ecore_evas_wayland_egl_new_internal(const char *disp_name, unsigned int parent,
+                                    int x, int y, int w, int h, Eina_Bool frame)
+{
+   return ecore_evas_wayland_egl_options_new_internal(disp_name, parent, x, y, w, h, frame, NULL);
+}
+
 static void 
 _ecore_evas_wl_move_resize(Ecore_Evas *ee, int x, int y, int w, int h)
 {
index 532b5e4..588e636 100644 (file)
@@ -45,6 +45,11 @@ struct _Evas_Engine_Info_Wayland_Egl
    Eina_Bool vsync : 1;
    Eina_Bool indirect : 1;
    unsigned char swap_mode : 4;
+
+   /* window surface should be made with these config */
+   int           depth_bits;
+   int           stencil_bits;
+   int           msaa_bits;
 };
 
 #endif
index 5906164..334e192 100644 (file)
@@ -730,6 +730,26 @@ evgl_eng_pbuffer_surface_destroy(void *data, void *surface)
    return 1;
 }
 
+static void
+evgl_eng_native_win_surface_config_get(void *data, int *win_depth,
+                                         int *win_stencil, int *win_msaa)
+{
+   Render_Engine *re = data;
+   if (!re) return;
+
+   if (win_depth)
+     *win_depth = eng_get_ob(re)->detected.depth_buffer_size;
+   if (win_stencil)
+     *win_stencil = eng_get_ob(re)->detected.stencil_buffer_size;
+   if (win_msaa)
+     *win_msaa = eng_get_ob(re)->detected.msaa;
+
+   DBG("Window config(depth %d, stencil %d, msaa %d)",
+       eng_get_ob(re)->detected.depth_buffer_size,
+       eng_get_ob(re)->detected.stencil_buffer_size,
+       eng_get_ob(re)->detected.msaa);
+}
+
 static const EVGL_Interface evgl_funcs =
 {
    evgl_eng_display_get,
@@ -749,7 +769,7 @@ static const EVGL_Interface evgl_funcs =
    NULL, // OpenGL-ES 1
    NULL, // OpenGL-ES 1
    NULL, // OpenGL-ES 1
-   NULL, // native_win_surface_config_get
+   evgl_eng_native_win_surface_config_get,
 };
 
 /* engine functions */
@@ -871,7 +891,8 @@ eng_setup(Evas *evas, void *info)
              glsym_evas_gl_preload_init();
           }
 
-        ob = eng_window_new(evas, inf, epd->output.w, epd->output.h, swap_mode);
+        ob = eng_window_new(evas, inf, epd->output.w, epd->output.h, swap_mode,
+                            inf->depth_bits, inf->stencil_bits, inf->msaa_bits);
         if (!ob) goto ob_err;
 
         if (!evas_render_engine_gl_generic_init(&re->generic, ob,
@@ -935,7 +956,8 @@ eng_setup(Evas *evas, void *info)
                   ob->gl_context->references++;
                   gl_wins--;
 
-                  ob = eng_window_new(evas, inf, epd->output.w, epd->output.h, swap_mode);
+                  ob = eng_window_new(evas, inf, epd->output.w, epd->output.h, swap_mode,
+                                      inf->depth_bits, inf->stencil_bits, inf->msaa_bits);
                   if (!ob) goto ob_err;
 
                   eng_window_use(ob);
index 28c62e8..29c479b 100755 (executable)
@@ -82,6 +82,16 @@ struct _Outbuf
 
    Eina_Bool lost_back : 1;
    Eina_Bool surf : 1;
+
+   struct {
+      unsigned char depth_buffer_size;
+      unsigned char stencil_buffer_size;
+      unsigned char msaa;
+   } detected;
+
+   int depth_bits;
+   int stencil_bits;
+   int msaa_bits;
 };
 
 struct _Context_3D
@@ -108,7 +118,8 @@ extern Evas_GL_Preload_Render_Call glsym_evas_gl_preload_render_unlock;
 extern unsigned int (*glsym_eglSwapBuffersWithDamage) (EGLDisplay a, void *b, const EGLint *d, EGLint c);
 extern unsigned int (*glsym_eglSetDamageRegionKHR) (EGLDisplay a, EGLSurface b, EGLint *c, EGLint d);
 
-Outbuf *eng_window_new(Evas *evas, Evas_Engine_Info_Wayland_Egl *einfo, int w, int h, Render_Engine_Swap_Mode swap_mode);
+Outbuf *eng_window_new(Evas *evas, Evas_Engine_Info_Wayland_Egl *einfo, int w, int h, Render_Engine_Swap_Mode swap_mode,
+                                  int depth_bits, int stencil_bits, int msaa_bits);
 void eng_window_free(Outbuf *gw);
 void eng_window_use(Outbuf *gw);
 void eng_window_unsurf(Outbuf *gw);
index 5385f4a..7011389 100644 (file)
@@ -10,7 +10,8 @@ static EGLContext context = EGL_NO_CONTEXT;
 static int win_count = 0;
 
 Outbuf *
-eng_window_new(Evas *evas, Evas_Engine_Info_Wayland_Egl *einfo, int w, int h, Render_Engine_Swap_Mode swap_mode)
+eng_window_new(Evas *evas, Evas_Engine_Info_Wayland_Egl *einfo, int w, int h, Render_Engine_Swap_Mode swap_mode,
+                          int depth_bits, int stencil_bits, int msaa_bits)
 {
    Outbuf *gw;
    int context_attrs[3];
@@ -19,6 +20,7 @@ eng_window_new(Evas *evas, Evas_Engine_Info_Wayland_Egl *einfo, int w, int h, Re
    int num_config, n = 0;
    const GLubyte *vendor, *renderer, *version;
    Eina_Bool blacklist = EINA_FALSE;
+   int val = 0;
 
    /* try to allocate space for our window */
    if (!(gw = calloc(1, sizeof(Outbuf))))
@@ -37,6 +39,9 @@ eng_window_new(Evas *evas, Evas_Engine_Info_Wayland_Egl *einfo, int w, int h, Re
    gw->depth = einfo->info.depth;
    gw->alpha = einfo->info.destination_alpha;
    gw->rot = einfo->info.rotation;
+   gw->depth_bits = depth_bits;
+   gw->stencil_bits = stencil_bits;
+   gw->msaa_bits = msaa_bits;
 
    context_attrs[0] = EGL_CONTEXT_CLIENT_VERSION;
    context_attrs[1] = 2;
@@ -59,9 +64,16 @@ eng_window_new(Evas *evas, Evas_Engine_Info_Wayland_Egl *einfo, int w, int h, Re
    config_attrs[n++] = EGL_ALPHA_SIZE;
    config_attrs[n++] = gw->alpha;
    config_attrs[n++] = EGL_DEPTH_SIZE;
-   config_attrs[n++] = 0;
+   config_attrs[n++] = gw->depth_bits;
    config_attrs[n++] = EGL_STENCIL_SIZE;
-   config_attrs[n++] = 0;
+   config_attrs[n++] = gw->stencil_bits;
+   if (msaa_bits > 0)
+     {
+        config_attrs[n++] = EGL_SAMPLE_BUFFERS;
+        config_attrs[n++] = 1;
+        config_attrs[n++] = EGL_SAMPLES;
+        config_attrs[n++] = gw->msaa_bits;
+     }
    config_attrs[n++] = EGL_NONE;
 
    /* FIXME: Remove this line as soon as eglGetDisplay() autodetection
@@ -170,6 +182,16 @@ eng_window_new(Evas *evas, Evas_Engine_Info_Wayland_Egl *einfo, int w, int h, Re
         return NULL;
      }
 
+   eglGetConfigAttrib(gw->egl_disp, gw->egl_config, EGL_DEPTH_SIZE, &val);
+   gw->detected.depth_buffer_size = val;
+   DBG("Detected depth size %d", val);
+   eglGetConfigAttrib(gw->egl_disp, gw->egl_config, EGL_STENCIL_SIZE, &val);
+   gw->detected.stencil_buffer_size = val;
+   DBG("Detected stencil size %d", val);
+   eglGetConfigAttrib(gw->egl_disp, gw->egl_config, EGL_SAMPLES, &val);
+   gw->detected.msaa = val;
+   DBG("Detected msaa %d", val);
+
    if (!(gw->gl_context = glsym_evas_gl_common_context_new()))
      {
         eng_window_free(gw);