devilhorns pushed a commit to branch master.

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

commit 58dbb63ba4bbc235477793b016ba31d2bf17d1fb
Author: Chris Michael <cp.mich...@samsung.com>
Date:   Tue Jun 2 09:05:26 2015 -0400

    evas-gl-drm: Remove old engine code
    
    Signed-off-by: Chris Michael <cp.mich...@samsung.com>
---
 .../evas/engines/gl_drm/Evas_Engine_GL_Drm.h       |  44 --
 src/modules/evas/engines/gl_drm/evas_drm.c         | 347 -----------
 src/modules/evas/engines/gl_drm/evas_drm_main.c    | 636 ---------------------
 src/modules/evas/engines/gl_drm/evas_engine.h      | 191 -------
 4 files changed, 1218 deletions(-)

diff --git a/src/modules/evas/engines/gl_drm/Evas_Engine_GL_Drm.h 
b/src/modules/evas/engines/gl_drm/Evas_Engine_GL_Drm.h
deleted file mode 100644
index 92069b6..0000000
--- a/src/modules/evas/engines/gl_drm/Evas_Engine_GL_Drm.h
+++ /dev/null
@@ -1,44 +0,0 @@
-#ifndef _EVAS_ENGINE_GL_DRM_H
-# define _EVAS_ENGINE_GL_DRM_H
-
-# include <gbm.h>
-# include <Ecore_Drm.h>
-
-typedef struct _Evas_Engine_Info_GL_Drm Evas_Engine_Info_GL_Drm;
-
-struct _Evas_Engine_Info_GL_Drm
-{
-   /* PRIVATE - don't mess with this baby or evas will poke its tongue out
-    * at you and make nasty noises */
-   Evas_Engine_Info magic;
-
-   /* engine specific data & parameters it needs to set up */
-   struct
-     {
-        struct gbm_device *gbm;
-        struct gbm_surface *surface;
-        uint32_t format;
-        uint32_t flags;
-        int depth, screen, rotation;
-        unsigned char destination_alpha : 1;
-        int fd;
-        int output, plane;
-        Ecore_Drm_Device *dev;
-     } info;
-
-   struct
-     {
-        void (*pre_swap) (void *data, Evas *evas);
-        void (*post_swap) (void *data, Evas *evas);
-        void *data;
-     } callback;
-
-   /* non-blocking or blocking mode */
-   Evas_Engine_Render_Mode render_mode;
-
-   unsigned char vsync : 1;
-   unsigned char indirect : 1;
-   unsigned char swap_mode : 4;
-};
-
-#endif
diff --git a/src/modules/evas/engines/gl_drm/evas_drm.c 
b/src/modules/evas/engines/gl_drm/evas_drm.c
deleted file mode 100644
index c049fb9..0000000
--- a/src/modules/evas/engines/gl_drm/evas_drm.c
+++ /dev/null
@@ -1,347 +0,0 @@
-#include "evas_engine.h"
-#include <sys/mman.h>
-
-static void
-_evas_drm_fb_destroy_callback(struct gbm_bo *bo, void *data)
-{
-   Buffer *buffer = data;
-   struct gbm_device *gbm = gbm_bo_get_device(bo);
-
-   if (buffer->fb)
-     drmModeRmFB(gbm_device_get_fd(gbm), buffer->fb);
-}
-
-static unsigned int
-_evas_drm_crtc_buffer_get(int fd, int crtc_id)
-{
-   drmModeCrtc *crtc;
-   unsigned int id;
-
-   if (!(crtc = drmModeGetCrtc(fd, crtc_id))) return 0;
-   id = crtc->buffer_id;
-   drmModeFreeCrtc(crtc);
-   return id;
-}
-
-static void
-_evas_drm_outbuf_page_flip(int fd EINA_UNUSED, unsigned int seq EINA_UNUSED, 
unsigned int tv_sec EINA_UNUSED, unsigned int tv_usec EINA_UNUSED, void *data)
-{
-   Outbuf *ob;
-   Buffer *buff;
-
-   /* get the output buffer from data */
-   if (!(ob = data)) return;
-
-   buff = &(ob->priv.buffer[ob->priv.curr]);
-   gbm_surface_release_buffer(ob->surface, buff->bo);
-
-   ob->priv.pending_flip = EINA_FALSE;
-   ob->priv.curr = (ob->priv.curr + 1) % ob->priv.num;
-}
-
-static Eina_Bool
-_evas_drm_outbuf_planes_setup(Outbuf *ob, drmModePlaneResPtr pres)
-{
-   drmModePlanePtr dplane;
-   Plane *oplane;
-   unsigned int p = 0;
-   unsigned int f = 0;
-
-   for (p = 0; p < pres->count_planes; p++)
-     {
-        /* try to get this plane */
-        if (!(dplane = drmModeGetPlane(ob->priv.fd, pres->planes[p])))
-          continue;
-
-        /* try to allocate space for our plane */
-        if (!(oplane =
-              malloc(sizeof(Plane)  +
-                     ((sizeof(unsigned int)) * dplane->count_formats))))
-          {
-             drmModeFreePlane(dplane);
-             continue;
-          }
-
-        oplane->crtcs = dplane->possible_crtcs;
-        oplane->id = dplane->plane_id;
-        oplane->num_formats = dplane->count_formats;
-        memcpy(oplane->formats, dplane->formats,
-               dplane->count_formats * sizeof(dplane->formats[0]));
-
-        DBG("Plane %d, %d %d", p, dplane->x, dplane->y);
-        DBG("\tFB: %d", dplane->fb_id);
-        DBG("\tCrtc: %d, %d %d", dplane->crtc_id,
-            dplane->crtc_x, dplane->crtc_y);
-
-        DBG("\tSupported Formats");
-        for (f = 0; f < dplane->count_formats; f++)
-          {
-             DBG("\t\t%C%C%C%C", (dplane->formats[f] & 0xFF),
-                 ((dplane->formats[f] >> 8) & 0xFF),
-                 ((dplane->formats[f] >> 16) & 0xFF),
-                 ((dplane->formats[f] >> 24) & 0xFF));
-          }
-
-        /* free this plane */
-        drmModeFreePlane(dplane);
-
-        /* append this plane */
-        ob->priv.planes = eina_list_append(ob->priv.planes, oplane);
-     }
-
-   if (eina_list_count(ob->priv.planes) < 1) return EINA_FALSE;
-   return EINA_TRUE;
-}
-
-Eina_Bool
-evas_drm_gbm_init(Evas_Engine_Info_GL_Drm *info, int w, int h)
-{
-   if (!info) return EINA_FALSE;
-   if (info->info.fd < 0)  return EINA_FALSE;
-
-   if (!(info->info.gbm = gbm_create_device(info->info.fd)))
-     return EINA_FALSE;
-
-   if (!(info->info.surface = 
-         gbm_surface_create(info->info.gbm, w, h,
-                            info->info.format, info->info.flags)))
-     {
-        gbm_device_destroy(info->info.gbm);
-        info->info.gbm = NULL;
-        return EINA_FALSE;
-     }
-
-   return EINA_TRUE;
-}
-
-Eina_Bool
-evas_drm_gbm_shutdown(Evas_Engine_Info_GL_Drm *info)
-{
-   if (!info) return EINA_TRUE;
-
-   if (info->info.surface)
-     {
-        gbm_surface_destroy(info->info.surface);
-        info->info.surface = NULL;
-     }
-   if (info->info.gbm)
-     {
-        gbm_device_destroy(info->info.gbm);
-        info->info.gbm = NULL;
-     }
-
-   return EINA_TRUE;
-}
-
-Eina_Bool
-evas_drm_outbuf_setup(Outbuf *ob)
-{
-   drmModeRes *res;
-   drmModeConnector *conn;
-   drmModePlaneResPtr pres;
-   drmModeEncoder *enc;
-   drmModeModeInfo crtc_mode;
-   int i = 0;
-
-   /* check for valid Output buffer */
-   if ((!ob) || (ob->priv.fd < 0)) return EINA_FALSE;
-
-   /* setup drmHandleEvent context */
-   memset(&ob->priv.ctx, 0, sizeof(ob->priv.ctx));
-   ob->priv.ctx.version = DRM_EVENT_CONTEXT_VERSION;
-   ob->priv.ctx.page_flip_handler = _evas_drm_outbuf_page_flip;
-
-   /* try to get drm resources */
-   if (!(res = drmModeGetResources(ob->priv.fd)))
-     {
-        CRI("Could not get drm resources: %m");
-        return EINA_FALSE;
-     }
-
-   /* loop the connectors */
-   for (; i < res->count_connectors; ++i)
-     {
-        int crtc_id = -1;
-        int m = 0;
-
-        /* try to get this connector */
-        if (!(conn = drmModeGetConnector(ob->priv.fd, res->connectors[i])))
-          {
-             WRN("Could not get drm connector %d: %m", i);
-             continue;
-          }
-
-        /* make sure this connector is actually connected */
-        if (conn->connection != DRM_MODE_CONNECTED)
-          {
-             /* free connector resources */
-             drmModeFreeConnector(conn);
-             continue;
-          }
-
-        /* make sure it has modes */
-        if (conn->count_modes == 0)
-          {
-             /* free connector resources */
-             drmModeFreeConnector(conn);
-             continue;
-          }
-
-        /* record the connector id */
-        ob->priv.conn = conn->connector_id;
-
-        if ((enc = drmModeGetEncoder(ob->priv.fd, conn->encoder_id)))
-          {
-             drmModeCrtc *crtc;
-
-             if ((crtc = drmModeGetCrtc(ob->priv.fd, enc->crtc_id)))
-               {
-                  crtc_id = enc->crtc_id;
-                  if (crtc->mode_valid) crtc_mode = crtc->mode;
-                  drmModeFreeCrtc(crtc);
-               }
-
-             drmModeFreeEncoder(enc);
-          }
-
-        /* record the crtc id */
-        ob->priv.crtc = crtc_id;
-
-        /* get the current framebuffer */
-        ob->priv.fb = _evas_drm_crtc_buffer_get(ob->priv.fd, crtc_id);
-
-        memset(&ob->priv.mode, 0, sizeof(ob->priv.mode));
-
-        for (m = 0; m < conn->count_modes; m++)
-          {
-             DBG("Output Available Mode: %d: %d %d %d", ob->priv.conn,
-                 conn->modes[m].hdisplay, conn->modes[m].vdisplay,
-                 conn->modes[m].vrefresh);
-             if (!memcmp(&crtc_mode, &conn->modes[m], sizeof(crtc_mode)))
-               {
-                  /* record the current mode */
-                  memcpy(&ob->priv.mode, &conn->modes[m], 
sizeof(ob->priv.mode));
-                  break;
-               }
-
-          }
-
-       if ((!ob->priv.mode.hdisplay) && (crtc_mode.clock != 0))
-          memcpy(&ob->priv.mode, &crtc_mode, sizeof(ob->priv.mode));
-
-        DBG("Output Current Mode: %d: %d %d", ob->priv.conn,
-            ob->priv.mode.hdisplay, ob->priv.mode.vdisplay);
-
-        if ((ob->priv.mode.hdisplay != conn->modes[0].hdisplay) ||
-            (ob->priv.mode.vdisplay != conn->modes[0].vdisplay))
-          {
-             /* set new crtc mode */
-             drmModeSetCrtc(ob->priv.fd, ob->priv.crtc, ob->priv.fb, 0, 0,
-                            &ob->priv.conn, 1, &ob->priv.mode);
-          }
-
-        /* free connector resources */
-        drmModeFreeConnector(conn);
-
-        break;
-     }
-
-   /* get any plane resource from the card */
-   pres = drmModeGetPlaneResources(ob->priv.fd);
-
-   /* if we have at least one plane, set it up */
-   if (pres->count_planes > 0)
-     {
-        if (!_evas_drm_outbuf_planes_setup(ob, pres))
-          WRN("Could not setup hardware planes");
-     }
-
-   /* free plane resources */
-   drmModeFreePlaneResources(pres);
-
-   /* free drm resources */
-   drmModeFreeResources(res);
-
-   return EINA_TRUE;
-}
-
-void
-evas_drm_outbuf_framebuffer_set(Outbuf *ob, Buffer *buffer)
-{
-   int ret;
-   uint32_t handles[4], pitches[4], offsets[4];
-   uint32_t width, height;
-   uint32_t format;
-
-   /* validate params */
-   if ((!ob) || (!buffer)) return;
-
-   if (buffer->valid) return;
-
-   width = gbm_bo_get_width(buffer->bo);
-   height = gbm_bo_get_height(buffer->bo);
-   buffer->stride = gbm_bo_get_stride(buffer->bo);
-   buffer->handle = gbm_bo_get_handle(buffer->bo).u32;
-   buffer->size = buffer->stride * height;
-   format = gbm_bo_get_format(buffer->bo);
-
-   handles[0] = buffer->handle;
-   pitches[0] = buffer->stride;
-   offsets[0] = 0;
-
-   ret = drmModeAddFB2(ob->priv.fd, width, height, format, handles,
-                       pitches, offsets, &(buffer->fb), 0);
-   if (ret)
-     {
-        ret = drmModeAddFB(ob->priv.fd, width, height, 24, 32,
-                           buffer->stride, buffer->handle, &(buffer->fb));
-     }
-   if (ret) ERR("Failed to AddFB: %m");
-
-   ret = drmModeSetCrtc(ob->priv.fd, ob->priv.crtc, buffer->fb, 0, 0,
-                        &ob->priv.conn, 1, &ob->priv.mode);
-   if (ret) ERR("Failed to set crtc: %m");
-
-   gbm_bo_set_user_data(buffer->bo, buffer, _evas_drm_fb_destroy_callback);
-
-   buffer->valid = EINA_TRUE;
-}
-
-Eina_Bool
-evas_drm_framebuffer_send(Outbuf *ob, Buffer *buffer)
-{
-   /* check for valid Output buffer */
-   if ((!ob) || (ob->priv.fd < 0)) return EINA_FALSE;
-
-   /* check for valid buffer */
-   if (!buffer) return EINA_FALSE;
-
-   if (ob->vsync)
-     {
-        if (drmModePageFlip(ob->priv.fd, ob->priv.crtc,
-                            buffer->fb, DRM_MODE_PAGE_FLIP_EVENT, ob) < 0)
-          {
-             ERR("Cannot flip crtc for connector %u: %m", ob->priv.conn);
-             return EINA_FALSE;
-          }
-
-        ob->priv.pending_flip = EINA_TRUE;
-
-        while (ob->priv.pending_flip)
-          drmHandleEvent(ob->priv.fd, &ob->priv.ctx);
-     }
-   else
-     {
-        /* NB: We don't actually need to do this if we are not vsync
-         * because we are drawing directly to the buffer anyway.
-         * If we enable the sending of buffer to crtc, it causes vsync */
-
-        /* send this buffer to the crtc */
-        /* evas_drm_outbuf_framebuffer_set(ob, buffer); */
-
-        /* increment buffer we are using */
-        ob->priv.curr = (ob->priv.curr + 1) % ob->priv.num;
-     }
-
-   return EINA_TRUE;
-}
diff --git a/src/modules/evas/engines/gl_drm/evas_drm_main.c 
b/src/modules/evas/engines/gl_drm/evas_drm_main.c
deleted file mode 100644
index 9918673..0000000
--- a/src/modules/evas/engines/gl_drm/evas_drm_main.c
+++ /dev/null
@@ -1,636 +0,0 @@
-#include "evas_engine.h"
-
-/* local variables */
-static Outbuf *_evas_gl_drm_window = NULL;
-static EGLContext context = EGL_NO_CONTEXT;
-static int win_count = 0;
-
-/* local function prototypes */
-static void _outbuf_buffer_swap(Outbuf *ob, Eina_Rectangle *rects, unsigned 
int count);
-static void _outbuf_flush_famebuffer(Outbuf *ob);
-
-/* local functions */
-static void
-_outbuf_buffer_swap(Outbuf *ob, Eina_Rectangle *rects EINA_UNUSED, unsigned 
int count EINA_UNUSED)
-{
-   Buffer *buff;
-
-   buff = &(ob->priv.buffer[ob->priv.curr]);
-
-   buff->bo = gbm_surface_lock_front_buffer(ob->surface);
-
-   /* if this buffer is not valid, we need to set it */
-   if (!buff->valid) evas_drm_outbuf_framebuffer_set(ob, buff);
-
-   /* send this buffer to the crtc */
-   evas_drm_framebuffer_send(ob, buff);
-}
-
-static void
-_outbuf_flush_famebuffer(Outbuf *ob)
-{
-   Eina_Rectangle *rects = NULL;
-   unsigned int n = 0;
-   //TODO: add region flush routine for SwapBuffersWithDamage
-
-   /* force a buffer swap */
-   _outbuf_buffer_swap(ob, rects, n);
-}
-
-Outbuf *
-eng_window_new(Evas_Engine_Info_GL_Drm *info, Evas *e, struct gbm_device *gbm, 
struct gbm_surface *surface, int screen, int depth, int w, int h, int indirect 
EINA_UNUSED, int alpha, int rot, Render_Engine_Swap_Mode swap_mode)
-{
-   Outbuf *gw;
-   int context_attrs[3];
-   int config_attrs[40];
-   int major_version, minor_version;
-   int num_config, n = 0;
-   const GLubyte *vendor, *renderer, *version, *glslversion;
-   Eina_Bool blacklist = EINA_FALSE;
-   char *num;
-
-   /* try to allocate space for outbuf */
-   gw = calloc(1, sizeof(Outbuf));
-   if (!gw) return NULL;
-
-   /* set properties of outbuf */
-   win_count++;
-   gw->gbm = gbm;
-   gw->surface = surface;
-   gw->screen = screen;
-   gw->depth = depth;
-   gw->w = w;
-   gw->h = h;
-   gw->alpha = alpha;
-   gw->rot = rot;
-   gw->swap_mode = swap_mode;
-   gw->info = info;
-   gw->evas = e;
-
-   /* setup drm outbuf */
-   /* set drm card fd */
-   gw->priv.fd = info->info.fd;
-   /* try to setup the drm card for this outbuf */
-   if (!evas_drm_outbuf_setup(gw))
-     {
-        ERR("Could not setup drm outbuf");
-        free(gw);
-        return NULL;
-     }
-
-   if (gw->w < gw->priv.mode.hdisplay) gw->w = gw->priv.mode.hdisplay;
-   if (gw->h < gw->priv.mode.vdisplay) gw->h = gw->priv.mode.vdisplay;
-
-   info->info.output = gw->priv.fb;
-   // TODO: change vsync for drm egl
-   //gw->vsync = info->vsync;
-
-   gw->priv.num = NUM_BUFFERS;
-   /* check for buffer override */
-   // TODO: change for gbm_bo related drm buffer number.
-   if ((num = getenv("EVAS_GL_DRM_BUFFERS")))
-     {
-        gw->priv.num = atoi(num);
-
-        /* cap maximum # of buffers */
-        if (gw->priv.num <= 0) gw->priv.num = 1;
-        else if (gw->priv.num > 3) gw->priv.num = 3;
-     }
-   /* end drm outbuf setup */
-
-   /* setup gbm egl surface */
-   context_attrs[0] = EGL_CONTEXT_CLIENT_VERSION;
-   context_attrs[1] = 2;
-   context_attrs[2] = EGL_NONE;
-
-   config_attrs[n++] = EGL_SURFACE_TYPE;
-   config_attrs[n++] = EGL_WINDOW_BIT;
-   config_attrs[n++] = EGL_RED_SIZE;
-   config_attrs[n++] = 1;
-   config_attrs[n++] = EGL_GREEN_SIZE;
-   config_attrs[n++] = 1;
-   config_attrs[n++] = EGL_BLUE_SIZE;
-   config_attrs[n++] = 1;
-   config_attrs[n++] = EGL_ALPHA_SIZE;
-   if (gw->alpha) config_attrs[n++] = 1;
-   else config_attrs[n++] = 0;
-   config_attrs[n++] = EGL_RENDERABLE_TYPE;
-   config_attrs[n++] = EGL_OPENGL_ES2_BIT;
-   config_attrs[n++] = EGL_NONE;
-
-#ifdef GL_DRM_DBG
-   DBG("GBM DEVICE: %x", (unsigned int)gbm);
-#endif
-
-   gw->egl_disp = eglGetDisplay((EGLNativeDisplayType)(gw->gbm));
-   if (gw->egl_disp  == EGL_NO_DISPLAY)
-     {
-        ERR("eglGetDisplay() fail. code=%#x", eglGetError());
-        eng_window_free(gw);
-        return NULL;
-     }
-   if (!eglInitialize(gw->egl_disp, &major_version, &minor_version))
-     {
-        ERR("eglInitialize() fail. code=%#x", eglGetError());
-        eng_window_free(gw);
-        return NULL;
-     }
-   eglBindAPI(EGL_OPENGL_ES_API);
-   if (eglGetError() != EGL_SUCCESS)
-     {
-        ERR("eglBindAPI() fail. code=%#x", eglGetError());
-        eng_window_free(gw);
-        return NULL;
-     }
-
-   num_config = 0;
-   if (!eglChooseConfig(gw->egl_disp, config_attrs, &gw->egl_config,
-                        1, &num_config) || (num_config != 1))
-     {
-        ERR("eglChooseConfig() fail. code=%#x", eglGetError());
-        eng_window_free(gw);
-        return NULL;
-     }
-
-   gw->egl_surface[0] =
-     eglCreateWindowSurface(gw->egl_disp, gw->egl_config,
-                            (EGLNativeWindowType)gw->surface, NULL);
-   if (gw->egl_surface[0] == EGL_NO_SURFACE)
-     {
-        ERR("eglCreateWindowSurface() fail for %p. code=%#x",
-            gw->surface, eglGetError());
-        eng_window_free(gw);
-        return NULL;
-     }
-
-   gw->egl_context[0] =
-     eglCreateContext(gw->egl_disp, gw->egl_config, context, context_attrs);
-   if (gw->egl_context[0] == EGL_NO_CONTEXT)
-     {
-        ERR("eglCreateContext() fail. code=%#x", eglGetError());
-        eng_window_free(gw);
-        return NULL;
-     }
-
-   if (context == EGL_NO_CONTEXT) context = gw->egl_context[0];
-
-   if (eglMakeCurrent(gw->egl_disp, gw->egl_surface[0],
-                      gw->egl_surface[0], gw->egl_context[0]) == EGL_FALSE)
-     {
-        ERR("eglMakeCurrent() fail. code=%#x", eglGetError());
-        eng_window_free(gw);
-        return NULL;
-     }
-
-   vendor = glGetString(GL_VENDOR);
-   renderer = glGetString(GL_RENDERER);
-   version = glGetString(GL_VERSION);
-   glslversion = glGetString(GL_SHADING_LANGUAGE_VERSION);
-   if (!vendor)   vendor   = (unsigned char *)"-UNKNOWN-";
-   if (!renderer) renderer = (unsigned char *)"-UNKNOWN-";
-   if (!version)  version  = (unsigned char *)"-UNKNOWN-";
-   if (!glslversion) glslversion = (unsigned char *)"-UNKNOWN-";
-   if (getenv("EVAS_GL_INFO"))
-     {
-        fprintf(stderr, "vendor  : %s\n", vendor);
-        fprintf(stderr, "renderer: %s\n", renderer);
-        fprintf(stderr, "version : %s\n", version);
-        fprintf(stderr, "glsl ver: %s\n", glslversion);
-     }
-
-   if (strstr((const char *)vendor, "Mesa Project"))
-     {
-        if (strstr((const char *)renderer, "Software Rasterizer"))
-          blacklist = EINA_TRUE;
-     }
-   if (strstr((const char *)renderer, "softpipe"))
-     blacklist = EINA_TRUE;
-   if (strstr((const char *)renderer, "llvmpipe"))
-     blacklist = EINA_TRUE;
-   if ((blacklist) && (!getenv("EVAS_GL_NO_BLACKLIST")))
-     {
-        ERR("OpenGL Driver blacklisted:");
-        ERR("Vendor: %s", (const char *)vendor);
-        ERR("Renderer: %s", (const char *)renderer);
-        ERR("Version: %s", (const char *)version);
-        eng_window_free(gw);
-        return NULL;
-     }
-
-   gw->gl_context = glsym_evas_gl_common_context_new();
-   if (!gw->gl_context)
-     {
-        eng_window_free(gw);
-        return NULL;
-     }
-
-#ifdef GL_GLES
-   gw->gl_context->egldisp = gw->egl_disp;
-   gw->gl_context->eglctxt = gw->egl_context[0];
-#endif
-
-   eng_window_use(gw);
-   glsym_evas_gl_common_context_resize(gw->gl_context, w, h, rot);
-
-   gw->surf = EINA_TRUE;
-
-   return gw;
-}
-
-void
-eng_window_free(Outbuf *gw)
-{
-   int ref = 0;
-
-   win_count--;
-   eng_window_use(gw);
-
-   if (gw == _evas_gl_drm_window) _evas_gl_drm_window = NULL;
-
-   if (gw->gl_context)
-     {
-        ref = gw->gl_context->references - 1;
-        glsym_evas_gl_common_context_free(gw->gl_context);
-     }
-
-   eglMakeCurrent(gw->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, 
EGL_NO_CONTEXT);
-
-   if (gw->egl_context[0] != context)
-     eglDestroyContext(gw->egl_disp, gw->egl_context[0]);
-
-   if (gw->egl_surface[0] != EGL_NO_SURFACE)
-     eglDestroySurface(gw->egl_disp, gw->egl_surface[0]);
-
-//TODO: consider gbm_surface destroy or not.
-#if 0
-   if (gw->surface)
-     {
-        gbm_surface_destroy(gw->surface);
-        gw->info->info.surface = NULL;
-     }
-#endif
-
-   if (ref == 0)
-     {
-        if (context) eglDestroyContext(gw->egl_disp, context);
-        eglTerminate(gw->egl_disp);
-        eglReleaseThread();
-        context = EGL_NO_CONTEXT;
-     }
-   free(gw);
-}
-
-Eina_Bool
-eng_window_make_current(void *data, void *doit)
-{
-   Outbuf *gw;
-
-   if (!(gw = data)) return EINA_FALSE;
-
-   if (doit)
-     {
-        if (!eglMakeCurrent(gw->egl_disp, gw->egl_surface[0],
-                            gw->egl_surface[0], gw->egl_context[0]))
-          return EINA_FALSE;
-     }
-   else
-     {
-        if (!eglMakeCurrent(gw->egl_disp, EGL_NO_SURFACE,
-                            EGL_NO_SURFACE, EGL_NO_CONTEXT))
-          return EINA_FALSE;
-     }
-
-   return EINA_TRUE;
-}
-
-void
-eng_window_use(Outbuf *gw)
-{
-   Eina_Bool force = EINA_FALSE;
-
-   glsym_evas_gl_preload_render_lock(eng_window_make_current, gw);
-
-   if (_evas_gl_drm_window)
-     {
-        if (eglGetCurrentContext() != _evas_gl_drm_window->egl_context[0])
-          force = EINA_TRUE;
-     }
-
-   if ((_evas_gl_drm_window != gw) || (force))
-     {
-        if (_evas_gl_drm_window)
-          {
-             glsym_evas_gl_common_context_use(_evas_gl_drm_window->gl_context);
-             
glsym_evas_gl_common_context_flush(_evas_gl_drm_window->gl_context);
-          }
-
-        _evas_gl_drm_window = gw;
-
-        if (gw)
-          {
-             if (gw->egl_surface[0] != EGL_NO_SURFACE)
-               {
-                  if (eglMakeCurrent(gw->egl_disp, gw->egl_surface[0],
-                                     gw->egl_surface[0],
-                                     gw->egl_context[0]) == EGL_FALSE)
-                    ERR("eglMakeCurrent() failed!");
-               }
-          }
-     }
-
-   if (gw) glsym_evas_gl_common_context_use(gw->gl_context);
-}
-
-void
-eng_window_unsurf(Outbuf *gw)
-{
-   if (!gw->surf) return;
-   if (!getenv("EVAS_GL_WIN_RESURF")) return;
-   if (getenv("EVAS_GL_INFO")) printf("unsurf %p\n", gw);
-
-   if (_evas_gl_drm_window)
-      glsym_evas_gl_common_context_flush(_evas_gl_drm_window->gl_context);
-   if (_evas_gl_drm_window == gw)
-     {
-        eglMakeCurrent(gw->egl_disp, EGL_NO_SURFACE,
-                       EGL_NO_SURFACE, EGL_NO_CONTEXT);
-        if (gw->egl_surface[0] != EGL_NO_SURFACE)
-           eglDestroySurface(gw->egl_disp, gw->egl_surface[0]);
-        gw->egl_surface[0] = EGL_NO_SURFACE;
-
-        _evas_gl_drm_window = NULL;
-     }
-
-   gw->surf = EINA_FALSE;
-}
-
-void
-eng_window_resurf(Outbuf *gw)
-{
-   if (gw->surf) return;
-   if (getenv("EVAS_GL_INFO")) printf("resurf %p\n", gw);
-
-   gw->egl_surface[0] =
-     eglCreateWindowSurface(gw->egl_disp, gw->egl_config,
-                            (EGLNativeWindowType)gw->surface, NULL);
-
-   if (gw->egl_surface[0] == EGL_NO_SURFACE)
-     {
-        ERR("eglCreateWindowSurface() fail for %p. code=%#x",
-            gw->surface, eglGetError());
-        return;
-     }
-
-   if (eglMakeCurrent(gw->egl_disp, gw->egl_surface[0], gw->egl_surface[0],
-                      gw->egl_context[0]) == EGL_FALSE)
-     ERR("eglMakeCurrent() failed!");
-
-   gw->surf = EINA_TRUE;
-}
-
-Context_3D *
-eng_gl_context_new(Outbuf *gw)
-{
-   Context_3D *ctx;
-   int context_attrs[3] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
-
-   if (!gw) return NULL;
-
-   ctx = calloc(1, sizeof(Context_3D));
-   if (!ctx) return NULL;
-
-   ctx->context = eglCreateContext(gw->egl_disp, gw->egl_config,
-                                   gw->egl_context[0], context_attrs);
-
-   if (!ctx->context)
-     {
-        ERR("EGL context creation failed.");
-        goto error;
-     }
-
-   ctx->display = gw->egl_disp;
-   ctx->surface = gw->egl_surface[0];
-
-   return ctx;
-
-error:
-   free(ctx);
-   return NULL;
-}
-
-void
-eng_gl_context_free(Context_3D *ctx)
-{
-   eglDestroyContext(ctx->display, ctx->context);
-   free(ctx);
-}
-
-void
-eng_gl_context_use(Context_3D *ctx)
-{
-   if (eglMakeCurrent(ctx->display, ctx->surface,
-                      ctx->surface, ctx->context) == EGL_FALSE)
-     ERR("eglMakeCurrent() failed.");
-}
-
-void
-eng_outbuf_reconfigure(Outbuf *ob, int w, int h, int rot, Outbuf_Depth depth 
EINA_UNUSED)
-{
-   ob->w = w;
-   ob->h = h;
-   ob->rot = rot;
-   eng_window_use(ob);
-   glsym_evas_gl_common_context_resize(ob->gl_context, w, h, rot);
-
-   //TODO: need drm gbm surface destroy & re-create.?
-}
-
-int
-eng_outbuf_get_rot(Outbuf *ob)
-{
-   return ob->rot;
-}
-
-Render_Engine_Swap_Mode
-eng_outbuf_swap_mode(Outbuf *ob)
-{
-   if (ob->swap_mode == MODE_AUTO && extn_have_buffer_age)
-     {
-        Render_Engine_Swap_Mode swap_mode;
-
-        EGLint age = 0;
-
-        if (!eglQuerySurface(ob->egl_disp, ob->egl_surface[0],
-                             EGL_BUFFER_AGE_EXT, &age))
-          age = 0;
-
-        if (age == 1) swap_mode = MODE_COPY;
-        else if (age == 2) swap_mode = MODE_DOUBLE;
-        else if (age == 3) swap_mode = MODE_TRIPLE;
-        else if (age == 4) swap_mode = MODE_QUADRUPLE;
-        else swap_mode = MODE_FULL;
-        if ((int)age != ob->prev_age) swap_mode = MODE_FULL;
-        ob->prev_age = age;
-
-        return swap_mode;
-     }
-
-   return ob->swap_mode;
-}
-
-Eina_Bool
-eng_outbuf_region_first_rect(Outbuf *ob)
-{
-   ob->gl_context->preserve_bit = GL_COLOR_BUFFER_BIT0_QCOM;
-
-   glsym_evas_gl_preload_render_lock(eng_preload_make_current, ob);
-   eng_window_use(ob);
-   if (!_re_wincheck(ob)) return EINA_TRUE;
-
-   glsym_evas_gl_common_context_resize(ob->gl_context, ob->w, ob->h, ob->rot);
-   glsym_evas_gl_common_context_flush(ob->gl_context);
-   glsym_evas_gl_common_context_newframe(ob->gl_context);
-
-   return EINA_FALSE;
-}
-
-void *
-eng_outbuf_new_region_for_update(Outbuf *ob, int x, int y, int w, int h, int 
*cx EINA_UNUSED, int *cy EINA_UNUSED, int *cw EINA_UNUSED, int *ch EINA_UNUSED)
-{
-   if ((w == ob->w) && (h == ob->h))
-     ob->gl_context->master_clip.enabled = EINA_FALSE;
-   else
-     {
-        ob->gl_context->master_clip.enabled = EINA_TRUE;
-        ob->gl_context->master_clip.x = x;
-        ob->gl_context->master_clip.y = y;
-        ob->gl_context->master_clip.w = w;
-        ob->gl_context->master_clip.h = h;
-     }
-   return ob->gl_context->def_surface;
-}
-
-void
-eng_outbuf_push_updated_region(Outbuf *ob, RGBA_Image *update EINA_UNUSED, int 
x EINA_UNUSED, int y EINA_UNUSED, int w EINA_UNUSED, int h EINA_UNUSED)
-{
-   /* Is it really necessary to flush per region ? Shouldn't we be able to
-      still do that for the full canvas when doing partial update */
-   if (!_re_wincheck(ob)) return;
-   ob->draw.drew = EINA_TRUE;
-   glsym_evas_gl_common_context_flush(ob->gl_context);
-}
-
-void
-eng_outbuf_push_free_region_for_update(Outbuf *ob EINA_UNUSED, RGBA_Image 
*update EINA_UNUSED)
-{
-   /* Nothing to do here as we don't really create an image per area */
-}
-
-void
-eng_outbuf_flush(Outbuf *ob, Tilebuf_Rect *rects EINA_UNUSED, Evas_Render_Mode 
render_mode)
-{
-   if (render_mode == EVAS_RENDER_MODE_ASYNC_INIT) goto end;
-
-   if (!_re_wincheck(ob)) goto end;
-   if (!ob->draw.drew) goto end;
-
-   ob->draw.drew = EINA_FALSE;
-   eng_window_use(ob);
-   glsym_evas_gl_common_context_done(ob->gl_context);
-
-   if (!ob->vsync)
-     {
-        if (ob->info->vsync) eglSwapInterval(ob->egl_disp, 1);
-        else eglSwapInterval(ob->egl_disp, 0);
-        ob->vsync = 1;
-     }
-
-   if (ob->info->callback.pre_swap)
-     ob->info->callback.pre_swap(ob->info->callback.data, ob->evas);
-
-// TODO: Check eglSwapBuffersWithDamage for gl_drm and apply
-#if 0
-   if ((glsym_eglSwapBuffersWithDamage) && (ob->swap_mode != MODE_FULL))
-
-     {
-        EGLint num = 0, *result = NULL, i = 0;
-        Tilebuf_Rect *r;
-
-        // if partial swaps can be done use re->rects
-        num = eina_inlist_count(EINA_INLIST_GET(rects));
-        if (num > 0)
-          {
-             result = alloca(sizeof(EGLint) * 4 * num);
-             EINA_INLIST_FOREACH(EINA_INLIST_GET(rects), r)
-               {
-                  int gw, gh;
-
-                  gw = ob->gl_context->w;
-                  gh = ob->gl_context->h;
-                  switch (ob->rot)
-                    {
-                     case 0:
-                       result[i + 0] = r->x;
-                       result[i + 1] = gh - (r->y + r->h);
-                       result[i + 2] = r->w;
-                       result[i + 3] = r->h;
-                       break;
-                     case 90:
-                       result[i + 0] = r->y;
-                       result[i + 1] = r->x;
-                       result[i + 2] = r->h;
-                       result[i + 3] = r->w;
-                       break;
-                     case 180:
-                       result[i + 0] = gw - (r->x + r->w);
-                       result[i + 1] = r->y;
-                       result[i + 2] = r->w;
-                       result[i + 3] = r->h;
-                       break;
-                     case 270:
-                       result[i + 0] = gh - (r->y + r->h);
-                       result[i + 1] = gw - (r->x + r->w);
-                       result[i + 2] = r->h;
-                       result[i + 3] = r->w;
-                       break;
-                     default:
-                       result[i + 0] = r->x;
-                       result[i + 1] = gh - (r->y + r->h);
-                       result[i + 2] = r->w;
-                       result[i + 3] = r->h;
-                       break;
-                    }
-                  i += 4;
-               }
-             glsym_eglSwapBuffersWithDamage(ob->egl_disp, ob->egl_surface[0],
-                                            result, num);
-          }
-     }
-   else
-#endif
-      eglSwapBuffers(ob->egl_disp, ob->egl_surface[0]);
-
-   if (ob->info->callback.post_swap)
-     ob->info->callback.post_swap(ob->info->callback.data, ob->evas);
-
-   //Flush GL Surface data to Framebuffer
-   _outbuf_flush_famebuffer(ob);
-
-   ob->frame_cnt++;
-
- end:
-   //TODO: Need render unlock after drm page flip?
-   glsym_evas_gl_preload_render_unlock(eng_preload_make_current, ob);
-}
-
-Evas_Engine_GL_Context *
-eng_outbuf_gl_context_get(Outbuf *ob)
-{
-   return ob->gl_context;
-}
-
-void *
-eng_outbuf_egl_display_get(Outbuf *ob)
-{
-   return ob->egl_disp;
-}
diff --git a/src/modules/evas/engines/gl_drm/evas_engine.h 
b/src/modules/evas/engines/gl_drm/evas_engine.h
deleted file mode 100644
index b97b047..0000000
--- a/src/modules/evas/engines/gl_drm/evas_engine.h
+++ /dev/null
@@ -1,191 +0,0 @@
-#ifndef EVAS_ENGINE_H
-# define EVAS_ENGINE_H
-
-#include "config.h"
-#include "evas_common_private.h"
-#include "evas_private.h"
-#include "Evas.h"
-#include "Evas_Engine_GL_Drm.h"
-#include "evas_macros.h"
-
-#define GL_GLEXT_PROTOTYPES
-#include <EGL/egl.h>
-#include <EGL/eglext.h>
-#include <EGL/eglmesaext.h>
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-#include "../gl_generic/Evas_Engine_GL_Generic.h"
-
-#include <xf86drm.h>
-#include <xf86drmMode.h>
-#include <drm_fourcc.h>
-
-#include <signal.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-extern int extn_have_buffer_age;
-extern int _evas_engine_gl_drm_log_dom;
-
-extern Evas_GL_Common_Context_New glsym_evas_gl_common_context_new;
-extern Evas_GL_Common_Context_Call glsym_evas_gl_common_context_flush;
-extern Evas_GL_Common_Context_Call glsym_evas_gl_common_context_free;
-extern Evas_GL_Common_Context_Call glsym_evas_gl_common_context_use;
-extern Evas_GL_Common_Context_Call glsym_evas_gl_common_context_newframe;
-extern Evas_GL_Common_Context_Call glsym_evas_gl_common_context_done;
-extern Evas_GL_Common_Context_Resize_Call glsym_evas_gl_common_context_resize;
-extern Evas_GL_Common_Buffer_Dump_Call glsym_evas_gl_common_buffer_dump;
-extern Evas_GL_Preload_Render_Call glsym_evas_gl_preload_render_lock;
-extern Evas_GL_Preload_Render_Call glsym_evas_gl_preload_render_unlock;
-
-/* define this to enable debug for the gl_drm engine */
-/* #define GL_DRM_DBG 0 */
-
-# ifdef ERR
-#  undef ERR
-# endif
-# define ERR(...) EINA_LOG_DOM_ERR(_evas_engine_gl_drm_log_dom, __VA_ARGS__)
-
-# ifdef DBG
-#  undef DBG
-# endif
-# define DBG(...) EINA_LOG_DOM_DBG(_evas_engine_gl_drm_log_dom, __VA_ARGS__)
-
-# ifdef INF
-#  undef INF
-# endif
-# define INF(...) EINA_LOG_DOM_INFO(_evas_engine_gl_drm_log_dom, __VA_ARGS__)
-
-# ifdef WRN
-#  undef WRN
-# endif
-# define WRN(...) EINA_LOG_DOM_WARN(_evas_engine_gl_drm_log_dom, __VA_ARGS__)
-
-# ifdef CRI
-#  undef CRI
-# endif
-# define CRI(...) EINA_LOG_DOM_CRIT(_evas_engine_gl_drm_log_dom, __VA_ARGS__)
-
-# define NUM_BUFFERS 2
-
-typedef struct _Buffer Buffer;
-typedef struct _Plane Plane;
-
-struct _Buffer
-{
-   int stride;
-   int size;
-   int handle;
-   unsigned int fb;
-   struct gbm_bo *bo; //used for hardware framebuffers
-   Eina_Bool valid : 1;
-};
-
-struct _Plane
-{
-   unsigned int id;
-   unsigned int crtcs;
-
-   struct
-     {
-        unsigned int x, y;
-        unsigned int w, h;
-     } src, dst;
-
-   unsigned int num_formats;
-   unsigned int formats[];
-};
-
-struct _Outbuf
-{
-   EGLContext egl_context[1];
-   EGLSurface egl_surface[1];
-   EGLConfig egl_config;
-   EGLDisplay egl_disp;
-   struct gbm_device *gbm;
-   struct gbm_surface *surface;
-   Evas *evas;
-   uint32_t format;
-   uint32_t flags;
-   Evas_Engine_GL_Context *gl_context;
-   Evas_Engine_Info_GL_Drm *info;
-   Render_Engine_Swap_Mode swap_mode;
-   int w, h;
-   int depth, rot, screen, alpha;
-   int prev_age;
-   int frame_cnt;
-   int vsync;
-   Eina_Bool lost_back : 1;
-   Eina_Bool surf : 1;
-
-   struct
-     {
-        Eina_Bool drew : 1;
-     } draw;
-
-   struct
-     {
-        int fd;
-        unsigned int conn, crtc, fb;
-        Buffer buffer[NUM_BUFFERS];
-        int curr, num;
-        drmModeModeInfo mode;
-        drmEventContext ctx;
-        Eina_List *pending_writes;
-        Eina_List *planes;
-        Eina_Bool pending_flip : 1;
-     } priv;
-};
-
-struct _Context_3D
-{
-   EGLDisplay display;
-   EGLContext context;
-   EGLSurface surface;
-};
-
-Outbuf *eng_window_new(Evas_Engine_Info_GL_Drm *info, Evas *e, struct 
gbm_device *gbm, struct gbm_surface *surface, int screen, int depth, int w, int 
h, int indirect, int alpha, int rot, Render_Engine_Swap_Mode swap_mode);
-void eng_window_free(Outbuf *gw);
-void eng_window_use(Outbuf *gw);
-void eng_window_unsurf(Outbuf *gw);
-void eng_window_resurf(Outbuf *gw);
-
-void eng_outbuf_reconfigure(Outbuf *ob, int w, int h, int rot, Outbuf_Depth 
depth);
-int eng_outbuf_get_rot(Outbuf *ob);
-Render_Engine_Swap_Mode eng_outbuf_swap_mode(Outbuf *ob);
-Eina_Bool eng_outbuf_region_first_rect(Outbuf *ob);
-void *eng_outbuf_new_region_for_update(Outbuf *ob, int x, int y, int w, int h, 
int *cx, int *cy, int *cw, int *ch);
-void eng_outbuf_push_free_region_for_update(Outbuf *ob, RGBA_Image *update);
-void eng_outbuf_push_updated_region(Outbuf *ob, RGBA_Image *update, int x, int 
y, int w, int h);
-void eng_outbuf_flush(Outbuf *ob, Tilebuf_Rect *rects, Evas_Render_Mode 
render_mode);
-Evas_Engine_GL_Context* eng_outbuf_gl_context_get(Outbuf *ob);
-void *eng_outbuf_egl_display_get(Outbuf *ob);
-
-void eng_gl_context_free(Context_3D *context);
-void eng_gl_context_use(Context_3D *context);
-
-Eina_Bool eng_preload_make_current(void *data, void *doit);
-
-Context_3D *eng_gl_context_new(Outbuf *win);
-
-static inline Eina_Bool
-_re_wincheck(Outbuf *ob)
-{
-   if (ob->surf) return EINA_TRUE;
-   eng_window_resurf(ob);
-   ob->lost_back = 1;
-   if (!ob->surf)
-     {
-        ERR("GL engine can't re-create window surface!");
-     }
-   return EINA_FALSE;
-}
-
-Eina_Bool evas_drm_gbm_init(Evas_Engine_Info_GL_Drm *info, int w, int h);
-Eina_Bool evas_drm_gbm_shutdown(Evas_Engine_Info_GL_Drm *info);
-Eina_Bool evas_drm_outbuf_setup(Outbuf *ob);
-void evas_drm_outbuf_framebuffer_set(Outbuf *ob, Buffer *buffer);
-Eina_Bool evas_drm_framebuffer_send(Outbuf *ob, Buffer *buffer);
-#endif

-- 


Reply via email to