jpeg pushed a commit to branch master.

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

commit 0c95b694742c712ec4c66e566f216f1b6c1b7079
Author: Jean-Philippe Andre <jp.an...@samsung.com>
Date:   Wed Mar 9 16:21:08 2016 +0900

    Evas.Image: Move native surfaces to Efl.Canvas.Surface
    
    X11, TBM and Wayland support are implemented for now.
---
 src/Makefile_Evas.am                              | 10 +++
 src/lib/evas/Evas_Common.h                        | 84 --------------------
 src/lib/evas/Evas_Legacy.h                        | 93 +++++++++++++++++++++++
 src/lib/evas/canvas/efl_canvas_surface.c          | 19 +++++
 src/lib/evas/canvas/efl_canvas_surface.eo         | 33 ++++++++
 src/lib/evas/canvas/efl_canvas_surface.h          | 13 ++++
 src/lib/evas/canvas/efl_canvas_surface_tbm.c      | 54 +++++++++++++
 src/lib/evas/canvas/efl_canvas_surface_tbm.eo     | 10 +++
 src/lib/evas/canvas/efl_canvas_surface_wayland.c  | 54 +++++++++++++
 src/lib/evas/canvas/efl_canvas_surface_wayland.eo | 10 +++
 src/lib/evas/canvas/efl_canvas_surface_x11.c      | 84 ++++++++++++++++++++
 src/lib/evas/canvas/efl_canvas_surface_x11.eo     | 28 +++++++
 src/lib/evas/canvas/evas_image.eo                 | 21 -----
 src/lib/evas/canvas/evas_image_private.h          |  2 +
 src/lib/evas/canvas/evas_object_image.c           | 42 +++++-----
 15 files changed, 434 insertions(+), 123 deletions(-)

diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am
index 28c670d..d1588aa 100644
--- a/src/Makefile_Evas.am
+++ b/src/Makefile_Evas.am
@@ -44,6 +44,10 @@ evas_eolian_pub_files = \
        lib/evas/canvas/efl_canvas_snapshot.eo \
        lib/evas/canvas/efl_canvas_proxy.eo \
        lib/evas/canvas/efl_canvas_scene3d.eo \
+       lib/evas/canvas/efl_canvas_surface.eo \
+       lib/evas/canvas/efl_canvas_surface_tbm.eo \
+       lib/evas/canvas/efl_canvas_surface_x11.eo \
+       lib/evas/canvas/efl_canvas_surface_wayland.eo \
        lib/evas/canvas/evas_filter.eo \
        $(NULL)
 
@@ -106,6 +110,8 @@ lib/evas/include/evas_common_private.h \
 lib/evas/include/evas_blend_ops.h \
 lib/evas/include/evas_filter.h \
 lib/evas/canvas/evas_vg_private.h \
+lib/evas/canvas/evas_image_private.h \
+lib/evas/canvas/efl_canvas_surface.h \
 lib/evas/common3d/primitives/primitive_common.h
 
 # Linebreak
@@ -179,6 +185,10 @@ lib/evas/canvas/evas_out.c \
 lib/evas/canvas/efl_canvas_proxy.c \
 lib/evas/canvas/efl_canvas_snapshot.c \
 lib/evas/canvas/efl_canvas_scene3d.c \
+lib/evas/canvas/efl_canvas_surface.c \
+lib/evas/canvas/efl_canvas_surface_tbm.c \
+lib/evas/canvas/efl_canvas_surface_x11.c \
+lib/evas/canvas/efl_canvas_surface_wayland.c \
 $(NULL)
 
 EXTRA_DIST += \
diff --git a/src/lib/evas/Evas_Common.h b/src/lib/evas/Evas_Common.h
index c41af8b..d3a1844 100644
--- a/src/lib/evas/Evas_Common.h
+++ b/src/lib/evas/Evas_Common.h
@@ -287,90 +287,6 @@ struct _Evas_Pixel_Import_Source
    void                         **rows; /**< an array of pointers (size 
depends on format) pointing to left edge of each scanline */
 };
 
