diff options
author | Martin Robinson <mrobinson@igalia.com> | 2013-05-09 10:45:44 -0700 |
---|---|---|
committer | Martin Robinson <mrobinson@igalia.com> | 2013-05-13 15:24:55 -0700 |
commit | 728e58e60f89076f626329ee3f006f011783f90b (patch) | |
tree | 3d262f37753a9b81cdb29dbc6a863150fd1db481 | |
parent | 1704292e493b3c635e115df59d07330d19b39514 (diff) |
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.
-rw-r--r-- | src/cairo-gl-device.c | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/src/cairo-gl-device.c b/src/cairo-gl-device.c index 0166c101..91ce9dee 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; |