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 <cp.michael@samsung.com>
This commit is contained in:
Chris Michael 2015-02-27 10:33:30 -05:00
parent 24c92d8caf
commit 3bb11b938c
5 changed files with 155 additions and 8 deletions

View File

@ -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

View File

@ -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
}

View File

@ -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"

View File

@ -0,0 +1,125 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#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;
}

View File

@ -0,0 +1,15 @@
#include "evas_engine.h"
#include <Ecore_X.h>
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);