forked from enlightenment/efl
ok. work on native pixmap suppport. have problmes - not sure why. see
comments (create/destory glx pixmap needed for updates to work, but this makes rendering dead-slow. without it rendering is fast, but updates dont happen (useless). anyone know why glxcreatepixmap is needed as well as bindteximage+release (and destroy pixmap) vs just bind/unbind? SVN revision: 45508
This commit is contained in:
parent
f5ab46c84e
commit
b06b71050a
|
@ -199,6 +199,7 @@ struct _Evas_GL_Image
|
|||
void *data;
|
||||
} func;
|
||||
unsigned char yinvert : 1;
|
||||
unsigned char loose : 1;
|
||||
} native;
|
||||
|
||||
unsigned char dirty : 1;
|
||||
|
@ -293,7 +294,7 @@ void evas_gl_common_shader_program_init(Evas_GL_Program *p,
|
|||
void evas_gl_common_rect_draw(Evas_GL_Context *gc, int x, int y, int w, int h);
|
||||
|
||||
Evas_GL_Texture *evas_gl_common_texture_new(Evas_GL_Context *gc, RGBA_Image *im);
|
||||
Evas_GL_Texture *evas_gl_common_texture_native_new(Evas_GL_Context *gc, int w, int h, int alpha);
|
||||
Evas_GL_Texture *evas_gl_common_texture_native_new(Evas_GL_Context *gc, int w, int h, int alpha, Evas_GL_Image *im);
|
||||
Evas_GL_Texture *evas_gl_common_texture_render_new(Evas_GL_Context *gc, int w, int h, int alpha);
|
||||
void evas_gl_common_texture_update(Evas_GL_Texture *tex, RGBA_Image *im);
|
||||
void evas_gl_common_texture_free(Evas_GL_Texture *tex);
|
||||
|
|
|
@ -905,6 +905,8 @@ shader_array_flush(Evas_GL_Context *gc)
|
|||
|
||||
if (gc->shader.cur_tex != gc->shader.current.cur_tex)
|
||||
{
|
||||
if (gc->shader.cur_tex) glEnable(GL_TEXTURE_2D);
|
||||
else glDisable(GL_TEXTURE_2D);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, gc->shader.cur_tex);
|
||||
}
|
||||
|
@ -943,10 +945,8 @@ shader_array_flush(Evas_GL_Context *gc)
|
|||
}
|
||||
if (gc->shader.blend != gc->shader.current.blend)
|
||||
{
|
||||
if (gc->shader.blend)
|
||||
glEnable(GL_BLEND);
|
||||
else
|
||||
glDisable(GL_BLEND);
|
||||
if (gc->shader.blend) glEnable(GL_BLEND);
|
||||
else glDisable(GL_BLEND);
|
||||
}
|
||||
if (gc->shader.smooth != gc->shader.current.smooth)
|
||||
{
|
||||
|
@ -1049,6 +1049,12 @@ shader_array_flush(Evas_GL_Context *gc)
|
|||
if (gc->array.im->native.func.unbind)
|
||||
gc->array.im->native.func.unbind(gc->array.im->native.func.data,
|
||||
gc->array.im);
|
||||
/*
|
||||
gc->shader.cur_tex = 0;
|
||||
glBindTexture(GL_TEXTURE_2D, gc->shader.cur_tex);
|
||||
if (gc->shader.cur_tex) glEnable(GL_TEXTURE_2D);
|
||||
else glDisable(GL_TEXTURE_2D);
|
||||
*/
|
||||
}
|
||||
|
||||
gc->shader.current.cur_prog = gc->shader.cur_prog;
|
||||
|
|
|
@ -200,7 +200,7 @@ evas_gl_common_image_native_enable(Evas_GL_Image *im)
|
|||
}
|
||||
|
||||
im->cs.space = EVAS_COLORSPACE_ARGB8888;
|
||||
im->tex = evas_gl_common_texture_native_new(im->gc, im->w, im->h, im->alpha);
|
||||
im->tex = evas_gl_common_texture_native_new(im->gc, im->w, im->h, im->alpha, im);
|
||||
im->tex_only = 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -306,7 +306,7 @@ _pool_tex_render_new(Evas_GL_Context *gc, int w, int h, int intformat, int forma
|
|||
}
|
||||
|
||||
static Evas_GL_Texture_Pool *
|
||||
_pool_tex_native_new(Evas_GL_Context *gc, int w, int h, int intformat, int format)
|
||||
_pool_tex_native_new(Evas_GL_Context *gc, int w, int h, int intformat, int format, Evas_GL_Image *im)
|
||||
{
|
||||
Evas_GL_Texture_Pool *pt;
|
||||
|
||||
|
@ -327,12 +327,19 @@ _pool_tex_native_new(Evas_GL_Context *gc, int w, int h, int intformat, int forma
|
|||
// is this really needed for gl-es?
|
||||
// glTexImage2D(GL_TEXTURE_2D, 0, intformat, w, h, 0, format,
|
||||
// GL_UNSIGNED_BYTE, 0);
|
||||
#else
|
||||
if (im->native.loose)
|
||||
{
|
||||
if (im->native.func.bind)
|
||||
im->native.func.bind(im->native.func.data, im);
|
||||
}
|
||||
#endif
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glBindTexture(GL_TEXTURE_2D, gc->shader.cur_tex);
|
||||
return pt;
|
||||
}
|
||||
|
@ -356,7 +363,7 @@ pt_unref(Evas_GL_Texture_Pool *pt)
|
|||
}
|
||||
|
||||
Evas_GL_Texture *
|
||||
evas_gl_common_texture_native_new(Evas_GL_Context *gc, int w, int h, int alpha)
|
||||
evas_gl_common_texture_native_new(Evas_GL_Context *gc, int w, int h, int alpha, Evas_GL_Image *im)
|
||||
{
|
||||
Evas_GL_Texture *tex;
|
||||
Eina_List *l_after = NULL;
|
||||
|
@ -369,9 +376,9 @@ evas_gl_common_texture_native_new(Evas_GL_Context *gc, int w, int h, int alpha)
|
|||
tex->references = 1;
|
||||
tex->alpha = alpha;
|
||||
if (alpha)
|
||||
tex->pt = _pool_tex_native_new(gc, w, h, rgba_ifmt, rgba_fmt);
|
||||
tex->pt = _pool_tex_native_new(gc, w, h, rgba_ifmt, rgba_fmt, im);
|
||||
else
|
||||
tex->pt = _pool_tex_native_new(gc, w, h, rgb_ifmt, rgb_fmt);
|
||||
tex->pt = _pool_tex_native_new(gc, w, h, rgb_ifmt, rgb_fmt, im);
|
||||
if (!tex->pt)
|
||||
{
|
||||
free(tex);
|
||||
|
|
|
@ -1024,6 +1024,15 @@ struct _Native
|
|||
#endif
|
||||
};
|
||||
|
||||
// FIXME: this is enabled so updates happen - but its SLOOOOOOOOOOOOOOOW
|
||||
// (i am sure this is the reason) not to mention seemingly superfluous. but
|
||||
// i need to enable it for it to work on fglrx at least. havent tried nvidia.
|
||||
//
|
||||
// why is this the case? does anyone know? has anyone tried it on other gfx
|
||||
// drivers?
|
||||
//
|
||||
//#define GLX_TEX_PIXMAP_RECREATE 1
|
||||
|
||||
static void
|
||||
_native_bind_cb(void *data, void *image)
|
||||
{
|
||||
|
@ -1040,6 +1049,7 @@ _native_bind_cb(void *data, void *image)
|
|||
# ifdef GLX_BIND_TO_TEXTURE_TARGETS_EXT
|
||||
if (glsym_glXBindTexImage)
|
||||
{
|
||||
#ifdef GLX_TEX_PIXMAP_RECREATE
|
||||
const int pixmap_att[] =
|
||||
{
|
||||
GLX_TEXTURE_TARGET_EXT,
|
||||
|
@ -1051,8 +1061,10 @@ _native_bind_cb(void *data, void *image)
|
|||
|
||||
n->glx_pixmap = glXCreatePixmap(re->win->disp, n->fbc,
|
||||
n->pixmap, pixmap_att);
|
||||
glsym_glXBindTexImage(re->win->disp, n->glx_pixmap,
|
||||
GLX_FRONT_LEFT_EXT, NULL);
|
||||
#endif
|
||||
if (!im->native.loose)
|
||||
glsym_glXBindTexImage(re->win->disp, n->glx_pixmap,
|
||||
GLX_FRONT_LEFT_EXT, NULL);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
@ -1074,10 +1086,13 @@ _native_unbind_cb(void *data, void *image)
|
|||
# ifdef GLX_BIND_TO_TEXTURE_TARGETS_EXT
|
||||
if (glsym_glXReleaseTexImage)
|
||||
{
|
||||
glsym_glXReleaseTexImage(re->win->disp, n->glx_pixmap,
|
||||
GLX_FRONT_LEFT_EXT);
|
||||
if (!im->native.loose)
|
||||
glsym_glXReleaseTexImage(re->win->disp, n->glx_pixmap,
|
||||
GLX_FRONT_LEFT_EXT);
|
||||
#ifdef GLX_TEX_PIXMAP_RECREATE
|
||||
glXDestroyPixmap(re->win->disp, n->glx_pixmap);
|
||||
n->glx_pixmap = 0;
|
||||
#endif
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
@ -1100,8 +1115,12 @@ _native_free_cb(void *data, void *image)
|
|||
# ifdef GLX_BIND_TO_TEXTURE_TARGETS_EXT
|
||||
if (n->glx_pixmap)
|
||||
{
|
||||
glsym_glXReleaseTexImage(re->win->disp, n->glx_pixmap,
|
||||
GLX_FRONT_LEFT_EXT);
|
||||
if (im->native.loose)
|
||||
{
|
||||
if (glsym_glXReleaseTexImage)
|
||||
glsym_glXReleaseTexImage(re->win->disp, n->glx_pixmap,
|
||||
GLX_FRONT_LEFT_EXT);
|
||||
}
|
||||
glXDestroyPixmap(re->win->disp, n->glx_pixmap);
|
||||
n->glx_pixmap = 0;
|
||||
}
|
||||
|
@ -1176,18 +1195,19 @@ eng_image_native_set(void *data, void *image, void *native)
|
|||
|
||||
eglChooseConfig(re->win->egl_disp, config_attrs,
|
||||
&egl_config, 1, &num_config);
|
||||
n->egl_surface = eglCreatePixmapSurface(re->win->egl_disp,
|
||||
egl_config, pm,
|
||||
NULL);
|
||||
evas_gl_common_image_native_enable(im);
|
||||
n->pixmap = pm;
|
||||
n->visual = vis;
|
||||
im->native.yinvert = 1;
|
||||
im->native.loose = 0;
|
||||
im->native.data = n;
|
||||
im->native.func.data = re;
|
||||
im->native.func.bind = _native_bind_cb;
|
||||
im->native.func.unbind = _native_unbind_cb;
|
||||
im->native.func.free = _native_free_cb;
|
||||
n->egl_surface = eglCreatePixmapSurface(re->win->egl_disp,
|
||||
egl_config, pm,
|
||||
NULL);
|
||||
evas_gl_common_image_native_enable(im);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
@ -1254,18 +1274,33 @@ eng_image_native_set(void *data, void *image, void *native)
|
|||
n = calloc(1, sizeof(Native));
|
||||
if (n)
|
||||
{
|
||||
evas_gl_common_image_native_enable(im);
|
||||
#ifndef GLX_TEX_PIXMAP_RECREATE
|
||||
const int pixmap_att[] =
|
||||
{
|
||||
GLX_TEXTURE_TARGET_EXT,
|
||||
GLX_TEXTURE_2D_EXT,
|
||||
GLX_TEXTURE_FORMAT_EXT,
|
||||
GLX_TEXTURE_FORMAT_RGBA_EXT,
|
||||
0
|
||||
};
|
||||
#endif
|
||||
memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface));
|
||||
n->pixmap = pm;
|
||||
n->visual = vis;
|
||||
memcpy(&(n->fbc), fbc, sizeof(GLXFBConfig));
|
||||
n->fbc = *fbc;
|
||||
im->native.yinvert = yinvert;
|
||||
im->native.loose = 0;
|
||||
im->native.data = n;
|
||||
im->native.func.data = re;
|
||||
im->native.func.bind = _native_bind_cb;
|
||||
im->native.func.unbind = _native_unbind_cb;
|
||||
im->native.func.free = _native_free_cb;
|
||||
#ifndef GLX_TEX_PIXMAP_RECREATE
|
||||
n->glx_pixmap = glXCreatePixmap(re->win->disp, n->fbc,
|
||||
n->pixmap, pixmap_att);
|
||||
#endif
|
||||
evas_gl_common_image_native_enable(im);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -133,15 +133,9 @@ eng_window_new(Display *disp,
|
|||
}
|
||||
// GLX
|
||||
#else
|
||||
|
||||
#if 1
|
||||
if (!context)
|
||||
context = glXCreateContext(disp, gw->visualinfo, NULL, GL_TRUE);
|
||||
gw->context = context;
|
||||
#else
|
||||
gw->context = glXCreateContext(disp, gw->visualinfo, context, GL_TRUE);
|
||||
if (!context) context = gw->context;
|
||||
#endif
|
||||
|
||||
glXMakeCurrent(gw->disp, gw->win, gw->context);
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue