[cairo-commit] src/cairo-gl-device.c

Martin Robinson mrobinson at kemper.freedesktop.org
Mon May 13 15:32:15 PDT 2013


 src/cairo-gl-device.c |   47 +++++++++++++++++++++++++++--------------------
 1 file changed, 27 insertions(+), 20 deletions(-)

New commits:
commit 728e58e60f89076f626329ee3f006f011783f90b
Author: Martin Robinson <mrobinson at igalia.com>
Date:   Thu May 9 10:45:44 2013 -0700

    gles: Switch default framebuffer destinations properly
    
    Make _cairo_gl_context_bind_framebuffer handle different types of GLES
    surfaces properly Since, the multisampling setting of a surface never changes
    in for GLES, so the first thing we do when setting the destination is to
    ignore the requested multisampling setting. This simplifies all
    following logic.

diff --git a/src/cairo-gl-device.c b/src/cairo-gl-device.c
index 0166c10..91ce9de 100644
--- a/src/cairo-gl-device.c
+++ b/src/cairo-gl-device.c
@@ -679,28 +679,33 @@ _cairo_gl_context_bind_framebuffer (cairo_gl_context_t *ctx,
 				    cairo_gl_surface_t *surface,
 				    cairo_bool_t multisampling)
 {
-    /* OpenGL ES surfaces only have either a multisample framebuffer or a
-     * singlesample framebuffer, so we cannot switch back and forth. */
-    if (ctx->gl_flavor == CAIRO_GL_FLAVOR_ES) {
-	_cairo_gl_ensure_framebuffer (ctx, surface);
-	ctx->dispatch.BindFramebuffer (GL_FRAMEBUFFER, surface->fb);
-	return;
-    }
+    if (_cairo_gl_surface_is_texture (surface)) {
+	/* OpenGL ES surfaces only have either a multisample framebuffer or a
+	 * singlesample framebuffer, so we cannot switch back and forth. */
+	if (ctx->gl_flavor == CAIRO_GL_FLAVOR_ES) {
+	    _cairo_gl_ensure_framebuffer (ctx, surface);
+	    ctx->dispatch.BindFramebuffer (GL_FRAMEBUFFER, surface->fb);
+	    return;
+	}
 
 #if CAIRO_HAS_GL_SURFACE
-    if (_cairo_gl_surface_is_texture (surface)) {
 	if (multisampling)
 	    bind_multisample_framebuffer (ctx, surface);
 	else
 	    bind_singlesample_framebuffer (ctx, surface);
+#endif
     } else {
 	ctx->dispatch.BindFramebuffer (GL_FRAMEBUFFER, 0);
-	if (multisampling)
-	    glEnable (GL_MULTISAMPLE);
-	else
-	    glDisable (GL_MULTISAMPLE);
-    }
+
+#if CAIRO_HAS_GL_SURFACE
+	if (ctx->gl_flavor == CAIRO_GL_FLAVOR_DESKTOP) {
+	    if (multisampling)
+		glEnable (GL_MULTISAMPLE);
+	    else
+		glDisable (GL_MULTISAMPLE);
+	}
 #endif
+    }
 
     surface->msaa_active = multisampling;
 }
@@ -710,17 +715,19 @@ _cairo_gl_context_set_destination (cairo_gl_context_t *ctx,
                                    cairo_gl_surface_t *surface,
                                    cairo_bool_t multisampling)
 {
-    cairo_bool_t changing_surface = ctx->current_target != surface || surface->needs_update;
-    cairo_bool_t changing_sampling = surface->msaa_active != multisampling;
+    cairo_bool_t changing_surface, changing_sampling;
+
+    /* The decision whether or not to use multisampling happens when
+     * we create an OpenGL ES surface, so we can never switch modes. */
+    if (ctx->gl_flavor == CAIRO_GL_FLAVOR_ES)
+	multisampling = surface->msaa_active;
+
+    changing_surface = ctx->current_target != surface || surface->needs_update;
+    changing_sampling = surface->msaa_active != multisampling;
     if (! changing_surface && ! changing_sampling)
 	return;
 
     if (! changing_surface) {
-	/* The decision whether or not to use multisampling happen when
-	 * we create an OpenGL ES surface, so switching modes is a no-op. */
-	if (ctx->gl_flavor == CAIRO_GL_FLAVOR_ES)
-	    return;
-
 	_cairo_gl_composite_flush (ctx);
 	_cairo_gl_context_bind_framebuffer (ctx, surface, multisampling);
 	return;


More information about the cairo-commit mailing list