forked from enlightenment/efl
native surface support lives - for GL (GLX) only. it works - or seemingly
does in my test casses. doesn't work for compositing though! don't know why. SVN revision: 45383
This commit is contained in:
parent
7c3f53b364
commit
ad2b33c0bb
|
@ -414,10 +414,13 @@ struct _Evas_Pixel_Import_Source
|
|||
struct _Evas_Native_Surface
|
||||
{
|
||||
union {
|
||||
void *p;
|
||||
unsigned short s;
|
||||
unsigned int i;
|
||||
unsigned long l;
|
||||
struct {
|
||||
void *visual;
|
||||
long pixmap;
|
||||
} x11;
|
||||
struct { /* padding data for future use - have space for 8 pointers */
|
||||
void *d[8];
|
||||
} padding;
|
||||
} data;
|
||||
};
|
||||
|
||||
|
|
|
@ -140,6 +140,7 @@ struct _Evas_GL_Context
|
|||
Eina_Bool use_texuv : 1;
|
||||
Eina_Bool use_texuv2 : 1;
|
||||
Eina_Bool use_texuv3 : 1;
|
||||
Evas_GL_Image *im;
|
||||
} array;
|
||||
struct {
|
||||
Eina_Bool size : 1;
|
||||
|
@ -163,6 +164,7 @@ struct _Evas_GL_Texture_Pool
|
|||
struct _Evas_GL_Texture
|
||||
{
|
||||
Evas_GL_Context *gc;
|
||||
Evas_GL_Image *im;
|
||||
Evas_GL_Texture_Pool *pt, *ptu, *ptv;
|
||||
int x, y, w, h;
|
||||
double sx1, sy1, sx2, sy2;
|
||||
|
@ -185,6 +187,18 @@ struct _Evas_GL_Image
|
|||
void *data;
|
||||
unsigned char no_free : 1;
|
||||
} cs;
|
||||
|
||||
struct {
|
||||
void *data;
|
||||
struct {
|
||||
void (*bind) (void *data, void *image);
|
||||
void (*unbind) (void *data, void *image);
|
||||
void (*free) (void *data, void *image);
|
||||
void *data;
|
||||
} func;
|
||||
unsigned char yinvert : 1;
|
||||
} native;
|
||||
|
||||
unsigned char dirty : 1;
|
||||
unsigned char cached : 1;
|
||||
unsigned char alpha : 1;
|
||||
|
@ -248,7 +262,7 @@ void evas_gl_common_context_image_push(Evas_GL_Context *gc,
|
|||
double sx, double sy, double sw, double sh,
|
||||
int x, int y, int w, int h,
|
||||
int r, int g, int b, int a,
|
||||
Eina_Bool smooth);
|
||||
Eina_Bool smooth, Eina_Bool tex_only);
|
||||
void evas_gl_common_context_font_push(Evas_GL_Context *gc,
|
||||
Evas_GL_Texture *tex,
|
||||
double sx, double sy, double sw, double sh,
|
||||
|
@ -277,6 +291,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_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);
|
||||
|
@ -289,6 +304,8 @@ Evas_GL_Image *evas_gl_common_image_load(Evas_GL_Context *gc, const char *fil
|
|||
Evas_GL_Image *evas_gl_common_image_new_from_data(Evas_GL_Context *gc, int w, int h, DATA32 *data, int alpha, int cspace);
|
||||
Evas_GL_Image *evas_gl_common_image_new_from_copied_data(Evas_GL_Context *gc, int w, int h, DATA32 *data, int alpha, int cspace);
|
||||
Evas_GL_Image *evas_gl_common_image_new(Evas_GL_Context *gc, int w, int h, int alpha, int cspace);
|
||||
void evas_gl_common_image_native_enable(Evas_GL_Image *im);
|
||||
void evas_gl_common_image_native_disable(Evas_GL_Image *im);
|
||||
void evas_gl_common_image_free(Evas_GL_Image *im);
|
||||
Evas_GL_Image *evas_gl_common_image_surface_new(Evas_GL_Context *gc, int w, int h, int alpha);
|
||||
void evas_gl_common_image_dirty(Evas_GL_Image *im, int x, int y, int w, int h);
|
||||
|
|
|
@ -24,18 +24,22 @@ gl_symbols(void)
|
|||
|
||||
FINDSYM(glsym_glGenFramebuffers, "glGenFramebuffers");
|
||||
FINDSYM(glsym_glGenFramebuffers, "glGenFramebuffersEXT");
|
||||
FINDSYM(glsym_glGenFramebuffers, "glGenFramebuffersARB");
|
||||
FALLBAK(glsym_glGenFramebuffers);
|
||||
|
||||
FINDSYM(glsym_glBindFramebuffer, "glBindFramebuffer");
|
||||
FINDSYM(glsym_glBindFramebuffer, "glBindFramebufferEXT");
|
||||
FINDSYM(glsym_glBindFramebuffer, "glBindFramebufferARB");
|
||||
FALLBAK(glsym_glBindFramebuffer);
|
||||
|
||||
FINDSYM(glsym_glFramebufferTexture2D, "glFramebufferTexture2D");
|
||||
FINDSYM(glsym_glFramebufferTexture2D, "glFramebufferTexture2DEXT");
|
||||
FINDSYM(glsym_glFramebufferTexture2D, "glFramebufferTexture2DARB");
|
||||
FALLBAK(glsym_glFramebufferTexture2D);
|
||||
|
||||
FINDSYM(glsym_glDeleteFramebuffers, "glDeleteFramebuffers");
|
||||
FINDSYM(glsym_glDeleteFramebuffers, "glDeleteFramebuffersEXT");
|
||||
FINDSYM(glsym_glDeleteFramebuffers, "glDeleteFramebuffersARB");
|
||||
FALLBAK(glsym_glDeleteFramebuffers);
|
||||
}
|
||||
|
||||
|
@ -513,7 +517,7 @@ evas_gl_common_context_image_push(Evas_GL_Context *gc,
|
|||
double sx, double sy, double sw, double sh,
|
||||
int x, int y, int w, int h,
|
||||
int r, int g, int b, int a,
|
||||
Eina_Bool smooth)
|
||||
Eina_Bool smooth, Eina_Bool tex_only)
|
||||
{
|
||||
int pnum, nv, nc, nu, nu2, nt, i;
|
||||
GLfloat tx1, tx2, ty1, ty2;
|
||||
|
@ -526,7 +530,8 @@ evas_gl_common_context_image_push(Evas_GL_Context *gc,
|
|||
gc->shader.blend = 1;
|
||||
|
||||
if ((gc->shader.cur_tex != tex->pt->texture)
|
||||
|| (gc->shader.cur_prog != gc->shared->shader.img.prog)
|
||||
|| ((tex_only) && (gc->shader.cur_prog != gc->shared->shader.tex.prog))
|
||||
|| ((!tex_only) && (gc->shader.cur_prog != gc->shared->shader.img.prog))
|
||||
|| (gc->shader.smooth != smooth)
|
||||
// || (gc->shader.blend != blend)
|
||||
|| (gc->shader.render_op != gc->dc->render_op)
|
||||
|
@ -535,18 +540,27 @@ evas_gl_common_context_image_push(Evas_GL_Context *gc,
|
|||
{
|
||||
shader_array_flush(gc);
|
||||
gc->shader.cur_tex = tex->pt->texture;
|
||||
gc->shader.cur_prog = gc->shared->shader.img.prog;
|
||||
if (tex_only)
|
||||
gc->shader.cur_prog = gc->shared->shader.tex.prog;
|
||||
else
|
||||
gc->shader.cur_prog =gc->shared->shader.img.prog;
|
||||
gc->shader.smooth = smooth;
|
||||
gc->shader.blend = 1;
|
||||
gc->shader.render_op = gc->dc->render_op;
|
||||
gc->shader.clip = 0;
|
||||
}
|
||||
if ((tex->im) && (tex->im->native.data))
|
||||
{
|
||||
shader_array_flush(gc);
|
||||
gc->array.im = tex->im;
|
||||
}
|
||||
gc->array.line = 0;
|
||||
gc->array.use_vertex = 1;
|
||||
gc->array.use_color = 1;
|
||||
gc->array.use_texuv = 1;
|
||||
gc->array.use_texuv2 = 1;
|
||||
gc->array.use_texuv3 = 0;
|
||||
|
||||
|
||||
pnum = gc->array.num;
|
||||
nv = pnum * 3; nc = pnum * 4; nu = pnum * 2; nu2 = pnum * 2;
|
||||
|
@ -589,6 +603,12 @@ evas_gl_common_context_image_push(Evas_GL_Context *gc,
|
|||
{
|
||||
PUSH_COLOR(r, g, b, a);
|
||||
}
|
||||
|
||||
if ((tex->im) && (tex->im->native.data))
|
||||
{
|
||||
shader_array_flush(gc);
|
||||
gc->array.im = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -877,6 +897,12 @@ shader_array_flush(Evas_GL_Context *gc)
|
|||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, gc->shader.cur_tex);
|
||||
}
|
||||
if (gc->array.im)
|
||||
{
|
||||
if (gc->array.im->native.func.bind)
|
||||
gc->array.im->native.func.bind(gc->array.im->native.func.data,
|
||||
gc->array.im);
|
||||
}
|
||||
if (gc->shader.render_op != gc->shader.current.render_op)
|
||||
{
|
||||
switch (gc->shader.render_op)
|
||||
|
@ -1007,6 +1033,13 @@ shader_array_flush(Evas_GL_Context *gc)
|
|||
|
||||
glDrawArrays(GL_TRIANGLES, 0, gc->array.num);
|
||||
}
|
||||
if (gc->array.im)
|
||||
{
|
||||
if (gc->array.im->native.func.unbind)
|
||||
gc->array.im->native.func.unbind(gc->array.im->native.func.data,
|
||||
gc->array.im);
|
||||
}
|
||||
|
||||
gc->shader.current.cur_prog = gc->shader.cur_prog;
|
||||
gc->shader.current.cur_tex = gc->shader.cur_tex;
|
||||
gc->shader.current.blend = gc->shader.blend;
|
||||
|
|
|
@ -91,10 +91,6 @@ evas_gl_common_image_new_from_data(Evas_GL_Context *gc, int w, int h, DATA32 *da
|
|||
abort();
|
||||
break;
|
||||
}
|
||||
/*
|
||||
im->cached = 1;
|
||||
gc->shared->images = eina_list_prepend(gc->shared->images, im);
|
||||
*/
|
||||
return im;
|
||||
}
|
||||
|
||||
|
@ -178,12 +174,67 @@ evas_gl_common_image_new(Evas_GL_Context *gc, int w, int h, int alpha, int cspac
|
|||
return im;
|
||||
}
|
||||
|
||||
void
|
||||
evas_gl_common_image_native_enable(Evas_GL_Image *im)
|
||||
{
|
||||
if (im->cs.data)
|
||||
{
|
||||
if (!im->cs.no_free) free(im->cs.data);
|
||||
im->cs.data = NULL;
|
||||
}
|
||||
im->cs.no_free = 0;
|
||||
if (im->cached)
|
||||
{
|
||||
im->gc->shared->images = eina_list_remove(im->gc->shared->images, im);
|
||||
im->cached = 0;
|
||||
}
|
||||
if (im->im)
|
||||
{
|
||||
evas_cache_image_drop(&im->im->cache_entry);
|
||||
im->im = NULL;
|
||||
}
|
||||
if (im->tex)
|
||||
{
|
||||
evas_gl_common_texture_free(im->tex);
|
||||
im->tex = NULL;
|
||||
}
|
||||
|
||||
im->cs.space = EVAS_COLORSPACE_ARGB8888;
|
||||
im->tex = evas_gl_common_texture_native_new(im->gc, im->w, im->h, im->alpha);
|
||||
im->tex_only = 1;
|
||||
}
|
||||
|
||||
void
|
||||
evas_gl_common_image_native_disable(Evas_GL_Image *im)
|
||||
{
|
||||
if (im->im)
|
||||
{
|
||||
evas_cache_image_drop(&im->im->cache_entry);
|
||||
im->im = NULL;
|
||||
}
|
||||
if (im->tex)
|
||||
{
|
||||
evas_gl_common_texture_free(im->tex);
|
||||
im->tex = NULL;
|
||||
}
|
||||
im->tex_only = 0;
|
||||
|
||||
im->im = (RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get());
|
||||
im->im->cache_entry.flags.alpha = im->alpha;
|
||||
im->cs.space = EVAS_COLORSPACE_ARGB8888;
|
||||
evas_cache_image_colorspace(&im->im->cache_entry, im->cs.space);
|
||||
im->im = (RGBA_Image *)evas_cache_image_size_set(&im->im->cache_entry, im->w, im->h);
|
||||
}
|
||||
|
||||
void
|
||||
evas_gl_common_image_free(Evas_GL_Image *im)
|
||||
{
|
||||
im->references--;
|
||||
if (im->references > 0) return;
|
||||
|
||||
|
||||
if (im->native.func.free)
|
||||
im->native.func.free(im->native.func.data, im);
|
||||
|
||||
if (im->cs.data)
|
||||
{
|
||||
if (!im->cs.no_free) free(im->cs.data);
|
||||
|
@ -317,6 +368,7 @@ evas_gl_common_image_map4_draw(Evas_GL_Context *gc, Evas_GL_Image *im,
|
|||
c = gc->dc->clip.use;
|
||||
cx = gc->dc->clip.x; cy = gc->dc->clip.y;
|
||||
cw = gc->dc->clip.w; ch = gc->dc->clip.h;
|
||||
im->tex->im = im;
|
||||
evas_gl_common_context_image_map4_push(gc, im->tex, p,
|
||||
c, cx, cy, cw, ch,
|
||||
r, g, b, a, smooth, im->tex_only);
|
||||
|
@ -355,6 +407,7 @@ evas_gl_common_image_draw(Evas_GL_Context *gc, Evas_GL_Image *im, int sx, int sy
|
|||
(im->cs.space == EVAS_COLORSPACE_YCBCR422P709_PL))
|
||||
yuv = 1;
|
||||
|
||||
im->tex->im = im;
|
||||
if ((!gc->dc->cutout.rects)
|
||||
// || (gc->dc->cutout.active > 32)
|
||||
)
|
||||
|
@ -383,7 +436,7 @@ evas_gl_common_image_draw(Evas_GL_Context *gc, Evas_GL_Image *im, int sx, int sy
|
|||
sx, sy, sw, sh,
|
||||
dx, dy, dw, dh,
|
||||
r, g, b, a,
|
||||
smooth);
|
||||
smooth, im->tex_only);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -404,7 +457,7 @@ evas_gl_common_image_draw(Evas_GL_Context *gc, Evas_GL_Image *im, int sx, int sy
|
|||
ssx, ssy, ssw, ssh,
|
||||
nx, ny, nw, nh,
|
||||
r, g, b, a,
|
||||
smooth);
|
||||
smooth, im->tex_only);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -421,7 +474,7 @@ evas_gl_common_image_draw(Evas_GL_Context *gc, Evas_GL_Image *im, int sx, int sy
|
|||
sx, sy, sw, sh,
|
||||
dx, dy, dw, dh,
|
||||
r, g, b, a,
|
||||
smooth);
|
||||
smooth, im->tex_only);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -460,7 +513,7 @@ evas_gl_common_image_draw(Evas_GL_Context *gc, Evas_GL_Image *im, int sx, int sy
|
|||
sx, sy, sw, sh,
|
||||
dx, dy, dw, dh,
|
||||
r, g, b, a,
|
||||
smooth);
|
||||
smooth, im->tex_only);
|
||||
continue;
|
||||
}
|
||||
ssx = (double)sx + ((double)(sw * (nx - dx)) / (double)(dw));
|
||||
|
@ -480,7 +533,7 @@ evas_gl_common_image_draw(Evas_GL_Context *gc, Evas_GL_Image *im, int sx, int sy
|
|||
ssx, ssy, ssw, ssh,
|
||||
nx, ny, nw, nh,
|
||||
r, g, b, a,
|
||||
smooth);
|
||||
smooth, im->tex_only);
|
||||
}
|
||||
evas_common_draw_context_apply_clear_cutouts(rects);
|
||||
/* restore clip info */
|
||||
|
|
|
@ -304,6 +304,32 @@ _pool_tex_render_new(Evas_GL_Context *gc, int w, int h, int intformat, int forma
|
|||
return pt;
|
||||
}
|
||||
|
||||
static Evas_GL_Texture_Pool *
|
||||
_pool_tex_native_new(Evas_GL_Context *gc, int w, int h, int intformat, int format)
|
||||
{
|
||||
Evas_GL_Texture_Pool *pt;
|
||||
|
||||
pt = calloc(1, sizeof(Evas_GL_Texture_Pool));
|
||||
if (!pt) return NULL;
|
||||
h = _tex_round_slot(gc, h) << 4;
|
||||
_tex_adjust(gc, &w, &h);
|
||||
pt->gc = gc;
|
||||
pt->w = w;
|
||||
pt->h = h;
|
||||
pt->intformat = intformat;
|
||||
pt->format = format;
|
||||
pt->dataformat = GL_UNSIGNED_BYTE;
|
||||
pt->references = 0;
|
||||
glGenTextures(1, &(pt->texture));
|
||||
glBindTexture(GL_TEXTURE_2D, pt->texture);
|
||||
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, gc->shader.cur_tex);
|
||||
return pt;
|
||||
}
|
||||
|
||||
static void
|
||||
pt_unref(Evas_GL_Texture_Pool *pt)
|
||||
{
|
||||
|
@ -319,6 +345,36 @@ pt_unref(Evas_GL_Texture_Pool *pt)
|
|||
free(pt);
|
||||
}
|
||||
|
||||
Evas_GL_Texture *
|
||||
evas_gl_common_texture_native_new(Evas_GL_Context *gc, int w, int h, int alpha)
|
||||
{
|
||||
Evas_GL_Texture *tex;
|
||||
Eina_List *l_after = NULL;
|
||||
int u = 0, v = 0;
|
||||
|
||||
tex = calloc(1, sizeof(Evas_GL_Texture));
|
||||
if (!tex) return NULL;
|
||||
|
||||
tex->gc = gc;
|
||||
tex->references = 1;
|
||||
tex->alpha = alpha;
|
||||
if (alpha)
|
||||
tex->pt = _pool_tex_native_new(gc, w, h, rgba_ifmt, rgba_fmt);
|
||||
else
|
||||
tex->pt = _pool_tex_native_new(gc, w, h, rgb_ifmt, rgb_fmt);
|
||||
if (!tex->pt)
|
||||
{
|
||||
free(tex);
|
||||
return NULL;
|
||||
}
|
||||
tex->x = 0;
|
||||
tex->y = 0;
|
||||
tex->w = w;
|
||||
tex->h = h;
|
||||
tex->pt->references++;
|
||||
return tex;
|
||||
}
|
||||
|
||||
Evas_GL_Texture *
|
||||
evas_gl_common_texture_render_new(Evas_GL_Context *gc, int w, int h, int alpha)
|
||||
{
|
||||
|
|
|
@ -27,7 +27,7 @@ if !EVAS_STATIC_BUILD_GL_X11
|
|||
pkg_LTLIBRARIES = module.la
|
||||
|
||||
module_la_SOURCES = $(GL_X11_SOURCES)
|
||||
module_la_LIBADD = @EINA_LIBS@ $(GL_X11_LIBADD) $(top_builddir)/src/lib/libevas.la
|
||||
module_la_LIBADD = @EINA_LIBS@ $(GL_X11_LIBADD) $(top_builddir)/src/lib/libevas.la @dlopen_libs@
|
||||
module_la_LDFLAGS = -module -avoid-version
|
||||
module_la_LIBTOOLFLAGS = --tag=disable-static
|
||||
|
||||
|
|
|
@ -1,13 +1,63 @@
|
|||
#include "evas_engine.h"
|
||||
|
||||
#include <dlfcn.h> /* dlopen,dlclose,etc */
|
||||
|
||||
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
|
||||
// EGL / GLES
|
||||
# if defined(GLES_VARIETY_S3C6410)
|
||||
# elif defined(GLES_VARIETY_SGX)
|
||||
# endif
|
||||
#else
|
||||
// GLX
|
||||
#endif
|
||||
|
||||
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
|
||||
# if defined(GLES_VARIETY_S3C6410)
|
||||
# elif defined(GLES_VARIETY_SGX)
|
||||
# endif
|
||||
// GLX
|
||||
#else
|
||||
typedef void (*_eng_fn) (void);
|
||||
|
||||
_eng_fn (*glsym_glXGetProcAddress) (const char *a) = NULL;
|
||||
void (*glsym_glXBindTexImage) (Display *a, GLXDrawable b, int c, int *d) = NULL;
|
||||
void (*glsym_glXReleaseTexImage) (Display *a, GLXDrawable b, int c) = NULL;
|
||||
#endif
|
||||
|
||||
static void
|
||||
_sym_init(void)
|
||||
{
|
||||
static int done = 0;
|
||||
|
||||
#define FINDSYM(dst, sym) \
|
||||
if ((!dst) && (glsym_glXGetProcAddress)) dst = glsym_glXGetProcAddress(sym); \
|
||||
if (!dst) dst = dlsym(RTLD_DEFAULT, sym)
|
||||
|
||||
if (done) return;
|
||||
|
||||
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
|
||||
# if defined(GLES_VARIETY_S3C6410)
|
||||
# elif defined(GLES_VARIETY_SGX)
|
||||
# endif
|
||||
#else
|
||||
FINDSYM(glsym_glXGetProcAddress, "glXGetProcAddress");
|
||||
FINDSYM(glsym_glXGetProcAddress, "glXGetProcAddressEXT");
|
||||
FINDSYM(glsym_glXGetProcAddress, "glXGetProcAddressARB");
|
||||
|
||||
FINDSYM(glsym_glXBindTexImage, "glXBindTexImage");
|
||||
FINDSYM(glsym_glXBindTexImage, "glXBindTexImageEXT");
|
||||
FINDSYM(glsym_glXBindTexImage, "glXBindTexImageARB");
|
||||
|
||||
FINDSYM(glsym_glXReleaseTexImage, "glXReleaseTexImage");
|
||||
FINDSYM(glsym_glXReleaseTexImage, "glXReleaseTexImageEXT");
|
||||
FINDSYM(glsym_glXReleaseTexImage, "glXReleaseTexImageARB");
|
||||
|
||||
printf("glXGetProcAddress: %p\n"
|
||||
"glXBindTexImage: %p\n"
|
||||
"glXReleaseTexImage: %p\n",
|
||||
glsym_glXGetProcAddress,
|
||||
glsym_glXBindTexImage, glsym_glXReleaseTexImage);
|
||||
#endif
|
||||
}
|
||||
|
||||
int _evas_engine_GL_X11_log_dom = -1;
|
||||
/* function tables - filled in later (func and parent func) */
|
||||
|
@ -30,6 +80,7 @@ static void *
|
|||
eng_info(Evas *e)
|
||||
{
|
||||
Evas_Engine_Info_GL_X11 *info;
|
||||
|
||||
info = calloc(1, sizeof(Evas_Engine_Info_GL_X11));
|
||||
info->magic.magic = rand();
|
||||
info->func.best_visual_get = eng_best_visual_get;
|
||||
|
@ -161,6 +212,8 @@ eng_setup(Evas *e, void *in)
|
|||
e->engine.func->context_new(e->engine.data.output);
|
||||
eng_window_use(re->win);
|
||||
|
||||
_sym_init();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -337,21 +390,21 @@ eng_output_flush(void *data)
|
|||
eglSwapBuffers(re->win->egl_disp, re->win->egl_surface[0]);
|
||||
#else
|
||||
# ifdef VSYNC_TO_SCREEN
|
||||
{
|
||||
unsigned int rc;
|
||||
|
||||
glXGetVideoSyncSGI(&rc);
|
||||
glXWaitVideoSyncSGI(2, (rc + 1) % 2, &rc);
|
||||
}
|
||||
// {
|
||||
// unsigned int rc;
|
||||
//
|
||||
// glXGetVideoSyncSGI(&rc);
|
||||
// glXWaitVideoSyncSGI(2, (rc + 1) % 2, &rc);
|
||||
// }
|
||||
# endif
|
||||
# ifdef SLOW_GL_COPY_RECT
|
||||
glXSwapBuffers(re->win->disp, re->win->win);
|
||||
# else
|
||||
/* SLOW AS ALL HELL! */
|
||||
evas_gl_common_swap_rect(re->win->gl_context,
|
||||
re->win->draw.x1, re->win->draw.y1,
|
||||
re->win->draw.x2 - re->win->draw.x1 + 1,
|
||||
re->win->draw.y2 - re->win->draw.y1 + 1);
|
||||
// /* SLOW AS ALL HELL! */
|
||||
// evas_gl_common_swap_rect(re->win->gl_context,
|
||||
// re->win->draw.x1, re->win->draw.y1,
|
||||
// re->win->draw.x2 - re->win->draw.x1 + 1,
|
||||
// re->win->draw.y2 - re->win->draw.y1 + 1);
|
||||
# endif
|
||||
// glFlush();
|
||||
// glXWaitGL();
|
||||
|
@ -945,17 +998,291 @@ eng_image_colorspace_set(void *data, void *image, int cspace)
|
|||
im->cs.space = cspace;
|
||||
}
|
||||
|
||||
static void
|
||||
eng_image_native_set(void *data __UNUSED__, void *image __UNUSED__, void *native __UNUSED__)
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
typedef struct _Native Native;
|
||||
|
||||
struct _Native
|
||||
{
|
||||
Evas_Native_Surface ns;
|
||||
Pixmap pixmap;
|
||||
Visual *visual;
|
||||
|
||||
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
|
||||
#else
|
||||
# ifdef GLX_BIND_TO_TEXTURE_TARGETS_EXT
|
||||
GLXFBConfig fbc;
|
||||
GLXPixmap glx_pixmap;
|
||||
# endif
|
||||
#endif
|
||||
};
|
||||
|
||||
static void
|
||||
_native_bind_cb(void *data, void *image)
|
||||
{
|
||||
Render_Engine *re = data;
|
||||
Evas_GL_Image *im = image;
|
||||
Native *n = im->native.data;
|
||||
|
||||
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
|
||||
// eglBindTexImage(egl->dpy, egl->pixmap_surface, EGL_SINGLE_BUFFER);
|
||||
#else
|
||||
# ifdef GLX_BIND_TO_TEXTURE_TARGETS_EXT
|
||||
if (glsym_glXBindTexImage)
|
||||
{
|
||||
const int pixmap_att[] =
|
||||
{
|
||||
GLX_TEXTURE_TARGET_EXT,
|
||||
GLX_TEXTURE_2D_EXT,
|
||||
GLX_TEXTURE_FORMAT_EXT,
|
||||
GLX_TEXTURE_FORMAT_RGBA_EXT,
|
||||
0
|
||||
};
|
||||
|
||||
n->glx_pixmap = glXCreatePixmap(re->win->disp, n->fbc,
|
||||
n->pixmap, pixmap_att);
|
||||
printf("bind: %p %i %i %p\n", re->win->disp, n->glx_pixmap, GLX_FRONT_LEFT_EXT, NULL);
|
||||
glsym_glXBindTexImage(re->win->disp, n->glx_pixmap,
|
||||
GLX_FRONT_LEFT_EXT, NULL);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
_native_unbind_cb(void *data, void *image)
|
||||
{
|
||||
Render_Engine *re = data;
|
||||
Evas_GL_Image *im = image;
|
||||
Native *n = im->native.data;
|
||||
|
||||
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
|
||||
// eglReleaseTexImage(egl->dpy, egl->pixmap_surface, EGL_SINGLE_BUFFER);
|
||||
#else
|
||||
# ifdef GLX_BIND_TO_TEXTURE_TARGETS_EXT
|
||||
if (glsym_glXReleaseTexImage)
|
||||
{
|
||||
printf("unbind: %p %i %i\n", re->win->disp, n->glx_pixmap, GLX_FRONT_LEFT_EXT);
|
||||
glsym_glXReleaseTexImage(re->win->disp, n->glx_pixmap,
|
||||
GLX_FRONT_LEFT_EXT);
|
||||
glXDestroyPixmap(re->win->disp, n->glx_pixmap);
|
||||
n->glx_pixmap = 0;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
_native_free_cb(void *data, void *image)
|
||||
{
|
||||
Render_Engine *re = data;
|
||||
Evas_GL_Image *im = image;
|
||||
Native *n = im->native.data;
|
||||
|
||||
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
|
||||
/* if (egl->pixmap_ctx != EGL_NO_CONTEXT)
|
||||
{
|
||||
eglDestroyContext(egl->dpy, egl->pixmap_ctx);
|
||||
egl->pixmap_ctx = EGL_NO_CONTEXT;
|
||||
}
|
||||
if (egl->pixmap_surface != EGL_NO_SURFACE)
|
||||
{
|
||||
eglDestroySurface(egl->dpy, egl->pixmap_surface);
|
||||
egl->pixmap_surface = EGL_NO_SURFACE;
|
||||
}
|
||||
res = true; */
|
||||
#else
|
||||
# ifdef GLX_BIND_TO_TEXTURE_TARGETS_EXT
|
||||
if (n->glx_pixmap)
|
||||
{
|
||||
glsym_glXReleaseTexImage(re->win->disp, n->glx_pixmap,
|
||||
GLX_FRONT_LEFT_EXT);
|
||||
glXDestroyPixmap(re->win->disp, n->glx_pixmap);
|
||||
n->glx_pixmap = 0;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
im->native.data = NULL;
|
||||
im->native.func.data = NULL;
|
||||
im->native.func.bind = NULL;
|
||||
im->native.func.unbind = NULL;
|
||||
im->native.func.free = NULL;
|
||||
free(n);
|
||||
}
|
||||
|
||||
static void
|
||||
eng_image_native_set(void *data, void *image, void *native)
|
||||
{
|
||||
Render_Engine *re = (Render_Engine *)data;
|
||||
Evas_Native_Surface *ns = native;
|
||||
Evas_GL_Image *im = image;
|
||||
Visual *vis = NULL;
|
||||
Pixmap pm = 0;
|
||||
|
||||
printf("eng_image_native_set\n");
|
||||
if (ns)
|
||||
{
|
||||
vis = ns->data.x11.visual;
|
||||
pm = ns->data.x11.pixmap;
|
||||
if (im->native.data)
|
||||
{
|
||||
Evas_Native_Surface *n = im->native.data;
|
||||
if ((n->data.x11.visual == vis) && (n->data.x11.pixmap == pm))
|
||||
{
|
||||
printf(" same\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
printf(" .1\n");
|
||||
if ((!ns) && (!im->native.data)) return;
|
||||
printf(" ..2\n");
|
||||
if (!im) return;
|
||||
printf(" ...3\n");
|
||||
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
|
||||
/* EGLConfig cfg;
|
||||
EGLint num;
|
||||
EGLint attbs[30] = { NULL, };
|
||||
|
||||
EGLint ctx_attbs[] =
|
||||
{
|
||||
EGL_CONTEXT_CLIENT_VERSION, 2,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
int i = 0;
|
||||
|
||||
attbs[i++] = EGL_RED_SIZE;
|
||||
attbs[i++] = egl->cfg_r;
|
||||
attbs[i++] = EGL_GREEN_SIZE;
|
||||
attbs[i++] = egl->cfg_g;
|
||||
attbs[i++] = EGL_BLUE_SIZE;
|
||||
attbs[i++] = egl->cfg_b;
|
||||
attbs[i++] = EGL_ALPHA_SIZE;
|
||||
attbs[i++] = egl->cfg_a;
|
||||
attbs[i++] = EGL_DEPTH_SIZE;
|
||||
attbs[i++] = egl->cfg_d;
|
||||
attbs[i++] = EGL_STENCIL_SIZE;
|
||||
attbs[i++] = egl->cfg_s;
|
||||
attbs[i++] = EGL_RENDERABLE_TYPE;
|
||||
attbs[i++] = EGL_OPENGL_ES2_BIT;
|
||||
attbs[i++] = EGL_SURFACE_TYPE;
|
||||
attbs[i++] = EGL_PIXMAP_BIT; // for pixmap surface
|
||||
attbs[i++] = EGL_NONE;
|
||||
|
||||
eglChooseConfig(egl->dpy, attbs, &cfg, 1, &num);
|
||||
egl->pixmap_surface = eglCreatePixmapSurface(egl->dpy, cfg, pixmap, NULL);
|
||||
eglBindAPI(EGL_OPENGL_ES_API);
|
||||
egl->pixmap_ctx = eglCreateContext(egl->dpy, cfg, EGL_NO_CONTEXT, ctx_attbs); */
|
||||
#else
|
||||
# ifdef GLX_BIND_TO_TEXTURE_TARGETS_EXT
|
||||
printf(" ....4\n");
|
||||
// FIXME: if there is already a natiive surface - free it
|
||||
if (im->native.data)
|
||||
{
|
||||
if (im->native.func.free)
|
||||
im->native.func.free(im->native.func.data, im);
|
||||
evas_gl_common_image_native_disable(im);
|
||||
}
|
||||
if (native)
|
||||
{
|
||||
VisualID vid;
|
||||
GLXFBConfig *fbc;
|
||||
int i, num;
|
||||
int yinvert = 0;
|
||||
|
||||
vid = XVisualIDFromVisual(vis);
|
||||
fbc = glXGetFBConfigs(re->win->disp,
|
||||
0 /* FIXME: screen 0 assumption */,
|
||||
&num);
|
||||
printf(" .....5\n");
|
||||
if (fbc)
|
||||
{
|
||||
printf(" ......6\n");
|
||||
for (i = 0; i < num; i++)
|
||||
{
|
||||
XVisualInfo *vi;
|
||||
int val;
|
||||
|
||||
vi = glXGetVisualFromFBConfig(re->win->disp, fbc[i]);
|
||||
if ((!vi) || (vi->visualid != vid))
|
||||
continue;
|
||||
|
||||
glXGetFBConfigAttrib(re->win->disp, fbc[i],
|
||||
GLX_DRAWABLE_TYPE, &val);
|
||||
if (!(val & GLX_PIXMAP_BIT)) continue;
|
||||
|
||||
glXGetFBConfigAttrib(re->win->disp, fbc[i],
|
||||
GLX_BIND_TO_TEXTURE_TARGETS_EXT, &val);
|
||||
if (!(val & GLX_TEXTURE_2D_BIT_EXT)) continue;
|
||||
|
||||
glXGetFBConfigAttrib(re->win->disp, fbc[i],
|
||||
GLX_BIND_TO_TEXTURE_RGBA_EXT, &val);
|
||||
if (!val)
|
||||
{
|
||||
glXGetFBConfigAttrib(re->win->disp, fbc[i],
|
||||
GLX_BIND_TO_TEXTURE_RGB_EXT, &val);
|
||||
if (!val) continue;
|
||||
}
|
||||
|
||||
glXGetFBConfigAttrib(re->win->disp, fbc[i],
|
||||
GLX_Y_INVERTED_EXT, &val);
|
||||
if (val) yinvert = 1;
|
||||
break;
|
||||
}
|
||||
if (i == num)
|
||||
{
|
||||
printf(" err \n");
|
||||
// error
|
||||
}
|
||||
else
|
||||
{
|
||||
Native *n;
|
||||
|
||||
printf(" .......7\n");
|
||||
n = calloc(1, sizeof(Native));
|
||||
if (n)
|
||||
{
|
||||
|
||||
printf(" .......8\n");
|
||||
evas_gl_common_image_native_enable(im);
|
||||
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.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;
|
||||
printf(" yinvert = %i\n", yinvert);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
static void *
|
||||
eng_image_native_get(void *data __UNUSED__, void *image __UNUSED__)
|
||||
eng_image_native_get(void *data, void *image)
|
||||
{
|
||||
return NULL;
|
||||
Render_Engine *re = (Render_Engine *)data;
|
||||
Evas_GL_Image *im = image;
|
||||
Native *n;
|
||||
if (!im) return NULL;
|
||||
n = im->native.data;
|
||||
if (!n) return NULL;
|
||||
return &(n->ns);
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void *
|
||||
eng_image_load(void *data, const char *file, const char *key, int *error, Evas_Image_Load_Opts *lo)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue