From 3bb11b938c7efef87a86638ea5427c174c7725ca Mon Sep 17 00:00:00 2001 From: Chris Michael Date: Fri, 27 Feb 2015 10:33:30 -0500 Subject: [PATCH] evas-software-x11: Provide TBM Native Surface support for xcb engine Summary: This adds support for native surfaces in xcb. Previously when the TBM Native Surface support was added, it broke the xcb build. These commits fix that issue. @fix Signed-off-by: Chris Michael --- src/Makefile_Evas.am | 4 +- .../evas/engines/software_x11/evas_engine.c | 12 +- .../evas/engines/software_x11/evas_native_tbm.c | 7 +- .../evas/engines/software_x11/evas_xcb_image.c | 125 +++++++++++++++++++++ .../evas/engines/software_x11/evas_xcb_image.h | 15 +++ 5 files changed, 155 insertions(+), 8 deletions(-) create mode 100644 src/modules/evas/engines/software_x11/evas_xcb_image.c create mode 100644 src/modules/evas/engines/software_x11/evas_xcb_image.h diff --git a/src/Makefile_Evas.am b/src/Makefile_Evas.am index 755912e..d8c6ede 100644 --- a/src/Makefile_Evas.am +++ b/src/Makefile_Evas.am @@ -1107,10 +1107,12 @@ modules/evas/engines/software_x11/evas_xcb_outbuf.c \ modules/evas/engines/software_x11/evas_xcb_buffer.c \ modules/evas/engines/software_x11/evas_xcb_color.c \ modules/evas/engines/software_x11/evas_xcb_main.c \ +modules/evas/engines/software_x11/evas_xcb_image.c \ modules/evas/engines/software_x11/evas_xcb_outbuf.h \ modules/evas/engines/software_x11/evas_xcb_buffer.h \ modules/evas/engines/software_x11/evas_xcb_color.h \ -modules/evas/engines/software_x11/evas_xcb_xdefaults.h +modules/evas/engines/software_x11/evas_xcb_xdefaults.h \ +modules/evas/engines/software_x11/evas_xcb_image.h SOFTWARE_X11_CPPFLAGS += @evas_engine_software_xcb_cflags@ SOFTWARE_X11_LIBADD += @evas_engine_software_xcb_libs@ endif diff --git a/src/modules/evas/engines/software_x11/evas_engine.c b/src/modules/evas/engines/software_x11/evas_engine.c index 2361226..65bb4df 100644 --- a/src/modules/evas/engines/software_x11/evas_engine.c +++ b/src/modules/evas/engines/software_x11/evas_engine.c @@ -18,6 +18,7 @@ # include "evas_xcb_outbuf.h" # include "evas_xcb_color.h" # include "evas_xcb_xdefaults.h" +# include "evas_xcb_image.h" #endif #ifdef BUILD_ENGINE_SOFTWARE_XLIB @@ -670,12 +671,15 @@ eng_image_native_set(void *data EINA_UNUSED, void *image, void *native) evas_cache_image_drop(ie); ie = ie2; -#ifdef BUILD_ENGINE_SOFTWARE_XLIB if (ns->type == EVAS_NATIVE_SURFACE_X11) { +#ifdef BUILD_ENGINE_SOFTWARE_XLIB return evas_xlib_image_native_set(re->generic.ob, ie, ns); - } #endif +#ifdef BUILD_ENGINE_SOFTWARE_XCB + return evas_xcb_image_native_set(re->generic.ob, ie, ns); +#endif + } if (ns->type == EVAS_NATIVE_SURFACE_TBM) { return evas_native_tbm_image_set(re->generic.ob, ie, ns); @@ -687,16 +691,12 @@ eng_image_native_set(void *data EINA_UNUSED, void *image, void *native) static void * eng_image_native_get(void *data EINA_UNUSED, void *image) { -#ifdef BUILD_ENGINE_SOFTWARE_XLIB RGBA_Image *im = image; Native *n; if (!im) return NULL; n = im->native.data; if (!n) return NULL; return &(n->ns); -#else - return NULL; -#endif } diff --git a/src/modules/evas/engines/software_x11/evas_native_tbm.c b/src/modules/evas/engines/software_x11/evas_native_tbm.c index ec7d037..85b3fc7 100644 --- a/src/modules/evas/engines/software_x11/evas_native_tbm.c +++ b/src/modules/evas/engines/software_x11/evas_native_tbm.c @@ -1,5 +1,10 @@ #include "evas_common_private.h" -#include "evas_xlib_image.h" +#ifdef BUILD_ENGINE_SOFTWARE_XLIB +# include "evas_xlib_image.h" +#endif +#ifdef BUILD_ENGINE_SOFTWARE_XCB +# include "evas_xcb_image.h" +#endif #include "evas_private.h" #include "Evas_Engine_Software_X11.h" diff --git a/src/modules/evas/engines/software_x11/evas_xcb_image.c b/src/modules/evas/engines/software_x11/evas_xcb_image.c new file mode 100644 index 0000000..d15dbe3 --- /dev/null +++ b/src/modules/evas/engines/software_x11/evas_xcb_image.c @@ -0,0 +1,125 @@ +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "evas_common_private.h" +#include "evas_xcb_image.h" + +static void +_evas_xcb_image_update(void *data EINA_UNUSED, void *image, int x, int y, int w, int h) +{ + RGBA_Image *im; + Native *n; + + im = image; + n = im->native.data; + + if (ecore_x_image_get(n->exim, n->pixmap, 0, 0, x, y, w, h)) + { + char *pix; + int bpl, rows, bpp; + + pix = ecore_x_image_data_get(n->exim, &bpl, &rows, &bpp); + if (!ecore_x_image_is_argb32_get(n->exim)) + { + Ecore_X_Colormap colormap; + + if (!im->image.data) + im->image.data = (DATA32 *)malloc(im->cache_entry.w * im->cache_entry.h * sizeof(DATA32)); + colormap = ecore_x_default_colormap_get(ecore_x_display_get(), ecore_x_default_screen_get()); + ecore_x_image_to_argb_convert(pix, bpp, bpl, colormap, n->visual, + x, y, w, h, im->image.data, + (w * sizeof(int)), 0, 0); + } + else + im->image.data = (DATA32 *)pix; + } +} + +static void +_native_cb_bind(void *data, void *image, int x, int y, int w, int h) +{ + RGBA_Image *im; + Native *n; + + im = image; + n = im->native.data; + + if ((n) && (n->ns.type == EVAS_NATIVE_SURFACE_X11)) + _evas_xcb_image_update(data, image, x, y, w, h); +} + +static void +_native_cb_free(void *data EINA_UNUSED, void *image) +{ + RGBA_Image *im; + Native *n; + + im = image; + n = im->native.data; + + if (n->exim) + { + ecore_x_image_free(n->exim); + n->exim = NULL; + } + n->visual = NULL; + + im->native.data = NULL; + im->native.func.data = NULL; + im->native.func.bind = NULL; + im->native.func.free = NULL; + im->image.data = NULL; + + free(n); +} + +void * +evas_xcb_image_native_set(void *data, void *image, void *native) +{ + RGBA_Image *im; + Evas_Native_Surface *ns; + + im = image; + ns = native; + if ((ns) && (ns->type == EVAS_NATIVE_SURFACE_X11)) + { + Native *n = NULL; + Ecore_X_Image *exim = NULL; + Ecore_X_Visual *vis = NULL; + Ecore_X_Pixmap pm = 0; + int w, h, depth; + + vis = ns->data.x11.visual; + pm = ns->data.x11.pixmap; + + depth = ecore_x_drawable_depth_get(pm); + w = im->cache_entry.w; + h = im->cache_entry.h; + + n = calloc(1, sizeof(Native)); + if (!n) return NULL; + + exim = ecore_x_image_new(w, h, vis, depth); + if (!exim) + { + ERR("Failed to create new Ecore_X_Image"); + free(n); + return NULL; + } + + memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface)); + n->pixmap = pm; + n->visual = vis; + n->exim = exim; + + im->native.data = n; + im->native.func.data = NULL; + im->native.func.bind = _native_cb_bind; + im->native.func.free = _native_cb_free; + + _evas_xcb_image_update(data, image, 0, 0, w, h); + } + + return im; +} diff --git a/src/modules/evas/engines/software_x11/evas_xcb_image.h b/src/modules/evas/engines/software_x11/evas_xcb_image.h new file mode 100644 index 0000000..ffd9e62 --- /dev/null +++ b/src/modules/evas/engines/software_x11/evas_xcb_image.h @@ -0,0 +1,15 @@ +#include "evas_engine.h" +#include + +typedef struct _Native Native; + +struct _Native +{ + Evas_Native_Surface ns; + Ecore_X_Pixmap pixmap; + Ecore_X_Visual *visual; + + Ecore_X_Image *exim; +}; + +void *evas_xcb_image_native_set(void *data, void *image, void *native); -- 2.7.4