[eglx] Update the EGLX backend
authorzhou jiangwei <dyllan.zhou@samsung.com>
Tue, 11 Aug 2009 13:18:37 +0000 (14:18 +0100)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Tue, 11 Aug 2009 13:19:24 +0000 (14:19 +0100)
The EGLX backend needs to be updated to the new ClutterBackendX11
code.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
clutter/eglx/clutter-backend-egl.c
clutter/eglx/clutter-backend-egl.h
clutter/eglx/clutter-stage-egl.c

index 5a4057d..35f6530 100644 (file)
@@ -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
index c5c3ae2..d3e11d0 100644 (file)
@@ -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;
index 517ae1b..a7507cc 100644 (file)
@@ -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");
         }
     }