change gl engine api a little - fixed in ecore-evas and expedite. expose

indirect option in ecore-evas with a new opt param for gl engines - will add
more opts over time.



SVN revision: 46177
This commit is contained in:
Carsten Haitzler 2010-02-15 05:05:05 +00:00
parent b933154d21
commit 440f6d0d7b
5 changed files with 121 additions and 66 deletions

View File

@ -152,7 +152,12 @@ EAPI void ecore_evas_software_x11_direct_resize_set(Ecore_Evas *ee, i
EAPI int ecore_evas_software_x11_direct_resize_get(const Ecore_Evas *ee);
EAPI void ecore_evas_software_x11_extra_event_window_add(Ecore_Evas *ee, Ecore_X_Window win);
#define ECORE_EVAS_GL_X11_OPT_NONE 0
#define ECORE_EVAS_GL_X11_OPT_INDIRECT 1
#define ECORE_EVAS_GL_X11_OPT_LAST 2
EAPI Ecore_Evas *ecore_evas_gl_x11_new(const char *disp_name, Ecore_X_Window parent, int x, int y, int w, int h);
EAPI Ecore_Evas *ecore_evas_gl_x11_options_new(const char *disp_name, Ecore_X_Window parent, int x, int y, int w, int h, int *opt);
EAPI Ecore_X_Window ecore_evas_gl_x11_window_get(const Ecore_Evas *ee);
EAPI void ecore_evas_gl_x11_direct_resize_set(Ecore_Evas *ee, int on);
EAPI int ecore_evas_gl_x11_direct_resize_get(const Ecore_Evas *ee);

View File

@ -92,7 +92,7 @@ xcb_visualtype_get(xcb_screen_t *screen, xcb_visualid_t visual)
/* noop */
# else
static Ecore_X_Window
_ecore_evas_x_gl_window_new(Ecore_Evas *ee, Ecore_X_Window parent, int x, int y, int w, int h, int override)
_ecore_evas_x_gl_window_new(Ecore_Evas *ee, Ecore_X_Window parent, int x, int y, int w, int h, int override, int *opt)
{
Evas_Engine_Info_GL_X11 *einfo;
Ecore_X_Window win;
@ -103,7 +103,21 @@ _ecore_evas_x_gl_window_new(Ecore_Evas *ee, Ecore_X_Window parent, int x, int y,
XSetWindowAttributes attr;
int screen;
/* FIXME: this is inefficient as its a round trip */
if (opt)
{
int op;
for (op = 0; opt[op]; op++)
{
if (opt[op] == ECORE_EVAS_GL_X11_OPT_INDIRECT)
{
op++;
einfo->indirect = opt[op];
}
}
}
/* FIXME: this is inefficient as its 1 or more round trips */
screen = DefaultScreen(ecore_x_display_get());
if (ScreenCount(ecore_x_display_get()) > 1)
{
@ -131,9 +145,15 @@ _ecore_evas_x_gl_window_new(Ecore_Evas *ee, Ecore_X_Window parent, int x, int y,
free(roots);
}
}
einfo->info.display = ecore_x_display_get();
einfo->info.screen = screen;
einfo->info.visual = einfo->func.best_visual_get(einfo);
einfo->info.colormap = einfo->func.best_colormap_get(einfo);
einfo->info.depth = einfo->func.best_depth_get(einfo);
attr.backing_store = NotUseful;
attr.override_redirect = override;
attr.colormap = einfo->func.best_colormap_get(ecore_x_display_get(), screen);
attr.colormap = einfo->info.colormap;
attr.border_pixel = 0;
attr.background_pixmap = None;
attr.event_mask =
@ -145,23 +165,12 @@ _ecore_evas_x_gl_window_new(Ecore_Evas *ee, Ecore_X_Window parent, int x, int y,
attr.bit_gravity = ForgetGravity;
win =
XCreateWindow(ecore_x_display_get(),
parent,
x, y,
w, h, 0,
einfo->func.best_depth_get(ecore_x_display_get(), screen),
InputOutput,
einfo->func.best_visual_get(ecore_x_display_get(), screen),
CWBackingStore | CWColormap |
CWBackPixmap | CWBorderPixel |
CWBitGravity | CWEventMask |
CWOverrideRedirect,
&attr);
einfo->info.display = ecore_x_display_get();
einfo->info.visual = einfo->func.best_visual_get(ecore_x_display_get(), screen);
einfo->info.colormap = einfo->func.best_colormap_get(ecore_x_display_get(), screen);
XCreateWindow(einfo->info.display, parent, x, y, w, h, 0,
einfo->info.depth, InputOutput, einfo->info.visual,
CWBackingStore | CWColormap | CWBackPixmap |
CWBorderPixel | CWBitGravity | CWEventMask |
CWOverrideRedirect, &attr);
einfo->info.drawable = win;
einfo->info.depth = einfo->func.best_depth_get(ecore_x_display_get(), screen);
evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
ecore_x_window_defaults_set(win);
@ -2765,6 +2774,13 @@ ecore_evas_software_x11_extra_event_window_add(Ecore_Evas *ee __UNUSED__, Ecore_
EAPI Ecore_Evas *
ecore_evas_gl_x11_new(const char *disp_name, Ecore_X_Window parent,
int x, int y, int w, int h)
{
return ecore_evas_gl_x11_options_new(disp_name, parent, x, y, w, h, NULL);
}
EAPI Ecore_Evas *
ecore_evas_gl_x11_options_new(const char *disp_name, Ecore_X_Window parent,
int x, int y, int w, int h, int *opt)
{
# ifdef HAVE_ECORE_X_XCB
Ecore_Evas *ee = NULL;
@ -2813,7 +2829,7 @@ ecore_evas_gl_x11_new(const char *disp_name, Ecore_X_Window parent,
if (parent == 0) parent = DefaultRootWindow(ecore_x_display_get());
ee->engine.x.win_root = parent;
ee->prop.window = _ecore_evas_x_gl_window_new(ee, ee->engine.x.win_root, x, y, w, h, 0);
ee->prop.window = _ecore_evas_x_gl_window_new(ee, ee->engine.x.win_root, x, y, w, h, 0, opt);
if (getenv("DESKTOP_STARTUP_ID"))
{

View File

@ -18,13 +18,14 @@ struct _Evas_Engine_Info_GL_X11
Visual *visual;
Colormap colormap;
int depth;
int screen;
} info;
/* engine specific function calls to query stuff about the destination */
/* engine (what visual & colormap & depth to use, performance info etc. */
struct {
Visual * (*best_visual_get) (Display *disp, int screen);
Colormap (*best_colormap_get) (Display *disp, int screen);
int (*best_depth_get) (Display *disp, int screen);
Visual * (*best_visual_get) (Evas_Engine_Info_GL_X11 *einfo);
Colormap (*best_colormap_get) (Evas_Engine_Info_GL_X11 *einfo);
int (*best_depth_get) (Evas_Engine_Info_GL_X11 *einfo);
} func;
struct {

View File

@ -114,8 +114,8 @@ Evas_GL_X11_Window *eng_window_new(Display *disp, Window win, int screen,
int depth, int w, int h, int indirect);
void eng_window_free(Evas_GL_X11_Window *gw);
void eng_window_use(Evas_GL_X11_Window *gw);
Visual *eng_best_visual_get(Display *disp, int screen);
Colormap eng_best_colormap_get(Display *disp, int screen);
int eng_best_depth_get(Display *disp, int screen);
Visual *eng_best_visual_get(Evas_Engine_Info_GL_X11 *einfo);
Colormap eng_best_colormap_get(Evas_Engine_Info_GL_X11 *einfo);
int eng_best_depth_get(Evas_Engine_Info_GL_X11 *einfo);
#endif

View File

@ -309,60 +309,89 @@ eng_window_use(Evas_GL_X11_Window *gw)
}
Visual *
eng_best_visual_get(Display *disp, int screen)
eng_best_visual_get(Evas_Engine_Info_GL_X11 *einfo)
{
if (!disp) return NULL;
if (!einfo) return NULL;
if (!einfo->info.display) return NULL;
if (!_evas_gl_x11_vi)
{
// EGL / GLES
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
int depth = DefaultDepth(disp, screen);
int depth = DefaultDepth(einfo->info.display,
einfo->info.screen);
_evas_gl_x11_vi = calloc(1, sizeof(XVisualInfo));
XMatchVisualInfo(disp, screen, depth, TrueColor, _evas_gl_x11_vi);
XMatchVisualInfo(einfo->info.display,
einfo->info.screen, depth, TrueColor,
_evas_gl_x11_vi);
// GLX
#else
#if 0 // use this if we want alpha
int config_attrs[20];
#if 1
int config_attrs[40];
GLXFBConfig *configs = NULL, config = 0;
int i, num;
i = 0;
config_attrs[i++] = GLX_DRAWABLE_TYPE;
config_attrs[i++] = GLX_WINDOW_BIT;
config_attrs[i++] = GLX_DOUBLEBUFFER;
config_attrs[i++] = 1;
config_attrs[i++] = GLX_RED_SIZE;
config_attrs[i++] = 4;
config_attrs[i++] = GLX_GREEN_SIZE;
config_attrs[i++] = 4;
config_attrs[i++] = GLX_BLUE_SIZE;
config_attrs[i++] = 4;
config_attrs[i++] = GLX_ALPHA_SIZE;
config_attrs[i++] = 0;
config_attrs[i++] = GLX_RENDER_TYPE;
config_attrs[i++] = 0;//GLX_RGBA_BIT;
config_attrs[i++] = GLX_DEPTH_SIZE;
config_attrs[i++] = 0;
config_attrs[i++] = GLX_STENCIL_SIZE;
config_attrs[i++] = 0;
config_attrs[i++] = GLX_AUX_BUFFERS;
config_attrs[i++] = 0;
config_attrs[i++] = GLX_STEREO;
config_attrs[i++] = 0;
config_attrs[i++] = GLX_TRANSPARENT_TYPE;
config_attrs[i++] = GLX_NONE;//GLX_TRANSPARENT_RGB;
// config_attrs[i++] = GLX_TRANSPARENT_TYPE;
// config_attrs[i++] = GLX_NONE;//GLX_TRANSPARENT_INDEX;
config_attrs[i++] = 0;
config_attrs[0] = GLX_DRAWABLE_TYPE;
config_attrs[1] = GLX_WINDOW_BIT;
config_attrs[2] = GLX_DOUBLEBUFFER;
config_attrs[3] = 1;
config_attrs[4] = GLX_RED_SIZE;
config_attrs[5] = 1;
config_attrs[6] = GLX_GREEN_SIZE;
config_attrs[7] = 1;
config_attrs[8] = GLX_BLUE_SIZE;
config_attrs[9] = 1;
config_attrs[10] = None;
// if rgba
config_attrs[10] = GLX_ALPHA_SIZE;
config_attrs[11] = 1;
config_attrs[12] = GLX_RENDER_TYPE;
config_attrs[13] = GLX_RGBA_BIT;
config_attrs[14] = None;
configs = glXChooseFBConfig(disp, 0, config_attrs, &num);
configs = glXChooseFBConfig(einfo->info.display,
einfo->info.screen,
config_attrs, &num);
for (i = 0; i < num; i++)
{
XVisualInfo *visinfo;
XRenderPictFormat *format;
visinfo = glXGetVisualFromFBConfig(disp, configs[i]);
visinfo = glXGetVisualFromFBConfig(einfo->info.display,
configs[i]);
if (!visinfo) continue;
format = XRenderFindVisualFormat(disp, visinfo->visual);
if (!format) continue;
if (format->direct.alphaMask > 0)
if (1) // non argb
{
config = configs[i];
_evas_gl_x11_vi = visinfo;
break;
}
else
{
format = XRenderFindVisualFormat(einfo->info.display, visinfo->visual);
if (!format)
{
XFree(visinfo);
continue;
}
if (format->direct.alphaMask > 0)
{
config = configs[i];
_evas_gl_x11_vi = visinfo;
break;
}
}
XFree(visinfo);
}
#else
@ -377,7 +406,8 @@ eng_best_visual_get(Display *disp, int screen)
GLX_BLUE_SIZE, 1,
None
};
_evas_gl_x11_vi = glXChooseVisual(disp, screen,
_evas_gl_x11_vi = glXChooseVisual(einfo->info.display,
einfo->info.screen,
_evas_gl_x11_configuration);
#endif
@ -388,15 +418,17 @@ eng_best_visual_get(Display *disp, int screen)
}
Colormap
eng_best_colormap_get(Display *disp, int screen)
eng_best_colormap_get(Evas_Engine_Info_GL_X11 *einfo)
{
if (!disp) return 0;
if (!_evas_gl_x11_vi) eng_best_visual_get(disp, screen);
if (!einfo) return 0;
if (!einfo->info.display) return 0;
if (!_evas_gl_x11_vi) eng_best_visual_get(einfo);
if (!_evas_gl_x11_vi) return 0;
if (!_evas_gl_x11_cmap)
{
_evas_gl_x11_cmap = XCreateColormap(disp,
RootWindow(disp, screen),
_evas_gl_x11_cmap = XCreateColormap(einfo->info.display,
RootWindow(einfo->info.display,
einfo->info.screen),
_evas_gl_x11_vi->visual,
0);
}
@ -404,10 +436,11 @@ eng_best_colormap_get(Display *disp, int screen)
}
int
eng_best_depth_get(Display *disp, int screen)
eng_best_depth_get(Evas_Engine_Info_GL_X11 *einfo)
{
if (!disp) return 0;
if (!_evas_gl_x11_vi) eng_best_visual_get(disp, screen);
if (!einfo) return 0;
if (!einfo->info.display) return 0;
if (!_evas_gl_x11_vi) eng_best_visual_get(einfo);
if (!_evas_gl_x11_vi) return 0;
return _evas_gl_x11_vi->depth;
}