[Cogl] [PATCH 3/3] Use the right context when pushing the GLES2 context to an onscreen

Neil Roberts neil at linux.intel.com
Mon Oct 1 04:06:06 PDT 2012


Previously when pushing the GLES2 context with an onscreen framebuffer
it would just call bind_onscreen. This actually binds it with Cogl's
context so presumably the context isolation wasn't working properly.
This patch splits out bind_onscreen to have a second function called
bind_onscreen_with_context that explicitly takes the EGL context to
use. Cogl now uses this when pushing the GLES2 context.
---
 cogl/winsys/cogl-winsys-egl.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/cogl/winsys/cogl-winsys-egl.c b/cogl/winsys/cogl-winsys-egl.c
index 91f247d..cd6ae3a 100644
--- a/cogl/winsys/cogl-winsys-egl.c
+++ b/cogl/winsys/cogl-winsys-egl.c
@@ -648,17 +648,17 @@ _cogl_winsys_onscreen_deinit (CoglOnscreen *onscreen)
 }
 
 static CoglBool
-bind_onscreen (CoglOnscreen *onscreen)
+bind_onscreen_with_context (CoglOnscreen *onscreen,
+                            EGLContext egl_context)
 {
   CoglFramebuffer *fb = COGL_FRAMEBUFFER (onscreen);
   CoglContext *context = fb->context;
-  CoglDisplayEGL *egl_display = context->display->winsys;
   CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
 
   CoglBool status = _cogl_winsys_egl_make_current (context->display,
                                                    egl_onscreen->egl_surface,
                                                    egl_onscreen->egl_surface,
-                                                   egl_display->egl_context);
+                                                   egl_context);
   if (status)
     {
       CoglRenderer *renderer = context->display->renderer;
@@ -673,6 +673,16 @@ bind_onscreen (CoglOnscreen *onscreen)
   return status;
 }
 
+static CoglBool
+bind_onscreen (CoglOnscreen *onscreen)
+{
+  CoglFramebuffer *fb = COGL_FRAMEBUFFER (onscreen);
+  CoglContext *context = fb->context;
+  CoglDisplayEGL *egl_display = context->display->winsys;
+
+  return bind_onscreen_with_context (onscreen, egl_display->egl_context);
+}
+
 static void
 _cogl_winsys_onscreen_bind (CoglOnscreen *onscreen)
 {
@@ -780,9 +790,9 @@ _cogl_winsys_set_gles2_context (CoglGLES2Context *gles2_ctx, CoglError **error)
 
   if (gles2_ctx->write_buffer &&
       cogl_is_onscreen (gles2_ctx->write_buffer))
-    {
-      status = bind_onscreen (COGL_ONSCREEN (gles2_ctx->write_buffer));
-    }
+    status =
+      bind_onscreen_with_context (COGL_ONSCREEN (gles2_ctx->write_buffer),
+                                  gles2_ctx->winsys);
   else
     status = _cogl_winsys_egl_make_current (ctx->display,
                                             egl_display->dummy_surface,
-- 
1.7.11.3.g3c3efa5



More information about the Cogl mailing list