-/**
- * @def EVAS_NATIVE_SURFACE_VERSION
- * Magic version number to know what the native surface struct looks like
- */
-
-#define EVAS_NATIVE_SURFACE_VERSION 3
-
-/**
- * Native surface types that image object supports
- *
- * @see Evas_Native_Surface
- * @see evas_object_image_native_surface_set()
- */
-typedef enum _Evas_Native_Surface_Type
-{
-   EVAS_NATIVE_SURFACE_NONE, /**< No surface type */
-   EVAS_NATIVE_SURFACE_X11,  /**< X Window system based type. pixmap id or 
visual of the pixmap */
-   EVAS_NATIVE_SURFACE_OPENGL, /**< OpenGL system based type. texture or 
framebuffer id*/
-   EVAS_NATIVE_SURFACE_WL, /**< Wayland system based type. buffer of surface */
-   EVAS_NATIVE_SURFACE_TBM, /**< Tizen system based type. tbm surface @since 
1.14  */
-   EVAS_NATIVE_SURFACE_EVASGL, /**< Evas GL based type. evas gl surface @since 
1.14 */
-} Evas_Native_Surface_Type;
-
-/**
- * @brief A generic datatype for engine specific native surface information.
- *
- * Please fill up Evas_Native_Surface fields that regarded with current surface
- * type. If you want to set the native surface type to
- * EVAS_NATIVE_SURFACE_X11, you need to set union data with x11.visual or
- * x11.pixmap. If you need to set the native surface as
- * EVAS_NATIVE_SURFACE_OPENGL, on the other hand, you need to set union data
- * with opengl.texture_id or opengl.framebuffer_id and so on.
- * If you need to set the native surface as EVAS_NATIVE_SURFACE_WL,
- * you need to set union data with wl.legacy_buffer.
- * If you need to set the native surface as EVAS_NATIVE_SURFACE_TBM,
- * you need to set union data with tbm surface. The version field
- * should be set with EVAS_NATIVE_SURFACE_VERSION in order to check abi
- * break in your application on the different efl library versions.
- *
- * @warning Native surface types totally depend on the system. Please
- *          be aware that the types are supported on your system before using
- *          them.
- *
- * @note The information stored in an @c Evas_Native_Surface returned by
- *       @ref evas_gl_native_surface_get() is not meant to be used by
- *       applications except for passing it to
- *       @ref evas_object_image_native_surface_set().
- *
- * @see evas_object_image_native_surface_set()
- */
-struct _Evas_Native_Surface
-{
-   int                      version; /**< Current Native Surface Version. Use 
EVAS_NATIVE_SURFACE_VERSION */
-   Evas_Native_Surface_Type type; /**< Surface type. @see 
Evas_Native_Surface_Type */
-   union {
-      struct
-      {
-         void         *visual; /**< visual of the pixmap to use (Visual) */
-         unsigned long pixmap; /**< pixmap id to use (Pixmap) */
-      } x11; /**< Set this struct fields if surface data is X11 based. */
-
-      struct
-      {
-         unsigned int texture_id; /**< opengl texture id to use from 
glGenTextures() */
-         unsigned int framebuffer_id; /**< 0 if not a FBO, FBO id otherwise 
from glGenFramebuffers() */
-         unsigned int internal_format; /**< same as 'internalFormat' for 
glTexImage2D() */
-         unsigned int format; /**< same as 'format' for glTexImage2D() */
-         unsigned int x, y, w, h; /**< region inside the texture to use (image 
size is assumed as texture size, with 0, 0 being the top-left and co-ordinates 
working down to the right and bottom being positive) */
-      } opengl; /**< Set this struct fields if surface data is OpenGL based. */
-      struct
-      {
-         void *legacy_buffer; /**< wayland client buffer to use */
-      } wl; /**< Set this struct fields if surface data is Wayland based. */
-      struct
-      {
-         void *buffer; /**< tbm surface buffer to use @since 1.14 */
-      } tbm; /**< Set this struct fields if surface data is Tizen based. 
@since 1.14 */
-      struct
-      {
-         void *surface; /**< evas gl surface to use @since 1.14 */
-      } evasgl; /**< Set this struct fields if surface data is Evas GL based. 
@since 1.14 */
-   } data; /**< Choose one union data according to your surface. */
-};
-
 #define EVAS_LAYER_MIN                   -32768 /**< bottom-most layer number 
*/
 #define EVAS_LAYER_MAX                   32767 /**< top-most layer number */
 
