From 13e055a351f83c56b895b131566a6e842d24ed2a Mon Sep 17 00:00:00 2001 From: zhou jiangwei Date: Tue, 11 Aug 2009 14:18:37 +0100 Subject: [PATCH] [eglx] Update the EGLX backend The EGLX backend needs to be updated to the new ClutterBackendX11 code. Signed-off-by: Emmanuele Bassi --- clutter/eglx/clutter-backend-egl.c | 43 ++++++++++++++++++++++++++++++++++++++ clutter/eglx/clutter-backend-egl.h | 1 + clutter/eglx/clutter-stage-egl.c | 4 ++-- 3 files changed, 46 insertions(+), 2 deletions(-) diff --git a/clutter/eglx/clutter-backend-egl.c b/clutter/eglx/clutter-backend-egl.c index 5a4057d..35f6530 100644 --- a/clutter/eglx/clutter-backend-egl.c +++ b/clutter/eglx/clutter-backend-egl.c @@ -262,11 +262,53 @@ clutter_backend_egl_create_stage (ClutterBackend *backend, return stage; } +static XVisualInfo * +clutter_backend_egl_get_visual_info (ClutterBackendX11 *backend_x11, + gboolean for_offscreen) +{ + EGLint visualId; + int i,nxvisuals; + XVisualInfo *visual_list, *visinfo = None; + XVisualInfo visual_template; + ClutterBackendEGL *backend_egl = CLUTTER_BACKEND_EGL (backend_x11); + + /* Find all the visuals in the screen */ + nxvisuals = 0; + visual_template.screen = backend_x11->xscreen_num; + visual_list = XGetVisualInfo (backend_x11->xdpy, VisualScreenMask, + &visual_template, + &nxvisuals); + if (!visual_list) + return None; + + /*get xvisual id*/ + eglGetConfigAttrib (backend_egl->edpy, backend_egl->egl_config, + EGL_NATIVE_VISUAL_ID, &visualId); + + /* look up the xvisual matching with egl native visual id*/ + for( i = 0; i < nxvisuals; i++) + { + if (visual_list[i].visualid == visualId) + break; + } + + if (i < nxvisuals) + { + visinfo = (XVisualInfo*) Xalloc (sizeof (XVisualInfo)); + *visinfo = visual_list[i]; + } + + XFree (visual_list); + + return visinfo; +} + static void clutter_backend_egl_class_init (ClutterBackendEGLClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); ClutterBackendClass *backend_class = CLUTTER_BACKEND_CLASS (klass); + ClutterBackendX11Class *backendx11_class = CLUTTER_BACKEND_X11_CLASS (klass); gobject_class->constructor = clutter_backend_egl_constructor; gobject_class->dispose = clutter_backend_egl_dispose; @@ -277,6 +319,7 @@ clutter_backend_egl_class_init (ClutterBackendEGLClass *klass) backend_class->get_features = clutter_backend_egl_get_features; backend_class->create_stage = clutter_backend_egl_create_stage; backend_class->ensure_context = clutter_backend_egl_ensure_context; + backendx11_class->get_visual_info = clutter_backend_egl_get_visual_info; } static void diff --git a/clutter/eglx/clutter-backend-egl.h b/clutter/eglx/clutter-backend-egl.h index c5c3ae2..d3e11d0 100644 --- a/clutter/eglx/clutter-backend-egl.h +++ b/clutter/eglx/clutter-backend-egl.h @@ -53,6 +53,7 @@ struct _ClutterBackendEGL EGLDisplay edpy; EGLSurface egl_surface; EGLContext egl_context; + EGLConfig egl_config; gint egl_version_major; gint egl_version_minor; diff --git a/clutter/eglx/clutter-stage-egl.c b/clutter/eglx/clutter-stage-egl.c index 517ae1b..a7507cc 100644 --- a/clutter/eglx/clutter-stage-egl.c +++ b/clutter/eglx/clutter-stage-egl.c @@ -101,7 +101,7 @@ clutter_stage_egl_realize (ClutterActor *actor) EGL_RED_SIZE, 5, EGL_GREEN_SIZE, 6, EGL_BLUE_SIZE, 5, - + EGL_STENCIL_SIZE, 8, #ifdef HAVE_COGL_GLES2 EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, #else /* HAVE_COGL_GLES2 */ @@ -248,7 +248,7 @@ clutter_stage_egl_realize (ClutterActor *actor) g_critical ("Unable to create a suitable EGL context"); goto fail; } - + backend_egl->egl_config = configs[0]; CLUTTER_NOTE (GL, "Created EGL Context"); } } -- 2.7.4