[cairo-commit] 3 commits - boilerplate/cairo-boilerplate-egl.c src/cairo-egl-context.c

Kristian Høgsberg krh at kemper.freedesktop.org
Fri Feb 18 07:06:46 PST 2011


 boilerplate/cairo-boilerplate-egl.c |   17 ++++++++++++-----
 src/cairo-egl-context.c             |   28 +++++++++++++++++-----------
 2 files changed, 29 insertions(+), 16 deletions(-)

New commits:
commit 00ffb09593b25a603cb5c1ad6d3712ea7776a027
Author: Alexandros Frantzis <alexandros.frantzis at linaro.org>
Date:   Fri Feb 11 17:46:51 2011 +0200

    boilerplate/egl: Ensure that we are using an RGBA32 egl config

diff --git a/boilerplate/cairo-boilerplate-egl.c b/boilerplate/cairo-boilerplate-egl.c
index 75439a9..1a5abec 100644
--- a/boilerplate/cairo-boilerplate-egl.c
+++ b/boilerplate/cairo-boilerplate-egl.c
@@ -73,8 +73,17 @@ _cairo_boilerplate_egl_create_surface (const char		 *name,
     egl_target_closure_t *gltc;
     cairo_surface_t *surface;
     int major, minor;
-    EGLConfig *configs;
+    EGLConfig config;
     EGLint numConfigs;
+    EGLint config_attribs[] = {
+	EGL_RED_SIZE, 8,
+	EGL_GREEN_SIZE, 8,
+	EGL_BLUE_SIZE, 8,
+	EGL_ALPHA_SIZE, 8,
+	EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
+	EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
+	EGL_NONE
+    };
 
     gltc = xcalloc (1, sizeof (egl_target_closure_t));
     *closure = gltc;
@@ -86,17 +95,15 @@ _cairo_boilerplate_egl_create_surface (const char		 *name,
 	return NULL;
     }
 
-    eglGetConfigs (gltc->dpy, NULL, 0, &numConfigs);
+    eglChooseConfig (gltc->dpy, config_attribs, &config, 1, &numConfigs);
     if (numConfigs == 0) {
 	free (gltc);
 	return NULL;
     }
-    configs = xmalloc(sizeof(*configs) *numConfigs);
-    eglGetConfigs (gltc->dpy, configs, numConfigs, &numConfigs);
 
     eglBindAPI (EGL_OPENGL_API);
 
-    gltc->ctx = eglCreateContext (gltc->dpy, configs[0], EGL_NO_CONTEXT, NULL);
+    gltc->ctx = eglCreateContext (gltc->dpy, config, EGL_NO_CONTEXT, NULL);
     if (gltc->ctx == EGL_NO_CONTEXT) {
 	eglTerminate (gltc->dpy);
 	free (gltc);
commit 2181a53f61c08c3461c74932add4bac7bfa0cf27
Author: Alexandros Frantzis <alexandros.frantzis at linaro.org>
Date:   Fri Feb 11 16:11:43 2011 +0200

    egl: Ensure that the dummy pbuffer surface is compatible with the supplied context
    
    In order to be able to make an egl context current when using a
    pbuffer surface, that surface must have been created with a config
    that is compatible with the context config. For Mesa, this means that
    the configs must be the same.

diff --git a/src/cairo-egl-context.c b/src/cairo-egl-context.c
index 9f14633..ec23852 100644
--- a/src/cairo-egl-context.c
+++ b/src/cairo-egl-context.c
@@ -140,7 +140,7 @@ cairo_egl_device_create (EGLDisplay dpy, EGLContext egl)
 	EGL_HEIGHT, 1,
 	EGL_NONE,
     };
-    EGLConfig *configs;
+    EGLConfig config;
     EGLint numConfigs;
 
     ctx = calloc (1, sizeof (cairo_egl_context_t));
@@ -158,15 +158,21 @@ cairo_egl_device_create (EGLDisplay dpy, EGLContext egl)
 
     if (!_egl_make_current_surfaceless (ctx)) {
 	/* Fall back to dummy surface, meh. */
-	eglGetConfigs (dpy, NULL, 0, &numConfigs);
-	configs = malloc (sizeof(*configs) *numConfigs);
-	if (configs == NULL) {
-	    free (ctx);
-	    return _cairo_gl_context_create_in_error (CAIRO_STATUS_NO_MEMORY);
-	}
-	eglGetConfigs (dpy, configs, numConfigs, &numConfigs);
-	ctx->dummy_surface = eglCreatePbufferSurface (dpy, configs[0], attribs);
-	free (configs);
+	EGLint config_attribs[] = {
+	    EGL_CONFIG_ID, 0,
+	    EGL_NONE
+	};
+
+	/*
+	 * In order to be able to make an egl context current when using a
+	 * pbuffer surface, that surface must have been created with a config
+	 * that is compatible with the context config. For Mesa, this means
+	 * that the configs must be the same.
+	 */
+	eglQueryContext (dpy, egl, EGL_CONFIG_ID, &config_attribs[1]);
+	eglChooseConfig (dpy, config_attribs, &config, 1, &numConfigs);
+
+	ctx->dummy_surface = eglCreatePbufferSurface (dpy, config, attribs);
 
 	if (ctx->dummy_surface == NULL) {
 	    free (ctx);
commit 3245d6e120a1b8502cf36c3869db40341fb20b2e
Author: Benjamin Franzke <benjaminfranzke at googlemail.com>
Date:   Thu Feb 10 18:07:43 2011 +0200

    egl: Fix eglMakeCurrent for egl surfaces

diff --git a/src/cairo-egl-context.c b/src/cairo-egl-context.c
index b4c18fc..9f14633 100644
--- a/src/cairo-egl-context.c
+++ b/src/cairo-egl-context.c
@@ -73,7 +73,7 @@ _egl_acquire (void *abstract_ctx)
     }
 
     eglMakeCurrent (ctx->display,
-		    ctx->dummy_surface, ctx->dummy_surface, ctx->context);
+		    current_surface, current_surface, ctx->context);
 }
 
 static void


More information about the cairo-commit mailing list