Render_Engine_Software_Generic generic;
};
-Evas_Native_Tbm_Surface_Image_Set_Call glsym_evas_native_tbm_surface_image_set = NULL;
-
/* For wl_buffer's native set */
static void *tbm_server_lib = NULL;
typedef struct _tbm_surface * tbm_surface_h;
fail = 1; \
}
- // Get function pointer to native_common that is now provided through the link of SW_Generic.
- LINK2GENERIC(evas_native_tbm_surface_image_set);
- if (fail == 1)
- {
- ERR("fail to dlsym about evas_native_tbm_surface_image_set symbol");
- return;
- }
tbm_server_lib = dlopen(wayland_tbm_server_lib, RTLD_LOCAL | RTLD_LAZY);
if (tbm_server_lib)
{
/* try to create a new render_engine */
if (!(re = _output_setup(info, epd->output.w, epd->output.h)))
return 0;
+
+ /* init tbm native surface lib */
+ if (re)
+ {
+ _evas_native_tbm_init();
+ }
}
else
{
free(re);
}
+ /* shutdown tbm native surface lib */
+ _evas_native_tbm_shutdown();
+
if (tbm_server_lib)
{
dlclose(tbm_server_lib);
{
Evas_Native_Surface *ns = native;
Image_Entry *ie = image;
- RGBA_Image *im = image, *im2;
+ RGBA_Image *im = image, *im2 = NULL;
void *wl_buf = NULL;
+ int stride = -1;
if (!im || !ns) return im;
ie->w, ie->h,
ns->data.x11.visual, 1,
EVAS_COLORSPACE_ARGB8888);
+ else if (ns->type == EVAS_NATIVE_SURFACE_TBM)
+ {
+ stride = _evas_native_tbm_surface_stride_get(NULL, ns);
+ if (stride > -1)
+ im2 = (RGBA_Image *)evas_cache_image_copied_data(evas_common_image_cache_get(),
+ stride, ie->h, NULL, ie->flags.alpha,
+ EVAS_COLORSPACE_ARGB8888);
+ }
else
im2 = (RGBA_Image *)evas_cache_image_data(evas_common_image_cache_get(),
ie->w, ie->h,
if (ns->type == EVAS_NATIVE_SURFACE_TBM)
{
- if (glsym_evas_native_tbm_surface_image_set)
- return glsym_evas_native_tbm_surface_image_set(NULL, im, ns);
- else
- return NULL;
+ return _evas_native_tbm_surface_image_set(NULL, im, ns);
}
else if (ns->type == EVAS_NATIVE_SURFACE_WL)
{
// TODO : need the code for all wl_buffer type
// For TBM surface
- if (glsym_wayland_tbm_server_get_surface && glsym_evas_native_tbm_surface_image_set)
+ if (glsym_wayland_tbm_server_get_surface)
{
tbm_surface_h _tbm_surface;
_tbm_surface = glsym_wayland_tbm_server_get_surface(NULL,ns->data.wl.legacy_buffer);
- return glsym_evas_native_tbm_surface_image_set(_tbm_surface, im, ns);
+ return _evas_native_tbm_surface_image_set(_tbm_surface, im, ns);
}
else
{
} ns_data; /**< Choose one union data according to your surface in Evas Engine. */
};
-EAPI void * evas_native_tbm_surface_image_set(void *data, void *image, void *native);
-
-typedef void *(*Evas_Native_Tbm_Surface_Image_Set_Call)(void *data, void *image, void *native);
+EAPI void *_evas_native_tbm_surface_image_set(void *data, void *image, void *native);
+EAPI int _evas_native_tbm_init(void);
+EAPI void _evas_native_tbm_shutdown(void);
+EAPI int _evas_native_tbm_surface_stride_get(void *data, void *native);
#endif //_EVAS_NATIVE_COMMON_H
static int (*sym_tbm_surface_unmap) (tbm_surface_h surface) = NULL;
static void (*sym_tbm_surface_internal_unref) (tbm_surface_h surface) = NULL;
static void (*sym_tbm_surface_internal_ref) (tbm_surface_h surface) = NULL;
+static int (*sym_tbm_surface_get_info) (tbm_surface_h surface, tbm_surface_info_s *info) = NULL;
-static Eina_Bool
-tbm_init(void)
+EAPI int
+_evas_native_tbm_init(void)
{
if (tbm_lib)
{
tbm_ref++;
- return EINA_TRUE;
+ return tbm_ref;
}
const char *tbm_libs[] =
"libtbm.so.0",
NULL,
};
-
int i, fail;
#define SYM(lib, xx) \
do { \
fail = 0;
SYM(tbm_lib, tbm_surface_map);
SYM(tbm_lib, tbm_surface_unmap);
+ SYM(tbm_lib, tbm_surface_get_info);
SYM(tbm_lib, tbm_surface_internal_unref);
SYM(tbm_lib, tbm_surface_internal_ref);
if (fail)
else break;
}
}
- if (!tbm_lib) return EINA_FALSE;
+ if (!tbm_lib) return 0;
tbm_ref++;
- return EINA_TRUE;
+ return tbm_ref;
}
-static void
-tbm_shutdown(void)
+EAPI void
+_evas_native_tbm_shutdown(void)
{
if (tbm_ref > 0)
{
tbm_ref--;
-
if (tbm_ref == 0)
{
if (tbm_lib)
rows = (const unsigned char **)evas_data;
- stride_y = EVAS_ROUND_UP_4(w);
- stride_uv = EVAS_ROUND_UP_8(w) / 2;
+ stride_y = w;
+ stride_uv = w / 2;
for (i = 0; i < rh; i++)
rows[i] = &source_data[i * stride_y];
- for (j = 0; j < (rh / 2); j++, i++)
+ for (j = 0; j < ((rh + 1) / 2); j++, i++)
rows[i] = &source_data[h * stride_y + j * stride_uv];
for (j = 0; j < (rh / 2); j++, i++)
rows[i] = &source_data[h * stride_y +
- (rh / 2) * stride_uv +
+ ((rh + 1) / 2) * stride_uv +
j * stride_uv];
}
ERR("Fail to tbm_surface_map()");
return;
}
-
- im->image.data = (DATA32 *)info.planes[0].ptr;
}
static void
else if (n->ns.type == EVAS_NATIVE_SURFACE_WL)
tbm_surf = n->ns_data.wl_surface.tbm_surface;
else
- return;
+ return;
if (sym_tbm_surface_unmap(tbm_surf))
{
tbm_surf = NULL;
if (tbm_surf)
- sym_tbm_surface_internal_unref(tbm_surf);
+ sym_tbm_surface_internal_unref(tbm_surf);
im->native.data = NULL;
im->native.func.bind = NULL;
im->native.func.data = NULL;
free(n);
- tbm_shutdown();
+ /*
+ _evas_native_tbm_shutdown();
+ */
}
+EAPI int
+_evas_native_tbm_surface_stride_get(void *data EINA_UNUSED, void *native)
+{
+ Evas_Native_Surface *ns = native;
+ tbm_surface_info_s info;
+ int stride;
+
+ if (!ns)
+ return -1;
+
+ if (sym_tbm_surface_get_info(ns->data.tbm.buffer, &info))
+ return -1;
+
+ stride = info.planes[0].stride;
+ return stride;
+ }
+
EAPI void *
-evas_native_tbm_surface_image_set(void *data, void *image, void *native)
+_evas_native_tbm_surface_image_set(void *data, void *image, void *native)
{
Evas_Native_Surface *ns = native;
RGBA_Image *im = image;
if (!tbm_surf) return NULL;
- if (!tbm_init())
+ /*
+ if (!_evas_native_tbm_init())
{
ERR("Could not initialize TBM!");
return NULL;
}
+ */
n = calloc(1, sizeof(Native));
if (!n) return NULL;
/* borrowing code from emotion here */
case TBM_FORMAT_YVU420: /* EVAS_COLORSPACE_YCBCR422P601_PL */
evas_cache_image_colorspace(&im->cache_entry, EVAS_COLORSPACE_YCBCR422P601_PL);
- _evas_video_yv12(im->cs.data, pixels_data, w, h, h);
+ _evas_video_yv12(im->cs.data, pixels_data, stride, h, h);
evas_common_image_colorspace_dirty(im);
break;
case TBM_FORMAT_YUV420: /* EVAS_COLORSPACE_YCBCR422P601_PL */
evas_cache_image_colorspace(&im->cache_entry, EVAS_COLORSPACE_YCBCR422P601_PL);
- _evas_video_i420(im->cs.data, pixels_data, w, h, h);
+ _evas_video_i420(im->cs.data, pixels_data, stride, h, h);
evas_common_image_colorspace_dirty(im);
break;
case TBM_FORMAT_NV12: /* EVAS_COLORSPACE_YCBCR420NV12601_PL */
evas_cache_image_colorspace(&im->cache_entry, EVAS_COLORSPACE_YCBCR420NV12601_PL);
- _evas_video_nv12(im->cs.data, pixels_data, w, h, h);
+ _evas_video_nv12(im->cs.data, pixels_data, stride, h, h);
evas_common_image_colorspace_dirty(im);
break;
/* Not planning to handle those in software */
re = _render_engine_ouput_setup(einfo, epd->output.w, epd->output.h);
if (re)
- re->generic.ob->info = einfo;
+ {
+ re->generic.ob->info = einfo;
+ /* init tbm native surface lib */
+ _evas_native_tbm_init();
+ }
else
goto err;
+
}
else
{
free(re);
}
+ /* shutdown tbm native surface lib */
+ _evas_native_tbm_shutdown();
+
if (tbm_server_lib)
{
dlclose(tbm_server_lib);
Evas_Native_Surface *ns = native;
Image_Entry *ie = image;
RGBA_Image *im = image, *im2 = NULL;
+ int stride = -1;
if (!im) return im;
EVAS_COLORSPACE_ARGB8888);
}
+ if (ns->type == EVAS_NATIVE_SURFACE_TBM)
+ {
+ stride = _evas_native_tbm_surface_stride_get(NULL, ns);
+ if (stride > -1)
+ im2 = (RGBA_Image *)evas_cache_image_copied_data(evas_common_image_cache_get(),
+ stride, ie->h, NULL, ie->flags.alpha,
+ EVAS_COLORSPACE_ARGB8888);
+ }
+ else
+ {
+ im2 = (RGBA_Image *)evas_cache_image_data(evas_common_image_cache_get(),
+ ie->w, ie->h,
+ NULL, 1,
+ EVAS_COLORSPACE_ARGB8888);
+ }
+
if (im->native.data)
{
if (im->native.func.free)
if (ns->type == EVAS_NATIVE_SURFACE_TBM)
{
- return evas_native_tbm_surface_image_set(NULL, im, ns);
+ return _evas_native_tbm_surface_image_set(NULL, im, ns);
}
else if (ns->type == EVAS_NATIVE_SURFACE_WL)
{
tbm_surface_get_info(_tbm_surface, &info);
- return evas_native_tbm_surface_image_set(_tbm_surface, im, ns);
+ return _evas_native_tbm_surface_image_set(_tbm_surface, im, ns);
}
else
{
# include <dlfcn.h>
#endif
-Evas_Native_Tbm_Surface_Image_Set_Call glsym_evas_native_tbm_surface_image_set = NULL;
int _evas_engine_soft_x11_log_dom = -1;
/* function tables - filled in later (func and parent func) */
#define LINK2GENERIC(sym) \
glsym_##sym = dlsym(RTLD_DEFAULT, #sym);
- // Get function pointer to native_common that is now provided through the link of SW_Generic.
- LINK2GENERIC(evas_native_tbm_surface_image_set);
-
done = 1;
}
#endif
e->engine.data.output = re;
+ /* init tbm native surface lib */
+ if (re)
+ {
+ _evas_native_tbm_init();
+ }
}
else
{
/* if ((re) && (re->ob)) re->ob->onebuf = ponebuf; */
}
if (!e->engine.data.output) return 0;
+
if (!e->engine.data.context)
{
e->engine.data.context =
free(re);
}
+ /* shutdown tbm native surface lib */
+ _evas_native_tbm_shutdown();
+
evas_common_shutdown();
}
Evas_Native_Surface *ns = native;
Image_Entry *ie = image, *ie2 = NULL;
RGBA_Image *im = image;
+ int stride = -1;
if (!im) return NULL;
if (!ns)
ie2 = evas_cache_image_data(evas_common_image_cache_get(),
ie->w, ie->h, ns->data.evasgl.surface, 1,
EVAS_COLORSPACE_ARGB8888);
+ else if (ns->type == EVAS_NATIVE_SURFACE_TBM)
+ {
+ stride = _evas_native_tbm_surface_stride_get(NULL, ns);
+ if (stride > -1)
+ ie2 = (RGBA_Image *)evas_cache_image_copied_data(evas_common_image_cache_get(),
+ stride, ie->h, NULL, ie->flags.alpha,
+ EVAS_COLORSPACE_ARGB8888);
+ }
else
ie2 = evas_cache_image_data(evas_common_image_cache_get(),
ie->w, ie->h, NULL, ie->flags.alpha,
}
else if (ns->type == EVAS_NATIVE_SURFACE_TBM)
{
- return glsym_evas_native_tbm_surface_image_set(re->generic.ob, ie, ns);
+ return evas_native_tbm_surface_image_set(re->generic.ob, ie, ns);
}
else if (ns->type == EVAS_NATIVE_SURFACE_EVASGL)
{
/* evas function tables - filled in later (func and parent func) */
static Evas_Func func, pfunc;
-Evas_Native_Tbm_Surface_Image_Set_Call glsym_evas_native_tbm_surface_image_set = NULL;
-
/* For wl_buffer's native set */
static void *tbm_server_lib = NULL;
typedef struct _tbm_surface * tbm_surface_h;
fail = 1; \
}
- // Get function pointer to native_common that is now provided through the link of SW_Generic.
- LINK2GENERIC(RTLD_DEFAULT, evas_native_tbm_surface_image_set);
- if (fail == 1)
- {
- ERR("fail to dlsym about evas_native_tbm_surface_image_set symbol");
- return;
- }
tbm_server_lib = dlopen(wayland_tbm_server_lib, RTLD_LOCAL | RTLD_LAZY);
if (tbm_server_lib)
{
re = _render_engine_swapbuf_setup(epd->output.w, epd->output.h, einfo);
if (re)
- re->generic.ob->info = einfo;
+ {
+ re->generic.ob->info = einfo;
+ /* init tbm native surface lib */
+ _evas_native_tbm_init();
+ }
else
goto err;
}
free(re);
}
+ /* shutdown tbm native surface lib */
+ _evas_native_tbm_shutdown();
+
if (tbm_server_lib)
{
dlclose(tbm_server_lib);
RGBA_Image *im = image;
RGBA_Image *im2 = NULL;
void *wl_buf = NULL;
+ int stride = -1;
if (!im) return im;
ie->w, ie->h,
ns->data.x11.visual, 1,
EVAS_COLORSPACE_ARGB8888);
+ else if (ns->type == EVAS_NATIVE_SURFACE_TBM)
+ {
+ stride = _evas_native_tbm_surface_stride_get(NULL, ns);
+ if (stride > -1)
+ im2 = (RGBA_Image *)evas_cache_image_copied_data(evas_common_image_cache_get(),
+ stride, ie->h, NULL, ie->flags.alpha,
+ EVAS_COLORSPACE_ARGB8888);
+ }
else
im2 = (RGBA_Image *)evas_cache_image_data(evas_common_image_cache_get(),
ie->w, ie->h,
if (ns->type == EVAS_NATIVE_SURFACE_TBM)
{
- if (glsym_evas_native_tbm_surface_image_set)
- return glsym_evas_native_tbm_surface_image_set(NULL, im, ns);
- else
- return NULL;
+ return _evas_native_tbm_surface_image_set(NULL, im, ns);
}
else if (ns->type == EVAS_NATIVE_SURFACE_WL)
{
// TODO : need the code for all wl_buffer type
// First of all, for TBM surface
- if (glsym_wayland_tbm_server_get_surface && glsym_evas_native_tbm_surface_image_set)
+ if (glsym_wayland_tbm_server_get_surface)
{
tbm_surface_h _tbm_surface;
_tbm_surface = glsym_wayland_tbm_server_get_surface(NULL,ns->data.wl.legacy_buffer);
- return glsym_evas_native_tbm_surface_image_set(_tbm_surface, im, ns);
+ return _evas_native_tbm_surface_image_set(_tbm_surface, im, ns);
}
else
{