struct { // xres - dpi
int dpi; // xres - dpi
} xr; // xres - dpi
+
+ int w, h;
};
static int initted = 0;
}
static int
+_re_wincheck(Render_Engine *re)
+{
+ if (re->win->surf) return 1;
+ eng_window_resurf(re->win);
+ if (!re->win->surf)
+ {
+ fprintf(stderr, "ERROR: GL engine can't re-create window surface!\n");
+ }
+ return 0;
+}
+
+static void
+_re_winfree(Render_Engine *re)
+{
+ if (!re->win->surf) return;
+ eng_window_unsurf(re->win);
+}
+
+static int
eng_setup(Evas *e, void *in)
{
Render_Engine *re;
re->info = info;
re->evas = e;
e->engine.data.output = re;
- re->win = eng_window_new(info->info.display,
- info->info.drawable,
- info->info.screen,
- info->info.visual,
- info->info.colormap,
- info->info.depth,
- e->output.w,
- e->output.h,
- info->indirect,
- info->info.destination_alpha,
- info->info.rotation);
+ re->w = e->output.w;
+ re->h = e->output.h;
+ re->win = eng_window_new(re->info->info.display,
+ re->info->info.drawable,
+ re->info->info.screen,
+ re->info->info.visual,
+ re->info->info.colormap,
+ re->info->info.depth,
+ re->w,
+ re->h,
+ re->info->indirect,
+ re->info->info.destination_alpha,
+ re->info->info.rotation);
if (!re->win)
{
free(re);
status = xrdb_user_query("Xft.dpi", "Xft.Dpi", &type, &val);
if ((!status) || (!type))
{
- if (!re->xrdb) re->xrdb = XrmGetDatabase(info->info.display);
+ if (!re->xrdb) re->xrdb = XrmGetDatabase(re->info->info.display);
if (re->xrdb)
status = XrmGetResource(re->xrdb,
"Xft.dpi", "Xft.Dpi", &type, &val);
else
{
re = e->engine.data.output;
- if ((info->info.display != re->win->disp) ||
- (info->info.drawable != re->win->win) ||
- (info->info.screen != re->win->screen) ||
- (info->info.visual != re->win->visual) ||
- (info->info.colormap != re->win->colormap) ||
- (info->info.depth != re->win->depth) ||
- (info->info.destination_alpha != re->win->alpha) ||
- (info->info.rotation != re->win->rot))
+ if (_re_wincheck(re))
{
- int inc = 0;
-
- if (re->win)
+ if ((re->info->info.display != re->win->disp) ||
+ (re->info->info.drawable != re->win->win) ||
+ (re->info->info.screen != re->win->screen) ||
+ (re->info->info.visual != re->win->visual) ||
+ (re->info->info.colormap != re->win->colormap) ||
+ (re->info->info.depth != re->win->depth) ||
+ (re->info->info.destination_alpha != re->win->alpha) ||
+ (re->info->info.rotation != re->win->rot))
{
- re->win->gl_context->references++;
- eng_window_free(re->win);
- inc = 1;
- gl_wins--;
+ int inc = 0;
+
+ if (re->win)
+ {
+ re->win->gl_context->references++;
+ eng_window_free(re->win);
+ inc = 1;
+ gl_wins--;
+ }
+ re->w = e->output.w;
+ re->h = e->output.h;
+ re->win = eng_window_new(re->info->info.display,
+ re->info->info.drawable,
+ re->info->info.screen,
+ re->info->info.visual,
+ re->info->info.colormap,
+ re->info->info.depth,
+ re->w,
+ re->h,
+ re->info->indirect,
+ re->info->info.destination_alpha,
+ re->info->info.rotation);
+ if (re->win) gl_wins++;
+ if ((re->win) && (inc))
+ re->win->gl_context->references--;
+ }
+ else if ((re->win->w != e->output.w) ||
+ (re->win->h != e->output.h))
+ {
+ re->w = e->output.w;
+ re->h = e->output.h;
+ re->win->w = e->output.w;
+ re->win->h = e->output.h;
+ eng_window_use(re->win);
+ evas_gl_common_context_resize(re->win->gl_context, re->win->w, re->win->h, re->win->rot);
}
- re->win = eng_window_new(info->info.display,
- info->info.drawable,
- info->info.screen,
- info->info.visual,
- info->info.colormap,
- info->info.depth,
- e->output.w,
- e->output.h,
- info->indirect,
- info->info.destination_alpha,
- info->info.rotation);
- if (re->win) gl_wins++;
- if ((re->win) && (inc))
- re->win->gl_context->references--;
- }
- else if ((re->win->w != e->output.w) ||
- (re->win->h != e->output.h))
- {
- re->win->w = e->output.w;
- re->win->h = e->output.h;
- eng_window_use(re->win);
- evas_gl_common_context_resize(re->win->gl_context, re->win->w, re->win->h, re->win->rot);
}
-
}
if (!re->win)
{
re = (Render_Engine *)data;
/* get the upate rect surface - return engine data as dummy */
if (!re->win->draw.redraw) return NULL;
+ if (!_re_wincheck(re)) return NULL;
evas_gl_common_context_flush(re->win->gl_context);
eng_window_use(re->win);
evas_gl_common_context_newframe(re->win->gl_context);
re = (Render_Engine *)data;
/* put back update surface.. in this case just unflag redraw */
+ if (!_re_wincheck(re)) return;
re->win->draw.redraw = 0;
re->win->draw.drew = 1;
evas_gl_common_context_flush(re->win->gl_context);
Render_Engine *re;
re = (Render_Engine *)data;
+ if (!_re_wincheck(re)) return;
if (!re->win->draw.drew) return;
//x// printf("frame -> flush\n");
re->win->draw.drew = 0;
evas_common_image_image_all_unload();
evas_common_font_font_all_unload();
evas_gl_common_image_all_unload(re->win->gl_context);
+ _re_winfree(re);
}
static void
uint32_t pmid;
if (!im) return NULL;
+
if (ns)
{
vis = ns->data.x11.visual;
static void
eng_image_size_get(void *data, void *image, int *w, int *h)
{
-// Render_Engine *re;
-//
-// re = (Render_Engine *)data;
if (!image)
{
*w = 0;
gw->rot = rot;
vi_use = _evas_gl_x11_vi;
- if (alpha)
+ if (gw->alpha)
{
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
if (_evas_gl_x11_rgba_vi)
config_attrs[n++] = 1;
// FIXME: end n900 breakage
#endif
- if (alpha)
+ if (gw->alpha)
{
config_attrs[n++] = EGL_ALPHA_SIZE;
config_attrs[n++] = 1;
{
#ifdef NEWGL
if (indirect)
- context = glXCreateNewContext(disp, fbconf,
+ context = glXCreateNewContext(gw->disp, fbconf,
GLX_RGBA_TYPE, NULL,
GL_TRUE);
else
- context = glXCreateNewContext(disp, fbconf,
+ context = glXCreateNewContext(gw->disp, fbconf,
GLX_RGBA_TYPE, NULL,
GL_FALSE);
#else
if (indirect)
- context = glXCreateContext(disp, gw->visualinfo, NULL, GL_FALSE);
+ context = glXCreateContext(gw->disp, gw->visualinfo, NULL, GL_FALSE);
else
- context = glXCreateContext(disp, gw->visualinfo, NULL, GL_TRUE);
+ context = glXCreateContext(gw->disp, gw->visualinfo, NULL, GL_TRUE);
#endif
}
#ifdef NEWGL
- if ((alpha) && (!rgba_context))
+ if ((gw->alpha) && (!rgba_context))
{
if (indirect)
- rgba_context = glXCreateNewContext(disp, rgba_fbconf,
+ rgba_context = glXCreateNewContext(gw->disp, rgba_fbconf,
GLX_RGBA_TYPE, context,
GL_TRUE);
else
- rgba_context = glXCreateNewContext(disp, rgba_fbconf,
+ rgba_context = glXCreateNewContext(gw->disp, rgba_fbconf,
GLX_RGBA_TYPE, context,
GL_FALSE);
}
- if (alpha)
- gw->glxwin = glXCreateWindow(disp, rgba_fbconf, gw->win, NULL);
+ if (gw->alpha)
+ gw->glxwin = glXCreateWindow(gw->disp, rgba_fbconf, gw->win, NULL);
else
- gw->glxwin = glXCreateWindow(disp, fbconf, gw->win, NULL);
+ gw->glxwin = glXCreateWindow(gw->disp, fbconf, gw->win, NULL);
- if (alpha) gw->context = rgba_context;
+ if (gw->alpha) gw->context = rgba_context;
else gw->context = context;
#else
gw->context = context;
// noothing yet. add more cases and options over time
}
- fbc = glXGetFBConfigs(disp, screen, &num);
+ fbc = glXGetFBConfigs(gw->disp, screen, &num);
if (!fbc)
{
printf("Error: glXGetFBConfigs() returned no fb configs\n");
{
XVisualInfo *vi;
int vd;
- int alpha, val, dbuf, stencil, depth;
+ int alph, val, dbuf, stencil, depth;
int rgba;
- vi = glXGetVisualFromFBConfig(disp, fbc[j]);
+ vi = glXGetVisualFromFBConfig(gw->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);
+ glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_ALPHA_SIZE, &alph);
+ glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_BUFFER_SIZE, &val);
- if ((val != i) && ((val - alpha) != i)) continue;
+ if ((val != i) && ((val - alph) != i)) continue;
val = 0;
rgba = 0;
if (i == 32)
{
- glXGetFBConfigAttrib(disp, fbc[j], GLX_BIND_TO_TEXTURE_RGBA_EXT, &val);
+ glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_BIND_TO_TEXTURE_RGBA_EXT, &val);
if (val)
{
rgba = 1;
if (!val)
{
if (rgba) continue;
- glXGetFBConfigAttrib(disp, fbc[j], GLX_BIND_TO_TEXTURE_RGB_EXT, &val);
+ glXGetFBConfigAttrib(gw->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);
+ glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_DOUBLEBUFFER, &val);
if (val > dbuf) continue;
dbuf = val;
stencil = 0x7fff;
- glXGetFBConfigAttrib(disp, fbc[j], GLX_STENCIL_SIZE, &val);
+ glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_STENCIL_SIZE, &val);
if (val > stencil) continue;
stencil = val;
depth = 0x7fff;
- glXGetFBConfigAttrib(disp, fbc[j], GLX_DEPTH_SIZE, &val);
+ glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_DEPTH_SIZE, &val);
if (val > depth) continue;
depth = val;
- glXGetFBConfigAttrib(disp, fbc[j], GLX_BIND_TO_MIPMAP_TEXTURE_EXT, &val);
+ glXGetFBConfigAttrib(gw->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);
+ glXGetFBConfigAttrib(gw->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);
+ glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_BIND_TO_TEXTURE_TARGETS_EXT, &val);
gw->depth_cfg[i].tex_target = val;
gw->depth_cfg[i].fbc = fbc[j];
}
}
XFree(fbc);
- if (!gw->depth_cfg[DefaultDepth(disp, screen)].fbc)
+ if (!gw->depth_cfg[DefaultDepth(gw->disp, screen)].fbc)
{
printf("texture from pixmap not going to work\n");
}
evas_gl_common_context_use(gw->gl_context);
evas_gl_common_context_resize(gw->gl_context, w, h, rot);
win_count++;
+ gw->surf = 1;
return gw;
}
evas_gl_common_context_use(gw->gl_context);
}
+void
+eng_window_unsurf(Evas_GL_X11_Window *gw)
+{
+ if (!gw->surf) return;
+ if (getenv("EVAS_GL_INFO"))
+ printf("unsurf %p\n", gw);
+#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+ if (gw->egl_surface[0] != EGL_NO_SURFACE)
+ eglDestroySurface(gw->egl_disp, gw->egl_surface[0]);
+ gw->egl_surface[0] = EGL_NO_SURFACE;
+ eglMakeCurrent(gw->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+#else
+ if (gw->glxwin) glXDestroyWindow(gw->disp, gw->glxwin);
+#endif
+ gw->surf = 0;
+}
+
+void
+eng_window_resurf(Evas_GL_X11_Window *gw)
+{
+ if (gw->surf) return;
+ if (getenv("EVAS_GL_INFO"))
+ printf("resurf %p\n", gw);
+#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
+ gw->egl_surface[0] = eglCreateWindowSurface(gw->egl_disp, gw->egl_config,
+ (EGLNativeWindowType)gw->win,
+ NULL);
+ if (gw->egl_surface[0] == EGL_NO_SURFACE)
+ {
+ printf("Error: eglCreateWindowSurface() fail for 0x%x.\n", (unsigned int)gw->win);
+ printf("Error: error # was: 0x%x\n", eglGetError());
+ return;
+ }
+#else
+#ifdef NEWGL
+ if (gw->alpha)
+ gw->glxwin = glXCreateWindow(gw->disp, rgba_fbconf, gw->win, NULL);
+ else
+ gw->glxwin = glXCreateWindow(gw->disp, fbconf, gw->win, NULL);
+#endif
+#endif
+ gw->surf = 1;
+}
+
Visual *
eng_best_visual_get(Evas_Engine_Info_GL_X11 *einfo)
{