change native api to allow for other types of native data like texture

id's, fbo's etc. too - at least it's versioned now.



SVN revision: 55315
This commit is contained in:
Carsten Haitzler 2010-12-06 07:09:51 +00:00
parent 157bf3a573
commit 640a4030f3
3 changed files with 326 additions and 265 deletions

View File

@ -339,16 +339,32 @@ struct _Evas_Pixel_Import_Source
void **rows; /**< an array of pointers (size depends on format) pointing to left edge of each scanline */
};
/* magic version number to know what the native surf struct looks like */
#define EVAS_NATIVE_SURFACE_VERSION 2
typedef enum _Evas_Native_Surface_Type
{
EVAS_NATIVE_SURFACE_NONE,
EVAS_NATIVE_SURFACE_X11,
EVAS_NATIVE_SURFACE_OPENGL
} Evas_Native_Surface_Type;
struct _Evas_Native_Surface
{
int version;
Evas_Native_Surface_Type type;
union {
struct {
void *visual;
unsigned long pixmap;
void *visual; /**< visual of the pixmap to use (Visual) */
unsigned long pixmap; /**< pixmap id to use (Pixmap) */
} x11;
struct { /* padding data for future use - have space for 8 pointers */
void *d[8];
} padding;
struct {
unsigned int texture_id; /**< opengl texture id to use from glGenTextures() */
unsigned int framebuffer_id; /**< 0 if not a FBO, FBO id otherwise from glGenFramebuffers() */
unsigned int internal_format; /**< same as 'internalFormat' for glTexImage2D() */
unsigned int format; /**< same as 'format' for glTexImage2D() */
unsigned int x, y, w, h; /**< region inside the texture to use (image size is assumed as texture size, with 0, 0 being the top-left and co-ordinates working down to the right and bottom being positive) */
} opengl;
} data;
};

View File

@ -1896,6 +1896,8 @@ evas_object_image_native_surface_set(Evas_Object *obj, Evas_Native_Surface *surf
return;
MAGIC_CHECK_END();
if (!obj->layer->evas->engine.func->image_native_set) return;
if ((surf->version < 2) ||
(surf->version > EVAS_NATIVE_SURFACE_VERSION)) return;
o->engine_data =
obj->layer->evas->engine.func->image_native_set(obj->layer->evas->engine.data.output,
o->engine_data,

View File

@ -1007,6 +1007,8 @@ _native_bind_cb(void *data, void *image)
Evas_GL_Image *im = image;
Native *n = im->native.data;
if (n->ns.type == EVAS_NATIVE_SURFACE_X11)
{
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
if (n->egl_surface)
{
@ -1034,18 +1036,25 @@ _native_bind_cb(void *data, void *image)
# endif
#endif
}
else if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL)
{
// FIXME: implement
}
}
static void
_native_unbind_cb(void *data, void *image)
{
Evas_GL_Image *im = image;
Native *n = im->native.data;
if (n->ns.type == EVAS_NATIVE_SURFACE_X11)
{
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
// nothing
#else
# ifdef GLX_BIND_TO_TEXTURE_TARGETS_EXT
Render_Engine *re = data;
Native *n = im->native.data;
if (glsym_glXReleaseTexImage)
{
@ -1058,6 +1067,11 @@ _native_unbind_cb(void *data, void *image)
# endif
#endif
}
else if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL)
{
// FIXME: implement
}
}
static void
_native_free_cb(void *data, void *image)
@ -1067,6 +1081,8 @@ _native_free_cb(void *data, void *image)
Native *n = im->native.data;
uint32_t pmid;
if (n->ns.type == EVAS_NATIVE_SURFACE_X11)
{
pmid = n->pixmap;
eina_hash_del(re->win->gl_context->shared->native_hash, &pmid, im);
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
@ -1108,6 +1124,11 @@ _native_free_cb(void *data, void *image)
}
# endif
#endif
}
else if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL)
{
// FIXME: implement
}
im->native.data = NULL;
im->native.func.data = NULL;
im->native.func.bind = NULL;
@ -1130,6 +1151,8 @@ eng_image_native_set(void *data, void *image, void *native)
if (!im) return NULL;
if (ns)
{
if (ns->type == EVAS_NATIVE_SURFACE_X11)
{
vis = ns->data.x11.visual;
pm = ns->data.x11.pixmap;
@ -1140,6 +1163,11 @@ eng_image_native_set(void *data, void *image, void *native)
return im;
}
}
else if (ns->type == EVAS_NATIVE_SURFACE_OPENGL)
{
// FIXME: implement
}
}
if ((!ns) && (!im->native.data)) return im;
eng_window_use(re->win);
@ -1151,6 +1179,8 @@ eng_image_native_set(void *data, void *image, void *native)
evas_gl_common_image_native_disable(im);
}
if (ns->type == EVAS_NATIVE_SURFACE_X11)
{
pmid = pm;
im2 = eina_hash_find(re->win->gl_context->shared->native_hash, &pmid);
if (im2 == im) return im;
@ -1164,11 +1194,18 @@ eng_image_native_set(void *data, void *image, void *native)
return im2;
}
}
}
else if (ns->type == EVAS_NATIVE_SURFACE_OPENGL)
{
// FIXME: implement
}
im2 = evas_gl_common_image_new_from_data(re->win->gl_context,
im->w, im->h, NULL, im->alpha,
EVAS_COLORSPACE_ARGB8888);
evas_gl_common_image_free(im);
im = im2;
if (ns->type == EVAS_NATIVE_SURFACE_X11)
{
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
if (native)
{
@ -1202,6 +1239,7 @@ eng_image_native_set(void *data, void *image, void *native)
if (!eglChooseConfig(re->win->egl_disp, config_attrs,
&egl_config, 1, &num_config))
ERR("eglChooseConfig() failed for pixmap 0x%x, num_config = %i", (unsigned int)pm, num_config);
memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface));
n->pixmap = pm;
n->visual = vis;
if (glsym_eglCreateImage)
@ -1340,6 +1378,11 @@ eng_image_native_set(void *data, void *image, void *native)
}
# endif
#endif
}
else if (ns->type == EVAS_NATIVE_SURFACE_OPENGL)
{
// FIXME: implement
}
return im;
}