summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Makefile_Evas.am10
-rw-r--r--src/lib/evas/Evas_Common.h84
-rw-r--r--src/lib/evas/Evas_Legacy.h93
-rw-r--r--src/lib/evas/canvas/efl_canvas_surface.c19
-rw-r--r--src/lib/evas/canvas/efl_canvas_surface.eo33
-rw-r--r--src/lib/evas/canvas/efl_canvas_surface.h13
-rw-r--r--src/lib/evas/canvas/efl_canvas_surface_tbm.c54
-rw-r--r--src/lib/evas/canvas/efl_canvas_surface_tbm.eo10
-rw-r--r--src/lib/evas/canvas/efl_canvas_surface_wayland.c54
-rw-r--r--src/lib/evas/canvas/efl_canvas_surface_wayland.eo10
-rw-r--r--src/lib/evas/canvas/efl_canvas_surface_x11.c84
-rw-r--r--src/lib/evas/canvas/efl_canvas_surface_x11.eo28
-rw-r--r--src/lib/evas/canvas/evas_image.eo21
-rw-r--r--src/lib/evas/canvas/evas_image_private.h2
-rw-r--r--src/lib/evas/canvas/evas_object_image.c42
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 = \
44 lib/evas/canvas/efl_canvas_snapshot.eo \ 44 lib/evas/canvas/efl_canvas_snapshot.eo \
45 lib/evas/canvas/efl_canvas_proxy.eo \ 45 lib/evas/canvas/efl_canvas_proxy.eo \
46 lib/evas/canvas/efl_canvas_scene3d.eo \ 46 lib/evas/canvas/efl_canvas_scene3d.eo \
47 lib/evas/canvas/efl_canvas_surface.eo \
48 lib/evas/canvas/efl_canvas_surface_tbm.eo \
49 lib/evas/canvas/efl_canvas_surface_x11.eo \
50 lib/evas/canvas/efl_canvas_surface_wayland.eo \
47 lib/evas/canvas/evas_filter.eo \ 51 lib/evas/canvas/evas_filter.eo \
48 $(NULL) 52 $(NULL)
49 53
@@ -106,6 +110,8 @@ lib/evas/include/evas_common_private.h \
106lib/evas/include/evas_blend_ops.h \ 110lib/evas/include/evas_blend_ops.h \
107lib/evas/include/evas_filter.h \ 111lib/evas/include/evas_filter.h \
108lib/evas/canvas/evas_vg_private.h \ 112lib/evas/canvas/evas_vg_private.h \
113lib/evas/canvas/evas_image_private.h \
114lib/evas/canvas/efl_canvas_surface.h \
109lib/evas/common3d/primitives/primitive_common.h 115lib/evas/common3d/primitives/primitive_common.h
110 116
111# Linebreak 117# Linebreak
@@ -179,6 +185,10 @@ lib/evas/canvas/evas_out.c \
179lib/evas/canvas/efl_canvas_proxy.c \ 185lib/evas/canvas/efl_canvas_proxy.c \
180lib/evas/canvas/efl_canvas_snapshot.c \ 186lib/evas/canvas/efl_canvas_snapshot.c \
181lib/evas/canvas/efl_canvas_scene3d.c \ 187lib/evas/canvas/efl_canvas_scene3d.c \
188lib/evas/canvas/efl_canvas_surface.c \
189lib/evas/canvas/efl_canvas_surface_tbm.c \
190lib/evas/canvas/efl_canvas_surface_x11.c \
191lib/evas/canvas/efl_canvas_surface_wayland.c \
182$(NULL) 192$(NULL)
183 193
184EXTRA_DIST += \ 194EXTRA_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
287 void **rows; /**< an array of pointers (size depends on format) pointing to left edge of each scanline */ 287 void **rows; /**< an array of pointers (size depends on format) pointing to left edge of each scanline */
288}; 288};
289 289
290/**
291 * @def EVAS_NATIVE_SURFACE_VERSION
292 * Magic version number to know what the native surface struct looks like
293 */
294
295#define EVAS_NATIVE_SURFACE_VERSION 3
296
297/**
298 * Native surface types that image object supports
299 *
300 * @see Evas_Native_Surface
301 * @see evas_object_image_native_surface_set()
302 */
303typedef enum _Evas_Native_Surface_Type
304{
305 EVAS_NATIVE_SURFACE_NONE, /**< No surface type */
306 EVAS_NATIVE_SURFACE_X11, /**< X Window system based type. pixmap id or visual of the pixmap */
307 EVAS_NATIVE_SURFACE_OPENGL, /**< OpenGL system based type. texture or framebuffer id*/
308 EVAS_NATIVE_SURFACE_WL, /**< Wayland system based type. buffer of surface */
309 EVAS_NATIVE_SURFACE_TBM, /**< Tizen system based type. tbm surface @since 1.14 */
310 EVAS_NATIVE_SURFACE_EVASGL, /**< Evas GL based type. evas gl surface @since 1.14 */
311} Evas_Native_Surface_Type;
312
313/**
314 * @brief A generic datatype for engine specific native surface information.
315 *
316 * Please fill up Evas_Native_Surface fields that regarded with current surface
317 * type. If you want to set the native surface type to
318 * EVAS_NATIVE_SURFACE_X11, you need to set union data with x11.visual or
319 * x11.pixmap. If you need to set the native surface as
320 * EVAS_NATIVE_SURFACE_OPENGL, on the other hand, you need to set union data
321 * with opengl.texture_id or opengl.framebuffer_id and so on.
322 * If you need to set the native surface as EVAS_NATIVE_SURFACE_WL,
323 * you need to set union data with wl.legacy_buffer.
324 * If you need to set the native surface as EVAS_NATIVE_SURFACE_TBM,
325 * you need to set union data with tbm surface. The version field
326 * should be set with EVAS_NATIVE_SURFACE_VERSION in order to check abi
327 * break in your application on the different efl library versions.
328 *
329 * @warning Native surface types totally depend on the system. Please
330 * be aware that the types are supported on your system before using
331 * them.
332 *
333 * @note The information stored in an @c Evas_Native_Surface returned by
334 * @ref evas_gl_native_surface_get() is not meant to be used by
335 * applications except for passing it to
336 * @ref evas_object_image_native_surface_set().
337 *
338 * @see evas_object_image_native_surface_set()
339 */
340struct _Evas_Native_Surface
341{
342 int version; /**< Current Native Surface Version. Use EVAS_NATIVE_SURFACE_VERSION */
343 Evas_Native_Surface_Type type; /**< Surface type. @see Evas_Native_Surface_Type */
344 union {
345 struct
346 {
347 void *visual; /**< visual of the pixmap to use (Visual) */
348 unsigned long pixmap; /**< pixmap id to use (Pixmap) */
349 } x11; /**< Set this struct fields if surface data is X11 based. */
350
351 struct
352 {
353 unsigned int texture_id; /**< opengl texture id to use from glGenTextures() */
354 unsigned int framebuffer_id; /**< 0 if not a FBO, FBO id otherwise from glGenFramebuffers() */
355 unsigned int internal_format; /**< same as 'internalFormat' for glTexImage2D() */
356 unsigned int format; /**< same as 'format' for glTexImage2D() */
357 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) */
358 } opengl; /**< Set this struct fields if surface data is OpenGL based. */
359 struct
360 {
361 void *legacy_buffer; /**< wayland client buffer to use */
362 } wl; /**< Set this struct fields if surface data is Wayland based. */
363 struct
364 {
365 void *buffer; /**< tbm surface buffer to use @since 1.14 */
366 } tbm; /**< Set this struct fields if surface data is Tizen based. @since 1.14 */
367 struct
368 {
369 void *surface; /**< evas gl surface to use @since 1.14 */
370 } evasgl; /**< Set this struct fields if surface data is Evas GL based. @since 1.14 */
371 } data; /**< Choose one union data according to your surface. */
372};
373
374#define EVAS_LAYER_MIN -32768 /**< bottom-most layer number */ 290#define EVAS_LAYER_MIN -32768 /**< bottom-most layer number */
375#define EVAS_LAYER_MAX 32767 /**< top-most layer number */ 291#define EVAS_LAYER_MAX 32767 /**< top-most layer number */
376 292
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
2524EAPI void evas_object_image_memfile_set(Evas_Object *obj, void *data, int size, char *format, char *key) EINA_ARG_NONNULL(1, 2); 2524EAPI void evas_object_image_memfile_set(Evas_Object *obj, void *data, int size, char *format, char *key) EINA_ARG_NONNULL(1, 2);
2525 2525
2526/** 2526/**
2527 * @def EVAS_NATIVE_SURFACE_VERSION
2528 * Magic version number to know what the native surface struct looks like
2529 */
2530
2531#define EVAS_NATIVE_SURFACE_VERSION 3
2532
2533/**
2534 * Native surface types that image object supports
2535 *
2536 * @see Evas_Native_Surface
2537 * @see evas_object_image_native_surface_set()
2538 */
2539typedef enum _Evas_Native_Surface_Type
2540{
2541 EVAS_NATIVE_SURFACE_NONE, /**< No surface type */
2542 EVAS_NATIVE_SURFACE_X11, /**< X Window system based type. pixmap id or visual of the pixmap */
2543 EVAS_NATIVE_SURFACE_OPENGL, /**< OpenGL system based type. texture or framebuffer id*/
2544 EVAS_NATIVE_SURFACE_WL, /**< Wayland system based type. buffer of surface */
2545 EVAS_NATIVE_SURFACE_TBM, /**< Tizen system based type. tbm surface @since 1.14 */
2546 EVAS_NATIVE_SURFACE_EVASGL, /**< Evas GL based type. evas gl surface @since 1.14 */
2547} Evas_Native_Surface_Type;
2548
2549/**
2550 * @brief A generic datatype for engine specific native surface information.
2551 *
2552 * Please fill up Evas_Native_Surface fields that regarded with current surface
2553 * type. If you want to set the native surface type to
2554 * EVAS_NATIVE_SURFACE_X11, you need to set union data with x11.visual or
2555 * x11.pixmap. If you need to set the native surface as
2556 * EVAS_NATIVE_SURFACE_OPENGL, on the other hand, you need to set union data
2557 * with opengl.texture_id or opengl.framebuffer_id and so on.
2558 * If you need to set the native surface as EVAS_NATIVE_SURFACE_WL,
2559 * you need to set union data with wl.legacy_buffer.
2560 * If you need to set the native surface as EVAS_NATIVE_SURFACE_TBM,
2561 * you need to set union data with tbm surface. The version field
2562 * should be set with EVAS_NATIVE_SURFACE_VERSION in order to check abi
2563 * break in your application on the different efl library versions.
2564 *
2565 * @warning Native surface types totally depend on the system. Please
2566 * be aware that the types are supported on your system before using
2567 * them.
2568 *
2569 * @note The information stored in an @c Evas_Native_Surface returned by
2570 * @ref evas_gl_native_surface_get() is not meant to be used by
2571 * applications except for passing it to
2572 * @ref evas_object_image_native_surface_set().
2573 *
2574 * @see evas_object_image_native_surface_set()
2575 */
2576struct _Evas_Native_Surface
2577{
2578 int version; /**< Current Native Surface Version. Use EVAS_NATIVE_SURFACE_VERSION */
2579 Evas_Native_Surface_Type type; /**< Surface type. @see Evas_Native_Surface_Type */
2580 union {
2581 struct
2582 {
2583 void *visual; /**< visual of the pixmap to use (Visual) */
2584 unsigned long pixmap; /**< pixmap id to use (Pixmap) */
2585 } x11; /**< Set this struct fields if surface data is X11 based. */
2586
2587 struct
2588 {
2589 unsigned int texture_id; /**< opengl texture id to use from glGenTextures() */
2590 unsigned int framebuffer_id; /**< 0 if not a FBO, FBO id otherwise from glGenFramebuffers() */
2591 unsigned int internal_format; /**< same as 'internalFormat' for glTexImage2D() */
2592 unsigned int format; /**< same as 'format' for glTexImage2D() */
2593 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) */
2594 } opengl; /**< Set this struct fields if surface data is OpenGL based. */
2595 struct
2596 {
2597 void *legacy_buffer; /**< wayland client buffer to use */
2598 } wl; /**< Set this struct fields if surface data is Wayland based. */
2599 struct
2600 {
2601 void *buffer; /**< tbm surface buffer to use @since 1.14 */
2602 } tbm; /**< Set this struct fields if surface data is Tizen based. @since 1.14 */
2603 struct
2604 {
2605 void *surface; /**< evas gl surface to use @since 1.14 */
2606 } evasgl; /**< Set this struct fields if surface data is Evas GL based. @since 1.14 */
2607 } data; /**< Choose one union data according to your surface. */
2608};
2609
2610/**
2527 * Set the native surface of a given image of the canvas 2611 * Set the native surface of a given image of the canvas
2528 * 2612 *
2529 * @param obj The given canvas pointer. 2613 * @param obj The given canvas pointer.
@@ -2535,6 +2619,15 @@ EAPI void evas_object_image_memfile_set(Evas_Object *ob
2535EAPI void evas_object_image_native_surface_set(Evas_Object *obj, Evas_Native_Surface *surf) EINA_ARG_NONNULL(1, 2); 2619EAPI void evas_object_image_native_surface_set(Evas_Object *obj, Evas_Native_Surface *surf) EINA_ARG_NONNULL(1, 2);
2536 2620
2537/** 2621/**
2622 * @brief Get the native surface of a given image of the canvas
2623 *
2624 * This function returns the native surface of a given canvas image.
2625 *
2626 * @return The native surface.
2627 */
2628EAPI Evas_Native_Surface *evas_object_image_native_surface_get(const Evas_Object *obj);
2629
2630/**
2538 * Preload an image object's image data in the background 2631 * Preload an image object's image data in the background
2539 * 2632 *
2540 * @param obj The given image object. 2633 * @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 @@
1#include "efl_canvas_surface.h"
2
3#define MY_CLASS EFL_CANVAS_SURFACE_MIXIN
4
5EOLIAN static Eo *
6_efl_canvas_surface_eo_base_constructor(Eo *eo, Efl_Canvas_Surface_Data *pd)
7{
8 eo = eo_constructor(eo_super(eo, MY_CLASS));
9 pd->surf.version = EVAS_NATIVE_SURFACE_VERSION;
10 return eo;
11}
12
13EOLIAN static void *
14_efl_canvas_surface_native_buffer_get(Eo *obj EINA_UNUSED, Efl_Canvas_Surface_Data *pd)
15{
16 return pd->buffer;
17}
18
19#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 @@
1mixin Efl.Canvas.Surface (Evas.Image, Efl.Gfx.Buffer, Efl.Gfx.View)
2{
3 [[Native surfaces usually bound to an externally-managed buffer.
4
5 The attached @.native_buffer is entirely platform-dependent, which means
6 some of this mixin's subclasses will not work (constructor returns $null)
7 on some platforms. This class is meant to be used from native code only
8 (C or C++), with direct access to the display system or a buffer
9 allocation system.
10 ]]
11 legacy_prefix: null;
12 methods {
13 @property native_buffer {
14 [[External buffer attached to this native surface.
15
16 Set to $null to detach this surface from the external buffer.
17 ]]
18 get {}
19 set {
20 [[Set the buffer. If this fails, this function returns $false,
21 and the surface is left without any attached buffer.
22 ]]
23 return: bool @warn_unused;
24 }
25 values {
26 buffer: void*; [[The external buffer, depends on its type.]]
27 }
28 }
29 }
30 implements {
31 Eo.Base.constructor;
32 }
33}
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 @@
1#define EFL_CANVAS_SURFACE_PROTECTED
2
3#include "evas_image_private.h"
4#include "efl_canvas_surface.eo.h"
5#include "efl_canvas_surface_tbm.eo.h"
6#include "efl_canvas_surface_x11.eo.h"
7#include "efl_canvas_surface_wayland.eo.h"
8
9typedef struct _Efl_Canvas_Surface_Data
10{
11 Evas_Native_Surface surf;
12 void *buffer;
13} 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 @@
1#include "efl_canvas_surface.h"
2
3#define MY_CLASS EFL_CANVAS_SURFACE_TBM_CLASS
4
5typedef struct _Efl_Canvas_Surface_Tbm_Data
6{
7 Efl_Canvas_Surface_Data *base;
8} Efl_Canvas_Surface_Tbm_Data;
9
10EOLIAN static Eo *
11_efl_canvas_surface_tbm_eo_base_constructor(Eo *eo, Efl_Canvas_Surface_Tbm_Data *pd)
12{
13 Evas_Object_Protected_Data *obj;
14
15 eo = eo_constructor(eo_super(eo, MY_CLASS));
16 obj = eo_data_scope_get(eo, EVAS_OBJECT_CLASS);
17 if (!obj) return NULL;
18
19 if (!ENFN->image_native_init(ENDT, EVAS_NATIVE_SURFACE_TBM))
20 {
21 ERR("TBM is not supported on this platform");
22 return NULL;
23 }
24
25 pd->base = eo_data_ref(eo, EFL_CANVAS_SURFACE_MIXIN);
26 pd->base->surf.type = EVAS_NATIVE_SURFACE_TBM;
27 return eo;
28}
29
30EOLIAN static void
31_efl_canvas_surface_tbm_eo_base_destructor(Eo *eo, Efl_Canvas_Surface_Tbm_Data *pd)
32{
33 Evas_Object_Protected_Data *obj = obj = eo_data_scope_get(eo, EVAS_OBJECT_CLASS);
34
35 ENFN->image_native_shutdown(ENDT, EVAS_NATIVE_SURFACE_TBM);
36 eo_data_unref(eo, pd->base);
37 eo_destructor(eo);
38}
39
40EOLIAN static Eina_Bool
41_efl_canvas_surface_tbm_efl_canvas_surface_native_buffer_set(Eo *eo, Efl_Canvas_Surface_Tbm_Data *pd, void *buffer)
42{
43 pd->base->surf.data.tbm.buffer = buffer;
44 if (!_evas_image_native_surface_set(eo, &pd->base->surf))
45 {
46 ERR("failed to set native buffer");
47 pd->base->buffer = NULL;
48 return EINA_FALSE;
49 }
50 pd->base->buffer = buffer;
51 return EINA_TRUE;
52}
53
54#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 @@
1class Efl.Canvas.Surface_Tbm (Efl.Canvas.Surface)
2{
3 legacy_prefix: null;
4 implements {
5 Eo.Base.constructor;
6 Eo.Base.destructor;
7 Efl.Canvas.Surface.native_buffer.set;
8 Efl.Canvas.Surface.native_buffer.get;
9 }
10}
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 @@
1#include "efl_canvas_surface.h"
2
3#define MY_CLASS EFL_CANVAS_SURFACE_WAYLAND_CLASS
4
5typedef struct _Efl_Canvas_Surface_Wayland_Data
6{
7 Efl_Canvas_Surface_Data *base;
8} Efl_Canvas_Surface_Wayland_Data;
9
10EOLIAN static Eo *
11_efl_canvas_surface_wayland_eo_base_constructor(Eo *eo, Efl_Canvas_Surface_Wayland_Data *pd)
12{
13 Evas_Object_Protected_Data *obj;
14
15 eo = eo_constructor(eo_super(eo, MY_CLASS));
16 obj = eo_data_scope_get(eo, EVAS_OBJECT_CLASS);
17 if (!obj) return NULL;
18
19 if (!ENFN->image_native_init(ENDT, EVAS_NATIVE_SURFACE_WL))
20 {
21 ERR("Wayland surfaces are not supported on this platform");
22 return NULL;
23 }
24
25 pd->base = eo_data_ref(eo, EFL_CANVAS_SURFACE_MIXIN);
26 pd->base->surf.type = EVAS_NATIVE_SURFACE_WL;
27 return eo;
28}
29
30EOLIAN static void
31_efl_canvas_surface_wayland_eo_base_destructor(Eo *eo, Efl_Canvas_Surface_Wayland_Data *pd)
32{
33 Evas_Object_Protected_Data *obj = obj = eo_data_scope_get(eo, EVAS_OBJECT_CLASS);
34
35 ENFN->image_native_shutdown(ENDT, EVAS_NATIVE_SURFACE_WL);
36 eo_data_unref(eo, pd->base);
37 eo_destructor(eo);
38}
39
40EOLIAN static Eina_Bool
41_efl_canvas_surface_wayland_efl_canvas_surface_native_buffer_set(Eo *eo, Efl_Canvas_Surface_Wayland_Data *pd, void *buffer)
42{
43 pd->base->surf.data.wl.legacy_buffer = buffer;
44 if (!_evas_image_native_surface_set(eo, &pd->base->surf))
45 {
46 ERR("failed to set native buffer");
47 pd->base->buffer = NULL;
48 return EINA_FALSE;
49 }
50 pd->base->buffer = buffer;
51 return EINA_TRUE;
52}
53
54#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 @@
1class Efl.Canvas.Surface_Wayland (Efl.Canvas.Surface)
2{
3 legacy_prefix: null;
4 implements {
5 Eo.Base.constructor;
6 Eo.Base.destructor;
7 Efl.Canvas.Surface.native_buffer.get;
8 Efl.Canvas.Surface.native_buffer.set;
9 }
10}
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 @@
1#include "efl_canvas_surface.h"
2
3#define MY_CLASS EFL_CANVAS_SURFACE_X11_CLASS
4
5typedef struct _Efl_Canvas_Surface_X11_Data
6{
7 Efl_Canvas_Surface_Data *base;
8 Efl_Canvas_Surface_X11_Pixmap px;
9} Efl_Canvas_Surface_X11_Data;
10
11EOLIAN static Eo *
12_efl_canvas_surface_x11_eo_base_constructor(Eo *eo, Efl_Canvas_Surface_X11_Data *pd)
13{
14 Evas_Object_Protected_Data *obj;
15
16 eo = eo_constructor(eo_super(eo, MY_CLASS));
17 obj = eo_data_scope_get(eo, EVAS_OBJECT_CLASS);
18 if (!obj) return NULL;
19
20 if (!ENFN->image_native_init(ENDT, EVAS_NATIVE_SURFACE_X11))
21 {
22 ERR("X11 is not supported on this platform");
23 return NULL;
24 }
25
26 pd->base = eo_data_ref(eo, EFL_CANVAS_SURFACE_MIXIN);
27 pd->base->surf.version = EVAS_NATIVE_SURFACE_VERSION;
28 pd->base->surf.type = EVAS_NATIVE_SURFACE_X11;
29 return eo;
30}
31
32EOLIAN static void
33_efl_canvas_surface_x11_eo_base_destructor(Eo *eo, Efl_Canvas_Surface_X11_Data *pd)
34{
35 Evas_Object_Protected_Data *obj = obj = eo_data_scope_get(eo, EVAS_OBJECT_CLASS);
36
37 ENFN->image_native_shutdown(ENDT, EVAS_NATIVE_SURFACE_X11);
38 eo_data_unref(eo, pd->base);
39 eo_destructor(eo);
40}
41
42EOLIAN static Eina_Bool
43_efl_canvas_surface_x11_pixmap_set(Eo *eo, Efl_Canvas_Surface_X11_Data *pd EINA_UNUSED, void *visual, unsigned long pixmap)
44{
45 pd->px.pixmap = pixmap;
46 pd->px.visual = visual;
47 if (!_evas_image_native_surface_set(eo, &pd->base->surf))
48 {
49 ERR("failed to set native buffer");
50 pd->base->buffer = NULL;
51 return EINA_FALSE;
52 }
53 pd->base->buffer = &pd->px;
54 return EINA_TRUE;
55}
56
57EOLIAN static void
58_efl_canvas_surface_x11_pixmap_get(Eo *eo EINA_UNUSED, Efl_Canvas_Surface_X11_Data *pd, void **visual, unsigned long *pixmap)
59{
60 if (pixmap) *pixmap = pd->px.pixmap;
61 if (visual) *visual = pd->px.visual;
62}
63
64EOLIAN static Eina_Bool
65_efl_canvas_surface_x11_efl_canvas_surface_native_buffer_set(Eo *eo, Efl_Canvas_Surface_X11_Data *pd, void *buffer)
66{
67 Efl_Canvas_Surface_X11_Pixmap *px = buffer;
68
69 if (px)
70 {
71 pd->px.pixmap = px->pixmap;
72 pd->px.visual = px->visual;
73 pd->base->buffer = &pd->px;
74 }
75 else
76 {
77 pd->px.pixmap = 0L;
78 pd->px.visual = NULL;
79 pd->base->buffer = NULL;
80 }
81 return efl_canvas_surface_x11_pixmap_set(eo, pd->px.visual, pd->px.pixmap);
82}
83
84#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 @@
1struct Efl.Canvas.Surface.X11_Pixmap
2{
3 [[The type used by @Efl.Canvas.Surface.native_buffer.]]
4 visual: void *; [[X11 Visual for this Pixmap.]]
5 pixmap: ulong; [[X11 Pixmap ID.]]
6}
7
8class Efl.Canvas.Surface_X11 (Efl.Canvas.Surface)
9{
10 legacy_prefix: null;
11 methods {
12 @property pixmap {
13 [[This is a helper for @Efl.Canvas.Surface.native_buffer.]]
14 get {}
15 set { return: bool; }
16 values {
17 visual: void *; [[X11 Visual for this Pixmap.]]
18 pixmap: ulong; [[X11 Pixmap ID.]]
19 }
20 }
21 }
22 implements {
23 Eo.Base.constructor;
24 Eo.Base.destructor;
25 Efl.Canvas.Surface.native_buffer.get;
26 Efl.Canvas.Surface.native_buffer.set;
27 }
28}
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
87 data: void *; [[The data pointer to be passed to $func.]] 87 data: void *; [[The data pointer to be passed to $func.]]
88 } 88 }
89 } 89 }
90
91 /* native surface */
92 @property native_surface {
93 set {
94 [[Set the native surface of a given image of the canvas
95
96 This function sets a native surface of a given canvas image.
97 ]]
98 legacy: null;
99 }
100 get {
101 [[Get the native surface of a given image of the canvas
102
103 This function returns the native surface of a given canvas
104 image.
105 ]]
106 }
107 values {
108 surf: Evas.Native_Surface* @nonull; [[The native surface.]]
109 }
110 }
111 } 90 }
112 implements { 91 implements {
113 Eo.Base.constructor; 92 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
146void _evas_image_3d_render(Evas *eo_e, Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o, Evas_Canvas3D_Scene *scene); 146void _evas_image_3d_render(Evas *eo_e, Evas_Object *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Data *o, Evas_Canvas3D_Scene *scene);
147void _evas_image_3d_set(Evas_Object *eo_obj, Evas_Canvas3D_Scene *scene); 147void _evas_image_3d_set(Evas_Object *eo_obj, Evas_Canvas3D_Scene *scene);
148void _evas_image_3d_unset(Evas_Object *eo_obj, Evas_Object_Protected_Data *image, Evas_Image_Data *o); 148void _evas_image_3d_unset(Evas_Object *eo_obj, Evas_Object_Protected_Data *image, Evas_Image_Data *o);
149Eina_Bool _evas_image_native_surface_set(Eo *eo_obj, Evas_Native_Surface *surf);
150Evas_Native_Surface *_evas_image_native_surface_get(const Evas_Object *eo_obj);
149 151
150/* save typing */ 152/* save typing */
151#define ENFN obj->layer->evas->engine.func 153#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
1607 evas_object_image_native_surface_set(obj, NULL); 1607 evas_object_image_native_surface_set(obj, NULL);
1608} 1608}
1609 1609
1610EAPI void 1610Eina_Bool
1611evas_object_image_native_surface_set(Evas_Object *eo_obj, Evas_Native_Surface *surf) 1611_evas_image_native_surface_set(Eo *eo_obj, Evas_Native_Surface *surf)
1612{ 1612{
1613 MAGIC_CHECK(eo_obj, Evas_Object, MAGIC_OBJ); 1613 Evas_Image_Data *o = eo_data_scope_get(eo_obj, EVAS_IMAGE_CLASS);
1614 return;
1615 MAGIC_CHECK_END();
1616 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); 1614 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
1617 evas_object_async_block(obj); 1615 evas_object_async_block(obj);
1618 evas_object_event_callback_del_full 1616 evas_object_event_callback_del_full
@@ -1620,29 +1618,30 @@ evas_object_image_native_surface_set(Evas_Object *eo_obj, Evas_Native_Surface *s
1620 if (surf) // We need to unset native surf on del to remove shared hash refs 1618 if (surf) // We need to unset native surf on del to remove shared hash refs
1621 evas_object_event_callback_add 1619 evas_object_event_callback_add
1622 (eo_obj, EVAS_CALLBACK_DEL, _on_image_native_surface_del, NULL); 1620 (eo_obj, EVAS_CALLBACK_DEL, _on_image_native_surface_del, NULL);
1623 evas_obj_image_native_surface_set(eo_obj, surf);
1624}
1625 1621
1626EOLIAN static void
1627_evas_image_native_surface_set(Eo *eo_obj, Evas_Image_Data *o, Evas_Native_Surface *surf)
1628{
1629 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
1630 evas_object_async_block(obj);
1631 evas_render_rendering_wait(obj->layer->evas); 1622 evas_render_rendering_wait(obj->layer->evas);
1632
1633 _evas_image_cleanup(eo_obj, obj, o); 1623 _evas_image_cleanup(eo_obj, obj, o);
1634 if (!ENFN->image_native_set) return; 1624 if (!ENFN->image_native_set) return EINA_FALSE;
1635 if ((surf) && 1625 if ((surf) &&
1636 ((surf->version < 2) || 1626 ((surf->version < 2) ||
1637 (surf->version > EVAS_NATIVE_SURFACE_VERSION))) return; 1627 (surf->version > EVAS_NATIVE_SURFACE_VERSION))) return EINA_FALSE;
1638 o->engine_data = ENFN->image_native_set(ENDT, o->engine_data, surf); 1628 o->engine_data = ENFN->image_native_set(ENDT, o->engine_data, surf);
1629 return (o->engine_data != NULL);
1639} 1630}
1640 1631
1641EOLIAN static Evas_Native_Surface* 1632EAPI void
1642_evas_image_native_surface_get(Eo *eo_obj, Evas_Image_Data *o) 1633evas_object_image_native_surface_set(Evas_Object *eo_obj, Evas_Native_Surface *surf)
1634{
1635 EVAS_OBJECT_LEGACY_API(eo_obj);
1636 _evas_image_native_surface_set(eo_obj, surf);
1637}
1638
1639Evas_Native_Surface *
1640_evas_image_native_surface_get(const Evas_Object *eo_obj)
1643{ 1641{
1644 Evas_Native_Surface *surf = NULL;
1645 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); 1642 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
1643 Evas_Image_Data *o = eo_data_scope_get(eo_obj, EVAS_IMAGE_CLASS);
1644 Evas_Native_Surface *surf = NULL;
1646 1645
1647 if (ENFN->image_native_get) 1646 if (ENFN->image_native_get)
1648 surf = ENFN->image_native_get(ENDT, o->engine_data); 1647 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)
1650 return surf; 1649 return surf;
1651} 1650}
1652 1651
1652EAPI Evas_Native_Surface *
1653evas_object_image_native_surface_get(const Evas_Object *eo_obj)
1654{
1655 EVAS_OBJECT_LEGACY_API(eo_obj, NULL);
1656 return _evas_image_native_surface_get(eo_obj);
1657}
1658
1653EOLIAN static void 1659EOLIAN static void
1654_evas_image_scale_hint_set(Eo *eo_obj, Evas_Image_Data *o, Evas_Image_Scale_Hint hint) 1660_evas_image_scale_hint_set(Eo *eo_obj, Evas_Image_Data *o, Evas_Image_Scale_Hint hint)
1655{ 1661{