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

Nikita Zlobin nick87720z at gmail.com
Fri Jul 30 17:23:12 UTC 2021


In Fri, 30 Jul 2021 16:55:52 +0200
Uli Schlachter <psychon at znc.in> wrote:

> 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

Hm, I just meaned background is cleared :), since I went straight to
drawing block.
There's full app for code playground, I use for experiments, including
bugs reproduction and workaround.
https://gitlab.com/-/snippets/2155489

Clearing code is in separate if(0) block (btw, I found need to disable
it when tested using dashed line with rounded caps to draw circles line
instead of doing it manually (it showed performance increase).

Errrrrr..... why reply to mailing list set default 'To:' field to Uli
instead of mailing list :/ .


More information about the cairo mailing list