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

Nikita Zlobin nick87720z at gmail.com
Fri Jul 30 23:10:28 UTC 2021


In Fri, 30 Jul 2021 20:08:17 +0200
Uli Schlachter <psychon at znc.in> wrote:

> Am 30.07.21 um 19:25 schrieb Nikita Zlobin:
> > 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:
> >> [...]
> >>> 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.
> > 
> > It has alpha channel, bit depth 32.
> > Test app reproduces it.
> [...]
> 
> Uhm. What exactly does the test app reproduce?
> 
> - I fixed up the Makefile to actually work
> - I added the XMapWindow() and sleep(1) calls that are in the source
> 
> When I run the program, it shows a black window. After a second, some
> dots appear. After another second, some more dots appear. After some
> time, I end up with a solid line.
> 
> Now, your program does *not* clear its background. When I replace the
> "if (0)" near "Clear surface" with "if (1)" and make it draw black
> instead of white (replacing cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
> with cairo_set_source_rgb (cr, 0, 0, 0);), I get:
> 
> - a black window for one second, as before
> - then the points appear and stay. They do not turn into a line.
> 
> So, just as I said: When drawing a background, it seems to work.
> 
> All the other code in that file confuses me...
> 
> Cheers,
> Uli

Strange, makefile should work. Is there problem with implicit rules?

Dots are from different test - it was benchmark for two different
drawing methods.

What you need is one with "Additive stich" in comment, using recording
surface. White background is intentional, because shapes in additive
stich test have dark colors (or you could make them bright, near to
white). In case of wrong stich (as with OVER operator) there would be
fringe between two concentric circles. This test is ok.

Problem is only with recording surface, as described.


More information about the cairo mailing list