derekf pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=cbbac076f47e6cd0782abe0ec3957f867059800c

commit cbbac076f47e6cd0782abe0ec3957f867059800c
Author: Derek Foreman <der...@osg.samsung.com>
Date:   Tue Nov 21 12:26:17 2017 -0600

    gl_drm: Use the same gbm_device for multiple instances
    
    If we want to share a gl context (we do) between multiple instances of
    gl_drm, we need to make sure they all use the same gbm_device.
    
    This resolves a blocker for multi-output on the gl_drm backend.
---
 src/modules/evas/engines/gl_drm/evas_engine.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/modules/evas/engines/gl_drm/evas_engine.c 
b/src/modules/evas/engines/gl_drm/evas_engine.c
index fd219bbd9b..39f5442218 100644
--- a/src/modules/evas/engines/gl_drm/evas_engine.c
+++ b/src/modules/evas/engines/gl_drm/evas_engine.c
@@ -34,6 +34,8 @@ int _extn_have_buffer_age = 1;
 static Eina_Bool initted = EINA_FALSE;
 static Eina_Bool dmabuf_present = EINA_FALSE;
 static int gl_wins = 0;
+static struct gbm_device *gbm_dev = NULL;
+static int gbm_dev_refs = 0;
 
 /* local function prototype types */
 typedef void (*glsym_func_void)();
@@ -125,6 +127,13 @@ eng_gbm_init(Evas_Engine_Info_GL_Drm *info)
    int fd;
    if (!info) return EINA_FALSE;
 
+   if (gbm_dev)
+     {
+        info->info.gbm = gbm_dev;
+        gbm_dev_refs++;
+        return EINA_TRUE;
+     }
+
    fd = ecore_drm2_device_fd_get(info->info.dev);
    if (!(info->info.gbm = gbm_create_device(fd)))
      {
@@ -132,6 +141,8 @@ eng_gbm_init(Evas_Engine_Info_GL_Drm *info)
         return EINA_FALSE;
      }
 
+   gbm_dev = info->info.gbm;
+   gbm_dev_refs = 1;
    return EINA_TRUE;
 }
 
@@ -142,8 +153,13 @@ eng_gbm_shutdown(Evas_Engine_Info_GL_Drm *info)
 
    if (info->info.gbm)
      {
-        gbm_device_destroy(info->info.gbm);
+        gbm_dev_refs--;
         info->info.gbm = NULL;
+        if (!gbm_dev_refs)
+          {
+             gbm_device_destroy(gbm_dev);
+             gbm_dev = NULL;
+          }
      }
 
    return EINA_TRUE;

-- 


Reply via email to