Discussion:
[cairo] Cairo to Wayland
Mike Gran
2017-06-24 14:58:13 UTC
Permalink
Hi all,

This might be more of a Wayland question than a Cairo question, but...

If I wanted to use Cairo to draw a raw Wayland client window,
what is the most efficient pathway? For a CPU solution,
I could have Cairo draw to an in-memory RGB array and then
send the damaged part of that array to Wayland.

But if there to directly interoperate between Wayland and
Cairo? Can I have both of them looking at the same EGL surface
or the same location in RAM or VRAM?

Regards,
Mike Gran
--
cairo mailing list
***@cairographics.org
https://lists.cairographics.org/mail
Tarnyko
2017-06-25 19:00:50 UTC
Permalink
Hi Mike,

Cairo supports Wayland directly, mast notably via its EGL backend, by using
the Wayland "wl_egl_window" abstraction.
Creation order is like this : wl_egl_window -> EGLSurface -> cairo_surface_t
.

Here is simplified C sample code :

EGLDisplay edpy;
EGLConfig ecfg;
EGLContext ectx;
EGLSurface esrf;
/* - Wayland - */
struct wl_surface *wlsurface;
struct wl_egl_window *wlwindow;
/* - Cairo - */
cairo_device_t *device;
cairo_surface_t *surface;
cairo_t *cr;

wlsurface = wl_compositor_create_surface (wlcompositor);
wlwindow = wl_egl_window_create (wlsurface, 320, 240);

/* create egl display context (edpy, ecfg, ectx) here ... */
esrf = eglCreateWindowSurface (edpy, ecfg, wlwindow, NULL);

device = cairo_egl_device_create (edpy, ectx);
surface = cairo_gl_surface_create_for_egl (device, esrf, 320, 240);
cr = cairo_create (surface);
cairo_rectangle (cr, 0, 0, 320, 240);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_set_source_rgba (cr, 0, 0, 0, 1);
cairo_paint (cr);


I hope it helps.
Regards, Tarnyko
Post by Mike Gran
Hi all,
This might be more of a Wayland question than a Cairo question, but...
If I wanted to use Cairo to draw a raw Wayland client window,
what is the most efficient pathway? For a CPU solution,
I could have Cairo draw to an in-memory RGB array and then
send the damaged part of that array to Wayland.
But if there to directly interoperate between Wayland and
Cairo? Can I have both of them looking at the same EGL surface
or the same location in RAM or VRAM?
Regards,
Mike Gran
--
cairo mailing list
https://lists.cairographics.org/mailman/listinfo/cairo
--
cairo mailing list
***@cairographics.org
https://lists.cairographics
Mike Gran
2017-06-25 20:06:02 UTC
Permalink
Post by Tarnyko
Hi Mike,
Cairo supports Wayland directly, mast notably via its EGL backend, by using
the Wayland "wl_egl_window" abstraction.
Creation order is like this : wl_egl_window -> EGLSurface -> cairo_surface_t
.
...

Thanks very much. That is exactly the information I needed.

Regards,
Mike
--
cairo mailing list
***@cairographics.org
https://lists
Loading...