evas gl: Properly verify that Evas GL works
authorJean-Philippe Andre <jp.andre@samsung.com>
Wed, 17 Jan 2018 06:17:59 +0000 (15:17 +0900)
committerWonki Kim <wonki_.kim@samsung.com>
Tue, 3 Apr 2018 02:42:48 +0000 (11:42 +0900)
For SW engine we need to verify that OSMesa is present. The patch
fb048e73120b39095cc87aa4f8d7f3d397a93c56 broke the logic.

Tested by temporarily removing OSMesa from my system.

Fixes T6617 (again)

src/lib/evas/canvas/evas_gl.c
src/lib/evas/include/evas_private.h
src/modules/evas/engines/gl_generic/evas_engine.c
src/modules/evas/engines/software_generic/evas_engine.c

index efe1ba1..4bd4a7d 100644 (file)
@@ -149,7 +149,10 @@ evas_gl_new(Evas *e)
    evas_gl->evas = efl_data_ref(e, EVAS_CANVAS_CLASS);
    LKI(evas_gl->lck);
 
-   if (!evas_gl->evas->engine.func->gl_context_create)
+   if (!evas_gl->evas->engine.func->gl_context_create ||
+       !evas_gl->evas->engine.func->gl_supports_evas_gl ||
+       !evas_gl->evas->engine.func->gl_supports_evas_gl(
+          _evas_engine_context(evas_gl->evas)))
      {
         ERR("Evas GL engine not available.");
         efl_data_unref(e, evas_gl->evas);
index 668981e..de3b14d 100755 (executable)
@@ -1432,6 +1432,7 @@ struct _Evas_Func
    int  (*font_right_inset_get)            (void *engine, Evas_Font_Set *font, const Evas_Text_Props *text_props);
 
    /* EFL-GL Glue Layer */
+   Eina_Bool (*gl_supports_evas_gl)      (void *engine);
    void *(*gl_output_set)                (void *engine, void *output);
    void *(*gl_surface_create)            (void *engine, void *config, int w, int h);
    void *(*gl_pbuffer_surface_create)    (void *engine, void *config, int w, int h, int const *attrib_list);
index 745ee21..31cd29a 100755 (executable)
@@ -1697,6 +1697,14 @@ evgl_init(Render_Engine_GL_Generic *engine)
 
 #define EVGLINIT(_ret) Render_Output_GL_Generic *re; if ((re = evgl_init(engine)) == NULL) return _ret
 
+static Eina_Bool
+eng_gl_supports_evas_gl(void *engine EINA_UNUSED)
+{
+   // Evas GL should always work... But let's do a full init anyway.
+   EVGLINIT(EINA_FALSE);
+   return EINA_TRUE;
+}
+
 static void *
 eng_gl_output_set(void *eng, void *output)
 {
@@ -3419,6 +3427,7 @@ module_open(Evas_Module *em)
    ORD(font_cache_set);
    ORD(font_cache_get);
 
+   ORD(gl_supports_evas_gl);
    ORD(gl_output_set);
    ORD(gl_surface_create);
    ORD(gl_pbuffer_surface_create);
index ea4ae12..2f577a8 100755 (executable)
@@ -3462,13 +3462,19 @@ _tls_check(void)
 }
 #endif
 
-static inline int
+static inline Eina_Bool
 _check_gl(void)
 {
    if (!gl_lib_init()) return 0;
    return 1;
 }
 
+static Eina_Bool
+eng_gl_supports_evas_gl(void *data EINA_UNUSED)
+{
+   return _check_gl();
+}
+
 static void *
 eng_gl_surface_create(void *data EINA_UNUSED, void *config, int w, int h)
 {
@@ -4904,6 +4910,7 @@ static Evas_Func func =
      eng_font_pen_coords_get,
      eng_font_text_props_info_create,
      eng_font_right_inset_get,
+     eng_gl_supports_evas_gl, // returns true iif OSMesa is present
      NULL, // No need to set output for software engine
      eng_gl_surface_create, // need software mesa for gl rendering <- gl_surface_create
      NULL, // need software mesa for gl rendering <- gl_pbuffer_surface_create