evas/gl_x11 : Add multiple_buffer member in native surface x11 type union.
authorMinkyoung Kim <mer.kim@samsung.com>
Wed, 17 Aug 2016 08:50:18 +0000 (17:50 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Wed, 17 Aug 2016 08:56:17 +0000 (17:56 +0900)
Summary:
If native surface is multiple buffer pixmap such as named pixmap, Evas should recreate eglImage everyframe.
Because DDK get the buffer ID once at eglImageCreate time.
So if internal buffer ID is changed, should recreate eglImage.

Test Plan: Wearable Tizen.

Reviewers: wonsik, raster, cedric, jpeg

Reviewed By: jpeg

Subscribers: spacegrapher, dkdk, cedric

Differential Revision: https://phab.enlightenment.org/D4211

src/lib/evas/Evas_Legacy.h
src/modules/evas/engines/gl_x11/evas_engine.c
src/modules/evas/engines/software_generic/evas_native_common.h

index 9608891..b200c28 100644 (file)
@@ -3245,7 +3245,7 @@ EAPI void                          evas_object_image_memfile_set(Evas_Object *ob
  * Magic version number to know what the native surface struct looks like
  */
 
-#define EVAS_NATIVE_SURFACE_VERSION 3
+#define EVAS_NATIVE_SURFACE_VERSION 4
 
 /**
  * Native surface types that image object supports
@@ -3300,6 +3300,7 @@ typedef struct _Evas_Native_Surface
       {
          void         *visual; /**< visual of the pixmap to use (Visual) */
          unsigned long pixmap; /**< pixmap id to use (Pixmap) */
+         unsigned int  multiple_buffer; /**< From version 4. 1 if pixmap is multiple buffer pixmap such as named pixmap created by enlightenment. driver dependent. @since 1.19 */
       } x11; /**< Set this struct fields if surface data is X11 based. */
 
       struct
index 34e04e5..093a025 100644 (file)
@@ -2037,6 +2037,31 @@ _native_bind_cb(void *image)
 #ifdef GL_GLES
        if (n->ns_data.x11.surface)
          {
+            if (n->ns_data.x11.multiple_buffer)
+              {
+                 EGLint err;
+                 if (!glsym_eglDestroyImage || !glsym_eglCreateImage)
+                   {
+                      ERR("Try eglDestroyImage()/eglCreateImage() on EGL with no support");
+                      return;
+                   }
+
+                 glsym_eglDestroyImage(im->native.disp, n->ns_data.x11.surface);
+                 if ((err = eglGetError()) != EGL_SUCCESS)
+                   {
+                      ERR("eglDestroyImage() failed.");
+                      glsym_evas_gl_common_error_set(err - EGL_SUCCESS);
+                   }
+
+                 n->ns_data.x11.surface = glsym_eglCreateImage(im->native.disp,
+                                                       EGL_NO_CONTEXT,
+                                                       EGL_NATIVE_PIXMAP_KHR,
+                                                       (void *)n->ns_data.x11.pixmap,
+                                                       NULL);
+                 if (!n->ns_data.x11.surface)
+                   ERR("eglCreateImage() for Pixmap 0x%#lx failed: %#x", n->ns_data.x11.pixmap, eglGetError());
+
+              }
             if (glsym_glEGLImageTargetTexture2DOES)
               {
                  glsym_glEGLImageTargetTexture2DOES(im->native.target, n->ns_data.x11.surface);
@@ -2628,6 +2653,13 @@ eng_image_native_set(void *data, void *image, void *native)
                                                                EGL_NO_CONTEXT,
                                                                EGL_NATIVE_PIXMAP_KHR,
                                                                (void *)pm, NULL);
+
+                 if ((ns->version < 4) ||
+                     ((ns->version == 4) && !(ns->data.x11.multiple_buffer == 1)))
+                   n->ns_data.x11.multiple_buffer = 0;
+                 else
+                   n->ns_data.x11.multiple_buffer = 1;
+
                  if (!n->ns_data.x11.surface)
                    {
                       ERR("eglCreateImage() for Pixmap %#lx failed: %#x", pm, eglGetError());
index a13b7a0..a3b721d 100644 (file)
@@ -64,6 +64,7 @@ struct _Native
          void                     *buffer;
          void                     *config;   /* egl configuration or glx configuration */
          void                     *surface; /* egl surface or glx surface */
+         unsigned char             multiple_buffer : 1; /* whether pixmap is multiple buffer */
       } x11; /**< Set this struct fields if surface data is SW X11 based. */
 
        /*  EVAS_NATIVE_SURFACE_WL */