void (*free) (void *data, void *image);
void *data;
} func;
- unsigned char yinvert : 1;
+ int yinvert;
+ int target;
+ int mipmap;
unsigned char loose : 1;
} native;
}
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->array.im->native.func.bind)
+ {
+ 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)
{
}
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);
+ if (!gc->array.im->native.func.bind)
+ {
+ 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);
&u, &v, &l_after, 1024);
if (!tex->pt)
{
+ memset(tex, 0x11, sizeof(Evas_GL_Texture)); // mark as freed
free(tex);
return NULL;
}
pt = calloc(1, sizeof(Evas_GL_Texture_Pool));
if (!pt) return NULL;
pt->gc = gc;
- pt->w = w;
- pt->h = h;
+ if (im->native.target == GL_TEXTURE_RECTANGLE_ARB)
+ {
+ printf("REEEEEEEEECT\n");
+ }
+ else
+ {
+ printf("%i %i\n", w, h);
+ // FIXME: handle npo2
+ pt->w = w;
+ pt->h = h;
+ }
pt->intformat = intformat;
pt->format = format;
pt->dataformat = GL_UNSIGNED_BYTE;
pt->references = 0;
pt->native = 1;
glGenTextures(1, &(pt->texture));
- glBindTexture(GL_TEXTURE_2D, pt->texture);
+ glBindTexture(im->native.target, pt->texture);
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
- // 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)
{
}
#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);
+ glTexParameteri(im->native.target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(im->native.target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameteri(im->native.target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(im->native.target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glBindTexture(im->native.target, 0);
+ glBindTexture(im->native.target, gc->shader.cur_tex);
return pt;
}
pt->gc->shared->tex.atlas [pt->slot][pt->fslot] =
eina_list_remove(pt->gc->shared->tex.atlas[pt->slot][pt->fslot], pt);
}
+
glDeleteTextures(1, &(pt->texture));
if (pt->fb) glsym_glDeleteFramebuffers(1, &(pt->fb));
+ memset(pt, 0x22, sizeof(Evas_GL_Texture_Pool)); // mark as freed
free(pt);
}
tex->pt = _pool_tex_native_new(gc, w, h, rgb_ifmt, rgb_fmt, im);
if (!tex->pt)
{
+ memset(tex, 0x33, sizeof(Evas_GL_Texture)); // mark as freed
free(tex);
return NULL;
}
tex->pt = _pool_tex_render_new(gc, w, h, rgb_ifmt, rgb_fmt);
if (!tex->pt)
{
+ memset(tex, 0x44, sizeof(Evas_GL_Texture)); // mark as freed
free(tex);
return NULL;
}
}
if (tex->ptu) pt_unref(tex->ptu);
if (tex->ptv) pt_unref(tex->ptv);
+ memset(tex, 0x55, sizeof(Evas_GL_Texture)); // mark as freed
free(tex);
}
&l_after, tw);
if (!tex->pt)
{
+ memset(tex, 0x66, sizeof(Evas_GL_Texture)); // mark as freed
free(tex);
return NULL;
}
tex->pt = _pool_tex_new(gc, w + 1, h + 1, lum_ifmt, lum_fmt);
if (!tex->pt)
{
+ memset(tex, 0x77, sizeof(Evas_GL_Texture)); // mark as freed
free(tex);
return NULL;
}
tex->ptu = _pool_tex_new(gc, (w / 2) + 1, (h / 2) + 1, lum_ifmt, lum_fmt);
if (!tex->ptu)
{
+ pt_unref(tex->pt);
+ memset(tex, 0x88, sizeof(Evas_GL_Texture)); // mark as freed
free(tex);
return NULL;
}
tex->ptv = _pool_tex_new(gc, (w / 2) + 1, (h / 2) + 1, lum_ifmt, lum_fmt);
if (!tex->ptv)
{
+ pt_unref(tex->pt);
+ pt_unref(tex->ptu);
+ memset(tex, 0x99, sizeof(Evas_GL_Texture)); // mark as freed
free(tex);
return NULL;
}
_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;
-int (*glsym_glXGetVideoSync) (Display *a) = NULL;
+int (*glsym_glXGetVideoSync) (unsigned int *a) = NULL;
int (*glsym_glXWaitVideoSync) (int a, int b, unsigned int *c) = NULL;
#endif
}
else
re->xr.dpi = atoi(str) * 1000;
+ evas_common_font_dpi_set(re->xr.dpi / 1000);
}
}
- evas_common_font_dpi_set(re->xr.dpi / 1000);
}
evas_common_cpu_init();
# endif
if (re->info->callback.pre_swap)
{
- glXWaitGL();
+ glFinish();
re->info->callback.pre_swap(re->info->callback.data, re->evas);
}
glXSwapBuffers(re->win->disp, re->win->win);
// why is this the case? does anyone know? has anyone tried it on other gfx
// drivers?
//
-#define GLX_TEX_PIXMAP_RECREATE 1
+//#define GLX_TEX_PIXMAP_RECREATE 1
static void
_native_bind_cb(void *data, void *image)
n->glx_pixmap = glXCreatePixmap(re->win->disp, n->fbc,
n->pixmap, pixmap_att);
#endif
- if (!im->native.loose)
- glsym_glXBindTexImage(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
# ifdef GLX_BIND_TO_TEXTURE_TARGETS_EXT
if (glsym_glXReleaseTexImage)
{
- if (!im->native.loose)
- glsym_glXReleaseTexImage(re->win->disp, n->glx_pixmap,
- GLX_FRONT_LEFT_EXT);
+ 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;
}
if (native)
{
- VisualID vid;
- GLXFBConfig *fbc;
- int i, num;
- int yinvert = 0;
+ int dummy;
+ unsigned int w, h, depth = 32, border;
+ Window wdummy;
+ Native *n;
- vid = XVisualIDFromVisual(vis);
- fbc = glXGetFBConfigs(re->win->disp,
- 0 /* FIXME: screen 0 assumption */,
- &num);
- if (fbc)
+ XGetGeometry(re->win->disp, pm, &wdummy, &dummy, &dummy,
+ &w, &h, &border, &depth);
+ n = calloc(1, sizeof(Native));
+ if (n)
{
- for (i = 0; i < num; i++)
+#ifndef GLX_TEX_PIXMAP_RECREATE
+ int pixmap_att[20];
+ int target = 0;
+ int i = 0;
+
+ if ((re->win->depth_cfg[depth].tex_target &
+ GLX_TEXTURE_2D_BIT_EXT) &&
+ (1) // we assume npo2 for now
+ // size is pow2 || mnpo2 supported
+ )
{
- 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)
+ printf("2d\n");
+ target = GLX_TEXTURE_2D_EXT;
+ }
+ else if ((re->win->depth_cfg[depth].tex_target &
+ GLX_TEXTURE_RECTANGLE_BIT_EXT))
+ {
+ printf("rect\n");
+ target = GLX_TEXTURE_RECTANGLE_EXT;
+ }
+ if (!target)
+ {
+ printf("broken text-from-pixmap\n");
+ if (!(re->win->depth_cfg[depth].tex_target &
+ GLX_TEXTURE_2D_BIT_EXT))
{
- glXGetFBConfigAttrib(re->win->disp, fbc[i],
- GLX_BIND_TO_TEXTURE_RGB_EXT, &val);
- if (!val) continue;
+ target = GLX_TEXTURE_RECTANGLE_EXT;
+ }
+ else if (!(re->win->depth_cfg[depth].tex_target &
+ GLX_TEXTURE_RECTANGLE_BIT_EXT))
+ {
+ target = GLX_TEXTURE_2D_EXT;
}
-
- glXGetFBConfigAttrib(re->win->disp, fbc[i],
- GLX_Y_INVERTED_EXT, &val);
- if (val) yinvert = 1;
- break;
}
- if (i == num)
+
+
+ pixmap_att[i++] = GLX_TEXTURE_FORMAT_EXT;
+ pixmap_att[i++] = re->win->depth_cfg[depth].tex_format;
+ pixmap_att[i++] = GLX_MIPMAP_TEXTURE_EXT;
+ pixmap_att[i++] = re->win->depth_cfg[depth].mipmap;
+
+ if (target)
{
- printf(" err \n");
- // error
+ pixmap_att[i++] = GLX_TEXTURE_TARGET_EXT;
+ pixmap_att[i++] = target;
+ }
+
+ pixmap_att[i++] = 0;
+#endif
+ memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface));
+ n->pixmap = pm;
+ n->visual = vis;
+ n->fbc = re->win->depth_cfg[depth].fbc;
+ im->native.yinvert = re->win->depth_cfg[depth].yinvert;
+ im->native.target = GL_TEXTURE_2D;
+ 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);
+ if (!target)
+ {
+ printf("notgt\n");
+ glXQueryDrawable(re->win->disp, n->pixmap, GLX_TEXTURE_TARGET_EXT, &target);
+ }
+ if (target == GLX_TEXTURE_2D_EXT)
+ {
+ im->native.target = GL_TEXTURE_2D;
+ im->native.mipmap = re->win->depth_cfg[depth].mipmap;
+ }
+ else if (target == GLX_TEXTURE_RECTANGLE_EXT)
+ {
+ im->native.target = GL_TEXTURE_RECTANGLE_ARB;
+ im->native.mipmap = 0;
}
else
{
- Native *n;
-
- n = calloc(1, sizeof(Native));
- if (n)
- {
-#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,
- GLX_TEXTURE_FORMAT_RGB_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);
- }
+ printf("still unknown target\n");
}
+#endif
+ evas_gl_common_image_native_enable(im);
}
}
# endif
EGLDisplay egl_disp;
#else
GLXContext context;
+ struct {
+ GLXFBConfig fbc;
+ int tex_format;
+ int tex_target;
+ int mipmap;
+ unsigned char yinvert : 1;
+ } depth_cfg[33]; // config for all 32 possible depths!
#endif
};
if (!context)
context = glXCreateContext(disp, gw->visualinfo, NULL, GL_TRUE);
gw->context = context;
-
- glXMakeCurrent(gw->disp, gw->win, gw->context);
+
+ if (gw->context)
+ {
+ int i, j, num;
+ GLXFBConfig *fbc;
+
+ glXMakeCurrent(gw->disp, gw->win, gw->context);
+
+ fbc = glXGetFBConfigs(disp, 0/* FIXME: assume screen 0 */, &num);
+ for (i = 0; i <= 32; i++)
+ {
+ for (j = 0; j < num; j++)
+ {
+ XVisualInfo *vi;
+ int vd;
+ int alpha, val, dbuf, stencil, depth;
+ int rgba;
+
+ vi = glXGetVisualFromFBConfig(disp, fbc[j]);
+ if (!vi) continue;
+ vd = vi->depth;
+ XFree(vi);
+
+ if (vd != i) continue;
+
+ glXGetFBConfigAttrib(disp, fbc[j], GLX_ALPHA_SIZE, &alpha);
+ glXGetFBConfigAttrib(disp, fbc[j], GLX_BUFFER_SIZE, &val);
+
+ if ((val != i) && ((val - alpha) != i)) continue;
+
+ val = 0;
+ rgba = 0;
+
+ if (i == 32)
+ {
+ glXGetFBConfigAttrib(disp, fbc[j], GLX_BIND_TO_TEXTURE_RGBA_EXT, &val);
+ if (val)
+ {
+ rgba = 1;
+ gw->depth_cfg[i].tex_format = GLX_TEXTURE_FORMAT_RGBA_EXT;
+ }
+ }
+ if (!val)
+ {
+ if (rgba) continue;
+ glXGetFBConfigAttrib(disp, fbc[j], GLX_BIND_TO_TEXTURE_RGB_EXT, &val);
+ if (!val) continue;
+ gw->depth_cfg[i].tex_format = GLX_TEXTURE_FORMAT_RGB_EXT;
+ }
+
+ dbuf = 0x7fff;
+ glXGetFBConfigAttrib(disp, fbc[j], GLX_DOUBLEBUFFER, &val);
+ if (val > dbuf) continue;
+ dbuf = val;
+
+ stencil = 0x7fff;
+ glXGetFBConfigAttrib(disp, fbc[j], GLX_STENCIL_SIZE, &val);
+ if (val > stencil) continue;
+ stencil = val;
+
+ depth = 0x7fff;
+ glXGetFBConfigAttrib(disp, fbc[j], GLX_DEPTH_SIZE, &val);
+ if (val > depth) continue;
+ depth = val;
+
+ glXGetFBConfigAttrib(disp, fbc[j], GLX_BIND_TO_MIPMAP_TEXTURE_EXT, &val);
+ if (val < 0) continue;
+ gw->depth_cfg[i].mipmap = val;
+
+ glXGetFBConfigAttrib(disp, fbc[j], GLX_Y_INVERTED_EXT, &val);
+ gw->depth_cfg[i].yinvert = val;
+
+ glXGetFBConfigAttrib(disp, fbc[j], GLX_BIND_TO_TEXTURE_TARGETS_EXT, &val);
+ gw->depth_cfg[i].tex_target = val;
+
+ gw->depth_cfg[i].fbc = fbc[i];
+ }
+ }
+ XFree(fbc);
+ if (!gw->depth_cfg[DefaultDepth(disp, 0/* FIXMEL assume screen 0*/)].fbc)
+ {
+ printf("text from pixmap not going to work\n");
+ }
+ }
#endif
_evas_gl_x11_window = gw;
}
else
re->xr.dpi = atoi(str) * 1000;
+ evas_common_font_dpi_set(re->xr.dpi / 1000);
}
}
- evas_common_font_dpi_set(re->xr.dpi / 1000);
}
re->ob = evas_software_xlib_outbuf_setup_x(w,
}
else
re->xr.dpi = atoi(str) * 1000;
+ evas_common_font_dpi_set(re->xr.dpi / 1000);
}
}
- evas_common_font_dpi_set(re->xr.dpi / 1000);
}
return re;