Skip to content

GtkGLArea performance fixes on OpenGL ES (GTK 3)

When using GtkGLArea on OpenGL ES, GDK uses a slow (and currently buggy) software fallback to copy the temporary framebuffer to the window.

There are a few semi-related issues here.

GtkGLArea creates a temporary framebuffer for the application to draw its stuff on. This temporary framebuffer can either be a renderbuffer or a texture. A renderbuffer may be faster than a texture if the glBlitFramebuffer function is available, but textures permit alpha blending.

The gdk_cairo_draw_from_gl function makes the questionable design decision of trying to automatically query whether the supplied GL object has an alpha channel, rather than requiring the caller to say so. The way this query is implemented doesn't work in OpenGL ES, so the function simply assumes all textures have an alpha channel.

Drawing transparent textures is slower than necessary; apart from the alpha-blending itself, this requires additional calls to gdk_gl_texture_from_surface.

And GDK doesn't correctly detect whether glBlitFramebuffer is available, so using a renderbuffer ends up forcing it to use a software fallback (convert the renderbuffer into a cairo image and then do alpha blending in cairo.)

These changes:

  • fix detection of glBlitFramebuffer;
  • fix detection of opaque textures;
  • and select whether to use a opaque renderbuffer or an opaque texture depending on which is supported.

Merge request reports