From patchwork Fri Feb 11 18:05:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: alexandros.frantzis@linaro.org X-Patchwork-Id: 130 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:40:14 -0000 Delivered-To: patches@linaro.org Received: by 10.147.124.5 with SMTP id b5cs226409yan; Fri, 11 Feb 2011 10:06:57 -0800 (PST) Received: by 10.204.98.131 with SMTP id q3mr3884293bkn.137.1297447616634; Fri, 11 Feb 2011 10:06:56 -0800 (PST) Received: from mail-ey0-f178.google.com (mail-ey0-f178.google.com [209.85.215.178]) by mx.google.com with ESMTPS id p10si2413523eeh.74.2011.02.11.10.06.56 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 11 Feb 2011 10:06:56 -0800 (PST) Received-SPF: neutral (google.com: 209.85.215.178 is neither permitted nor denied by best guess record for domain of alexandros.frantzis@linaro.org) client-ip=209.85.215.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.215.178 is neither permitted nor denied by best guess record for domain of alexandros.frantzis@linaro.org) smtp.mail=alexandros.frantzis@linaro.org Received: by mail-ey0-f178.google.com with SMTP id 5so1532792eyh.37 for ; Fri, 11 Feb 2011 10:06:56 -0800 (PST) Received: by 10.213.26.15 with SMTP id b15mr760386ebc.16.1297447616043; Fri, 11 Feb 2011 10:06:56 -0800 (PST) Received: from localhost ([194.219.210.40]) by mx.google.com with ESMTPS id x54sm926705eeh.17.2011.02.11.10.06.49 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 11 Feb 2011 10:06:51 -0800 (PST) From: alexandros.frantzis@linaro.org To: cairo@cairographics.org Subject: [PATCH 2/3] egl: Ensure that the dummy pbuffer surface is compatible with the supplied context Date: Fri, 11 Feb 2011 20:05:54 +0200 Message-Id: <1297447555-29654-3-git-send-email-alexandros.frantzis@linaro.org> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1297447555-29654-1-git-send-email-alexandros.frantzis@linaro.org> References: <1297447555-29654-1-git-send-email-alexandros.frantzis@linaro.org> From: Alexandros Frantzis 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. --- src/cairo-egl-context.c | 26 ++++++++++++++++---------- 1 files changed, 16 insertions(+), 10 deletions(-) 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);