[cairo] Best way to intermediate compositing, recording vs grouping

Uli Schlachter psychon at znc.in
Fri Jul 30 14:55:52 UTC 2021


Am 30.07.21 um 14:12 schrieb Nikita Zlobin:
[...]
> For now only groups approach works correctly.
> Recodring surface is only correct for first frame. But it seems, that
> when I use it next time, previous content is somehow held even despite
> surf was destroyed  / created again.

Destroying / creating a cairo xlib surface does not influence the
content of the window. Whatever was visible there before stays visible
and further drawing happens ontop of that.

>From a quick look at the code you provide, I can say: You are not
drawing a background or clearing the background or anything like that.

If you want the surface cleared / a background drawn, you'll have to do
that "by hand" with e.g. cairo_set_source_rgb(cr, 0, 0, 0);
cairo_paint(cr);.

> Even intentional "safeguard"
> surface creation with immediate destruction (as well as cairo_paint()
> with CLEAR operator... does rec surf ever interpret this?).

Well, you have a recording surface with CAIRO_CONTENT_COLOR_ALPHA.
Clearing that makes it completely transparent. Drawing this to another
surface then does not change anything, because, well, its transparent.

I don't know which visual you are using, but I bet that it does not have
an alpha channel. Thus, your group approach likely creates an immediate
surface with CAIRO_CONTENT_COLOR, i.e. no alpha channel. Clearing that
fills it completely with black.

Cheers,
Uli
-- 
- He wants the impossible...!
- That's the short definition of 'captain'.


More information about the cairo mailing list