diff --git a/src/lib/evas/Evas_Legacy.h b/src/lib/evas/Evas_Legacy.h
index 21d29d7..65f7a0a 100644
--- a/src/lib/evas/Evas_Legacy.h
+++ b/src/lib/evas/Evas_Legacy.h
@@ -2524,6 +2524,90 @@ EAPI Evas_Object                  
*evas_object_image_filled_add(Evas *e) EINA_WA
 EAPI void                          evas_object_image_memfile_set(Evas_Object 
*obj, void *data, int size, char *format, char *key) EINA_ARG_NONNULL(1, 2);
 
 /**
+ * @def EVAS_NATIVE_SURFACE_VERSION
+ * Magic version number to know what the native surface struct looks like
+ */
+
+#define EVAS_NATIVE_SURFACE_VERSION 3
+
+/**
+ * Native surface types that image object supports
+ *
+ * @see Evas_Native_Surface
+ * @see evas_object_image_native_surface_set()
+ */
+typedef enum _Evas_Native_Surface_Type
+{
+   EVAS_NATIVE_SURFACE_NONE, /**< No surface type */
+   EVAS_NATIVE_SURFACE_X11,  /**< X Window system based type. pixmap id or 
visual of the pixmap */
+   EVAS_NATIVE_SURFACE_OPENGL, /**< OpenGL system based type. texture or 
framebuffer id*/
+   EVAS_NATIVE_SURFACE_WL, /**< Wayland system based type. buffer of surface */
+   EVAS_NATIVE_SURFACE_TBM, /**< Tizen system based type. tbm surface @since 
1.14  */
+   EVAS_NATIVE_SURFACE_EVASGL, /**< Evas GL based type. evas gl surface @since 
1.14 */
+} Evas_Native_Surface_Type;
+
+/**
+ * @brief A generic datatype for engine specific native surface information.
+ *
+ * Please fill up Evas_Native_Surface fields that regarded with current surface
+ * type. If you want to set the native surface type to
+ * EVAS_NATIVE_SURFACE_X11, you need to set union data with x11.visual or
+ * x11.pixmap. If you need to set the native surface as
+ * EVAS_NATIVE_SURFACE_OPENGL, on the other hand, you need to set union data
+ * with opengl.texture_id or opengl.framebuffer_id and so on.
+ * If you need to set the native surface as EVAS_NATIVE_SURFACE_WL,
+ * you need to set union data with wl.legacy_buffer.
+ * If you need to set the native surface as EVAS_NATIVE_SURFACE_TBM,
+ * you need to set union data with tbm surface. The version field
+ * should be set with EVAS_NATIVE_SURFACE_VERSION in order to check abi
+ * break in your application on the different efl library versions.
+ *
+ * @warning Native surface types totally depend on the system. Please
+ *          be aware that the types are supported on your system before using
+ *          them.
+ *
+ * @note The information stored in an @c Evas_Native_Surface returned by
+ *       @ref evas_gl_native_surface_get() is not meant to be used by
+ *       applications except for passing it to
+ *       @ref evas_object_image_native_surface_set().
+ *
+ * @see evas_object_image_native_surface_set()
+ */
+struct _Evas_Native_Surface
+{
+   int                      version; /**< Current Native Surface Version. Use 
EVAS_NATIVE_SURFACE_VERSION */
+   Evas_Native_Surface_Type type; /**< Surface type. @see 
Evas_Native_Surface_Type */
+   union {
+      struct
+      {
+         void         *visual; /**< visual of the pixmap to use (Visual) */
+         unsigned long pixmap; /**< pixmap id to use (Pixmap) */
+      } x11; /**< Set this struct fields if surface data is X11 based. */
+
+      struct
+      {
+         unsigned int texture_id; /**< opengl texture id to use from 
glGenTextures() */
+         unsigned int framebuffer_id; /**< 0 if not a FBO, FBO id otherwise 
from glGenFramebuffers() */
+         unsigned int internal_format; /**< same as 'internalFormat' for 
glTexImage2D() */
+         unsigned int format; /**< same as 'format' for glTexImage2D() */
+         unsigned int x, y, w, h; /**< region inside the texture to use (image 
size is assumed as texture size, with 0, 0 being the top-left and co-ordinates 
working down to the right and bottom being positive) */
+      } opengl; /**< Set this struct fields if surface data is OpenGL based. */
+      struct
+      {
+         void *legacy_buffer; /**< wayland client buffer to use */
+      } wl; /**< Set this struct fields if surface data is Wayland based. */
+      struct
+      {
+         void *buffer; /**< tbm surface buffer to use @since 1.14 */
+      } tbm; /**< Set this struct fields if surface data is Tizen based. 
@since 1.14 */
+      struct
+      {
+         void *surface; /**< evas gl surface to use @since 1.14 */
+      } evasgl; /**< Set this struct fields if surface data is Evas GL based. 
@since 1.14 */
+   } data; /**< Choose one union data according to your surface. */
+};
+
+/**
  * Set the native surface of a given image of the canvas
  *
  * @param obj The given canvas pointer.
@@ -2535,6 +2619,15 @@ EAPI void                          
evas_object_image_memfile_set(Evas_Object *ob
 EAPI void                          
evas_object_image_native_surface_set(Evas_Object *obj, Evas_Native_Surface 
*surf) EINA_ARG_NONNULL(1, 2);
 
 /**
+ * @brief Get the native surface of a given image of the canvas
+ *
+ * This function returns the native surface of a given canvas image.
+ *
+ * @return The native surface.
+ */
+EAPI Evas_Native_Surface          *evas_object_image_native_surface_get(const 
Evas_Object *obj);
+
+/**
  * Preload an image object's image data in the background
  *
  * @param obj The given image object.
diff --git a/src/lib/evas/canvas/efl_canvas_surface.c 
b/src/lib/evas/canvas/efl_canvas_surface.c
new file mode 100644
index 0000000..7f52945
--- /dev/null
+++ b/src/lib/evas/canvas/efl_canvas_surface.c
@@ -0,0 +1,19 @@
+#include "efl_canvas_surface.h"
+
+#define MY_CLASS EFL_CANVAS_SURFACE_MIXIN
+
+EOLIAN static Eo *
+_efl_canvas_surface_eo_base_constructor(Eo *eo, Efl_Canvas_Surface_Data *pd)
+{
+   eo = eo_constructor(eo_super(eo, MY_CLASS));
+   pd->surf.version = EVAS_NATIVE_SURFACE_VERSION;
+   return eo;
+}
+
+EOLIAN static void *
+_efl_canvas_surface_native_buffer_get(Eo *obj EINA_UNUSED, 
Efl_Canvas_Surface_Data *pd)
+{
+   return pd->buffer;
+}
+
+#include "efl_canvas_surface.eo.c"
diff --git a/src/lib/evas/canvas/efl_canvas_surface.eo 
b/src/lib/evas/canvas/efl_canvas_surface.eo
new file mode 100644
index 0000000..cc4b8d7
--- /dev/null
+++ b/src/lib/evas/canvas/efl_canvas_surface.eo
@@ -0,0 +1,33 @@
+mixin Efl.Canvas.Surface (Evas.Image, Efl.Gfx.Buffer, Efl.Gfx.View)
+{
+   [[Native surfaces usually bound to an externally-managed buffer.
+
+     The attached @.native_buffer is entirely platform-dependent, which means
+     some of this mixin's subclasses will not work (constructor returns $null)
+     on some platforms. This class is meant to be used from native code only
+     (C or C++), with direct access to the display system or a buffer
+     allocation system.
+   ]]
+   legacy_prefix: null;
+   methods {
+      @property native_buffer {
+          [[External buffer attached to this native surface.
+
+            Set to $null to detach this surface from the external buffer.
+          ]]
+          get {}
+          set {
+             [[Set the buffer. If this fails, this function returns $false,
+               and the surface is left without any attached buffer.
+             ]]
+             return: bool @warn_unused;
+          }
+          values {
+             buffer: void*; [[The external buffer, depends on its type.]]
+          }
+      }
+   }
+   implements {
+      Eo.Base.constructor;
+   }
+}
diff --git a/src/lib/evas/canvas/efl_canvas_surface.h 
b/src/lib/evas/canvas/efl_canvas_surface.h
new file mode 100644
index 0000000..4bd93e5
--- /dev/null
+++ b/src/lib/evas/canvas/efl_canvas_surface.h
@@ -0,0 +1,13 @@
+#define EFL_CANVAS_SURFACE_PROTECTED
+
+#include "evas_image_private.h"
+#include "efl_canvas_surface.eo.h"
+#include "efl_canvas_surface_tbm.eo.h"
+#include "efl_canvas_surface_x11.eo.h"
+#include "efl_canvas_surface_wayland.eo.h"
+
+typedef struct _Efl_Canvas_Surface_Data
+{
+   Evas_Native_Surface surf;
+   void *buffer;
+} Efl_Canvas_Surface_Data;
diff --git a/src/lib/evas/canvas/efl_canvas_surface_tbm.c 
b/src/lib/evas/canvas/efl_canvas_surface_tbm.c
new file mode 100644
index 0000000..10351bb
--- /dev/null
+++ b/src/lib/evas/canvas/efl_canvas_surface_tbm.c
@@ -0,0 +1,54 @@
+#include "efl_canvas_surface.h"
+
+#define MY_CLASS EFL_CANVAS_SURFACE_TBM_CLASS
+
+typedef struct _Efl_Canvas_Surface_Tbm_Data
+{
+   Efl_Canvas_Surface_Data *base;
+} Efl_Canvas_Surface_Tbm_Data;
+
+EOLIAN static Eo *
+_efl_canvas_surface_tbm_eo_base_constructor(Eo *eo, 
Efl_Canvas_Surface_Tbm_Data *pd)
+{
+   Evas_Object_Protected_Data *obj;
+
+   eo = eo_constructor(eo_super(eo, MY_CLASS));
+   obj = eo_data_scope_get(eo, EVAS_OBJECT_CLASS);
+   if (!obj) return NULL;
+
+   if (!ENFN->image_native_init(ENDT, EVAS_NATIVE_SURFACE_TBM))
+     {
+        ERR("TBM is not supported on this platform");
+        return NULL;
+     }
+
+   pd->base = eo_data_ref(eo, EFL_CANVAS_SURFACE_MIXIN);
+   pd->base->surf.type = EVAS_NATIVE_SURFACE_TBM;
+   return eo;
+}
+
+EOLIAN static void
+_efl_canvas_surface_tbm_eo_base_destructor(Eo *eo, Efl_Canvas_Surface_Tbm_Data 
*pd)
+{
+   Evas_Object_Protected_Data *obj = obj = eo_data_scope_get(eo, 
EVAS_OBJECT_CLASS);
+
+   ENFN->image_native_shutdown(ENDT, EVAS_NATIVE_SURFACE_TBM);
+   eo_data_unref(eo, pd->base);
+   eo_destructor(eo);
+}
+
+EOLIAN static Eina_Bool
+_efl_canvas_surface_tbm_efl_canvas_surface_native_buffer_set(Eo *eo, 
Efl_Canvas_Surface_Tbm_Data *pd, void *buffer)
+{
+   pd->base->surf.data.tbm.buffer = buffer;
+   if (!_evas_image_native_surface_set(eo, &pd->base->surf))
+     {
+        ERR("failed to set native buffer");
+        pd->base->buffer = NULL;
+        return EINA_FALSE;
+     }
+   pd->base->buffer = buffer;
+   return EINA_TRUE;
+}
+
+#include "efl_canvas_surface_tbm.eo.c"
diff --git a/src/lib/evas/canvas/efl_canvas_surface_tbm.eo 
b/src/lib/evas/canvas/efl_canvas_surface_tbm.eo
new file mode 100644
index 0000000..58d5086
--- /dev/null
+++ b/src/lib/evas/canvas/efl_canvas_surface_tbm.eo
@@ -0,0 +1,10 @@
+class Efl.Canvas.Surface_Tbm (Efl.Canvas.Surface)
+{
+   legacy_prefix: null;
+   implements {
+      Eo.Base.constructor;
+      Eo.Base.destructor;
+      Efl.Canvas.Surface.native_buffer.set;
+      Efl.Canvas.Surface.native_buffer.get;
+   }
+}
diff --git a/src/lib/evas/canvas/efl_canvas_surface_wayland.c 
b/src/lib/evas/canvas/efl_canvas_surface_wayland.c
new file mode 100644
index 0000000..1798107
--- /dev/null
+++ b/src/lib/evas/canvas/efl_canvas_surface_wayland.c
@@ -0,0 +1,54 @@
+#include "efl_canvas_surface.h"
+
+#define MY_CLASS EFL_CANVAS_SURFACE_WAYLAND_CLASS
+
+typedef struct _Efl_Canvas_Surface_Wayland_Data
+{
+   Efl_Canvas_Surface_Data *base;
+} Efl_Canvas_Surface_Wayland_Data;
+
+EOLIAN static Eo *
+_efl_canvas_surface_wayland_eo_base_constructor(Eo *eo, 
Efl_Canvas_Surface_Wayland_Data *pd)
+{
+   Evas_Object_Protected_Data *obj;
+
+   eo = eo_constructor(eo_super(eo, MY_CLASS));
+   obj = eo_data_scope_get(eo, EVAS_OBJECT_CLASS);
+   if (!obj) return NULL;
+
+   if (!ENFN->image_native_init(ENDT, EVAS_NATIVE_SURFACE_WL))
+     {
+        ERR("Wayland surfaces are not supported on this platform");
+        return NULL;
+     }
+
+   pd->base = eo_data_ref(eo, EFL_CANVAS_SURFACE_MIXIN);
+   pd->base->surf.type = EVAS_NATIVE_SURFACE_WL;
+   return eo;
+}
+
+EOLIAN static void
+_efl_canvas_surface_wayland_eo_base_destructor(Eo *eo, 
Efl_Canvas_Surface_Wayland_Data *pd)
+{
+   Evas_Object_Protected_Data *obj = obj = eo_data_scope_get(eo, 
EVAS_OBJECT_CLASS);
+
+   ENFN->image_native_shutdown(ENDT, EVAS_NATIVE_SURFACE_WL);
+   eo_data_unref(eo, pd->base);
+   eo_destructor(eo);
+}
+
+EOLIAN static Eina_Bool
+_efl_canvas_surface_wayland_efl_canvas_surface_native_buffer_set(Eo *eo, 
Efl_Canvas_Surface_Wayland_Data *pd, void *buffer)
+{
+   pd->base->surf.data.wl.legacy_buffer = buffer;
+   if (!_evas_image_native_surface_set(eo, &pd->base->surf))
+     {
+        ERR("failed to set native buffer");
+        pd->base->buffer = NULL;
+        return EINA_FALSE;
+     }
+   pd->base->buffer = buffer;
+   return EINA_TRUE;
+}
+
+#include "efl_canvas_surface_wayland.eo.c"
diff --git a/src/lib/evas/canvas/efl_canvas_surface_wayland.eo 
b/src/lib/evas/canvas/efl_canvas_surface_wayland.eo
new file mode 100644
index 0000000..1e92818
--- /dev/null
+++ b/src/lib/evas/canvas/efl_canvas_surface_wayland.eo
@@ -0,0 +1,10 @@
+class Efl.Canvas.Surface_Wayland (Efl.Canvas.Surface)
+{
+   legacy_prefix: null;
+   implements {
+      Eo.Base.constructor;
+      Eo.Base.destructor;
+      Efl.Canvas.Surface.native_buffer.get;
+      Efl.Canvas.Surface.native_buffer.set;
+   }
+}
diff --git a/src/lib/evas/canvas/efl_canvas_surface_x11.c 
b/src/lib/evas/canvas/efl_canvas_surface_x11.c
new file mode 100644
index 0000000..1aab748
--- /dev/null
+++ b/src/lib/evas/canvas/efl_canvas_surface_x11.c
@@ -0,0 +1,84 @@
+#include "efl_canvas_surface.h"
+
+#define MY_CLASS EFL_CANVAS_SURFACE_X11_CLASS
+
+typedef struct _Efl_Canvas_Surface_X11_Data
+{
+   Efl_Canvas_Surface_Data *base;
+   Efl_Canvas_Surface_X11_Pixmap px;
+} Efl_Canvas_Surface_X11_Data;
+
+EOLIAN static Eo *
+_efl_canvas_surface_x11_eo_base_constructor(Eo *eo, 
Efl_Canvas_Surface_X11_Data *pd)
+{
+   Evas_Object_Protected_Data *obj;
+
+   eo = eo_constructor(eo_super(eo, MY_CLASS));
+   obj = eo_data_scope_get(eo, EVAS_OBJECT_CLASS);
+   if (!obj) return NULL;
+
+   if (!ENFN->image_native_init(ENDT, EVAS_NATIVE_SURFACE_X11))
+     {
+        ERR("X11 is not supported on this platform");
+        return NULL;
+     }
+
+   pd->base = eo_data_ref(eo, EFL_CANVAS_SURFACE_MIXIN);
+   pd->base->surf.version = EVAS_NATIVE_SURFACE_VERSION;
+   pd->base->surf.type = EVAS_NATIVE_SURFACE_X11;
+   return eo;
+}
+
+EOLIAN static void
+_efl_canvas_surface_x11_eo_base_destructor(Eo *eo, Efl_Canvas_Surface_X11_Data 
*pd)
+{
+   Evas_Object_Protected_Data *obj = obj = eo_data_scope_get(eo, 
EVAS_OBJECT_CLASS);
+
+   ENFN->image_native_shutdown(ENDT, EVAS_NATIVE_SURFACE_X11);
+   eo_data_unref(eo, pd->base);
+   eo_destructor(eo);
+}
+
+EOLIAN static Eina_Bool
+_efl_canvas_surface_x11_pixmap_set(Eo *eo, Efl_Canvas_Surface_X11_Data *pd 
EINA_UNUSED, void *visual, unsigned long pixmap)
+{
+   pd->px.pixmap = pixmap;
+   pd->px.visual = visual;
+   if (!_evas_image_native_surface_set(eo, &pd->base->surf))
+     {
+        ERR("failed to set native buffer");
+        pd->base->buffer = NULL;
+        return EINA_FALSE;
+     }
+   pd->base->buffer = &pd->px;
+   return EINA_TRUE;
+}
+
+EOLIAN static void
+_efl_canvas_surface_x11_pixmap_get(Eo *eo EINA_UNUSED, 
Efl_Canvas_Surface_X11_Data *pd, void **visual, unsigned long *pixmap)
+{
+   if (pixmap) *pixmap = pd->px.pixmap;
+   if (visual) *visual = pd->px.visual;
+}
+
+EOLIAN static Eina_Bool
+_efl_canvas_surface_x11_efl_canvas_surface_native_buffer_set(Eo *eo, 
Efl_Canvas_Surface_X11_Data *pd, void *buffer)
+{
+   Efl_Canvas_Surface_X11_Pixmap *px = buffer;
+
+   if (px)
+     {
+        pd->px.pixmap = px->pixmap;
+        pd->px.visual = px->visual;
+        pd->base->buffer = &pd->px;
+     }
+   else
+     {
+        pd->px.pixmap = 0L;
+        pd->px.visual = NULL;
+        pd->base->buffer = NULL;
+     }
+   return efl_canvas_surface_x11_pixmap_set(eo, pd->px.visual, pd->px.pixmap);
+}
+
+#include "efl_canvas_surface_x11.eo.c"
diff --git a/src/lib/evas/canvas/efl_canvas_surface_x11.eo 
b/src/lib/evas/canvas/efl_canvas_surface_x11.eo
new file mode 100644
index 0000000..d94a246
--- /dev/null
+++ b/src/lib/evas/canvas/efl_canvas_surface_x11.eo
@@ -0,0 +1,28 @@
+struct Efl.Canvas.Surface.X11_Pixmap
+{
+   [[The type used by @Efl.Canvas.Surface.native_buffer.]]
+   visual: void *; [[X11 Visual for this Pixmap.]]
+   pixmap: ulong;  [[X11 Pixmap ID.]]
+}
+
+class Efl.Canvas.Surface_X11 (Efl.Canvas.Surface)
+{
+   legacy_prefix: null;
+   methods {
+      @property pixmap {
+         [[This is a helper for @Efl.Canvas.Surface.native_buffer.]]
+         get {}
+         set { return: bool; }
+         values {
+            visual: void *; [[X11 Visual for this Pixmap.]]
+            pixmap: ulong;  [[X11 Pixmap ID.]]
+         }
+      }
+   }
+   implements {
+      Eo.Base.constructor;
+      Eo.Base.destructor;
+      Efl.Canvas.Surface.native_buffer.get;
+      Efl.Canvas.Surface.native_buffer.set;
+   }
+}
diff --git a/src/lib/evas/canvas/evas_image.eo 
b/src/lib/evas/canvas/evas_image.eo
index 4bb000d..60109ac 100644
--- a/src/lib/evas/canvas/evas_image.eo
+++ b/src/lib/evas/canvas/evas_image.eo
@@ -87,27 +87,6 @@ class Evas.Image (Evas.Object, Efl.File, Efl.Image, 
Efl.Image_Load, Efl.Image_An
             data: void *; [[The data pointer to be passed to $func.]]
          }
       }
-
-      /* native surface */
-      @property native_surface {
-         set {
-            [[Set the native surface of a given image of the canvas
-
-              This function sets a native surface of a given canvas image.
-            ]]
-            legacy: null;
-         }
-         get {
-            [[Get the native surface of a given image of the canvas
-
-              This function returns the native surface of a given canvas
-              image.
-            ]]
-         }
-         values {
-            surf: Evas.Native_Surface* @nonull; [[The native surface.]]
-         }
-      }
    }
    implements {
       Eo.Base.constructor;
diff --git a/src/lib/evas/canvas/evas_image_private.h 
b/src/lib/evas/canvas/evas_image_private.h
index fd7e072..28ae863 100644
--- a/src/lib/evas/canvas/evas_image_private.h
+++ b/src/lib/evas/canvas/evas_image_private.h
@@ -146,6 +146,8 @@ void _evas_image_proxy_error(Evas_Object *proxy, void 
*context, void *output, vo
 void _evas_image_3d_render(Evas *eo_e, Evas_Object *eo_obj, 
Evas_Object_Protected_Data *obj, Evas_Image_Data *o, Evas_Canvas3D_Scene 
*scene);
 void _evas_image_3d_set(Evas_Object *eo_obj, Evas_Canvas3D_Scene *scene);
 void _evas_image_3d_unset(Evas_Object *eo_obj, Evas_Object_Protected_Data 
*image, Evas_Image_Data *o);
+Eina_Bool _evas_image_native_surface_set(Eo *eo_obj, Evas_Native_Surface 
*surf);
+Evas_Native_Surface *_evas_image_native_surface_get(const Evas_Object *eo_obj);
 
 /* save typing */
 #define ENFN obj->layer->evas->engine.func
diff --git a/src/lib/evas/canvas/evas_object_image.c 
b/src/lib/evas/canvas/evas_object_image.c
index 42056bf..f9e6bc4 100644
--- a/src/lib/evas/canvas/evas_object_image.c
+++ b/src/lib/evas/canvas/evas_object_image.c
@@ -1607,12 +1607,10 @@ _on_image_native_surface_del(void *data EINA_UNUSED, 
Evas *e EINA_UNUSED, Evas_O
    evas_object_image_native_surface_set(obj, NULL);
 }
 
-EAPI void
-evas_object_image_native_surface_set(Evas_Object *eo_obj, Evas_Native_Surface 
*surf)
+Eina_Bool
+_evas_image_native_surface_set(Eo *eo_obj, Evas_Native_Surface *surf)
 {
-   MAGIC_CHECK(eo_obj, Evas_Object, MAGIC_OBJ);
-   return;
-   MAGIC_CHECK_END();
+   Evas_Image_Data *o = eo_data_scope_get(eo_obj, EVAS_IMAGE_CLASS);
    Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, 
EVAS_OBJECT_CLASS);
    evas_object_async_block(obj);
    evas_object_event_callback_del_full
@@ -1620,29 +1618,30 @@ evas_object_image_native_surface_set(Evas_Object 
*eo_obj, Evas_Native_Surface *s
    if (surf) // We need to unset native surf on del to remove shared hash refs
      evas_object_event_callback_add
      (eo_obj, EVAS_CALLBACK_DEL, _on_image_native_surface_del, NULL);
-   evas_obj_image_native_surface_set(eo_obj, surf);
-}
 
-EOLIAN static void
-_evas_image_native_surface_set(Eo *eo_obj, Evas_Image_Data *o, 
Evas_Native_Surface *surf)
-{
-   Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, 
EVAS_OBJECT_CLASS);
-   evas_object_async_block(obj);
    evas_render_rendering_wait(obj->layer->evas);
-
    _evas_image_cleanup(eo_obj, obj, o);
-   if (!ENFN->image_native_set) return;
+   if (!ENFN->image_native_set) return EINA_FALSE;
    if ((surf) &&
        ((surf->version < 2) ||
-        (surf->version > EVAS_NATIVE_SURFACE_VERSION))) return;
+        (surf->version > EVAS_NATIVE_SURFACE_VERSION))) return EINA_FALSE;
    o->engine_data = ENFN->image_native_set(ENDT, o->engine_data, surf);
