void _cairo_gl_context_set_destination (cairo_gl_context_t *ctx, cairo_gl_surface_t *surface, cairo_bool_t multisampling) { /* OpenGL ES surfaces are always in MSAA mode once it's been turned on, * so we don't need to check whether we are switching modes for that * surface type. */ if (ctx->current_target == surface && ! surface->needs_update && (ctx->gl_flavor == CAIRO_GL_FLAVOR_ES || surface->msaa_active == multisampling)) return; _cairo_gl_composite_flush (ctx); ctx->current_target = surface; surface->needs_update = FALSE; if (_cairo_gl_surface_is_texture (surface)) { if (ctx->gl_flavor == CAIRO_GL_FLAVOR_ES) { _cairo_gl_ensure_framebuffer (ctx, surface); ctx->dispatch.BindFramebuffer (GL_FRAMEBUFFER, surface->fb); #if CAIRO_HAS_GL_SURFACE } else if (multisampling) _cairo_gl_activate_surface_as_multisampling (ctx, surface); else { _cairo_gl_activate_surface_as_nonmultisampling (ctx, surface); #endif } } else { ctx->make_current (ctx, surface); #if CAIRO_HAS_GL_SURFACE if (multisampling) glEnable(GL_MULTISAMPLE); else glDisable(GL_MULTISAMPLE); #endif ctx->dispatch.BindFramebuffer (GL_FRAMEBUFFER, 0); #if CAIRO_HAS_GL_SURFACE glDrawBuffer (GL_BACK_LEFT); glReadBuffer (GL_BACK_LEFT); #endif } glViewport (0, 0, surface->width, surface->height); if (_cairo_gl_surface_is_texture (surface)) _gl_identity_ortho (ctx->modelviewprojection_matrix, 0, surface->width, 0, surface->height); else _gl_identity_ortho (ctx->modelviewprojection_matrix, 0, surface->width, surface->height, 0); }
void _cairo_gl_context_set_destination (cairo_gl_context_t *ctx, cairo_gl_surface_t *surface, cairo_bool_t 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) { _cairo_gl_composite_flush (ctx); _cairo_gl_context_bind_framebuffer (ctx, surface, multisampling); return; } _cairo_gl_composite_flush (ctx); ctx->current_target = surface; surface->needs_update = FALSE; if (! _cairo_gl_surface_is_texture (surface)) { ctx->make_current (ctx, surface); } _cairo_gl_context_bind_framebuffer (ctx, surface, multisampling); if (! _cairo_gl_surface_is_texture (surface)) { #if CAIRO_HAS_GL_SURFACE glDrawBuffer (GL_BACK_LEFT); glReadBuffer (GL_BACK_LEFT); #endif } glDisable (GL_DITHER); glViewport (0, 0, surface->width, surface->height); if (_cairo_gl_surface_is_texture (surface)) _gl_identity_ortho (ctx->modelviewprojection_matrix, 0, surface->width, 0, surface->height); else _gl_identity_ortho (ctx->modelviewprojection_matrix, 0, surface->width, surface->height, 0); }