[cairo] trouble with GL and GLES surfaces

Theo Veenker theo.veenker at beexy.nl
Fri Dec 29 16:26:32 UTC 2017

Hi all,

I decided to spend some time on playing with cairo's GL backend. First I looked at 1.15.11 
(this is all under Linux Mint 18 64-bit, kernel 4.4.0-98, X.Org 1.18.4).

Cairo 1.15.11 configured with --enable-gl worked for me. I could use 
cairo_gl_surface_create_for_window(), cairo_gl_surface_create() and 
cairo_surface_create_similar() as advertised.

However when configured with --enable-glesv2 I ran into some problems:
- Cairo_gl_surface_create_for_egl() is fine, but both cairo_gl_surface_create() and 
cairo_surface_create_similar() consistently fail with CAIRO_STATUS_DEVICE_ERROR.
- Copying a (any) surface using cairo_paint() into a surface created by 
cairo_gl_surface_create_for_egl() causes a core dump. That is, at first it sometimes looks 
OK. And then when I trigger a redraw it segfaults. This does not happen with 1.14.12. 
Valgrind consistently shows it is accessing location 0xC. Here's a snippit of the valgrind 
==24122== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==24122==  Access not within mapped region at address 0xC
==24122==    at 0x5AF0562: _cairo_gl_pattern_texture_setup (cairo-gl-operand.c:292)
==24122==    by 0x5AF0562: _cairo_gl_operand_init (cairo-gl-operand.c:555)
==24122==    by 0x5AEC03F: _cairo_gl_composite_set_source (cairo-gl-composite.c:150)
==24122==    by 0x5AEC03F: _blit_texture_to_renderbuffer (cairo-gl-composite.c:108)
==24122==    by 0x5AEC1BC: _cairo_gl_composite_init (cairo-gl-composite.c:1278)
==24122==    by 0x5AF3B43: copy_boxes.part.0 (cairo-gl-spans-compositor.c:342)
==24122==    by 0x5A9FDBC: upload_boxes (cairo-spans-compositor.c:518)
==24122==    by 0x5A9FDBC: composite_aligned_boxes (cairo-spans-compositor.c:630)
==24122==    by 0x5A9FDBC: clip_and_composite_boxes.part.11 (cairo-spans-compositor.c:882)
==24122==    by 0x5A9FE7D: clip_and_composite_boxes (cairo-spans-compositor.c:901)
==24122==    by 0x5AA0198: _cairo_spans_compositor_mask (cairo-spans-compositor.c:999)
==24122==    by 0x5A57578: _cairo_compositor_paint (cairo-compositor.c:65)
==24122==    by 0x5AABAF0: _cairo_surface_paint (cairo-surface.c:2198)
==24122==    by 0x5AF6108: _cairo_gl_surface_draw_image (cairo-gl-surface.c:1049)
==24122==    by 0x5AF39FA: draw_image_boxes (cairo-gl-spans-compositor.c:311)
==24122==    by 0x5A9FDEF: upload_boxes (cairo-spans-compositor.c:514)
==24122==    by 0x5A9FDEF: composite_aligned_boxes (cairo-spans-compositor.c:630)
==24122==    by 0x5A9FDEF: clip_and_composite_boxes.part.11 (cairo-spans-compositor.c:882)

Then I tried the same thing using cairo 1.14.2. Here I don't see any of the problems 
mentioned above. However I did notice a different problem with the regular GL (non-GLES) 
- It appears I can't use a GL surface (as created by cairo_gl_surface_create() or 
cairo_surface_create_similar()) as a source for cairo_set_source_surface(). No error is 
reported by cairo_set_source_surface() or cairo_paint(). This does however work correctly 
when configured with --enable-glesv2.

I did not test the GLESv3 backend as I have no idea where to get the glesv3 package 
referred to by cairo.pc.


Theo Veenker  |  Beexy - Behavioral Experiment Software
+31(0)524-541531  |  +31(0)6-42525777 mobile
theo.veenker at beexy.nl  |  www.beexy.nl

More information about the cairo mailing list