+   return (o->engine_data != NULL);
 }
 
-EOLIAN static Evas_Native_Surface*
-_evas_image_native_surface_get(Eo *eo_obj, Evas_Image_Data *o)
+EAPI void
+evas_object_image_native_surface_set(Evas_Object *eo_obj, Evas_Native_Surface 
*surf)
+{
+   EVAS_OBJECT_LEGACY_API(eo_obj);
+   _evas_image_native_surface_set(eo_obj, surf);
+}
+
+Evas_Native_Surface *
+_evas_image_native_surface_get(const Evas_Object *eo_obj)
 {
-   Evas_Native_Surface *surf = NULL;
    Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, 
EVAS_OBJECT_CLASS);
+   Evas_Image_Data *o = eo_data_scope_get(eo_obj, EVAS_IMAGE_CLASS);
+   Evas_Native_Surface *surf = NULL;
 
    if (ENFN->image_native_get)
      surf = ENFN->image_native_get(ENDT, o->engine_data);
@@ -1650,6 +1649,13 @@ _evas_image_native_surface_get(Eo *eo_obj, 
Evas_Image_Data *o)
    return surf;
 }
 
+EAPI Evas_Native_Surface *
+evas_object_image_native_surface_get(const Evas_Object *eo_obj)
+{
+   EVAS_OBJECT_LEGACY_API(eo_obj, NULL);
+   return _evas_image_native_surface_get(eo_obj);
+}
+
 EOLIAN static void
 _evas_image_scale_hint_set(Eo *eo_obj, Evas_Image_Data *o, 
Evas_Image_Scale_Hint hint)
 {

-- 


Reply via email to