summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Makefile.am1
-rw-r--r--configure.ac72
-rw-r--r--pc/.gitignore1
-rw-r--r--pc/ecore-buffer.pc.in12
-rw-r--r--src/Makefile.am1
-rw-r--r--src/Makefile_Ecore_Buffer.am113
-rw-r--r--src/bin/ecore_buffer/.gitignore1
-rw-r--r--src/bin/ecore_buffer/bq_mgr.c899
-rw-r--r--src/bin/ecore_buffer/bq_mgr_protocol.c131
-rw-r--r--src/bin/ecore_buffer/bq_mgr_protocol.h247
-rw-r--r--src/examples/ecore/.gitignore3
-rw-r--r--src/examples/ecore/Makefile.am19
-rw-r--r--src/examples/ecore/ecore_buffer_consumer_example.c192
-rw-r--r--src/examples/ecore/ecore_buffer_example.c128
-rw-r--r--src/examples/ecore/ecore_buffer_provider_example.c274
-rw-r--r--src/lib/ecore_buffer/Ecore_Buffer.h629
-rw-r--r--src/lib/ecore_buffer/Ecore_Buffer_Queue.h449
-rw-r--r--src/lib/ecore_buffer/bq_mgr_protocol.c131
-rw-r--r--src/lib/ecore_buffer/bq_mgr_protocol.h329
-rw-r--r--src/lib/ecore_buffer/buffer_queue.c153
-rw-r--r--src/lib/ecore_buffer/buffer_queue.h23
-rw-r--r--src/lib/ecore_buffer/ecore_buffer.c491
-rw-r--r--src/lib/ecore_buffer/ecore_buffer_con.c253
-rw-r--r--src/lib/ecore_buffer/ecore_buffer_con.h20
-rw-r--r--src/lib/ecore_buffer/ecore_buffer_consumer.c417
-rw-r--r--src/lib/ecore_buffer/ecore_buffer_private.h31
-rw-r--r--src/lib/ecore_buffer/ecore_buffer_provider.c391
-rw-r--r--src/lib/ecore_buffer/ecore_buffer_queue_main.c54
-rw-r--r--src/lib/ecore_buffer/shared_buffer.c148
-rw-r--r--src/lib/ecore_buffer/shared_buffer.h41
-rw-r--r--src/modules/ecore_buffer/shm/ecore_buffer_shm.c172
-rw-r--r--src/modules/ecore_buffer/x11_dri2/ecore_buffer_x11_dri2.c538
-rw-r--r--src/modules/ecore_buffer/x11_dri3/ecore_buffer_x11_dri3.c602
33 files changed, 6966 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
index 34927d7290..d02db5e5b7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -140,6 +140,7 @@ pc/ecore-imf.pc \
140pc/ecore-imf-evas.pc \ 140pc/ecore-imf-evas.pc \
141pc/ecore-evas.pc \ 141pc/ecore-evas.pc \
142pc/ecore-avahi.pc \ 142pc/ecore-avahi.pc \
143pc/ecore-buffer.pc \
143pc/ector.pc \ 144pc/ector.pc \
144pc/embryo.pc \ 145pc/embryo.pc \
145pc/eio.pc \ 146pc/eio.pc \
diff --git a/configure.ac b/configure.ac
index 9b0e8cace5..1673471d91 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1705,6 +1705,17 @@ AC_ARG_ENABLE([tile-rotate],
1705 ], 1705 ],
1706 [have_tile_rotate="no"]) 1706 [have_tile_rotate="no"])
1707 1707
1708# Ecore Buffer
1709AC_ARG_ENABLE([ecore-buffer],
1710 [AS_HELP_STRING([--enable-ecore-buffer],[enable ecore-buffer. @<:@default=disabled@:>@])],
1711 [
1712 if test "x${enableval}" = "xyes" ; then
1713 want_ecore_buffer="yes"
1714 else
1715 want_ecore_buffer="no"
1716 fi
1717 ],
1718 [want_ecore_buffer="no"])
1708 1719
1709# Image Loaders 1720# Image Loaders
1710 1721
@@ -4587,6 +4598,65 @@ AC_ARG_ENABLE([i-really-know-what-i-am-doing-and-that-this-will-probably-break-t
4587 ], 4598 ],
4588 [ BARF_OK="xno" ]) 4599 [ BARF_OK="xno" ])
4589 4600
4601#### Ecore_Buffer
4602build_ecore_buffer_x11_dri2="no"
4603build_ecore_buffer_x11_dri3="no"
4604EFL_LIB_START_OPTIONAL([Ecore_Buffer], [test "${want_ecore_buffer}" = "yes"])
4605### Checks for libraries
4606EFL_INTERNAL_DEPEND_PKG([ECORE_BUFFER], [eina])
4607EFL_INTERNAL_DEPEND_PKG([ECORE_BUFFER], [eo])
4608EFL_INTERNAL_DEPEND_PKG([ECORE_BUFFER], [ecore])
4609EFL_DEPEND_PKG([ECORE_BUFFER], [WAYLAND],
4610 [wayland-server >= 1.5.0 wayland-client >= 1.5.0])
4611
4612PKG_CHECK_MODULES([X11_DRI_COMMON],
4613 [
4614 libtbm >= 1.1.0,
4615 libdrm >= 2.4.35,
4616 ],
4617 [have_x11_dri_common_pkgs="yes"],
4618 [have_x11_dri_common_pkgs="no"]
4619)
4620
4621if test "x$have_x11_dri_common_pkgs" = "xyes" ; then
4622 EFL_INTERNAL_DEPEND_PKG([ECORE_BUFFER], [ecore_x])
4623
4624 PKG_CHECK_MODULES([X11_DRI2], [libdri2],
4625 [have_x11_dri2_pkgs="yes"],
4626 [have_x11_dri2_pkgs="no"])
4627 PKG_CHECK_MODULES([X11_DRI3],
4628 [
4629 xshmfence,
4630 xcb,
4631 x11-xcb,
4632 xcb-sync,
4633 xcb-dri3
4634 ],
4635 [have_x11_dri3_pkgs="yes"],
4636 [have_x11_dri3_pkgs="no"])
4637fi
4638
4639if test "x${have_x11_dri2_pkgs}" = "xyes" ; then
4640 build_ecore_buffer_x11_dri2="yes"
4641 AC_DEFINE(BUILD_ECORE_BUFFER_X11_DRI2, 1, [Support for X11_DRI2 Backend in Ecore_Buffer])
4642fi
4643
4644if test "x${have_x11_dri3_pkgs}" = "xyes" ; then
4645 build_ecore_buffer_x11_dri3="yes"
4646 AC_DEFINE(BUILD_ECORE_BUFFER_X11_DRI3, 1, [Support for X11_DRI3 Backend in Ecore_Buffer])
4647fi
4648EFL_EVAL_PKGS([ECORE_BUFFER])
4649
4650EFL_ADD_FEATURE([ECORE_BUFFER], [shm], ["yes"])
4651EFL_ADD_FEATURE([ECORE_BUFFER], [x11_dri2], [${build_ecore_buffer_x11_dri2}])
4652EFL_ADD_FEATURE([ECORE_BUFFER], [x11_dri3], [${build_ecore_buffer_x11_dri3}])
4653
4654EFL_LIB_END_OPTIONAL([Ecore_Buffer])
4655
4656AM_CONDITIONAL([BUILD_ECORE_BUFFER_X11_DRI2], [test "${build_ecore_buffer_x11_dri2}" = "xyes"])
4657AM_CONDITIONAL([BUILD_ECORE_BUFFER_X11_DRI3], [test "${build_ecore_buffer_x11_dri3}" = "xyes"])
4658
4659#### End of Ecore_Buffer
4590 4660
4591AC_CONFIG_FILES([ 4661AC_CONFIG_FILES([
4592Makefile 4662Makefile
@@ -4667,6 +4737,7 @@ pc/ecore-imf-evas.pc
4667pc/ecore-audio.pc 4737pc/ecore-audio.pc
4668pc/ecore-audio-cxx.pc 4738pc/ecore-audio-cxx.pc
4669pc/ecore-avahi.pc 4739pc/ecore-avahi.pc
4740pc/ecore-buffer.pc
4670pc/ector.pc 4741pc/ector.pc
4671pc/embryo.pc 4742pc/embryo.pc
4672pc/eio.pc 4743pc/eio.pc
@@ -4827,6 +4898,7 @@ echo "Ecore_X.........: ${with_x11} (${features_ecore_x})"
4827echo "Ecore_SDL.......: $want_sdl" 4898echo "Ecore_SDL.......: $want_sdl"
4828echo "Ecore_Wayland...: $want_wayland" 4899echo "Ecore_Wayland...: $want_wayland"
4829echo "IVI-Shell.......: $want_wayland_ivi_shell" 4900echo "IVI-Shell.......: $want_wayland_ivi_shell"
4901echo "Ecore_Buffer....: $want_ecore_buffer (${features_ecore_buffer})"
4830if test "${have_linux}" = "yes"; then 4902if test "${have_linux}" = "yes"; then
4831echo "Ecore_FB........: $want_fb (${features_ecore_fb})" 4903echo "Ecore_FB........: $want_fb (${features_ecore_fb})"
4832elif test "${have_ps3}" = "yes"; then 4904elif test "${have_ps3}" = "yes"; then
diff --git a/pc/.gitignore b/pc/.gitignore
index f13d852670..5aadf61079 100644
--- a/pc/.gitignore
+++ b/pc/.gitignore
@@ -17,6 +17,7 @@
17/ecore-win32.pc 17/ecore-win32.pc
18/ecore-x.pc 18/ecore-x.pc
19/ecore.pc 19/ecore.pc
20/ecore-buffer.pc
20/ector.pc 21/ector.pc
21/edje.pc 22/edje.pc
22/eet.pc 23/eet.pc
diff --git a/pc/ecore-buffer.pc.in b/pc/ecore-buffer.pc.in
new file mode 100644
index 0000000000..a23a2a444f
--- /dev/null
+++ b/pc/ecore-buffer.pc.in
@@ -0,0 +1,12 @@
1prefix=@prefix@
2exec_prefix=@exec_prefix@
3libdir=@libdir@
4includedir=@includedir@
5
6Name: ecore-buffer
7Description: E core library, graphic buffer module
8Requires.private: @requirements_pc_ecore_buffer@
9Version: @VERSION@
10Libs: -L${libdir} -lecore_buffer
11Libs.private: @requirements_libs_ecore_buffer@
12Cflags: -I${includedir}/efl-@VMAJ@ -I${includedir}/ecore-buffer-@VMAJ@
diff --git a/src/Makefile.am b/src/Makefile.am
index 0522fa33ca..dccc538af2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -54,6 +54,7 @@ include Makefile_Ecore_Avahi.am
54include Makefile_Embryo.am 54include Makefile_Embryo.am
55include Makefile_Eio.am 55include Makefile_Eio.am
56include Makefile_Efreet.am 56include Makefile_Efreet.am
57include Makefile_Ecore_Buffer.am
57include Makefile_EPhysics.am 58include Makefile_EPhysics.am
58include Makefile_Edje.am 59include Makefile_Edje.am
59include Makefile_Emotion.am 60include Makefile_Emotion.am
diff --git a/src/Makefile_Ecore_Buffer.am b/src/Makefile_Ecore_Buffer.am
new file mode 100644
index 0000000000..c357c5cd00
--- /dev/null
+++ b/src/Makefile_Ecore_Buffer.am
@@ -0,0 +1,113 @@
1if HAVE_ECORE_BUFFER
2
3### Library
4
5lib_LTLIBRARIES += lib/ecore_buffer/libecore_buffer.la
6
7installed_ecorebuffermainheadersdir = $(includedir)/ecore-buffer-@VMAJ@
8dist_installed_ecorebuffermainheaders_DATA = \
9lib/ecore_buffer/Ecore_Buffer.h \
10lib/ecore_buffer/Ecore_Buffer_Queue.h
11
12lib_ecore_buffer_libecore_buffer_la_SOURCES = \
13lib/ecore_buffer/bq_mgr_protocol.c \
14lib/ecore_buffer/buffer_queue.c \
15lib/ecore_buffer/shared_buffer.c \
16lib/ecore_buffer/ecore_buffer.c \
17lib/ecore_buffer/ecore_buffer_queue_main.c \
18lib/ecore_buffer/ecore_buffer_con.c \
19lib/ecore_buffer/ecore_buffer_provider.c \
20lib/ecore_buffer/ecore_buffer_consumer.c
21
22lib_ecore_buffer_libecore_buffer_la_CPPFLAGS = \
23-I$(top_builddir)/src/lib/efl \
24-DPACKAGE_BUILD_DIR=\"$(abs_top_builddir)\" \
25-DPACKAGE_LIB_DIR=\"$(libdir)\" \
26@ECORE_BUFFER_CFLAGS@
27
28lib_ecore_buffer_libecore_buffer_la_LIBADD = @ECORE_BUFFER_LIBS@
29lib_ecore_buffer_libecore_buffer_la_DEPENDENCIES = @ECORE_BUFFER_INTERNAL_LIBS@
30lib_ecore_buffer_libecore_buffer_la_LDFLAGS = @EFL_LTLIBRARY_FLAGS@
31
32### Binary
33bqmgr_bindir=$(libdir)/ecore_buffer/bin/$(MODULE_ARCH)
34bqmgr_bin_PROGRAMS = bin/ecore_buffer/bq_mgr
35
36bin_ecore_buffer_bq_mgr_SOURCES = \
37bin/ecore_buffer/bq_mgr_protocol.c \
38bin/ecore_buffer/bq_mgr.c
39
40bin_ecore_buffer_bq_mgr_CPPFLAGS = \
41-I$(top_builddir)/src/lib/efl \
42@ECORE_BUFFER_CFLAGS@
43bin_ecore_buffer_bq_mgr_LDADD = @USE_ECORE_INTERNAL_LIBS@ @USE_ECORE_BUFFER_LIBS@
44bin_ecore_buffer_bq_mgr_DEPENDENCIES = @USE_ECORE_INTERNAL_LIBS@ @USE_ECORE_BUFFER_INTERNAL_LIBS@
45
46### Backends
47
48ecorebuffershmdir = $(libdir)/ecore_buffer/modules/shm/$(MODULE_ARCH)
49ecorebuffershm_LTLIBRARIES = modules/ecore_buffer/shm/module.la
50
51modules_ecore_buffer_shm_module_la_SOURCES = \
52 modules/ecore_buffer/shm/ecore_buffer_shm.c
53modules_ecore_buffer_shm_module_la_CPPFLAGS = \
54 -I$(top_builddir)/src/lib/efl \
55 @ECORE_BUFFER_CFLAGS@ \
56 -I$(top_srcdir)/src/modules/ecore_buffer/shm
57modules_ecore_buffer_shm_module_la_LIBADD = \
58 @ECORE_BUFFER_LIBS@ \
59 @USE_ECORE_BUFFER_INTERNAL_LIBS@
60modules_ecore_buffer_shm_module_la_DEPENDENCIES = \
61 @USE_ECORE_BUFFER_INTERNAL_LIBS@
62modules_ecore_buffer_shm_module_la_LDFLAGS = -module @EFL_LTMODULE_FLAGS@
63modules_ecore_buffer_shm_module_la_LIBTOOLFLAGS = --tag=disable-static
64
65if BUILD_ECORE_BUFFER_X11_DRI2
66ecorebufferx11dri2dir = $(libdir)/ecore_buffer/modules/x11_dri2/$(MODULE_ARCH)
67ecorebufferx11dri2_LTLIBRARIES = modules/ecore_buffer/x11_dri2/module.la
68
69modules_ecore_buffer_x11_dri2_module_la_SOURCES = \
70 modules/ecore_buffer/x11_dri2/ecore_buffer_x11_dri2.c
71modules_ecore_buffer_x11_dri2_module_la_CPPFLAGS = \
72 -I$(top_builddir)/src/lib/efl \
73 @ECORE_BUFFER_CFLAGS@ \
74 @X11_DRI_COMMON_CFLAGS@ \
75 @X11_DRI2_CFLAGS@ \
76 -I$(top_srcdir)/src/modules/ecore_buffer/x11_dri2
77modules_ecore_buffer_x11_dri2_module_la_LIBADD = \
78 @ECORE_BUFFER_LIBS@ \
79 @USE_ECORE_BUFFER_INTERNAL_LIBS@ \
80 @X11_DRI_COMMON_LIBS@ \
81 @X11_DRI2_LIBS@
82modules_ecore_buffer_x11_dri2_module_la_DEPENDENCIES = \
83 @USE_ECORE_X_INTERNAL_LIBS@ \
84 @USE_ECORE_BUFFER_INTERNAL_LIBS@
85modules_ecore_buffer_x11_dri2_module_la_LDFLAGS = -module @EFL_LTMODULE_FLAGS@
86modules_ecore_buffer_x11_dri2_module_la_LIBTOOLFLAGS = --tag=disable-static
87endif
88
89if BUILD_ECORE_BUFFER_X11_DRI3
90ecorebufferx11dri3dir = $(libdir)/ecore_buffer/modules/x11_dri3/$(MODULE_ARCH)
91ecorebufferx11dri3_LTLIBRARIES = modules/ecore_buffer/x11_dri3/module.la
92
93modules_ecore_buffer_x11_dri3_module_la_SOURCES = \
94 modules/ecore_buffer/x11_dri3/ecore_buffer_x11_dri3.c
95modules_ecore_buffer_x11_dri3_module_la_CPPFLAGS = \
96 -I$(top_builddir)/src/lib/efl \
97 @ECORE_BUFFER_CFLAGS@ \
98 @X11_DRI_COMMON_CFLAGS@ \
99 @X11_DRI3_CFLAGS@ \
100 -I$(top_srcdir)/src/modules/ecore_buffer/x11_dri3
101modules_ecore_buffer_x11_dri3_module_la_LIBADD = \
102 @ECORE_BUFFER_LIBS@ \
103 @USE_ECORE_BUFFER_INTERNAL_LIBS@ \
104 @X11_DRI_COMMON_LIBS@ \
105 @X11_DRI3_LIBS@
106modules_ecore_buffer_x11_dri3_module_la_DEPENDENCIES = \
107 @USE_ECORE_X_INTERNAL_LIBS@ \
108 @USE_ECORE_BUFFER_INTERNAL_LIBS@
109modules_ecore_buffer_x11_dri3_module_la_LDFLAGS = -module @EFL_LTMODULE_FLAGS@
110modules_ecore_buffer_x11_dri3_module_la_LIBTOOLFLAGS = --tag=disable-static
111endif
112
113endif
diff --git a/src/bin/ecore_buffer/.gitignore b/src/bin/ecore_buffer/.gitignore
new file mode 100644
index 0000000000..846a9e2122
--- /dev/null
+++ b/src/bin/ecore_buffer/.gitignore
@@ -0,0 +1 @@
/bq_mgr
diff --git a/src/bin/ecore_buffer/bq_mgr.c b/src/bin/ecore_buffer/bq_mgr.c
new file mode 100644
index 0000000000..4cb3c1f759
--- /dev/null
+++ b/src/bin/ecore_buffer/bq_mgr.c
@@ -0,0 +1,899 @@
1#include <signal.h>
2#include <unistd.h>
3#include <sys/socket.h>
4#include <sys/types.h>
5#include <sys/xattr.h>
6
7#include <Eina.h>
8#include <Ecore_Getopt.h>
9#include <wayland-server.h>
10
11#include "bq_mgr_protocol.h"
12
13#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
14
15#define BQ_LOG(f, x...) printf("[ES|%30.30s|%04d] " f "\n", __func__, __LINE__, ##x)
16#define BQ_DEBUG(f, x...) if (debug) printf("[ES|%30.30s|%04d] " f "\n", __func__, __LINE__, ##x)
17#define BQ_OBJECT_NEW(x, f) bq_object_new(sizeof(x), ((Bq_Object_Free_Func)(f)))
18#define BQ_OBJECT(x) ((Bq_Object *)(x))
19#define BQ_OBJECT_RESOURCE(x) (((Bq_Object *)(x))->resource)
20
21typedef void (*Bq_Object_Free_Func) (void *obj);
22
23typedef struct _Bq_Object Bq_Object;
24typedef struct _Bq_Mgr Bq_Mgr;
25typedef struct _Bq_Buffer_Queue Bq_Buffer_Queue;
26typedef struct _Bq_Buffer_Consumer Bq_Buffer_Consumer;
27typedef struct _Bq_Buffer_Provider Bq_Buffer_Provider;
28typedef struct _Bq_Buffer Bq_Buffer;
29typedef enum _Bq_Buffer_Type Bq_Buffer_Type;
30
31struct _Bq_Object
32{
33 int ref;
34 Bq_Object_Free_Func free_fn;
35 Eina_Bool deleted;
36 struct wl_resource *resource;
37};
38
39struct _Bq_Mgr
40{
41 Bq_Object bq_obj;
42
43 struct wl_display *wdpy;
44 struct wl_event_source *signals[3];
45
46 /*BufferQueue manager*/
47 struct wl_global *bq_mgr;
48 Eina_Hash *buffer_queues;
49};
50
51
52struct _Bq_Buffer_Queue
53{
54 Bq_Object bq_obj;
55 Eina_Hash *link;
56
57 char *name;
58 struct wl_signal connect;
59
60 Bq_Buffer_Consumer *consumer;
61 Bq_Buffer_Provider *provider;
62 Eina_Inlist *buffers;
63};
64
65struct _Bq_Buffer_Consumer
66{
67 Bq_Object bq_obj;
68 Bq_Buffer_Queue *buffer_queue;
69
70 int32_t queue_size;
71 int32_t width;
72 int32_t height;
73};
74
75struct _Bq_Buffer_Provider
76{
77 Bq_Object bq_obj;
78 Bq_Buffer_Queue *buffer_queue;
79};
80
81enum _Bq_Buffer_Type
82{
83 bq_BUFFER_TYPE_ID,
84 bq_BUFFER_TYPE_FD,
85};
86
87struct _Bq_Buffer
88{
89 Bq_Object bq_obj; /*Dont use wl_resource in bq_obj*/
90 EINA_INLIST;
91
92 struct wl_resource *consumer;
93 struct wl_resource *provider;
94 uint32_t serial;
95
96 char *engine;
97 Bq_Buffer_Type type;
98 int32_t width;
99 int32_t height;
100 int32_t format;
101 uint32_t flags;
102
103 int32_t id;
104 int32_t offset0;
105 int32_t stride0;
106 int32_t offset1;
107 int32_t stride1;
108 int32_t offset2;
109 int32_t stride2;
110};
111
112static Eina_Bool debug;
113
114static void *
115bq_object_new(size_t size, Bq_Object_Free_Func fn)
116{
117 Bq_Object *o = calloc(1, size);
118
119 if ((!o)) return NULL;
120
121 o->ref = 1;
122 o->free_fn = fn;
123
124 return o;
125}
126
127static int
128bq_object_ref(Bq_Object *o)
129{
130 o->ref++;
131
132 return o->ref;
133}
134
135static int
136bq_object_unref(Bq_Object *o)
137{
138 o->ref--;
139
140 if (o->ref <= 0 || o->deleted)
141 {
142 if (o->free_fn)
143 o->free_fn(o);
144
145 free(o);
146 }
147
148 return o->ref;
149}
150
151static int
152bq_object_free(Bq_Object *o)
153{
154 if (!o) return 0;
155 if (o->deleted) return 0;
156
157 o->deleted = EINA_TRUE;
158
159 return bq_object_unref(o);
160}
161
162static void
163bq_mgr_buffer_queue_free(Bq_Buffer_Queue *bq)
164{
165 Bq_Buffer *buf;
166
167 if (!bq) return;
168
169 BQ_DEBUG("destroy buffer queue : %s\n", bq->name);
170
171 if (bq->consumer)
172 {
173 wl_resource_destroy(BQ_OBJECT_RESOURCE(bq->consumer));
174 bq->consumer = NULL;
175 }
176
177 if (bq->provider)
178 {
179 wl_resource_destroy(BQ_OBJECT_RESOURCE(bq->provider));
180 bq->provider = NULL;
181 }
182
183 while (bq->buffers)
184 {
185 buf = EINA_INLIST_CONTAINER_GET(bq->buffers,Bq_Buffer);
186 bq->buffers = eina_inlist_remove(bq->buffers, bq->buffers);
187 if (buf->consumer)
188 {
189 wl_resource_destroy(buf->consumer);
190 buf->consumer = NULL;
191 }
192
193 if (buf->provider)
194 {
195 wl_resource_destroy(buf->provider);
196 buf->provider = NULL;
197 }
198 }
199
200 if (bq->link)
201 {
202 eina_hash_del(bq->link, bq->name, bq);
203 bq->link = NULL;
204 }
205 if (bq->name)
206 {
207 free(bq->name);
208 bq->name = NULL;
209 }
210}
211
212static Bq_Buffer_Queue*
213bq_mgr_buffer_queue_new(Bq_Mgr *bq_mgr, const char *name)
214{
215 Bq_Buffer_Queue *bq;
216
217 bq = eina_hash_find(bq_mgr->buffer_queues, name);
218 if (bq)
219 {
220 bq_object_ref(BQ_OBJECT(bq));
221 return bq;
222 }
223
224 bq = BQ_OBJECT_NEW(Bq_Buffer_Queue, bq_mgr_buffer_queue_free);
225 EINA_SAFETY_ON_NULL_RETURN_VAL(bq, NULL);
226
227 bq->link = bq_mgr->buffer_queues;
228 bq->name = strdup(name);
229 if (!eina_hash_add(bq->link,bq->name,bq))
230 {
231 bq_object_free(BQ_OBJECT(bq));
232 return NULL;
233 }
234
235 wl_signal_init(&bq->connect);
236 bq->buffers = NULL;
237 return bq;
238}
239
240static void
241bq_mgr_buffer_consumer_release_buffer(struct wl_client *client EINA_UNUSED,
242 struct wl_resource *resource,
243 struct wl_resource *buffer)
244{
245 Bq_Buffer_Queue *bq;
246 Bq_Buffer_Consumer *bq_consumer;
247 Bq_Buffer_Provider *bq_provider;
248 Bq_Buffer *bq_buffer;
249
250 bq_consumer = (Bq_Buffer_Consumer*)wl_resource_get_user_data(resource);
251 bq_buffer = (Bq_Buffer*)wl_resource_get_user_data(buffer);
252 bq = bq_consumer->buffer_queue;
253 bq_provider = bq->provider;
254
255 if (bq_provider && bq_buffer->provider)
256 {
257 bq_provider_send_add_buffer(BQ_OBJECT_RESOURCE(bq_provider),
258 bq_buffer->provider, bq_buffer->serial);
259 }
260}
261
262static const struct bq_consumer_interface _bq_consumer_interface = {
263 bq_mgr_buffer_consumer_release_buffer
264};
265
266static void
267bq_mgr_buffer_consumer_destroy(struct wl_resource *resource)
268{
269 Bq_Buffer_Consumer *bq_consumer = wl_resource_get_user_data(resource);
270 Bq_Buffer_Provider *bq_provider;
271 Bq_Buffer_Queue *bq;
272 Bq_Buffer *buf;
273
274 if (!bq_consumer) return;
275
276 BQ_DEBUG("destroy buffer consumer : %s\n", bq_consumer->buffer_queue->name);
277
278 bq = bq_consumer->buffer_queue;
279 bq_provider = bq->provider;
280
281 bq->consumer = NULL;
282 BQ_OBJECT_RESOURCE(bq_consumer) = NULL;
283
284 if (bq_provider)
285 {
286 bq_provider_send_disconnected(BQ_OBJECT_RESOURCE(bq_provider));
287 }
288
289 while (bq->buffers)
290 {
291 buf = EINA_INLIST_CONTAINER_GET(bq->buffers,Bq_Buffer);
292 bq->buffers = eina_inlist_remove(bq->buffers,bq->buffers);
293
294 BQ_DEBUG("destroy BUFFER : %d\n", buf->type);
295 if (buf->consumer)
296 {
297 wl_resource_destroy(buf->consumer);
298 buf->consumer = NULL;
299 bq_object_unref(BQ_OBJECT(buf));
300 }
301
302 if (buf->provider)
303 {
304 wl_resource_destroy(buf->provider);
305 buf->provider = NULL;
306 bq_object_unref(BQ_OBJECT(buf));
307 }
308 }
309
310 bq_object_unref(BQ_OBJECT(bq_consumer));
311 bq_object_unref(BQ_OBJECT(bq));
312}
313
314static void
315bq_mgr_buffer_destroy(struct wl_resource *resource)
316{
317 Bq_Buffer *buf = wl_resource_get_user_data(resource);
318
319 if (resource == buf->consumer)
320 {
321 BQ_DEBUG("destroy buffer : consumer\n");
322 }
323 else if (resource == buf->provider)
324 {
325 BQ_DEBUG("destroy buffer : provider\n");
326 }
327}
328
329static void
330bq_buffer_create_consumer_side(Bq_Buffer_Consumer *bq_consumer, Bq_Buffer *bq_buffer)
331{
332 if (!bq_consumer) return;
333
334 bq_buffer->consumer = wl_resource_create(wl_resource_get_client(BQ_OBJECT_RESOURCE(bq_consumer)),
335 &bq_buffer_interface, 1, 0);
336 wl_resource_set_implementation(bq_buffer->consumer, NULL, bq_buffer, bq_mgr_buffer_destroy);
337 bq_object_ref(BQ_OBJECT(bq_buffer));
338
339 bq_consumer_send_buffer_attached(BQ_OBJECT_RESOURCE(bq_consumer),
340 bq_buffer->consumer,
341 bq_buffer->engine,
342 bq_buffer->width,
343 bq_buffer->height,
344 bq_buffer->format,
345 bq_buffer->flags);
346}
347
348static void
349bq_buffer_set_consumer_side(Bq_Buffer_Consumer *bq_consumer, Bq_Buffer *bq_buffer)
350{
351 if (!bq_consumer) return;
352 EINA_SAFETY_ON_NULL_RETURN(bq_buffer);
353 EINA_SAFETY_ON_NULL_RETURN(bq_buffer->consumer);
354
355 if (bq_buffer->type == bq_BUFFER_TYPE_ID)
356 bq_consumer_send_set_buffer_id(BQ_OBJECT_RESOURCE(bq_consumer),
357 bq_buffer->consumer,
358 bq_buffer->id,
359 bq_buffer->offset0,
360 bq_buffer->stride0,
361 bq_buffer->offset1,
362 bq_buffer->stride1,
363 bq_buffer->offset2,
364 bq_buffer->stride2);
365 else
366 {
367 bq_consumer_send_set_buffer_fd(BQ_OBJECT_RESOURCE(bq_consumer),
368 bq_buffer->consumer,
369 bq_buffer->id,
370 bq_buffer->offset0,
371 bq_buffer->stride0,
372 bq_buffer->offset1,
373 bq_buffer->stride1,
374 bq_buffer->offset2,
375 bq_buffer->stride2);
376 close(bq_buffer->id);
377 }
378}
379
380static void
381bq_mgr_buffer_queue_create_consumer(struct wl_client *client,
382 struct wl_resource *resource,
383 uint32_t id,
384 const char *name,
385 int32_t queue_size,
386 int32_t width,
387 int32_t height)
388{
389 Bq_Mgr *bq_mgr = (Bq_Mgr*)wl_resource_get_user_data(resource);
390 Bq_Buffer_Queue *bq;
391 Bq_Buffer_Consumer *bq_consumer;
392 Bq_Buffer_Provider *bq_provider;
393 Bq_Buffer *buf;
394
395 EINA_SAFETY_ON_NULL_RETURN(bq_mgr);
396
397 bq = bq_mgr_buffer_queue_new(bq_mgr,name);
398 EINA_SAFETY_ON_NULL_RETURN(bq);
399
400 if (bq->consumer)
401 {
402 bq_object_unref(BQ_OBJECT(bq));
403 wl_resource_post_error(resource,
404 BQ_MGR_ERROR_ALREADY_USED,
405 "%s consumer already used",name);
406 return;
407 }
408
409 bq_consumer = BQ_OBJECT_NEW(Bq_Buffer_Consumer, NULL);
410 EINA_SAFETY_ON_NULL_RETURN(bq_consumer);
411 BQ_OBJECT_RESOURCE(bq_consumer) = wl_resource_create(client,
412 &bq_consumer_interface,
413 1, id);
414 if (!BQ_OBJECT_RESOURCE(bq_consumer))
415 {
416 bq_object_unref(BQ_OBJECT(bq_consumer));
417 wl_client_post_no_memory(client);
418 return;
419 }
420
421 wl_resource_set_implementation(BQ_OBJECT_RESOURCE(bq_consumer),
422 &_bq_consumer_interface,
423 bq_consumer,
424 bq_mgr_buffer_consumer_destroy);
425
426 bq_consumer->buffer_queue = bq;
427 bq_consumer->queue_size = queue_size;
428 bq_consumer->width = width;
429 bq_consumer->height = height;
430
431 bq_provider = bq->provider;
432 bq->consumer = bq_consumer;
433 if (bq_provider)
434 {
435 bq_provider_send_connected(BQ_OBJECT_RESOURCE(bq_provider),
436 queue_size, width, height);
437 bq_consumer_send_connected(BQ_OBJECT_RESOURCE(bq_consumer));
438 }
439
440 EINA_INLIST_FOREACH(bq->buffers,buf)
441 {
442 bq_buffer_create_consumer_side(bq_consumer, buf);
443 bq_buffer_set_consumer_side(bq_consumer, buf);
444 }
445}
446
447static void
448bq_buffer_free(Bq_Buffer *buf)
449{
450 if (buf->engine)
451 free(buf->engine);
452}
453
454static void
455bq_mgr_buffer_provider_attatch_buffer(struct wl_client *client,
456 struct wl_resource *resource,
457 uint32_t buffer,
458 const char *engine,
459 int32_t width,
460 int32_t height,
461 int32_t format,
462 uint32_t flags)
463{
464 Bq_Buffer_Provider *bq_provider = wl_resource_get_user_data(resource);
465 Bq_Buffer_Consumer *bq_consumer;
466 Bq_Buffer_Queue *bq;
467 Bq_Buffer *bq_buffer;
468
469 EINA_SAFETY_ON_NULL_RETURN(bq_provider);
470 bq = bq_provider->buffer_queue;
471 bq_consumer = bq->consumer;
472
473 bq_buffer = BQ_OBJECT_NEW(Bq_Buffer, bq_buffer_free);
474 bq_buffer->provider = wl_resource_create(client, &bq_buffer_interface, 1, buffer);
475 wl_resource_set_implementation(bq_buffer->provider, NULL, bq_buffer, bq_mgr_buffer_destroy);
476
477 if (!bq_buffer->provider)
478 {
479 wl_client_post_no_memory(client);
480 bq_object_unref(BQ_OBJECT(bq_buffer));
481 return;
482 }
483
484 bq_buffer->engine = strdup(engine);
485 bq_buffer->width = width;
486 bq_buffer->height = height;
487 bq_buffer->format = format;
488 bq_buffer->flags = flags;
489
490 bq->buffers = eina_inlist_append(bq->buffers,EINA_INLIST_GET(bq_buffer));
491 BQ_DEBUG("add BUFFER : %d\n", bq_buffer->type);
492
493 bq_buffer_create_consumer_side(bq_consumer, bq_buffer);
494
495}
496
497static void
498bq_mgr_buffer_provider_set_buffer_id(struct wl_client *client EINA_UNUSED,
499 struct wl_resource *resource,
500 struct wl_resource *buffer,
501 int32_t id,
502 int32_t offset0,
503 int32_t stride0,
504 int32_t offset1,
505 int32_t stride1,
506 int32_t offset2,
507 int32_t stride2)
508{
509 Bq_Buffer_Provider *bq_provider = wl_resource_get_user_data(resource);
510 Bq_Buffer_Consumer *bq_consumer;
511 Bq_Buffer_Queue *bq;
512 Bq_Buffer *bq_buffer;
513
514 EINA_SAFETY_ON_NULL_RETURN(bq_provider);
515 bq = bq_provider->buffer_queue;
516 bq_consumer = bq->consumer;
517 bq_buffer = wl_resource_get_user_data(buffer);
518 EINA_SAFETY_ON_NULL_RETURN(bq_buffer);
519
520 bq_buffer->type = bq_BUFFER_TYPE_ID;
521 bq_buffer->id = id;
522 bq_buffer->offset0 = offset0;
523 bq_buffer->stride0 = stride0;
524 bq_buffer->offset1 = offset1;
525 bq_buffer->stride1 = stride1;
526 bq_buffer->offset2 = offset2;
527 bq_buffer->stride2 = stride2;
528
529 bq_buffer_set_consumer_side(bq_consumer, bq_buffer);
530}
531
532static void
533bq_mgr_buffer_provider_set_buffer_fd(struct wl_client *client EINA_UNUSED,
534 struct wl_resource *resource,
535 struct wl_resource *buffer,
536 int32_t fd,
537 int32_t offset0,
538 int32_t stride0,
539 int32_t offset1,
540 int32_t stride1,
541 int32_t offset2,
542 int32_t stride2)
543{
544 Bq_Buffer_Provider *bq_provider = wl_resource_get_user_data(resource);
545 Bq_Buffer_Consumer *bq_consumer;
546 Bq_Buffer_Queue *bq;
547 Bq_Buffer *bq_buffer;
548
549 EINA_SAFETY_ON_NULL_RETURN(bq_provider);
550 bq = bq_provider->buffer_queue;
551 bq_consumer = bq->consumer;
552 bq_buffer = wl_resource_get_user_data(buffer);
553 EINA_SAFETY_ON_NULL_RETURN(bq_buffer);
554
555 bq_buffer->type = bq_BUFFER_TYPE_FD;
556 bq_buffer->id = fd;
557 bq_buffer->offset0 = offset0;
558 bq_buffer->stride0 = stride0;
559 bq_buffer->offset1 = offset1;
560 bq_buffer->stride1 = stride1;
561 bq_buffer->offset2 = offset2;
562 bq_buffer->stride2 = stride2;
563
564 bq_buffer_set_consumer_side(bq_consumer, bq_buffer);
565}
566
567
568static void
569bq_mgr_buffer_provider_detach_buffer(struct wl_client *client EINA_UNUSED,
570 struct wl_resource *resource,
571 struct wl_resource *buffer)
572{
573 Bq_Buffer_Provider *bq_provider = wl_resource_get_user_data(resource);
574 Bq_Buffer_Consumer *bq_consumer;
575 Bq_Buffer_Queue *bq;
576 Bq_Buffer *bq_buffer;
577
578 EINA_SAFETY_ON_NULL_RETURN(bq_provider);
579 bq = bq_provider->buffer_queue;
580 bq_consumer = bq->consumer;
581 bq_buffer = wl_resource_get_user_data(buffer);
582
583 if (bq_consumer)
584 {
585 bq_consumer_send_buffer_detached(BQ_OBJECT_RESOURCE(bq_consumer),
586 bq_buffer->consumer);
587 wl_resource_destroy(bq_buffer->consumer);
588 bq_object_unref(BQ_OBJECT(bq_buffer));
589 }
590
591 wl_resource_destroy(bq_buffer->provider);
592 bq->buffers = eina_inlist_remove(bq->buffers,EINA_INLIST_GET(bq_buffer));
593 bq_object_unref(BQ_OBJECT(bq_buffer));
594}
595
596static void
597bq_mgr_buffer_provider_enqueue_buffer(struct wl_client *client EINA_UNUSED,
598 struct wl_resource *resource,
599 struct wl_resource *buffer,
600 uint32_t serial)
601{
602 Bq_Buffer_Provider *bq_provider = wl_resource_get_user_data(resource);
603 Bq_Buffer_Consumer *bq_consumer;
604 Bq_Buffer_Queue *bq;
605 Bq_Buffer *bq_buffer;
606
607 EINA_SAFETY_ON_NULL_RETURN(bq_provider);
608 bq = bq_provider->buffer_queue;
609 bq_consumer = bq->consumer;
610 if (!bq_consumer)
611 {
612 wl_resource_post_error(BQ_OBJECT_RESOURCE(bq_consumer),
613 BQ_PROVIDER_ERROR_CONNECTION,
614 "Not connected:%s", bq->name);
615 return;
616 }
617
618 bq_buffer = wl_resource_get_user_data(buffer);
619 EINA_SAFETY_ON_NULL_RETURN(bq_buffer);
620 bq_buffer->serial = serial;
621
622 bq_consumer_send_add_buffer(BQ_OBJECT_RESOURCE(bq_consumer),
623 bq_buffer->consumer,
624 bq_buffer->serial);
625}
626
627static const struct bq_provider_interface _bq_provider_interface = {
628 bq_mgr_buffer_provider_attatch_buffer,
629 bq_mgr_buffer_provider_set_buffer_id,
630 bq_mgr_buffer_provider_set_buffer_fd,
631 bq_mgr_buffer_provider_detach_buffer,
632 bq_mgr_buffer_provider_enqueue_buffer
633};
634
635static void
636bq_mgr_buffer_provider_destroy(struct wl_resource *resource)
637{
638 Bq_Buffer_Queue *bq;
639 Bq_Buffer_Provider *bq_provider = wl_resource_get_user_data(resource);
640 Bq_Buffer_Consumer *bq_consumer;
641 Bq_Buffer *buf;
642
643 EINA_SAFETY_ON_NULL_RETURN(bq_provider);
644 BQ_DEBUG("destroy buffer provider : %s\n", bq_provider->buffer_queue->name);
645 bq = bq_provider->buffer_queue;
646 bq_consumer = bq->consumer;
647
648 BQ_OBJECT_RESOURCE(bq_provider) = NULL;
649 bq->provider = NULL;
650
651 while (bq->buffers)
652 {
653 buf = EINA_INLIST_CONTAINER_GET(bq->buffers, Bq_Buffer);
654 bq->buffers = eina_inlist_remove(bq->buffers, bq->buffers);
655
656 if (buf->consumer)
657 {
658 bq_consumer_send_buffer_detached(BQ_OBJECT_RESOURCE(bq_consumer), buf->consumer);
659 wl_resource_destroy(buf->consumer);
660 buf->consumer = NULL;
661 bq_object_unref(BQ_OBJECT(buf));
662 }
663
664 if (buf->provider)
665 {
666 wl_resource_destroy(buf->provider);
667 buf->provider = NULL;
668 bq_object_unref(BQ_OBJECT(buf));
669 }
670 }
671
672 if (bq_consumer)
673 {
674 if (BQ_OBJECT_RESOURCE(bq_consumer))
675 bq_consumer_send_disconnected(BQ_OBJECT_RESOURCE(bq_consumer));
676 }
677
678 bq_object_unref(BQ_OBJECT(bq_provider));
679 bq_object_unref(BQ_OBJECT(bq));
680}
681
682static void
683bq_mgr_buffer_queue_create_provider(struct wl_client *client,
684 struct wl_resource *resource,
685 uint32_t id,
686 const char *name)
687{
688 Bq_Mgr *bq_mgr = (Bq_Mgr*)wl_resource_get_user_data(resource);
689 Bq_Buffer_Queue *bq;
690 Bq_Buffer_Provider *bq_provider;
691 Bq_Buffer_Consumer *bq_consumer;
692
693 EINA_SAFETY_ON_NULL_RETURN(bq_mgr);
694
695 bq = bq_mgr_buffer_queue_new(bq_mgr,name);
696 EINA_SAFETY_ON_NULL_RETURN(bq);
697
698 if (bq->provider)
699 {
700 bq_object_unref(BQ_OBJECT(bq));
701 wl_resource_post_error(resource,
702 BQ_MGR_ERROR_ALREADY_USED,
703 "%s rpovider already used",name);
704 return;
705 }
706
707 bq_provider = BQ_OBJECT_NEW(Bq_Buffer_Provider, NULL);
708 EINA_SAFETY_ON_NULL_GOTO(bq_provider, on_error);
709
710 BQ_OBJECT_RESOURCE(bq_provider)= wl_resource_create(client,
711 &bq_provider_interface,
712 1, id);
713 EINA_SAFETY_ON_NULL_GOTO(BQ_OBJECT_RESOURCE(bq_provider), on_error);
714
715 wl_resource_set_implementation(BQ_OBJECT_RESOURCE(bq_provider),
716 &_bq_provider_interface,
717 bq_provider,
718 bq_mgr_buffer_provider_destroy);
719
720 bq_provider->buffer_queue = bq;
721 bq->provider = bq_provider;
722 bq_consumer = bq->consumer;
723 if (bq_consumer)
724 {
725 /*Send connect*/
726 bq_consumer_send_connected(BQ_OBJECT_RESOURCE(bq_consumer));
727 bq_provider_send_connected(BQ_OBJECT_RESOURCE(bq_provider),
728 bq_consumer->queue_size,
729 bq_consumer->width, bq_consumer->height);
730 }
731
732 return;
733
734on_error:
735 if (bq) bq_object_unref(BQ_OBJECT(bq));
736 if (bq_provider) bq_object_unref(BQ_OBJECT(bq_provider));
737 wl_client_post_no_memory(client);
738}
739
740static const struct bq_mgr_interface _bq_mgr_interface =
741{
742 bq_mgr_buffer_queue_create_consumer,
743 bq_mgr_buffer_queue_create_provider
744};
745
746static void
747bq_mgr_buffer_queue_bind(struct wl_client *client, void *data,
748 uint32_t version EINA_UNUSED, uint32_t id)
749{
750 Bq_Mgr *bq_mgr = (Bq_Mgr*)data;
751 struct wl_resource *resource;
752
753 resource = wl_resource_create(client, &bq_mgr_interface,
754 1, id);
755 if (resource == NULL) {
756 wl_client_post_no_memory(client);
757 return;
758 }
759
760 wl_resource_set_implementation(resource,
761 &_bq_mgr_interface,
762 bq_mgr, NULL);
763}
764
765Eina_Bool
766bq_mgr_buffer_queue_manager_init(Bq_Mgr *bq_mgr)
767{
768 EINA_SAFETY_ON_NULL_RETURN_VAL(bq_mgr,EINA_FALSE);
769 bq_mgr->bq_mgr = wl_global_create(bq_mgr->wdpy
770 ,&bq_mgr_interface,1
771 ,bq_mgr
772 ,bq_mgr_buffer_queue_bind);
773
774 EINA_SAFETY_ON_NULL_RETURN_VAL(bq_mgr->bq_mgr,EINA_FALSE);
775
776 bq_mgr->buffer_queues = eina_hash_string_superfast_new(NULL);
777 EINA_SAFETY_ON_NULL_RETURN_VAL(bq_mgr->buffer_queues,EINA_FALSE);
778
779 return EINA_TRUE;
780}
781
782static const Ecore_Getopt optdesc =
783{
784 "tbm_daemon",
785 "%prog [options]",
786 "0.1.0",
787 "(C) Samsung",
788 "BSD 2-Clause",
789 "Tizen Buffer Manager Daemon",
790 EINA_FALSE,
791 {
792 ECORE_GETOPT_STORE_STR('s', "socket_name",
793 "socket name"),
794 ECORE_GETOPT_STORE_BOOL('d',"debug","enable debug log"),
795 ECORE_GETOPT_VERSION('v', "version"),
796 ECORE_GETOPT_HELP('h', "help"),
797 ECORE_GETOPT_SENTINEL
798 }
799};
800
801static int
802bq_mgr_on_term_signal(int signal_number, void *data)
803{
804 Bq_Mgr *bq_mgr = data;
805
806 BQ_LOG("caught signal %d\n", signal_number);
807 wl_display_terminate(bq_mgr->wdpy);
808
809 return 1;
810}
811
812static void
813bq_mgr_free(Bq_Mgr *bq_mgr)
814{
815 int i;
816
817 for (i = ARRAY_LENGTH(bq_mgr->signals) - 1; i >= 0; i--)
818 {
819 if (bq_mgr->signals[i])
820 wl_event_source_remove(bq_mgr->signals[i]);
821 }
822
823 if (bq_mgr->wdpy)
824 wl_display_destroy(bq_mgr->wdpy);
825}
826
827static Bq_Mgr*
828bq_mgr_new(char *sock_name)
829{
830 static char *default_sock_name = "bq_mgr_daemon";
831 Bq_Mgr *bq_mgr = BQ_OBJECT_NEW(Bq_Mgr, bq_mgr_free);
832 struct wl_event_loop *loop;
833
834 if (!bq_mgr) return NULL;
835
836 bq_mgr->wdpy = wl_display_create();
837 loop = wl_display_get_event_loop(bq_mgr->wdpy);
838 EINA_SAFETY_ON_NULL_GOTO(loop, on_err);
839
840 bq_mgr->signals[0] = wl_event_loop_add_signal(loop, SIGTERM, bq_mgr_on_term_signal, bq_mgr);
841 bq_mgr->signals[1] = wl_event_loop_add_signal(loop, SIGINT, bq_mgr_on_term_signal, bq_mgr);
842 bq_mgr->signals[2] = wl_event_loop_add_signal(loop, SIGQUIT, bq_mgr_on_term_signal, bq_mgr);
843
844 if (!sock_name)
845 sock_name = default_sock_name;
846 wl_display_add_socket(bq_mgr->wdpy, sock_name);
847
848 return bq_mgr;
849
850on_err:
851 bq_object_free(BQ_OBJECT(bq_mgr));
852 return NULL;
853}
854
855int
856main(int argc, char **argv)
857{
858 Bq_Mgr *bq_mgr = NULL;
859 int res, ret = EXIT_FAILURE;
860 char *opt_path = NULL;
861 Eina_Bool quit = EINA_FALSE;
862 Ecore_Getopt_Value values[] =
863 {
864 ECORE_GETOPT_VALUE_STR(opt_path),
865 ECORE_GETOPT_VALUE_BOOL(debug),
866 ECORE_GETOPT_VALUE_BOOL(quit),
867 ECORE_GETOPT_VALUE_BOOL(quit),
868 ECORE_GETOPT_VALUE_NONE
869 };
870
871 eina_init();
872
873 res = ecore_getopt_parse(&optdesc,
874 values,
875 argc, argv);
876
877 if ((res < 0) || (quit)) goto finish;
878
879 if (opt_path)
880 BQ_LOG("socket_name : %s\n", opt_path);
881
882 bq_mgr = bq_mgr_new(opt_path);
883 if (!bq_mgr) goto finish;
884
885 if (!bq_mgr_buffer_queue_manager_init(bq_mgr))
886 {
887 bq_mgr_free(bq_mgr);
888 goto finish;
889 }
890
891 wl_display_run(bq_mgr->wdpy);
892
893 ret = EXIT_SUCCESS;
894finish:
895 eina_shutdown();
896 bq_object_free(BQ_OBJECT(bq_mgr));
897
898 return ret;
899}
diff --git a/src/bin/ecore_buffer/bq_mgr_protocol.c b/src/bin/ecore_buffer/bq_mgr_protocol.c
new file mode 100644
index 0000000000..fe8b98c9bc
--- /dev/null
+++ b/src/bin/ecore_buffer/bq_mgr_protocol.c
@@ -0,0 +1,131 @@
1#include <stdlib.h>
2#include <stdint.h>
3#include "wayland-util.h"
4
5extern const struct wl_interface bq_buffer_interface;
6extern const struct wl_interface bq_consumer_interface;
7extern const struct wl_interface bq_provider_interface;
8
9static const struct wl_interface *types[] = {
10 NULL,
11 NULL,
12 NULL,
13 &bq_consumer_interface,
14 NULL,
15 NULL,
16 NULL,
17 NULL,
18 &bq_provider_interface,
19 NULL,
20 &bq_buffer_interface,
21 &bq_buffer_interface,
22 NULL,
23 NULL,
24 NULL,
25 NULL,
26 NULL,
27 &bq_buffer_interface,
28 NULL,
29 NULL,
30 NULL,
31 NULL,
32 NULL,
33 NULL,
34 NULL,
35 &bq_buffer_interface,
36 NULL,
37 NULL,
38 NULL,
39 NULL,
40 NULL,
41 NULL,
42 NULL,
43 &bq_buffer_interface,
44 &bq_buffer_interface,
45 NULL,
46 &bq_buffer_interface,
47 NULL,
48 NULL,
49 NULL,
50 NULL,
51 NULL,
52 &bq_buffer_interface,
53 NULL,
54 NULL,
55 NULL,
56 NULL,
57 NULL,
58 NULL,
59 NULL,
60 &bq_buffer_interface,
61 NULL,
62 NULL,
63 NULL,
64 NULL,
65 NULL,
66 NULL,
67 NULL,
68 &bq_buffer_interface,
69 &bq_buffer_interface,
70 NULL,
71 &bq_buffer_interface,
72 NULL,
73};
74
75static const struct wl_message bq_mgr_requests[] = {
76 { "create_consumer", "nsiii", types + 3 },
77 { "create_provider", "ns", types + 8 },
78};
79
80WL_EXPORT const struct wl_interface bq_mgr_interface = {
81 "bq_mgr", 1,
82 2, bq_mgr_requests,
83 0, NULL,
84};
85
86static const struct wl_message bq_consumer_requests[] = {
87 { "release_buffer", "o", types + 10 },
88};
89
90static const struct wl_message bq_consumer_events[] = {
91 { "connected", "", types + 0 },
92 { "disconnected", "", types + 0 },
93 { "buffer_attached", "nsiiiu", types + 11 },
94 { "set_buffer_id", "oiiiiiii", types + 17 },
95 { "set_buffer_fd", "ohiiiiii", types + 25 },
96 { "buffer_detached", "o", types + 33 },
97 { "add_buffer", "ou", types + 34 },
98};
99
100WL_EXPORT const struct wl_interface bq_consumer_interface = {
101 "bq_consumer", 1,
102 1, bq_consumer_requests,
103 7, bq_consumer_events,
104};
105
106static const struct wl_message bq_provider_requests[] = {
107 { "attach_buffer", "nsiiiu", types + 36 },
108 { "set_buffer_id", "oiiiiiii", types + 42 },
109 { "set_buffer_fd", "ohiiiiii", types + 50 },
110 { "detach_buffer", "o", types + 58 },
111 { "enqueue_buffer", "ou", types + 59 },
112};
113
114static const struct wl_message bq_provider_events[] = {
115 { "connected", "iii", types + 0 },
116 { "disconnected", "", types + 0 },
117 { "add_buffer", "ou", types + 61 },
118};
119
120WL_EXPORT const struct wl_interface bq_provider_interface = {
121 "bq_provider", 1,
122 5, bq_provider_requests,
123 3, bq_provider_events,
124};
125
126WL_EXPORT const struct wl_interface bq_buffer_interface = {
127 "bq_buffer", 1,
128 0, NULL,
129 0, NULL,
130};
131
diff --git a/src/bin/ecore_buffer/bq_mgr_protocol.h b/src/bin/ecore_buffer/bq_mgr_protocol.h
new file mode 100644
index 0000000000..b2d7bcc775
--- /dev/null
+++ b/src/bin/ecore_buffer/bq_mgr_protocol.h
@@ -0,0 +1,247 @@
1#ifndef BQ_MGR_SERVER_PROTOCOL_H
2#define BQ_MGR_SERVER_PROTOCOL_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdint.h>
9#include <stddef.h>
10#include "wayland-server.h"
11
12struct wl_client;
13struct wl_resource;
14
15struct bq_mgr;
16struct bq_consumer;
17struct bq_provider;
18struct bq_buffer;
19
20extern const struct wl_interface bq_mgr_interface;
21extern const struct wl_interface bq_consumer_interface;
22extern const struct wl_interface bq_provider_interface;
23extern const struct wl_interface bq_buffer_interface;
24
25#ifndef BQ_MGR_ERROR_ENUM
26#define BQ_MGR_ERROR_ENUM
27enum bq_mgr_error {
28 BQ_MGR_ERROR_INVALID_PERMISSION = 0,
29 BQ_MGR_ERROR_INVALID_NAME = 1,
30 BQ_MGR_ERROR_ALREADY_USED = 2,
31};
32#endif /* BQ_MGR_ERROR_ENUM */
33
34struct bq_mgr_interface {
35 /**
36 * create_consumer - (none)
37 * @id: (none)
38 * @name: (none)
39 * @queue_size: (none)
40 * @width: (none)
41 * @height: (none)
42 */
43 void (*create_consumer)(struct wl_client *client,
44 struct wl_resource *resource,
45 uint32_t id,
46 const char *name,
47 int32_t queue_size,
48 int32_t width,
49 int32_t height);
50 /**
51 * create_provider - (none)
52 * @id: (none)
53 * @name: (none)
54 */
55 void (*create_provider)(struct wl_client *client,
56 struct wl_resource *resource,
57 uint32_t id,
58 const char *name);
59};
60
61
62struct bq_consumer_interface {
63 /**
64 * release_buffer - (none)
65 * @buffer: (none)
66 */
67 void (*release_buffer)(struct wl_client *client,
68 struct wl_resource *resource,
69 struct wl_resource *buffer);
70};
71
72#define BQ_CONSUMER_CONNECTED 0
73#define BQ_CONSUMER_DISCONNECTED 1
74#define BQ_CONSUMER_BUFFER_ATTACHED 2
75#define BQ_CONSUMER_SET_BUFFER_ID 3
76#define BQ_CONSUMER_SET_BUFFER_FD 4
77#define BQ_CONSUMER_BUFFER_DETACHED 5
78#define BQ_CONSUMER_ADD_BUFFER 6
79
80#define BQ_CONSUMER_CONNECTED_SINCE_VERSION 1
81#define BQ_CONSUMER_DISCONNECTED_SINCE_VERSION 1
82#define BQ_CONSUMER_BUFFER_ATTACHED_SINCE_VERSION 1
83#define BQ_CONSUMER_SET_BUFFER_ID_SINCE_VERSION 1
84#define BQ_CONSUMER_SET_BUFFER_FD_SINCE_VERSION 1
85#define BQ_CONSUMER_BUFFER_DETACHED_SINCE_VERSION 1
86#define BQ_CONSUMER_ADD_BUFFER_SINCE_VERSION 1
87
88static inline void
89bq_consumer_send_connected(struct wl_resource *resource_)
90{
91 wl_resource_post_event(resource_, BQ_CONSUMER_CONNECTED);
92}
93
94static inline void
95bq_consumer_send_disconnected(struct wl_resource *resource_)
96{
97 wl_resource_post_event(resource_, BQ_CONSUMER_DISCONNECTED);
98}
99
100static inline void
101bq_consumer_send_buffer_attached(struct wl_resource *resource_, struct wl_resource *buffer, const char *engine, int32_t width, int32_t height, int32_t format, uint32_t flags)
102{
103 wl_resource_post_event(resource_, BQ_CONSUMER_BUFFER_ATTACHED, buffer, engine, width, height, format, flags);
104}
105
106static inline void
107bq_consumer_send_set_buffer_id(struct wl_resource *resource_, struct wl_resource *buffer, int32_t id, int32_t offset0, int32_t stride0, int32_t offset1, int32_t stride1, int32_t offset2, int32_t stride2)
108{
109 wl_resource_post_event(resource_, BQ_CONSUMER_SET_BUFFER_ID, buffer, id, offset0, stride0, offset1, stride1, offset2, stride2);
110}
111
112static inline void
113bq_consumer_send_set_buffer_fd(struct wl_resource *resource_, struct wl_resource *buffer, int32_t fd, int32_t offset0, int32_t stride0, int32_t offset1, int32_t stride1, int32_t offset2, int32_t stride2)
114{
115 wl_resource_post_event(resource_, BQ_CONSUMER_SET_BUFFER_FD, buffer, fd, offset0, stride0, offset1, stride1, offset2, stride2);
116}
117
118static inline void
119bq_consumer_send_buffer_detached(struct wl_resource *resource_, struct wl_resource *buffer)
120{
121 wl_resource_post_event(resource_, BQ_CONSUMER_BUFFER_DETACHED, buffer);
122}
123
124static inline void
125bq_consumer_send_add_buffer(struct wl_resource *resource_, struct wl_resource *buffer, uint32_t serial)
126{
127 wl_resource_post_event(resource_, BQ_CONSUMER_ADD_BUFFER, buffer, serial);
128}
129
130#ifndef BQ_PROVIDER_ERROR_ENUM
131#define BQ_PROVIDER_ERROR_ENUM
132enum bq_provider_error {
133 BQ_PROVIDER_ERROR_OVERFLOW_QUEUE_SIZE = 0,
134 BQ_PROVIDER_ERROR_CONNECTION = 1,
135};
136#endif /* BQ_PROVIDER_ERROR_ENUM */
137
138struct bq_provider_interface {
139 /**
140 * attach_buffer - (none)
141 * @buffer: (none)
142 * @engine: (none)
143 * @width: (none)
144 * @height: (none)
145 * @format: (none)
146 * @flags: (none)
147 */
148 void (*attach_buffer)(struct wl_client *client,
149 struct wl_resource *resource,
150 uint32_t buffer,
151 const char *engine,
152 int32_t width,
153 int32_t height,
154 int32_t format,
155 uint32_t flags);
156 /**
157 * set_buffer_id - (none)
158 * @buffer: (none)
159 * @id: (none)
160 * @offset0: (none)
161 * @stride0: (none)
162 * @offset1: (none)
163 * @stride1: (none)
164 * @offset2: (none)
165 * @stride2: (none)
166 */
167 void (*set_buffer_id)(struct wl_client *client,
168 struct wl_resource *resource,
169 struct wl_resource *buffer,
170 int32_t id,
171 int32_t offset0,
172 int32_t stride0,
173 int32_t offset1,
174 int32_t stride1,
175 int32_t offset2,
176 int32_t stride2);
177 /**
178 * set_buffer_fd - (none)
179 * @buffer: (none)
180 * @fd: (none)
181 * @offset0: (none)
182 * @stride0: (none)
183 * @offset1: (none)
184 * @stride1: (none)
185 * @offset2: (none)
186 * @stride2: (none)
187 */
188 void (*set_buffer_fd)(struct wl_client *client,
189 struct wl_resource *resource,
190 struct wl_resource *buffer,
191 int32_t fd,
192 int32_t offset0,
193 int32_t stride0,
194 int32_t offset1,
195 int32_t stride1,
196 int32_t offset2,
197 int32_t stride2);
198 /**
199 * detach_buffer - (none)
200 * @buffer: (none)
201 */
202 void (*detach_buffer)(struct wl_client *client,
203 struct wl_resource *resource,
204 struct wl_resource *buffer);
205 /**
206 * enqueue_buffer - (none)
207 * @buffer: (none)
208 * @serial: (none)
209 */
210 void (*enqueue_buffer)(struct wl_client *client,
211 struct wl_resource *resource,
212 struct wl_resource *buffer,
213 uint32_t serial);
214};
215
216#define BQ_PROVIDER_CONNECTED 0
217#define BQ_PROVIDER_DISCONNECTED 1
218#define BQ_PROVIDER_ADD_BUFFER 2
219
220#define BQ_PROVIDER_CONNECTED_SINCE_VERSION 1
221#define BQ_PROVIDER_DISCONNECTED_SINCE_VERSION 1
222#define BQ_PROVIDER_ADD_BUFFER_SINCE_VERSION 1
223
224static inline void
225bq_provider_send_connected(struct wl_resource *resource_, int32_t queue_size, int32_t width, int32_t height)
226{
227 wl_resource_post_event(resource_, BQ_PROVIDER_CONNECTED, queue_size, width, height);
228}
229
230static inline void
231bq_provider_send_disconnected(struct wl_resource *resource_)
232{
233 wl_resource_post_event(resource_, BQ_PROVIDER_DISCONNECTED);
234}
235
236static inline void
237bq_provider_send_add_buffer(struct wl_resource *resource_, struct wl_resource *buffer, uint32_t serial)
238{
239 wl_resource_post_event(resource_, BQ_PROVIDER_ADD_BUFFER, buffer, serial);
240}
241
242
243#ifdef __cplusplus
244}
245#endif
246
247#endif
diff --git a/src/examples/ecore/.gitignore b/src/examples/ecore/.gitignore
index acc3750839..8b84fca973 100644
--- a/src/examples/ecore/.gitignore
+++ b/src/examples/ecore/.gitignore
@@ -43,3 +43,6 @@
43/ecore_thread_example 43/ecore_thread_example
44/ecore_time_functions_example 44/ecore_time_functions_example
45/ecore_timer_example 45/ecore_timer_example
46/ecore_buffer_example
47/ecore_buffer_consumer_example
48/ecore_buffer_provider_example
diff --git a/src/examples/ecore/Makefile.am b/src/examples/ecore/Makefile.am
index f73c4f9e3b..179408e369 100644
--- a/src/examples/ecore/Makefile.am
+++ b/src/examples/ecore/Makefile.am
@@ -8,6 +8,7 @@ AM_CPPFLAGS = \
8-I$(top_srcdir)/src/lib/eo \ 8-I$(top_srcdir)/src/lib/eo \
9-I$(top_srcdir)/src/lib/evas \ 9-I$(top_srcdir)/src/lib/evas \
10-I$(top_srcdir)/src/lib/ecore \ 10-I$(top_srcdir)/src/lib/ecore \
11-I$(top_srcdir)/src/lib/ecore_buffer \
11-I$(top_srcdir)/src/lib/ecore_input \ 12-I$(top_srcdir)/src/lib/ecore_input \
12-I$(top_srcdir)/src/lib/ecore_input_evas \ 13-I$(top_srcdir)/src/lib/ecore_input_evas \
13-I$(top_srcdir)/src/lib/ecore_file \ 14-I$(top_srcdir)/src/lib/ecore_file \
@@ -35,6 +36,9 @@ AM_CPPFLAGS = \
35 36
36EXTRA_PROGRAMS = \ 37EXTRA_PROGRAMS = \
37ecore_animator_example \ 38ecore_animator_example \
39ecore_buffer_example \
40ecore_buffer_consumer_example \
41ecore_buffer_provider_example \
38ecore_client_bench \ 42ecore_client_bench \
39ecore_compose_get_example \ 43ecore_compose_get_example \
40ecore_con_client_example \ 44ecore_con_client_example \
@@ -112,6 +116,18 @@ $(ECORE_COMMON_LDADD)
112ecore_animator_example_SOURCES = ecore_animator_example.c 116ecore_animator_example_SOURCES = ecore_animator_example.c
113ecore_animator_example_LDADD = $(ECORE_EVAS_COMMON_LDADD) 117ecore_animator_example_LDADD = $(ECORE_EVAS_COMMON_LDADD)
114 118
119ecore_buffer_example_SOURCES = ecore_buffer_example.c
120ecore_buffer_example_LDADD = $(ECORE_EVAS_COMMON_LDADD) \
121 $(top_builddir)/src/lib/ecore_buffer/libecore_buffer.la
122
123ecore_buffer_consumer_example_SOURCES = ecore_buffer_consumer_example.c
124ecore_buffer_consumer_example_LDADD = $(ECORE_EVAS_COMMON_LDADD) \
125 $(top_builddir)/src/lib/ecore_buffer/libecore_buffer.la
126
127ecore_buffer_provider_example_SOURCES = ecore_buffer_provider_example.c
128ecore_buffer_provider_example_LDADD = $(ECORE_EVAS_COMMON_LDADD) \
129 $(top_builddir)/src/lib/ecore_buffer/libecore_buffer.la
130
115ecore_client_bench_SOURCES = ecore_client_bench.c 131ecore_client_bench_SOURCES = ecore_client_bench.c
116ecore_client_bench_LDADD = $(ECORE_CON_COMMON_LDADD) 132ecore_client_bench_LDADD = $(ECORE_CON_COMMON_LDADD)
117 133
@@ -249,6 +265,9 @@ ecore_con_eet_server_example_LDADD = $(ECORE_CON_COMMON_LDADD)
249 265
250SRCS = \ 266SRCS = \
251ecore_animator_example.c \ 267ecore_animator_example.c \
268ecore_buffer_example.c \
269ecore_buffer_consumer_example.c \
270ecore_buffer_provider_example.c \
252ecore_audio_custom.c \ 271ecore_audio_custom.c \
253ecore_audio_playback.c \ 272ecore_audio_playback.c \
254ecore_audio_to_ogg.c \ 273ecore_audio_to_ogg.c \
diff --git a/src/examples/ecore/ecore_buffer_consumer_example.c b/src/examples/ecore/ecore_buffer_consumer_example.c
new file mode 100644
index 0000000000..e24a3e2ff1
--- /dev/null
+++ b/src/examples/ecore/ecore_buffer_consumer_example.c
@@ -0,0 +1,192 @@
1#include <stdio.h>
2#include <Eina.h>
3#include <Ecore.h>
4#include <Ecore_Evas.h>
5#include <Ecore_Buffer.h>
6#include <Ecore_Buffer_Queue.h>
7#include <Evas.h>
8
9#ifdef DEBUG
10#define LOG(f, x...) printf("[CONSUMER|%30.30s|%04d] " f "\n", __func__, __LINE__, ##x)
11#else
12#define LOG(f, x...)
13#endif
14
15#define WIDTH 720
16#define HEIGHT 960
17
18typedef struct _Consumer_Data
19{
20 Ecore_Buffer_Consumer *consumer;
21 Ecore_Buffer *buffer;
22 Ecore_Job *render_job;
23 struct
24 {
25 Evas *e;
26 Ecore_Evas *ee;
27 Evas_Object *bg, *img;
28 } win;
29} Consumer_Data;
30
31const char *name = "ecore_buffer_queue_test";
32
33static void
34shutdown_all(void)
35{
36 ecore_buffer_queue_shutdown();
37 ecore_buffer_shutdown();
38 ecore_evas_shutdown();
39 ecore_shutdown();
40 eina_shutdown();
41}
42
43static Eina_Bool
44init_all(void)
45{
46 if (!eina_init()) goto err;
47 if (!ecore_init()) goto err;
48 if (!ecore_evas_init()) goto err;
49 if (!ecore_buffer_init()) goto err;
50 if (!ecore_buffer_queue_init()) goto err;
51
52 return EINA_TRUE;
53err:
54 shutdown_all();
55 return EINA_FALSE;
56}
57
58static void
59_cb_render_post(void *data, Evas *e EINA_UNUSED, void *event_info EINA_UNUSED)
60{
61 Consumer_Data *cd = (Consumer_Data *)data;
62
63 if (cd->buffer)
64 {
65 ecore_buffer_consumer_buffer_release(cd->consumer, cd->buffer);
66 cd->buffer = NULL;
67 }
68}
69
70static void
71_consumer_cb_render_job(void *data)
72{
73 Consumer_Data *cd = (Consumer_Data *)data;
74 void *pixel_data;
75 unsigned int w, h;
76
77 LOG("Startup - Render");
78
79 if (!(cd->buffer = ecore_buffer_consumer_buffer_dequeue(cd->consumer)))
80 {
81 LOG("Failed to dequeue buffer");
82 goto end;
83 }
84
85 LOG("Success to get Compositable Buffer, "
86 "Drawing it to Consumer's Canvas now... - buffer:%p", cd->buffer);
87 // Get pixel data and set it to object.
88 pixel_data = ecore_buffer_data_get(cd->buffer);
89 ecore_buffer_size_get(cd->buffer, &w, &h);
90 evas_object_image_data_set(cd->win.img, pixel_data);
91 evas_object_image_data_update_add(cd->win.img, 0, 0, w, h);
92
93 ecore_job_del(cd->render_job);
94 cd->render_job = NULL;
95
96end:
97 LOG("Done - Render");
98}
99
100static void
101_consumer_render_queue(Consumer_Data *cd)
102{
103 if (!cd) return;
104
105 LOG("Render Queue");
106
107 if (!cd->render_job)
108 cd->render_job = ecore_job_add(_consumer_cb_render_job, cd);
109}
110
111static void
112_cb_provider_add(Ecore_Buffer_Consumer *consumer EINA_UNUSED, void *data EINA_UNUSED)
113{
114 LOG("Connected with Provider");
115}
116
117static void
118_cb_provider_del(Ecore_Buffer_Consumer *consumer EINA_UNUSED, void *data EINA_UNUSED)
119{
120 LOG("Disconnected with Provider, Shutdown Consumer now.");
121 ecore_main_loop_quit();
122}
123
124static void
125_cb_buffer_enqueued(Ecore_Buffer_Consumer *consumer EINA_UNUSED, void *data)
126{
127 Consumer_Data *cd = (Consumer_Data *)data;
128
129 LOG("Buffer Enqueued");
130
131 _consumer_render_queue(cd);
132}
133
134int
135main(void)
136{
137 Consumer_Data *cd;
138 Evas_Object *o;
139 const int queue_size = 3;
140
141 if (!init_all())
142 {
143 LOG("Initializing failed");
144 return -1;
145 }
146
147 cd = (Consumer_Data *)calloc(sizeof(Consumer_Data), 1);
148
149 if (!(cd->consumer = ecore_buffer_consumer_new(name, queue_size, WIDTH, HEIGHT)))
150 {
151 LOG("Failed to create consumer");
152 goto shutdown;
153 }
154
155 ecore_buffer_consumer_provider_add_cb_set(cd->consumer, _cb_provider_add, cd);
156 ecore_buffer_consumer_provider_del_cb_set(cd->consumer, _cb_provider_del, cd);
157 ecore_buffer_consumer_buffer_enqueued_cb_set(cd->consumer, _cb_buffer_enqueued, cd);
158
159 cd->win.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
160 cd->win.e = ecore_evas_get(cd->win.ee);
161
162 o = evas_object_rectangle_add(cd->win.e);
163 evas_object_move(o, 0, 0);
164 evas_object_resize(o, WIDTH, HEIGHT);
165 evas_object_color_set(o, 255, 0, 0, 255);
166 evas_object_show(o);
167 cd->win.bg = o;
168
169 o = evas_object_image_add(cd->win.e);
170 evas_object_image_fill_set(o, 0, 0, WIDTH, HEIGHT);
171 evas_object_image_size_set(o, WIDTH, HEIGHT);
172
173 evas_object_move(o, 0, 0);
174 evas_object_resize(o, WIDTH, HEIGHT);
175 evas_object_show(o);
176 cd->win.img = o;
177
178 ecore_evas_show(cd->win.ee);
179
180 evas_event_callback_add(cd->win.e, EVAS_CALLBACK_RENDER_POST, _cb_render_post, cd);
181
182 ecore_main_loop_begin();
183
184shutdown:
185 if (cd->win.ee) ecore_evas_free(cd->win.ee);
186 if (cd->buffer) ecore_buffer_consumer_buffer_release(cd->consumer, cd->buffer);
187 if (cd->consumer) ecore_buffer_consumer_free(cd->consumer);
188 if (cd) free(cd);
189
190 shutdown_all();
191 return 0;
192}
diff --git a/src/examples/ecore/ecore_buffer_example.c b/src/examples/ecore/ecore_buffer_example.c
new file mode 100644
index 0000000000..7ceeb1710e
--- /dev/null
+++ b/src/examples/ecore/ecore_buffer_example.c
@@ -0,0 +1,128 @@
1#include <stdio.h>
2#include <Eina.h>
3#include <Ecore.h>
4#include <Ecore_Evas.h>
5#include <Evas.h>
6#include <Ecore_Buffer.h>
7#include <Ecore_Buffer_Queue.h>
8
9#define WIDTH 720
10#define HEIGHT 960
11
12struct _Window
13{
14 Evas *e;
15 Ecore_Evas *ee;
16 Evas_Object *bg, *img;
17 Ecore_Buffer *buffer;
18};
19
20struct _Window win;
21Eina_List *hdls;
22
23static void
24paint_pixels(void *image, int padding, int width, int height, uint32_t time)
25{
26 const int halfh = padding + (height - padding * 2) / 2;
27 const int halfw = padding + (width - padding * 2) / 2;
28 int ir, or;
29 uint32_t *pixel = image;
30 int y;
31
32 /* squared radii thresholds */
33 or = (halfw < halfh ? halfw : halfh) - 8;
34 ir = or - 32;
35 or *= or;
36 ir *= ir;
37
38 pixel += padding * width;
39 for (y = padding; y < height - padding; y++) {
40 int x;
41 int y2 = (y - halfh) * (y - halfh);
42
43 pixel += padding;
44 for (x = padding; x < width - padding; x++) {
45 uint32_t v;
46
47 /* squared distance from center */
48 int r2 = (x - halfw) * (x - halfw) + y2;
49
50 if (r2 < ir)
51 v = (r2 / 32 + time / 64) * 0x0080401;
52 else if (r2 < or)
53 v = (y + time / 32) * 0x0080401;
54 else
55 v = (x + time / 16) * 0x0080401;
56 v &= 0x00ffffff;
57 v |= 0xff000000;
58
59 *pixel++ = v;
60 }
61
62 pixel += padding;
63 }
64}
65
66static void
67_cb_post_render(Ecore_Evas *ee EINA_UNUSED)
68{
69 void *data;
70
71 // Get pixel data and update.
72 data = ecore_buffer_data_get(win.buffer);
73 paint_pixels(data, 0, WIDTH, HEIGHT, ecore_loop_time_get() * 1000);
74 evas_object_image_data_set(win.img, data);
75 evas_object_image_data_update_add(win.img, 0, 0, WIDTH, HEIGHT);
76}
77
78int
79main(void)
80{
81 Evas_Object *o;
82 void *data;
83
84 eina_init();
85 ecore_init();
86 ecore_evas_init();
87 ecore_buffer_init();
88
89 win.ee = ecore_evas_new(NULL, 0, 0, WIDTH, HEIGHT, NULL);
90 win.e = ecore_evas_get(win.ee);
91
92 o = evas_object_rectangle_add(win.e);
93 evas_object_move(o, 0, 0);
94 evas_object_resize(o, WIDTH, HEIGHT);
95 evas_object_color_set(o, 255, 0, 0, 255);
96 evas_object_show(o);
97 win.bg = o;
98
99 o = evas_object_image_add(win.e);
100 evas_object_image_fill_set(o, 0, 0, WIDTH, HEIGHT);
101 evas_object_image_size_set(o, WIDTH, HEIGHT);
102
103 evas_object_move(o, 0, 0);
104 evas_object_resize(o, WIDTH, HEIGHT);
105 evas_object_show(o);
106 win.img = o;
107
108 // Create buffer and drawing.
109 win.buffer = ecore_buffer_new("shm", WIDTH, HEIGHT, 0, 0);
110 data = ecore_buffer_data_get(win.buffer);
111 paint_pixels(data, 0, WIDTH, HEIGHT, 0);
112 evas_object_image_data_set(win.img, data);
113 evas_object_image_data_update_add(win.img, 0, 0, WIDTH, HEIGHT);
114
115 ecore_evas_show(win.ee);
116
117 ecore_evas_callback_post_render_set(win.ee, _cb_post_render);
118
119 ecore_main_loop_begin();
120
121 ecore_buffer_free(win.buffer);
122 ecore_buffer_shutdown();
123 ecore_evas_shutdown();
124 ecore_shutdown();
125 eina_shutdown();
126
127 return 0;
128}
diff --git a/src/examples/ecore/ecore_buffer_provider_example.c b/src/examples/ecore/ecore_buffer_provider_example.c
new file mode 100644
index 0000000000..112854b4dc
--- /dev/null
+++ b/src/examples/ecore/ecore_buffer_provider_example.c
@@ -0,0 +1,274 @@
1#include <stdio.h>
2#include <Eina.h>
3#include <Ecore.h>
4#include <Ecore_Evas.h>
5#include <Ecore_Buffer.h>
6#include <Ecore_Buffer_Queue.h>
7#include <Evas.h>
8
9#ifdef DEBUG
10#define LOG(f, x...) printf("[PROVIDER|%30.30s|%04d] " f "\n", __func__, __LINE__, ##x)
11#else
12#define LOG(f, x...)
13#endif
14
15typedef struct _Provider_Data
16{
17 Ecore_Buffer_Provider *provider;
18 Ecore_Buffer *buffer;
19 Eina_List *buffer_list;
20 Ecore_Job *render_job;
21 Ecore_Idle_Enterer *post_render;
22 unsigned int w, h;
23} Provider_Data;
24
25const char *name = "ecore_buffer_queue_test";
26
27static void _provider_render_queue(Provider_Data *pd);
28
29static void
30shutdown_all(void)
31{
32 ecore_buffer_queue_shutdown();
33 ecore_buffer_shutdown();
34 ecore_evas_shutdown();
35 ecore_shutdown();
36 eina_shutdown();
37}
38
39static Eina_Bool
40init_all(void)
41{
42 if (!eina_init()) goto err;
43 if (!ecore_init()) goto err;
44 if (!ecore_evas_init()) goto err;
45 if (!ecore_buffer_init()) goto err;
46 if (!ecore_buffer_queue_init()) goto err;
47
48 return EINA_TRUE;
49err:
50 shutdown_all();
51 return EINA_FALSE;
52}
53
54Ecore_Buffer *
55_provider_buffer_get(Provider_Data *pd, unsigned int w, unsigned int h, unsigned int format)
56{
57 Ecore_Buffer *buffer = NULL;
58 Ecore_Buffer_Return ret;
59 unsigned int res_w, res_h, res_format;
60
61 LOG("Dequeue");
62 ret = ecore_buffer_provider_buffer_acquire(pd->provider, &buffer);
63
64 if (ret == ECORE_BUFFER_RETURN_NEED_ALLOC)
65 {
66 buffer = ecore_buffer_new("shm", w, h, format, 0);
67 pd->buffer_list = eina_list_append(pd->buffer_list, buffer);
68 LOG("No buffer in Queue, Create Buffer");
69 }
70 else if (ret == ECORE_BUFFER_RETURN_SUCCESS)
71 {
72 ecore_buffer_size_get(buffer, &res_w, &res_h);
73 res_format = ecore_buffer_format_get(buffer);
74 if ((res_w != w) || (res_h != h) || (res_format != format))
75 {
76 LOG("Need to Reallocate Buffer, Free it First: %p", buffer);
77 pd->buffer_list = eina_list_remove(pd->buffer_list, buffer);
78 ecore_buffer_free(buffer);
79
80 buffer = ecore_buffer_new("shm", w, h, format, 0);
81 pd->buffer_list = eina_list_append(pd->buffer_list, buffer);
82 LOG("Create Buffer: %p", buffer);
83 }
84 }
85
86 return buffer;
87}
88
89static void
90paint_pixels(void *image, int padding, int width, int height, uint32_t time)
91{
92 const int halfh = padding + (height - padding * 2) / 2;
93 const int halfw = padding + (width - padding * 2) / 2;
94 int ir, or;
95 uint32_t *pixel = image;
96 int y;
97
98 /* squared radii thresholds */
99 or = (halfw < halfh ? halfw : halfh) - 8;
100 ir = or - 32;
101 or *= or;
102 ir *= ir;
103
104 pixel += padding * width;
105 for (y = padding; y < height - padding; y++) {
106 int x;
107 int y2 = (y - halfh) * (y - halfh);
108
109 pixel += padding;
110 for (x = padding; x < width - padding; x++) {
111 uint32_t v;
112
113 /* squared distance from center */
114 int r2 = (x - halfw) * (x - halfw) + y2;
115
116 if (r2 < ir)
117 v = (r2 / 32 + time / 64) * 0x0080401;
118 else if (r2 < or)
119 v = (y + time / 32) * 0x0080401;
120 else
121 v = (x + time / 16) * 0x0080401;
122 v &= 0x00ffffff;
123 v |= 0xff000000;
124
125 *pixel++ = v;
126 }
127
128 pixel += padding;
129 }
130}
131
132static Eina_Bool
133_cb_render_post(void *data)
134{
135 Provider_Data *pd = (Provider_Data *)data;
136 Ecore_Buffer *next_buffer = NULL;
137
138 LOG("Startup - Post Render");
139
140 LOG("Submit Buffer - buffer: %p", pd->buffer);
141 ecore_buffer_provider_buffer_enqueue(pd->provider, pd->buffer);
142 pd->buffer = NULL;
143
144 next_buffer = _provider_buffer_get(pd, pd->w, pd->h, ECORE_BUFFER_FORMAT_XRGB8888);
145 if (next_buffer)
146 {
147 LOG("Drawable Buffer is Existed, ADD Render job again - buffer:%p", next_buffer);
148 pd->buffer = next_buffer;
149 _provider_render_queue(pd);
150 }
151
152 ecore_idle_enterer_del(pd->post_render);
153 pd->post_render = NULL;
154
155 LOG("Done - Post Render");
156
157 return ECORE_CALLBACK_RENEW;
158}
159
160static void
161_provider_cb_render_job(void *data)
162{
163 Provider_Data *pd = (Provider_Data *)data;
164
165 LOG("Startup - Render");
166
167 if (!pd->buffer)
168 {
169 pd->buffer = _provider_buffer_get(pd,
170 pd->w, pd->h, ECORE_BUFFER_FORMAT_XRGB8888);
171 }
172
173 if (pd->buffer)
174 {
175 void *data;
176
177 LOG("Success to get Drawable Buffer, Drawing now... - buffer:%p", pd->buffer);
178 // Drawing...
179 data = ecore_buffer_data_get(pd->buffer);
180 paint_pixels(data, 0, pd->w, pd->h, ecore_loop_time_get() * 1000);
181
182 if (!pd->post_render)
183 {
184 pd->post_render =
185 ecore_idle_enterer_before_add(_cb_render_post, pd);
186 }
187 }
188
189 ecore_job_del(pd->render_job);
190 pd->render_job = NULL;
191}
192
193static void
194_provider_render_queue(Provider_Data *pd)
195{
196 if (!pd) return;
197
198 LOG("Render Queue");
199
200 if (!pd->render_job)
201 pd->render_job = ecore_job_add(_provider_cb_render_job, pd);
202}
203
204static void
205_cb_consumer_add(Ecore_Buffer_Provider *provider EINA_UNUSED, int queue_size EINA_UNUSED, int w, int h, void *data)
206{
207 Provider_Data *pd = (Provider_Data *)data;
208
209 LOG("Connected with Consumer, Now We can use Ecore_Buffer_Queue - queue_size:%d, geo(%dx%d)",
210 queue_size, w, h);
211
212 pd->w = w;
213 pd->h = h;
214
215 _provider_render_queue(pd);
216}
217
218static void
219_cb_consumer_del(Ecore_Buffer_Provider *provider EINA_UNUSED, void *data EINA_UNUSED)
220{
221 LOG("Disconnected with Consumer, Shutdown Provider now.");
222
223 ecore_main_loop_quit();
224}
225
226static void
227_cb_buffer_released(Ecore_Buffer_Provider *provider EINA_UNUSED, void *data)
228{
229 Provider_Data *pd = (Provider_Data *)data;
230
231 LOG("Buffer Enqueued");
232
233 _provider_render_queue(pd);
234}
235
236int
237main(void)
238{
239 Provider_Data *pd;
240
241 if (!init_all())
242 {
243 LOG("Initializing failed");
244 return -1;
245 }
246
247 pd = (Provider_Data *)calloc(sizeof(Provider_Data), 1);
248
249 if (!(pd->provider = ecore_buffer_provider_new(name)))
250 {
251 LOG("Failed to create provider");
252 goto shutdown;
253 }
254
255 ecore_buffer_provider_consumer_add_cb_set(pd->provider, _cb_consumer_add, pd);
256 ecore_buffer_provider_consumer_del_cb_set(pd->provider, _cb_consumer_del, pd);
257 ecore_buffer_provider_buffer_released_cb_set(pd->provider, _cb_buffer_released, pd);
258
259 ecore_main_loop_begin();
260
261shutdown:
262 if (pd->buffer_list)
263 {
264 Ecore_Buffer *b;
265
266 EINA_LIST_FREE(pd->buffer_list, b)
267 ecore_buffer_free(b);
268 }
269 if (pd->provider) ecore_buffer_provider_free(pd->provider);
270 if (pd) free(pd);
271
272 shutdown_all();
273 return 0;
274}
diff --git a/src/lib/ecore_buffer/Ecore_Buffer.h b/src/lib/ecore_buffer/Ecore_Buffer.h
new file mode 100644
index 0000000000..36c82daad7
--- /dev/null
+++ b/src/lib/ecore_buffer/Ecore_Buffer.h
@@ -0,0 +1,629 @@
1#ifndef _ECORE_BUFFER_H_
2# define _ECORE_BUFFER_H_
3
4#ifdef EAPI
5# undef EAPI
6#endif
7
8#ifdef _WIN32
9# ifdef EFL_ECORE_BUFFER_BUILD
10# ifdef DLL_EXPORT
11# define EAPI __declspec(dllexport)
12# else
13# define EAPI
14# endif /* ! DLL_EXPORT */
15# else
16# define EAPI __declspec(dllimport)
17# endif /* ! EFL_ECORE_BUFFER_BUILD */
18#else
19# ifdef __GNUC__
20# if __GNUC__ >= 4
21# define EAPI __attribute__ ((visibility("default")))
22# else
23# define EAPI
24# endif
25# else
26# define EAPI
27# endif
28#endif /* ! _WIN32 */
29
30/**
31 * @defgroup Ecore_Buffer_Group Ecore_Buffer - Graphics buffer functions
32 * @ingroup Ecore
33 *
34 * The Ecore Buffer is an abstraction of graphic buffer.
35 *
36 * This library also provides simple mechanisms for sharing graphic buffer bet-
37 * ween processes using wayland socket. Ecore Buffer Queue is for this
38 * function, and it consists of two main object,
39 * The Ecore_Buffer_Consumer and the Ecore_Buffer_Provider.
40 */
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46#define __ecore_buffer_fourcc_code(a,b,c,d) ((unsigned int)(a) | ((unsigned int)(b) << 8) | \
47 ((unsigned int)(c) << 16) | ((unsigned int)(d) << 24))
48
49/* color index */
50/**
51 * @brief Definition for the Ecore_Buffer format C8 ([7:0] C).
52 * @since 1.15
53 */
54#define ECORE_BUFFER_FORMAT_C8 __ecore_buffer_fourcc_code('C', '8', ' ', ' ')
55/* 8 bpp RGB */
56/**
57 * @brief Definition for the Ecore_Buffer format RGB332 ([7:0] R:G:B 3:3:2).
58 * @since 1.15
59 */
60#define ECORE_BUFFER_FORMAT_RGB332 __ecore_buffer_fourcc_code('R', 'G', 'B', '8')
61/**
62 * @brief Definition for the Ecore_Buffer format RGB233 ([7:0] B:G:R 2:3:3).
63 * @since 1.15
64 */
65#define ECORE_BUFFER_FORMAT_BGR233 __ecore_buffer_fourcc_code('B', 'G', 'R', '8')
66/* 16 bpp RGB */
67/**
68 * @brief Definition for the Ecore_Buffer format XRGB4444 ([15:0] x:R:G:B 4:4:4:4 little endian).
69 * @since 1.15
70 */
71#define ECORE_BUFFER_FORMAT_XRGB4444 __ecore_buffer_fourcc_code('X', 'R', '1', '2')
72/**
73 * @brief Definition for the Ecore_Buffer format XBRG4444 ([15:0] x:B:G:R 4:4:4:4 little endian).
74 * @since 1.15
75 */
76#define ECORE_BUFFER_FORMAT_XBGR4444 __ecore_buffer_fourcc_code('X', 'B', '1', '2')
77/**
78 * @brief Definition for the Ecore_Buffer format RGBX4444 ([15:0] R:G:B:x 4:4:4:4 little endian).
79 * @since 1.15
80 */
81#define ECORE_BUFFER_FORMAT_RGBX4444 __ecore_buffer_fourcc_code('R', 'X', '1', '2')
82/**
83 * @brief Definition for the Ecore_Buffer format BGRX4444 ([15:0] B:G:R:x 4:4:4:4 little endian).
84 * @since 1.15
85 */
86#define ECORE_BUFFER_FORMAT_BGRX4444 __ecore_buffer_fourcc_code('B', 'X', '1', '2')
87/**
88 * @brief Definition for the Ecore_Buffer format ARGB4444 ([15:0] A:R:G:B 4:4:4:4 little endian).
89 * @since 1.15
90 */
91#define ECORE_BUFFER_FORMAT_ARGB4444 __ecore_buffer_fourcc_code('A', 'R', '1', '2')
92/**
93 * @brief Definition for the Ecore_Buffer format ABGR4444 ([15:0] A:B:G:R 4:4:4:4 little endian).
94 * @since 1.15
95 */
96#define ECORE_BUFFER_FORMAT_ABGR4444 __ecore_buffer_fourcc_code('A', 'B', '1', '2')
97/**
98 * @brief Definition for the Ecore_Buffer format RGBA4444 ([15:0] R:G:B:A 4:4:4:4 little endian).
99 * @since 1.15
100 */
101#define ECORE_BUFFER_FORMAT_RGBA4444 __ecore_buffer_fourcc_code('R', 'A', '1', '2')
102/**
103 * @brief Definition for the Ecore_Buffer format BGRA4444 ([15:0] B:G:R:A 4:4:4:4 little endian).
104 * @since 1.15
105 */
106#define ECORE_BUFFER_FORMAT_BGRA4444 __ecore_buffer_fourcc_code('B', 'A', '1', '2')
107/**
108 * @brief Definition for the Ecore_Buffer format XRGB1555 ([15:0] x:R:G:B 1:5:5:5 little endian).
109 * @since 1.15
110 */
111#define ECORE_BUFFER_FORMAT_XRGB1555 __ecore_buffer_fourcc_code('X', 'R', '1', '5')
112/**
113 * @brief Definition for the Ecore_Buffer format XBGR1555 ([15:0] x:B:G:R 1:5:5:5 little endian).
114 * @since 1.15
115 */
116#define ECORE_BUFFER_FORMAT_XBGR1555 __ecore_buffer_fourcc_code('X', 'B', '1', '5')
117/**
118 * @brief Definition for the Ecore_Buffer format RGBX5551 ([15:0] R:G:B:x 5:5:5:1 little endian).
119 * @since 1.15
120 */
121#define ECORE_BUFFER_FORMAT_RGBX5551 __ecore_buffer_fourcc_code('R', 'X', '1', '5')
122/**
123 * @brief Definition for the Ecore_Buffer format BGRX5551 ([15:0] B:G:R:x 5:5:5:1 little endian).
124 * @since 1.15
125 */
126#define ECORE_BUFFER_FORMAT_BGRX5551 __ecore_buffer_fourcc_code('B', 'X', '1', '5')
127/**
128 * @brief Definition for the Ecore_Buffer format ARGB1555 ([15:0] A:R:G:B 1:5:5:5 little endian).
129 * @since 1.15
130 */
131#define ECORE_BUFFER_FORMAT_ARGB1555 __ecore_buffer_fourcc_code('A', 'R', '1', '5')
132/**
133 * @brief Definition for the Ecore_Buffer format ABGR1555 ([15:0] A:B:G:R 1:5:5:5 little endian).
134 * @since 1.15
135 */
136#define ECORE_BUFFER_FORMAT_ABGR1555 __ecore_buffer_fourcc_code('A', 'B', '1', '5')
137/**
138 * @brief Definition for the Ecore_Buffer format RGBA5551 ([15:0] R:G:B:A 5:5:5:1 little endian).
139 * @since 1.15
140 */
141#define ECORE_BUFFER_FORMAT_RGBA5551 __ecore_buffer_fourcc_code('R', 'A', '1', '5')
142/**
143 * @brief Definition for the Ecore_Buffer format BGRA5551 ([15:0] B:G:R:A 5:5:5:1 little endian).
144 * @since 1.15
145 */
146#define ECORE_BUFFER_FORMAT_BGRA5551 __ecore_buffer_fourcc_code('B', 'A', '1', '5')
147/**
148 * @brief Definition for the Ecore_Buffer format RGB565 ([15:0] R:G:B 5:6:5 little endian).
149 * @since 1.15
150 */
151#define ECORE_BUFFER_FORMAT_RGB565 __ecore_buffer_fourcc_code('R', 'G', '1', '6')
152/**
153 * @brief Definition for the Ecore_Buffer format BGR565 ([15:0] B:G:R 5:6:5 little endian).
154 * @since 1.15
155 */
156#define ECORE_BUFFER_FORMAT_BGR565 __ecore_buffer_fourcc_code('B', 'G', '1', '6')
157/* 24 bpp RGB */
158/**
159 * @brief Definition for the Ecore_Buffer format RGB888 ([23:0] R:G:B little endian).
160 * @since 1.15
161 */
162#define ECORE_BUFFER_FORMAT_RGB888 __ecore_buffer_fourcc_code('R', 'G', '2', '4')
163/**
164 * @brief Definition for the Ecore_Buffer format BGR888 ([23:0] B:G:R little endian).
165 * @since 1.15
166 */
167#define ECORE_BUFFER_FORMAT_BGR888 __ecore_buffer_fourcc_code('B', 'G', '2', '4')
168/* 32 bpp RGB */
169/**
170 * @brief Definition for the Ecore_Buffer format XRGB8888 ([31:0] x:R:G:B 8:8:8:8 little endian).
171 * @since 1.15
172 */
173#define ECORE_BUFFER_FORMAT_XRGB8888 __ecore_buffer_fourcc_code('X', 'R', '2', '4')
174/**
175 * @brief Definition for the Ecore_Buffer format XBGR8888 ([31:0] x:B:G:R 8:8:8:8 little endian).
176 * @since 1.15
177 */
178#define ECORE_BUFFER_FORMAT_XBGR8888 __ecore_buffer_fourcc_code('X', 'B', '2', '4')
179/**
180 * @brief Definition for the Ecore_Buffer format RGBX8888 ([31:0] R:G:B:x 8:8:8:8 little endian).
181 * @since 1.15
182 */
183#define ECORE_BUFFER_FORMAT_RGBX8888 __ecore_buffer_fourcc_code('R', 'X', '2', '4')
184/**
185 * @brief Definition for the Ecore_Buffer format BGRX8888 ([31:0] B:G:R:x 8:8:8:8 little endian).
186 * @since 1.15
187 */
188#define ECORE_BUFFER_FORMAT_BGRX8888 __ecore_buffer_fourcc_code('B', 'X', '2', '4')
189/**
190 * @brief Definition for the Ecore_Buffer format ARGB8888 ([31:0] A:R:G:B 8:8:8:8 little endian).
191 * @since 1.15
192 */
193#define ECORE_BUFFER_FORMAT_ARGB8888 __ecore_buffer_fourcc_code('A', 'R', '2', '4')
194/**
195 * @brief Definition for the Ecore_Buffer format ABGR8888 ([31:0] [31:0] A:B:G:R 8:8:8:8 little endian).
196 * @since 1.15
197 */
198#define ECORE_BUFFER_FORMAT_ABGR8888 __ecore_buffer_fourcc_code('A', 'B', '2', '4')
199/**
200 * @brief Definition for the Ecore_Buffer format RGBA8888 ([31:0] R:G:B:A 8:8:8:8 little endian).
201 * @since 1.15
202 */
203#define ECORE_BUFFER_FORMAT_RGBA8888 __ecore_buffer_fourcc_code('R', 'A', '2', '4')
204/**
205 * @brief Definition for the Ecore_Buffer format BGRA8888 ([31:0] B:G:R:A 8:8:8:8 little endian).
206 * @since 1.15
207 */
208#define ECORE_BUFFER_FORMAT_BGRA8888 __ecore_buffer_fourcc_code('B', 'A', '2', '4')
209/**
210 * @brief Definition for the Ecore_Buffer format XRGB2101010 ([31:0] x:R:G:B 2:10:10:10 little endian).
211 * @since 1.15
212 */
213#define ECORE_BUFFER_FORMAT_XRGB2101010 __ecore_buffer_fourcc_code('X', 'R', '3', '0')
214/**
215 * @brief Definition for the Ecore_Buffer format XBGR2101010 ([31:0] x:B:G:R 2:10:10:10 little endian).
216 * @since 1.15
217 */
218#define ECORE_BUFFER_FORMAT_XBGR2101010 __ecore_buffer_fourcc_code('X', 'B', '3', '0')
219/**
220 * @brief Definition for the Ecore_Buffer format RGBX1010102 ([31:0] R:G:B:x 10:10:10:2 little endian).
221 * @since 1.15
222 */
223#define ECORE_BUFFER_FORMAT_RGBX1010102 __ecore_buffer_fourcc_code('R', 'X', '3', '0')
224/**
225 * @brief Definition for the Ecore_Buffer format BGRX1010102 ([31:0] B:G:R:x 10:10:10:2 little endian).
226 * @since 1.15
227 */
228#define ECORE_BUFFER_FORMAT_BGRX1010102 __ecore_buffer_fourcc_code('B', 'X', '3', '0')
229/**
230 * @brief Definition for the Ecore_Buffer format ARGB2101010 ([31:0] A:R:G:B 2:10:10:10 little endian).
231 * @since 1.15
232 */
233#define ECORE_BUFFER_FORMAT_ARGB2101010 __ecore_buffer_fourcc_code('A', 'R', '3', '0')
234/**
235 * @brief Definition for the Ecore_Buffer format ABGR2101010 ([31:0] A:B:G:R 2:10:10:10 little endian).
236 * @since 1.15
237 */
238#define ECORE_BUFFER_FORMAT_ABGR2101010 __ecore_buffer_fourcc_code('A', 'B', '3', '0')
239/**
240 * @brief Definition for the Ecore_Buffer format RGBA1010102 ([31:0] R:G:B:A 10:10:10:2 little endian).
241 * @since 1.15
242 */
243#define ECORE_BUFFER_FORMAT_RGBA1010102 __ecore_buffer_fourcc_code('R', 'A', '3', '0')
244/**
245 * @brief Definition for the Ecore_Buffer format BGRA1010102 ([31:0] B:G:R:A 10:10:10:2 little endian).
246 * @since 1.15
247 */
248#define ECORE_BUFFER_FORMAT_BGRA1010102 __ecore_buffer_fourcc_code('B', 'A', '3', '0')
249/* packed YCbCr */
250/**
251 * @brief Definition for the Ecore_Buffer format YUYV ([31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian).
252 * @since 1.15
253 */
254#define ECORE_BUFFER_FORMAT_YUYV __ecore_buffer_fourcc_code('Y', 'U', 'Y', 'V')
255/**
256 * @brief Definition for the Ecore_Buffer format YVYU ([31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian).
257 * @since 1.15
258 */
259#define ECORE_BUFFER_FORMAT_YVYU __ecore_buffer_fourcc_code('Y', 'V', 'Y', 'U')
260/**
261 * @brief Definition for the Ecore_Buffer format UYVY ([31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian).
262 * @since 1.15
263 */
264#define ECORE_BUFFER_FORMAT_UYVY __ecore_buffer_fourcc_code('U', 'Y', 'V', 'Y')
265/**
266 * @brief Definition for the Ecore_Buffer format VYUY ([31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian).
267 * @since 1.15
268 */
269#define ECORE_BUFFER_FORMAT_VYUY __ecore_buffer_fourcc_code('V', 'Y', 'U', 'Y')
270/**
271 * @brief Definition for the Ecore_Buffer format AYUV ([31:0] A:Y:Cb:Cr 8:8:8:8 little endian).
272 * @since 1.15
273 */
274#define ECORE_BUFFER_FORMAT_AYUV __ecore_buffer_fourcc_code('A', 'Y', 'U', 'V')
275/*
276 * 2 plane YCbCr
277 * index 0 = Y plane, [7:0] Y
278 * index 1 = Cr:Cb plane, [15:0] Cr:Cb little endian
279 * or
280 * index 1 = Cb:Cr plane, [15:0] Cb:Cr little endian
281 */
282/**
283 * @brief Definition for the Ecore_Buffer format NV12 (2x2 subsampled Cr:Cb plane).
284 * @since 1.15
285 */
286#define ECORE_BUFFER_FORMAT_NV12 __ecore_buffer_fourcc_code('N', 'V', '1', '2')
287/**
288 * @brief Definition for the Ecore_Buffer format NV21 (2x2 subsampled Cb:Cr plane).
289 * @since 1.15
290 */
291#define ECORE_BUFFER_FORMAT_NV21 __ecore_buffer_fourcc_code('N', 'V', '2', '1')
292/**
293 * @brief Definition for the Ecore_Buffer format NV16 (2x1 subsampled Cr:Cb plane).
294 * @since 1.15
295 */
296#define ECORE_BUFFER_FORMAT_NV16 __ecore_buffer_fourcc_code('N', 'V', '1', '6')
297/**
298 * @brief Definition for the Ecore_Buffer format NV61 (2x1 subsampled Cb:Cr plane).
299 * @since 1.15
300 */
301#define ECORE_BUFFER_FORMAT_NV61 __ecore_buffer_fourcc_code('N', 'V', '6', '1')
302/*
303 * 3 plane YCbCr
304 * index 0: Y plane, [7:0] Y
305 * index 1: Cb plane, [7:0] Cb
306 * index 2: Cr plane, [7:0] Cr
307 * or
308 * index 1: Cr plane, [7:0] Cr
309 * index 2: Cb plane, [7:0] Cb
310 */
311/**
312 * @brief Definition for the Ecore_Buffer format YUV410 (4x4 subsampled Cb (1) and Cr (2) planes).
313 */
314#define ECORE_BUFFER_FORMAT_YUV410 __ecore_buffer_fourcc_code('Y', 'U', 'V', '9')
315/**
316 * @brief Definition for the Ecore_Buffer format YVU410 (4x4 subsampled Cr (1) and Cb (2) planes).
317 * @since 1.15
318 */
319#define ECORE_BUFFER_FORMAT_YVU410 __ecore_buffer_fourcc_code('Y', 'V', 'U', '9')
320/**
321 * @brief Definition for the Ecore_Buffer format YUV411 (4x1 subsampled Cb (1) and Cr (2) planes).
322 * @since 1.15
323 */
324#define ECORE_BUFFER_FORMAT_YUV411 __ecore_buffer_fourcc_code('Y', 'U', '1', '1')
325/**
326 * @brief Definition for the Ecore_Buffer format YVU411 (4x1 subsampled Cr (1) and Cb (2) planes).
327 * @since 1.15
328 */
329#define ECORE_BUFFER_FORMAT_YVU411 __ecore_buffer_fourcc_code('Y', 'V', '1', '1')
330/**
331 * @brief Definition for the Ecore_Buffer format YUV420 (2x2 subsampled Cb (1) and Cr (2) planes).
332 * @since 1.15
333 */
334#define ECORE_BUFFER_FORMAT_YUV420 __ecore_buffer_fourcc_code('Y', 'U', '1', '2')
335/**
336 * @brief Definition for the Ecore_Buffer format YVU420 (2x2 subsampled Cr (1) and Cb (2) planes).
337 * @since 1.15
338 */
339#define ECORE_BUFFER_FORMAT_YVU420 __ecore_buffer_fourcc_code('Y', 'V', '1', '2')
340/**
341 * @brief Definition for the Ecore_Buffer format YUV422 (2x1 subsampled Cb (1) and Cr (2) planes).
342 * @since 1.15
343 */
344#define ECORE_BUFFER_FORMAT_YUV422 __ecore_buffer_fourcc_code('Y', 'U', '1', '6')
345/**
346 * @brief Definition for the Ecore_Buffer format YVU422 (2x1 subsampled Cr (1) and Cb (2) planes).
347 * @since 1.15
348 */
349#define ECORE_BUFFER_FORMAT_YVU422 __ecore_buffer_fourcc_code('Y', 'V', '1', '6')
350/**
351 * @brief Definition for the Ecore_Buffer format YUV444 (non-subsampled Cb (1) and Cr (2) planes).
352 * @since 1.15
353 */
354#define ECORE_BUFFER_FORMAT_YUV444 __ecore_buffer_fourcc_code('Y', 'U', '2', '4')
355/**
356 * @brief Definition for the Ecore_Buffer format YVU444 (non-subsampled Cr (1) and Cb (2) planes).
357 * @since 1.15
358 */
359#define ECORE_BUFFER_FORMAT_YVU444 __ecore_buffer_fourcc_code('Y', 'V', '2', '4')
360
361/**
362 * @defgroup Ecore_Buffer_Lib_Group Ecore Buffer Library Functions
363 * @ingroup Ecore_Buffer_Group
364 *
365 * Utility functions that set up and shut down the Ecore Buffer library.
366 * This group of functions is applied to an Ecore_Buffer object.
367 *
368 * @{
369 */
370
371/**
372 * @typedef Ecore_Buffer
373 * An object representing a graphic buffer.
374 * @since 1.15
375 */
376typedef struct _Ecore_Buffer Ecore_Buffer;
377/**
378 * @typedef Ecore_Buffer_Backend
379 * The interfaces for backend of buffer.
380 * @since 1.15
381 */
382typedef struct _Ecore_Buffer_Backend Ecore_Buffer_Backend;
383/**
384 * @typedef Ecore_Export_Type
385 * Types for export buffer.
386 * @since 1.15
387 */
388typedef enum _Ecore_Export_Type Ecore_Export_Type;
389/**
390 * @typedef Ecore_Buffer_Format
391 * The format of Ecore_Buffer.
392 * @since 1.15
393 */
394typedef unsigned int Ecore_Buffer_Format;
395/**
396 * @typedef Ecore_Buffer_Pixmap
397 * An Id of Pixmap.
398 * @since 1.15
399 */
400typedef unsigned long Ecore_Pixmap;
401/**
402 * @typedef Ecore_Buffer_Module_Data
403 * The data of module.
404 * @since 1.15
405 */
406typedef void* Ecore_Buffer_Module_Data;
407/**
408 * @typedef Ecore_Buffer_Data
409 * The data of Ecore_Buffer.
410 * @since 1.15
411 */
412typedef void* Ecore_Buffer_Data;
413/**
414 * @typedef Ecore_Buffer_Cb
415 * Called whenever Ecore_Buffer is freed.
416 * @since 1.15
417 */
418typedef void (*Ecore_Buffer_Cb)(Ecore_Buffer* buf, void* data);
419
420/**
421 * @enum _Ecore_Export_Type
422 * Types for export buffer.
423 * @since 1.15
424 */
425enum _Ecore_Export_Type
426{
427 EXPORT_TYPE_INVALID,
428 EXPORT_TYPE_ID,
429 EXPORT_TYPE_FD
430};
431
432/**
433 * @struct _Ecore_Buffer_Backend
434 * @brief Structure used when initializing Ecore Buffer Backend. This structure
435 * is mainly used by modules implementing the Ecore Buffer Backend interface.
436 * @since 1.15
437 */
438struct _Ecore_Buffer_Backend
439{
440 const char *name; /**< The name of backend */
441
442 Ecore_Buffer_Module_Data (*init)(const char *context, const char *options); /**< Initialize the backend */
443 void (*shutdown)(Ecore_Buffer_Module_Data bmdata); /**< Shut down the backend */
444 Ecore_Buffer_Data (*buffer_alloc)(Ecore_Buffer_Module_Data bmdata,
445 int width, int height,
446 Ecore_Buffer_Format format,
447 unsigned int flags); /**< Newly allocate memory for buffer */
448 void (*buffer_free)(Ecore_Buffer_Module_Data bmdata,
449 Ecore_Buffer_Data bdata); /**< Free allocated memory */
450 Ecore_Export_Type (*buffer_export)(Ecore_Buffer_Module_Data bmdata,
451 Ecore_Buffer_Data bdata, int *id); /**< Get the id or fd of Ecore_Buffer for exporting it */
452 Ecore_Buffer_Data (*buffer_import)(Ecore_Buffer_Module_Data bmdata,
453 int w, int h,
454 Ecore_Buffer_Format format,
455 Ecore_Export_Type type,
456 int export_id,
457 unsigned int flags); /**< Import and create Ecore_Buffer from id or fd */
458 void *(*data_get)(Ecore_Buffer_Module_Data bmdata,
459 Ecore_Buffer_Data bdata);
460 Ecore_Pixmap (*pixmap_get)(Ecore_Buffer_Module_Data bmdata,
461 Ecore_Buffer_Data bdata); /**< Get the pixmap handle */
462 void *(*tbm_surface_get)(Ecore_Buffer_Module_Data bmdata,
463 Ecore_Buffer_Data bdata); /**< Get the tbm_surface_h handle */
464};
465
466/**
467 * @brief Initialize the Ecore_Buffer system.
468 *
469 * @since 1.15
470 *
471 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
472 *
473 * @see ecore_buffer_shutdown()
474 */
475EAPI Eina_Bool ecore_buffer_init(void);
476/**
477 * @brief Shut down the Ecore_Buffer system.
478 *
479 * @since 1.15
480 *
481 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
482 *
483 * @see ecore_buffer_init()
484 */
485EAPI Eina_Bool ecore_buffer_shutdown(void);
486/**
487 * @brief Registers the given buffer backend.
488 *
489 * @since 1.15
490 *
491 * @param[in] be The backend
492 *
493 * @return @c EINA_TRUE if backend has been correctly registered, @c EINA_FALSE otherwise.
494 */
495EAPI Eina_Bool ecore_buffer_register(Ecore_Buffer_Backend *be);
496/**
497 * @brief Unregisters the given buffer backend.
498 *
499 * @since 1.15
500 *
501 * @param[in] be The backend
502 */
503EAPI void ecore_buffer_unregister(Ecore_Buffer_Backend *be);
504/**
505 * @brief Creates a new Ecore_Buffer given type
506 *
507 * @since 1.15
508 *
509 * @param[in] engine the name of backend
510 * @param[in] width width for Ecore_Buffer
511 * @param[in] height height for Ecore_Buffer
512 * @param[in] format format for Ecore_Buffer
513 * @param[in] flags flags for Ecore_Buffer
514 *
515 * @return Newly allocated Ecore_Buffer instance, NULL otherwise.
516 */
517EAPI Ecore_Buffer *ecore_buffer_new(const char *engine, unsigned int width, unsigned int height, Ecore_Buffer_Format format, unsigned int flags);
518/**
519 * @brief Free the given Ecore_Buffer.
520 *
521 * @since 1.15
522 *
523 * @param[in] buf The Ecore_Buffer to free
524 */
525EAPI void ecore_buffer_free(Ecore_Buffer *buf);
526/**
527 * @brief Set a callback for Ecore_Buffer free events.
528 *
529 * @since 1.15
530 *
531 * @param[in] buf The Ecore_Buffer to set callbacks on
532 * @param[in] func The function to call
533 * @param[in] data A pointer to the user data to store.
534 *
535 * A call to this function will set a callback on an Ecore_Buffer, causing
536 * @p func to be called whenever @p buf is freed.
537 *
538 * @see ecore_buffer_free_callback_remove()
539 */
540EAPI void ecore_buffer_free_callback_add(Ecore_Buffer *buf, Ecore_Buffer_Cb func, void *data);
541/**
542 * @brief Remove a callback for Ecore_Buffer free events.
543 *
544 * @since 1.15
545 *
546 * @param[in] buf The Ecore_Buffer to remove callbacks on
547 * @param[in] func The function to remove
548 * @param[in] data A pointer to the user data to remove
549 *
550 * @see ecore_buffer_free_callback_add()
551 */
552EAPI void ecore_buffer_free_callback_remove(Ecore_Buffer *buf, Ecore_Buffer_Cb func, void *data);
553/**
554 * @brief Get a pointer to the raw data of the given Ecore_Buffer.
555 *
556 * @param[in] buf The Ecore_Buffer.
557 *
558 * @return The pointer of raw data.
559 */
560EAPI void *ecore_buffer_data_get(Ecore_Buffer *buf);
561/**
562 * @brief Return the Pixmap of given Ecore_Buffer.
563 *
564 * @since 1.15
565 *
566 * @param[in] buf The Ecore_Buffer
567 *
568 * @return The Pixmap instance, 0 otherwise.
569 */
570EAPI Ecore_Pixmap ecore_buffer_pixmap_get(Ecore_Buffer *buf);
571/**
572 * @brief Return the tbm surface handle of given Ecore_Buffer.
573 *
574 * @since 1.15
575 *
576 * @param[in] buf The Ecore_Buffer
577 *
578 * @return The tbm surface handle, NULL otherwise.
579 *
580 * The tbm surface handle will be used for the API of libtbm.
581 * The API is described in tbm_surface.h in libtbm.
582 */
583EAPI void *ecore_buffer_tbm_surface_get(Ecore_Buffer *buf);
584/**
585 * @brief Return size of given Ecore_Buffer.
586 *
587 * @since 1.15
588 *
589 * @param[in] buf The Ecore_Buffer
590 * @param[out] width where to return the width value. May be @c NULL.
591 * @param[out] height where to return the height value. May be @c NULL.
592 *
593 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
594 */
595EAPI Eina_Bool ecore_buffer_size_get(Ecore_Buffer *buf, unsigned int *width, unsigned int *height);
596/**
597 * @brief Return format of given Ecore_Buffer.
598 *
599 * @since 1.15
600 *
601 * @param[in] buf The Ecore_Buffer
602 *
603 * @return The format of given Ecore_Buffer.
604 *
605 * return value can be one of those pre-defined value such as ECORE_BUFFER_FORMAT_XRGB8888.
606 */
607EAPI Ecore_Buffer_Format ecore_buffer_format_get(Ecore_Buffer *buf);
608/**
609 * @brief Return flags of given Ecore_Buffer.
610 *
611 * @since 1.15
612 *
613 * @param[in] buf The Ecore_Buffer
614 *
615 * @return The flags of given Ecore_Buffer.
616 *
617 * NOTE: Not Defined yet.
618 */
619EAPI unsigned int ecore_buffer_flags_get(Ecore_Buffer *buf);
620
621/**
622 * @}
623 */
624
625#ifdef __cplusplus
626}
627#endif
628
629#endif
diff --git a/src/lib/ecore_buffer/Ecore_Buffer_Queue.h b/src/lib/ecore_buffer/Ecore_Buffer_Queue.h
new file mode 100644
index 0000000000..81dad17976
--- /dev/null
+++ b/src/lib/ecore_buffer/Ecore_Buffer_Queue.h
@@ -0,0 +1,449 @@
1#ifndef _ECORE_BUFFER_QUEUE_H_
2#define _ECORE_BUFFER_QUEUE_H_
3
4#ifdef EAPI
5# undef EAPI
6#endif
7
8#ifdef _WIN32
9# ifdef EFL_ECORE_BUFFER_BUILD
10# ifdef DLL_EXPORT
11# define EAPI __declspec(dllexport)
12# else
13# define EAPI
14# endif /* ! DLL_EXPORT */
15# else
16# define EAPI __declspec(dllimport)
17# endif /* ! EFL_ECORE_BUFFER_BUILD */
18#else
19# ifdef __GNUC__
20# if __GNUC__ >= 4
21# define EAPI __attribute__ ((visibility("default")))
22# else
23# define EAPI
24# endif
25# else
26# define EAPI
27# endif
28#endif /* ! _WIN32 */
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34#include <Eina.h>
35#include "Ecore_Buffer.h"
36
37/**
38 * @defgroup Ecore_Buffer_Queue_Group Ecore Buffer Queue functions
39 * @ingroup Ecore_Buffer_Group
40 *
41 * Ecore Buffer Queue is a queue which conntects processes for sharing
42 * Ecore_Buffer.
43 * one process (related object is Ecore_Buffer_Provider) has rear terminal
44 * position of Ecore_Buffer Queue which can enqueue the Ecore_Buffer,
45 * and the other process (related object is Ecore_Buffer_Consumer) has front
46 * terminal position of Ecore_Buffer_Queue which can dequeue the Ecore_Buffer.
47 */
48
49/**
50 * @defgroup Ecore_Buffer_Provider_Group Ecore Buffer Provider functions
51 * @ingroup Ecore_Buffer_Queue_Group
52 *
53 * This group of functions is applied to an Ecore_Buffer_Provider object.
54 * Ecore_Buffer_Provider provides Ecore_Buffer to Ecore_Buffer_Consumer(usally
55 * different process or thread from Ecore_Buffer_Provider).
56 * Ecore_Buffer_Provider should creates Ecore_Buffer as a provider.
57 */
58
59/**
60 * @defgroup Ecore_Buffer_Consumer_Group Ecore Buffer Consumer functions
61 * @ingroup Ecore_Buffer_Queue_Group
62 *
63 * This group of functions is applied to an Ecore_Buffer_Consumer object.
64 * Ecore_Buffer_Consumer receives Ecore_Buffer enqueued by Ecore_Buffer_Provider.
65 * Consumer must release Ecore_Buffer when it's no longer used.
66 * Thus, the Ecore_Buffer_Provider is now free to re-use or destroy Ecore_Buffer.
67 */
68
69/**
70 * @typedef Ecore_Buffer_Return
71 * @enum _Ecore_Buffer_Return
72 * types for an buffer queue state on provider side.
73 * @ingroup Ecore_Buffer_Provider_Group
74 * @see ecore_buffer_provider_buffer_acquire()
75 * @see ecore_buffer_provider_buffer_acquirable_check()
76 */
77typedef enum _Ecore_Buffer_Return
78{
79 ECORE_BUFFER_RETURN_ERROR, /**< on error @since 1.15 */
80 ECORE_BUFFER_RETURN_SUCCESS, /**< success to dequeue a buffer @since 1.15 */
81 ECORE_BUFFER_RETURN_EMPTY, /**< Empty queue @since 1.15 */
82 ECORE_BUFFER_RETURN_NOT_EMPTY, /**< Not empty queue @since 1.15 */
83 ECORE_BUFFER_RETURN_NEED_ALLOC, /**< need to create Ecore_Buffer @since 1.15 */
84} Ecore_Buffer_Return;
85/**
86 * @typedef Ecore_Buffer_Consumer
87 * An object representing a consumer of Ecore_Buffer.
88 *
89 * @since 1.15
90 *
91 * @ingroup Ecore_Buffer_Consumer_Group
92 */
93typedef struct _Ecore_Buffer_Consumer Ecore_Buffer_Consumer;
94/**
95 * @typedef Ecore_Buffer_Provider
96 * An object representing a provider of Ecore_Buffer.
97 *
98 * @since 1.15
99 *
100 * @ingroup Ecore_Buffer_Provider_Group
101 */
102typedef struct _Ecore_Buffer_Provider Ecore_Buffer_Provider;
103/**
104 * @typedef Ecore_Buffer_Consumer_Provider_Add_Cb
105 *
106 * @brief Called whenever a Ecore_Buffer_Provider connected.
107 *
108 * @since 1.15
109 *
110 * @see ecore_buffer_consumer_provider_add_cb_set()
111 * @ingroup Ecore_Buffer_Consumer_Group
112 */
113typedef void (*Ecore_Buffer_Consumer_Provider_Add_Cb) (Ecore_Buffer_Consumer *consumer, void *data);
114/**
115 * @typedef Ecore_Buffer_Consumer_Provider_Del_Cb
116 *
117 * @brief Called whenever a Ecore_Buffer_Provider disonnected.
118 *
119 * @since 1.15
120 *
121 * @see ecore_buffer_consumer_provider_del_cb_set()
122 * @ingroup Ecore_Buffer_Consumer_Group
123 */
124typedef void (*Ecore_Buffer_Consumer_Provider_Del_Cb) (Ecore_Buffer_Consumer *consumer, void *data);
125/**
126 * @typedef Ecore_Buffer_Consumer_Enqueue_Cb
127 *
128 * @brief Called whenever a Ecore_Buffer enqueued in buffer queue.
129 *
130 * @since 1.15
131 *
132 * @see ecore_buffer_consumer_buffer_enqueued_cb_set()
133 * @ingroup Ecore_Buffer_Consumer_Group
134 */
135typedef void (*Ecore_Buffer_Consumer_Enqueue_Cb) (Ecore_Buffer_Consumer *consumer, void *data);
136/**
137 * @typedef Ecore_Buffer_Provider_Consumer_Add_Cb
138 *
139 * @brief Called whenever a Ecore_Buffer_Consumer connected.
140 *
141 * @since 1.15
142 *
143 * @see ecore_buffer_provider_consumer_add_cb_set()
144 * @ingroup Ecore_Buffer_Provider_Group
145 */
146typedef void (*Ecore_Buffer_Provider_Consumer_Add_Cb) (Ecore_Buffer_Provider *provider, int queue_size, int w, int h, void *data);
147/**
148 * @typedef Ecore_Buffer_Provider_Consumer_Del_Cb
149 *
150 * @brief Called whenever a Ecore_Buffer_Consumer disconnected.
151 *
152 * @since 1.15
153 *
154 * @see ecore_buffer_provider_consumer_del_cb_set()
155 * @ingroup Ecore_Buffer_Provider_Group
156 */
157typedef void (*Ecore_Buffer_Provider_Consumer_Del_Cb) (Ecore_Buffer_Provider *provider, void *data);
158/**
159 * @typedef Ecore_Buffer_Provider_Enqueue_Cb
160 *
161 * @brief Called whenever a Ecore_Buffer is released.
162 *
163 * @since 1.15
164 *
165 * @see ecore_buffer_provider_buffer_released_cb_set()
166 * @ingroup Ecore_Buffer_Provider_Group
167 */
168typedef void (*Ecore_Buffer_Provider_Enqueue_Cb) (Ecore_Buffer_Provider *provider, void *data);
169
170/**
171 * @addtogroup Ecore_Buffer_Queue_Group
172 * @{
173 */
174
175/**
176 * @brief Init the Ecore_Buffer_Queue system.
177 *
178 * @since 1.15
179 *
180 * @return How many times the lib has been initialized, 0 indicates failure.
181 *
182 * Set up the connection of Buffer Queue deamon, and Init Ecore_Buffer_Queue libraries.
183 *
184 * @see ecore_buffer_queue_shutdown()
185 */
186EAPI int ecore_buffer_queue_init(void);
187/**
188 * @brief Shut down the Ecore_Buffer_Queue system.
189 *
190 * @since 1.15
191 *
192 * this closes the connection of Buffer Queue deamon, and Shut down Ecore_Buffer_Queue libraries.
193 *
194 * @see ecore_buffer_queue_init()
195 */
196EAPI int ecore_buffer_queue_shutdown(void);
197
198/**
199 * @}
200 */
201
202/**
203 * @addtogroup Ecore_Buffer_Consumer_Group
204 * @{
205 */
206
207/**
208 * @brief Creates a new Buffer Consumer based on name and common parameters.
209 *
210 * @since 1.15
211 *
212 * @param[in] name the name of Buffer_Queue, this is needed by Consumer and Provider to connect each other.
213 * @param[in] queue_size size of Queue (If you pass this 0, then default size two(2) is appied)
214 * @param[in] w width of buffer recommeneded to provider.
215 * @param[in] h height of buffer recommended to provider.
216 *
217 * @return Ecore_Buffer_Consumer instance or @c NULL if creation failed.
218 */
219EAPI Ecore_Buffer_Consumer *ecore_buffer_consumer_new(const char *name, int32_t queue_size, int32_t w, int32_t h);
220/**
221 * @brief Free an Ecore_Buffer_Consumer
222 *
223 * @since 1.15
224 *
225 * @param[in] consumer The Ecore_Buffer_Consumer to free
226 *
227 * This frees up any memory used by the Ecore_Buffer_Consumer.
228 */
229EAPI void ecore_buffer_consumer_free(Ecore_Buffer_Consumer *consumer);
230/**
231 * @brief Return the latest Ecore_Buffer submitted by provider.
232 *
233 * @since 1.15
234 *
235 * @param[in] consumer The Ecore_Buffer_Consumer to request for buffer
236 *
237 * @return Ecore_Buffer handle or NULL if acquirement failed.
238 *
239 * @see ecore_buffer_consumer_buffer_release()
240 *
241 * Consumer can store Ecore_Buffer submitted by Provider as much as size of queue
242 * which is passed as a argument of ecore_buffer_consumer_new().
243 */
244EAPI Ecore_Buffer *ecore_buffer_consumer_buffer_dequeue(Ecore_Buffer_Consumer *consumer);
245/**
246 * @brief Release the acquired Ecore_Buffer.
247 *
248 * @since 1.15
249 *
250 * @param[in] consumer The Ecore_Buffer_Consumer to request release buffer
251 * @param[in] buffer The Ecore_Buffer to release
252 *
253 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
254 *
255 * @see ecore_buffer_consumer_buffer_dequeue()
256 *
257 * Consumer should release the Ecore_Buffer after acquiring and using it.
258 * By doing release, Ecore_Buffer will be used by provider again,
259 * or freed internally if Ecore_Buffer is not necessary anymore.
260 * If not, the resource of Ecore_Buffer is continually owned by consumer until released.
261 */
262EAPI Eina_Bool ecore_buffer_consumer_buffer_release(Ecore_Buffer_Consumer *consumer, Ecore_Buffer *buffer);
263/**
264 * @brief Check if Queue of Ecore_Buffer is empty.
265 *
266 * @since 1.15
267 *
268 * @param[in] consumer The Ecore_Buffer_Consumer to query
269 *
270 * @return @c EINA_TRUE means queue is empty, @c EINA_FALSE otherwise.
271 */
272EAPI Eina_Bool ecore_buffer_consumer_queue_is_empty(Ecore_Buffer_Consumer *consumer);
273/**
274 * @brief Set a callback for provider connection events.
275 *
276 * @since 1.15
277 *
278 * @param[in] consumer The Ecore_Buffer_Consumer to set callbacks on
279 * @param[in] func The function to call
280 * @param[in] data A pointer to the user data to store.
281 *
282 * A call to this function will set a callback on an Ecore_Buffer_Consumer, causing
283 * @p func to be called whenever @p consumer is connected with provider.
284 */
285EAPI void ecore_buffer_consumer_provider_add_cb_set(Ecore_Buffer_Consumer *consumer, Ecore_Buffer_Consumer_Provider_Add_Cb func, void *data);
286/**
287 * @brief Set a callback for provider disconnection events.
288 *
289 * @since 1.15
290 *
291 * @param[in] consumer The Ecore_Buffer_Consumer to set callbacks on
292 * @param[in] func The function to call
293 * @param[in] data A pointer to the user data to store.
294 *
295 * A call to this function will set a callback on an Ecore_Buffer_Consumer, causing
296 * @p func to be called whenever @p consumer is disconnected with provider.
297 */
298EAPI void ecore_buffer_consumer_provider_del_cb_set(Ecore_Buffer_Consumer *consumer, Ecore_Buffer_Consumer_Provider_Del_Cb func, void *data);
299/**
300 * @brief Set a callback for enqueued buffer events.
301 *
302 * @since 1.15
303 *
304 * @param[in] consumer The Ecore_Buffer_Consumer to set callbacks on
305 * @param[in] func The function to call
306 * @param[in] data A pointer to the user data to store.
307 *
308 * A call to this function will set a callback on an Ecore_Buffer_Consumer, causing
309 * @p func to be called whenever @p consumer has received buffer submitted from provider.
310 *
311 * You may success acuiqre Ecore_Buffer after this callback called.
312 */
313EAPI void ecore_buffer_consumer_buffer_enqueued_cb_set(Ecore_Buffer_Consumer *consumer, Ecore_Buffer_Consumer_Enqueue_Cb func, void *data);
314
315/**
316 * @}
317 */
318
319/**
320 * @addtogroup Ecore_Buffer_Provider_Group
321 * @{
322 */
323
324/**
325 * @brief Creates a new Buffer Provider based on name.
326 *
327 * @since 1.15
328 *
329 * @param[in] name the name of Buffer_Queue.
330 *
331 * @return Ecore_Buffer_Provider instance or @c NULL if creation failed.
332 */
333EAPI Ecore_Buffer_Provider *ecore_buffer_provider_new(const char *name);
334/**
335 * @brief Free an Ecore_Buffer_Provider
336 *
337 * @since 1.15
338 *
339 * @param[in] provider The Ecore_Buffer_Provider to free
340 *
341 * This frees up any memory used by the Ecore_Buffer_Provider.
342 */
343EAPI void ecore_buffer_provider_free(Ecore_Buffer_Provider *provider);
344/**
345 * @brief Return the Ecore_Buffer released by consumer or State of Queue.
346 *
347 * @since 1.15
348 *
349 * @param[in] provider The Ecore_Buffer_Provider to request for buffer
350 * @param[out] ret_buf A Pointer to the Ecore_Buffer
351 *
352 * @return The enumeration of Ecore_Buffer_Return to indicate result of Dequeueing.
353 *
354 * This function gives you drawable buffer and inform you the state of Queue.
355 * Each return value of enumeration has meaning as below.
356 * @li ECORE_BUFFER_RETURN_ERROR, means error occured.
357 * @li ECORE_BUFFER_RETURN_SUCCESS, means success to dequeue, therefore ret_buf is valid.
358 * @li ECORE_BUFFER_RETURN_EMPTY, means queue is empty, not available slot in Queue.
359 * in other words, there is no free drawable buffer in Queue.
360 * @li ECORE_BUFFER_RETURN_NEED_ALLOC, means that there is available slot, but not allocated.
361 * so, You may create new Ecore_Buffer, and then just enqueue the Ecore_Buffer.
362 *
363 * @see ecore_buffer_new(), ecore_buffer_provider_buffer_enqueue()
364 */
365EAPI Ecore_Buffer_Return ecore_buffer_provider_buffer_acquire(Ecore_Buffer_Provider *provider, Ecore_Buffer **ret_buf);
366/**
367 * @brief Submit the Ecore_Buffer to Consumer to request compositing.
368 *
369 * @since 1.15
370 *
371 * @param[in] provider The Ecore_Buffer_Provider connected with consumer.
372 * @param[in] buffer The Ecore_Buffer to submit
373 *
374 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
375 *
376 * This function allow you to submit the Ecore_Buffer to consumer to request compositing.
377 * And this will be success, in case only you submit dequeued Ecore_Buffer,
378 * and new Ecore_Buffer after received return value of ECORE_BUFFER_RETURN_NEED_ALLOC by ecore_buffer_provider_buffer_acquire().
379 *
380 * @see ecore_buffer_new(), ecore_buffer_provider_buffer_dequeue()
381 */
382EAPI Eina_Bool ecore_buffer_provider_buffer_enqueue(Ecore_Buffer_Provider *provider, Ecore_Buffer *buffer);
383/**
384 * @brief Check if state of queue.
385 *
386 * @since 1.15
387 *
388 * @param[in] provider The Ecore_Buffer_Provider to query
389 *
390 * @li ECORE_BUFFER_RETURN_NOT_EMPTY, means there is a dequeueable Ecore_Buffer at least one.
391 * @li ECORE_BUFFER_RETURN_EMPTY, means queue is empty, not available slot in Queue.
392 * in other words, there is no free drawable buffer in Queue.
393 * @li ECORE_BUFFER_RETURN_NEED_ALLOC, means that there is available slot, but not allocated.
394 * so, You may create new Ecore_Buffer, and then just enqueue the Ecore_Buffer.
395 *
396 * @return @c EINA_TRUE means queue is empty, @c EINA_FALSE otherwise.
397 */
398EAPI Ecore_Buffer_Return ecore_buffer_provider_buffer_acquirable_check(Ecore_Buffer_Provider *provider);
399/**
400 * @brief Set a callback for consumer connection events.
401 *
402 * @since 1.15
403 *
404 * @param[in] provider The Ecore_Buffer_Provider to set callbacks on
405 * @param[in] func The function to call
406 * @param[in] data A pointer to the user data to store.
407 *
408 * A call to this function will set a callback on an Ecore_Buffer_Provider, causing
409 * @p func to be called whenever @p provider is connected with consumer.
410 */
411EAPI void ecore_buffer_provider_consumer_add_cb_set(Ecore_Buffer_Provider *provider, Ecore_Buffer_Provider_Consumer_Add_Cb func, void *data);
412/**
413 * @brief Set a callback for consumer disconnection events.
414 *
415 * @since 1.15
416 *
417 * @param[in] provider The Ecore_Buffer_Provider to set callbacks on
418 * @param[in] func The function to call
419 * @param[in] data A pointer to the user data to store.
420 *
421 * A call to this function will set a callback on an Ecore_Buffer_Provider, causing
422 * @p func to be called whenever @p provider is disconnected with consumer.
423 */
424EAPI void ecore_buffer_provider_consumer_del_cb_set(Ecore_Buffer_Provider *provider, Ecore_Buffer_Provider_Consumer_Del_Cb func, void *data);
425/**
426 * @brief Set a callback for released buffer events.
427 *
428 * @since 1.15
429 *
430 * @param[in] provider The Ecore_Buffer_Provider to set callbacks on
431 * @param[in] func The function to call
432 * @param[in] data A pointer to the user data to store.
433 *
434 * A call to this function will set a callback on an Ecore_Buffer_Provider, causing
435 * @p func to be called whenever @p provider has received Ecore_Buffer released from provider.
436 *
437 * You may success dequeue the Ecore_Buffer after this callback called.
438 */
439EAPI void ecore_buffer_provider_buffer_released_cb_set(Ecore_Buffer_Provider *provider, Ecore_Buffer_Provider_Enqueue_Cb func, void *data);
440
441/**
442 * @}
443 */
444
445#ifdef __cplusplus
446}
447#endif
448
449#endif /* _ECORE_BUFFER_QUEUE_H_ */
diff --git a/src/lib/ecore_buffer/bq_mgr_protocol.c b/src/lib/ecore_buffer/bq_mgr_protocol.c
new file mode 100644
index 0000000000..fe8b98c9bc
--- /dev/null
+++ b/src/lib/ecore_buffer/bq_mgr_protocol.c
@@ -0,0 +1,131 @@
1#include <stdlib.h>
2#include <stdint.h>
3#include "wayland-util.h"
4
5extern const struct wl_interface bq_buffer_interface;
6extern const struct wl_interface bq_consumer_interface;
7extern const struct wl_interface bq_provider_interface;
8
9static const struct wl_interface *types[] = {
10 NULL,
11 NULL,
12 NULL,
13 &bq_consumer_interface,
14 NULL,
15 NULL,
16 NULL,
17 NULL,
18 &bq_provider_interface,
19 NULL,
20 &bq_buffer_interface,
21 &bq_buffer_interface,
22 NULL,
23 NULL,
24 NULL,
25 NULL,
26 NULL,
27 &bq_buffer_interface,
28 NULL,
29 NULL,
30 NULL,
31 NULL,
32 NULL,
33 NULL,
34 NULL,
35 &bq_buffer_interface,
36 NULL,
37 NULL,
38 NULL,
39 NULL,
40 NULL,
41 NULL,
42 NULL,
43 &bq_buffer_interface,
44 &bq_buffer_interface,
45 NULL,
46 &bq_buffer_interface,
47 NULL,
48 NULL,
49 NULL,
50 NULL,
51 NULL,
52 &bq_buffer_interface,
53 NULL,
54 NULL,
55 NULL,
56 NULL,
57 NULL,
58 NULL,
59 NULL,
60 &bq_buffer_interface,
61 NULL,
62 NULL,
63 NULL,
64 NULL,
65 NULL,
66 NULL,
67 NULL,
68 &bq_buffer_interface,
69 &bq_buffer_interface,
70 NULL,
71 &bq_buffer_interface,
72 NULL,
73};
74
75static const struct wl_message bq_mgr_requests[] = {
76 { "create_consumer", "nsiii", types + 3 },
77 { "create_provider", "ns", types + 8 },
78};
79
80WL_EXPORT const struct wl_interface bq_mgr_interface = {
81 "bq_mgr", 1,
82 2, bq_mgr_requests,
83 0, NULL,
84};
85
86static const struct wl_message bq_consumer_requests[] = {
87 { "release_buffer", "o", types + 10 },
88};
89
90static const struct wl_message bq_consumer_events[] = {
91 { "connected", "", types + 0 },
92 { "disconnected", "", types + 0 },
93 { "buffer_attached", "nsiiiu", types + 11 },
94 { "set_buffer_id", "oiiiiiii", types + 17 },
95 { "set_buffer_fd", "ohiiiiii", types + 25 },
96 { "buffer_detached", "o", types + 33 },
97 { "add_buffer", "ou", types + 34 },
98};
99
100WL_EXPORT const struct wl_interface bq_consumer_interface = {
101 "bq_consumer", 1,
102 1, bq_consumer_requests,
103 7, bq_consumer_events,
104};
105
106static const struct wl_message bq_provider_requests[] = {
107 { "attach_buffer", "nsiiiu", types + 36 },
108 { "set_buffer_id", "oiiiiiii", types + 42 },
109 { "set_buffer_fd", "ohiiiiii", types + 50 },
110 { "detach_buffer", "o", types + 58 },
111 { "enqueue_buffer", "ou", types + 59 },
112};
113
114static const struct wl_message bq_provider_events[] = {
115 { "connected", "iii", types + 0 },
116 { "disconnected", "", types + 0 },
117 { "add_buffer", "ou", types + 61 },
118};
119
120WL_EXPORT const struct wl_interface bq_provider_interface = {
121 "bq_provider", 1,
122 5, bq_provider_requests,
123 3, bq_provider_events,
124};
125
126WL_EXPORT const struct wl_interface bq_buffer_interface = {
127 "bq_buffer", 1,
128 0, NULL,
129 0, NULL,
130};
131
diff --git a/src/lib/ecore_buffer/bq_mgr_protocol.h b/src/lib/ecore_buffer/bq_mgr_protocol.h
new file mode 100644
index 0000000000..7cf9ad9380
--- /dev/null
+++ b/src/lib/ecore_buffer/bq_mgr_protocol.h
@@ -0,0 +1,329 @@
1#ifndef BQ_MGR_CLIENT_PROTOCOL_H
2#define BQ_MGR_CLIENT_PROTOCOL_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <stdint.h>
9#include <stddef.h>
10#include "wayland-client.h"
11
12struct wl_client;
13struct wl_resource;
14
15struct bq_mgr;
16struct bq_consumer;
17struct bq_provider;
18struct bq_buffer;
19
20extern const struct wl_interface bq_mgr_interface;
21extern const struct wl_interface bq_consumer_interface;
22extern const struct wl_interface bq_provider_interface;
23extern const struct wl_interface bq_buffer_interface;
24
25#ifndef BQ_MGR_ERROR_ENUM
26#define BQ_MGR_ERROR_ENUM
27enum bq_mgr_error {
28 BQ_MGR_ERROR_INVALID_PERMISSION = 0,
29 BQ_MGR_ERROR_INVALID_NAME = 1,
30 BQ_MGR_ERROR_ALREADY_USED = 2,
31};
32#endif /* BQ_MGR_ERROR_ENUM */
33
34#define BQ_MGR_CREATE_CONSUMER 0
35#define BQ_MGR_CREATE_PROVIDER 1
36
37static inline void
38bq_mgr_set_user_data(struct bq_mgr *bq_mgr, void *user_data)
39{
40 wl_proxy_set_user_data((struct wl_proxy *) bq_mgr, user_data);
41}
42
43static inline void *
44bq_mgr_get_user_data(struct bq_mgr *bq_mgr)
45{
46 return wl_proxy_get_user_data((struct wl_proxy *) bq_mgr);
47}
48
49static inline void
50bq_mgr_destroy(struct bq_mgr *bq_mgr)
51{
52 wl_proxy_destroy((struct wl_proxy *) bq_mgr);
53}
54
55static inline struct bq_consumer *
56bq_mgr_create_consumer(struct bq_mgr *bq_mgr, const char *name, int32_t queue_size, int32_t width, int32_t height)
57{
58 struct wl_proxy *id;
59
60 id = wl_proxy_marshal_constructor((struct wl_proxy *) bq_mgr,
61 BQ_MGR_CREATE_CONSUMER, &bq_consumer_interface, NULL, name, queue_size, width, height);
62
63 return (struct bq_consumer *) id;
64}
65
66static inline struct bq_provider *
67bq_mgr_create_provider(struct bq_mgr *bq_mgr, const char *name)
68{
69 struct wl_proxy *id;
70
71 id = wl_proxy_marshal_constructor((struct wl_proxy *) bq_mgr,
72 BQ_MGR_CREATE_PROVIDER, &bq_provider_interface, NULL, name);
73
74 return (struct bq_provider *) id;
75}
76
77struct bq_consumer_listener {
78 /**
79 * connected - (none)
80 */
81 void (*connected)(void *data,
82 struct bq_consumer *bq_consumer);
83 /**
84 * disconnected - (none)
85 */
86 void (*disconnected)(void *data,
87 struct bq_consumer *bq_consumer);
88 /**
89 * buffer_attached - (none)
90 * @buffer: (none)
91 * @engine: (none)
92 * @width: (none)
93 * @height: (none)
94 * @format: (none)
95 * @flags: (none)
96 */
97 void (*buffer_attached)(void *data,
98 struct bq_consumer *bq_consumer,
99 struct bq_buffer *buffer,
100 const char *engine,
101 int32_t width,
102 int32_t height,
103 int32_t format,
104 uint32_t flags);
105 /**
106 * set_buffer_id - (none)
107 * @buffer: (none)
108 * @id: (none)
109 * @offset0: (none)
110 * @stride0: (none)
111 * @offset1: (none)
112 * @stride1: (none)
113 * @offset2: (none)
114 * @stride2: (none)
115 */
116 void (*set_buffer_id)(void *data,
117 struct bq_consumer *bq_consumer,
118 struct bq_buffer *buffer,
119 int32_t id,
120 int32_t offset0,
121 int32_t stride0,
122 int32_t offset1,
123 int32_t stride1,
124 int32_t offset2,
125 int32_t stride2);
126 /**
127 * set_buffer_fd - (none)
128 * @buffer: (none)
129 * @fd: (none)
130 * @offset0: (none)
131 * @stride0: (none)
132 * @offset1: (none)
133 * @stride1: (none)
134 * @offset2: (none)
135 * @stride2: (none)
136 */
137 void (*set_buffer_fd)(void *data,
138 struct bq_consumer *bq_consumer,
139 struct bq_buffer *buffer,
140 int32_t fd,
141 int32_t offset0,
142 int32_t stride0,
143 int32_t offset1,
144 int32_t stride1,
145 int32_t offset2,
146 int32_t stride2);
147 /**
148 * buffer_detached - (none)
149 * @buffer: (none)
150 */
151 void (*buffer_detached)(void *data,
152 struct bq_consumer *bq_consumer,
153 struct bq_buffer *buffer);
154 /**
155 * add_buffer - (none)
156 * @buffer: (none)
157 * @serial: (none)
158 */
159 void (*add_buffer)(void *data,
160 struct bq_consumer *bq_consumer,
161 struct bq_buffer *buffer,
162 uint32_t serial);
163};
164
165static inline int
166bq_consumer_add_listener(struct bq_consumer *bq_consumer,
167 const struct bq_consumer_listener *listener, void *data)
168{
169 return wl_proxy_add_listener((struct wl_proxy *) bq_consumer,
170 (void (**)(void)) listener, data);
171}
172
173#define BQ_CONSUMER_RELEASE_BUFFER 0
174
175static inline void
176bq_consumer_set_user_data(struct bq_consumer *bq_consumer, void *user_data)
177{
178 wl_proxy_set_user_data((struct wl_proxy *) bq_consumer, user_data);
179}
180
181static inline void *
182bq_consumer_get_user_data(struct bq_consumer *bq_consumer)
183{
184 return wl_proxy_get_user_data((struct wl_proxy *) bq_consumer);
185}
186
187static inline void
188bq_consumer_destroy(struct bq_consumer *bq_consumer)
189{
190 wl_proxy_destroy((struct wl_proxy *) bq_consumer);
191}
192
193static inline void
194bq_consumer_release_buffer(struct bq_consumer *bq_consumer, struct bq_buffer *buffer)
195{
196 wl_proxy_marshal((struct wl_proxy *) bq_consumer,
197 BQ_CONSUMER_RELEASE_BUFFER, buffer);
198}
199
200#ifndef BQ_PROVIDER_ERROR_ENUM
201#define BQ_PROVIDER_ERROR_ENUM
202enum bq_provider_error {
203 BQ_PROVIDER_ERROR_OVERFLOW_QUEUE_SIZE = 0,
204 BQ_PROVIDER_ERROR_CONNECTION = 1,
205};
206#endif /* BQ_PROVIDER_ERROR_ENUM */
207
208struct bq_provider_listener {
209 /**
210 * connected - (none)
211 * @queue_size: (none)
212 * @width: (none)
213 * @height: (none)
214 */
215 void (*connected)(void *data,
216 struct bq_provider *bq_provider,
217 int32_t queue_size,
218 int32_t width,
219 int32_t height);
220 /**
221 * disconnected - (none)
222 */
223 void (*disconnected)(void *data,
224 struct bq_provider *bq_provider);
225 /**
226 * add_buffer - (none)
227 * @buffer: (none)
228 * @serial: (none)
229 */
230 void (*add_buffer)(void *data,
231 struct bq_provider *bq_provider,
232 struct bq_buffer *buffer,
233 uint32_t serial);
234};
235
236static inline int
237bq_provider_add_listener(struct bq_provider *bq_provider,
238 const struct bq_provider_listener *listener, void *data)
239{
240 return wl_proxy_add_listener((struct wl_proxy *) bq_provider,
241 (void (**)(void)) listener, data);
242}
243
244#define BQ_PROVIDER_ATTACH_BUFFER 0
245#define BQ_PROVIDER_SET_BUFFER_ID 1
246#define BQ_PROVIDER_SET_BUFFER_FD 2
247#define BQ_PROVIDER_DETACH_BUFFER 3
248#define BQ_PROVIDER_ENQUEUE_BUFFER 4
249
250static inline void
251bq_provider_set_user_data(struct bq_provider *bq_provider, void *user_data)
252{
253 wl_proxy_set_user_data((struct wl_proxy *) bq_provider, user_data);
254}
255
256static inline void *
257bq_provider_get_user_data(struct bq_provider *bq_provider)
258{
259 return wl_proxy_get_user_data((struct wl_proxy *) bq_provider);
260}
261
262static inline void
263bq_provider_destroy(struct bq_provider *bq_provider)
264{
265 wl_proxy_destroy((struct wl_proxy *) bq_provider);
266}
267
268static inline struct bq_buffer *
269bq_provider_attach_buffer(struct bq_provider *bq_provider, const char *engine, int32_t width, int32_t height, int32_t format, uint32_t flags)
270{
271 struct wl_proxy *buffer;
272
273 buffer = wl_proxy_marshal_constructor((struct wl_proxy *) bq_provider,
274 BQ_PROVIDER_ATTACH_BUFFER, &bq_buffer_interface, NULL, engine, width, height, format, flags);
275
276 return (struct bq_buffer *) buffer;
277}
278
279static inline void
280bq_provider_set_buffer_id(struct bq_provider *bq_provider, struct bq_buffer *buffer, int32_t id, int32_t offset0, int32_t stride0, int32_t offset1, int32_t stride1, int32_t offset2, int32_t stride2)
281{
282 wl_proxy_marshal((struct wl_proxy *) bq_provider,
283 BQ_PROVIDER_SET_BUFFER_ID, buffer, id, offset0, stride0, offset1, stride1, offset2, stride2);
284}
285
</