ecore-drm: Create drmEventContext Once during device open
authorChris Michael <cp.michael@samsung.com>
Tue, 7 Apr 2015 18:30:43 +0000 (14:30 -0400)
committerStefan Schmidt <s.schmidt@samsung.com>
Fri, 10 Apr 2015 09:09:50 +0000 (11:09 +0200)
Summary: This changes allows us to reuse the same drmEventContext once
so that when we get drm events, we are not constantly recreating the
drmEventContext.

@fix

Signed-off-by: Chris Michael <cp.michael@samsung.com>
src/lib/ecore_drm/Ecore_Drm.h
src/lib/ecore_drm/ecore_drm_device.c

index 8b07cb5..cb6c6b2 100644 (file)
@@ -117,6 +117,10 @@ struct _Ecore_Drm_Device
    int current_fb;
    Ecore_Drm_Fb *current, *next;
    Ecore_Drm_Fb *dumb[2];
+
+   drmEventContext drm_ctx;
+
+   Eina_Bool active : 1;
 };
 
 struct _Ecore_Drm_Event_Activate
@@ -205,6 +209,8 @@ EAPI int ecore_drm_device_fd_get(Ecore_Drm_Device *dev);
 EAPI void ecore_drm_device_window_set(Ecore_Drm_Device *dev, unsigned int window);
 EAPI const char *ecore_drm_device_name_get(Ecore_Drm_Device *dev);
 
+EAPI void ecore_drm_device_fb_set(Ecore_Drm_Device *dev, Ecore_Drm_Fb *fb);
+
 /**
  * Setup an Ecore_Drm_Device for software rendering
  *
index 12f55ab..b0f7953 100644 (file)
@@ -58,19 +58,12 @@ static Eina_Bool
 _ecore_drm_device_cb_event(void *data, Ecore_Fd_Handler *hdlr EINA_UNUSED)
 {
    Ecore_Drm_Device *dev;
-   drmEventContext ctx;
 
    if (!(dev = data)) return ECORE_CALLBACK_RENEW;
 
    DBG("Drm Device Event");
 
-   memset(&ctx, 0, sizeof(ctx));
-
-   ctx.version = DRM_EVENT_CONTEXT_VERSION;
-   ctx.page_flip_handler = _ecore_drm_device_cb_page_flip;
-   ctx.vblank_handler = _ecore_drm_device_cb_vblank;
-
-   drmHandleEvent(dev->drm.fd, &ctx);
+   drmHandleEvent(dev->drm.fd, &dev->drm_ctx);
 
    return ECORE_CALLBACK_RENEW;
 }
@@ -327,6 +320,11 @@ ecore_drm_device_open(Ecore_Drm_Device *dev)
         return EINA_FALSE;
      }
 
+   memset(&dev->drm_ctx, 0, sizeof(dev->drm_ctx));
+   dev->drm_ctx.version = DRM_EVENT_CONTEXT_VERSION;
+   dev->drm_ctx.page_flip_handler = _ecore_drm_device_cb_page_flip;
+   dev->drm_ctx.vblank_handler = _ecore_drm_device_cb_vblank;
+
    events = (EEZE_UDEV_EVENT_ADD | EEZE_UDEV_EVENT_REMOVE |
              EEZE_UDEV_EVENT_CHANGE);