Canvas: allow to group rendering of child items

> This group functionality can be convenient for performing
> intermediate compositing. One common use of a group is to
> render objects as opaque within the group, (so that they
> occlude each other), and then blend the result with
> translucence onto the destination.
https://www.cairographics.org/manual/cairo-cairo-t.html#cairo-push-group

The main use case where will be to render opaque layered
[MIDI] regions transparently onto a grid.
This commit is contained in:
Robin Gareus
2022-12-09 01:34:01 +01:00
parent dcf981fe07
commit 70b00f5201
2 changed files with 45 additions and 0 deletions

View File

@@ -59,6 +59,25 @@ public:
* overridden as necessary.
*/
void prepare_for_render (Rect const & area) const;
/** Render all children of this container as group,
* so that they occlude each other. Then blend the result
* onto the destination with the given alpha level.
*
* @param alpha
* - alpha < 0 render normally, do not group rendering. This is the default.
* - alpha == 0 do not render at all. rendered items would be invisible.
* - alpha < 1.0 use a group to render objects, blend flattened result with the given transparency.
* - alpha >= 1.0 simply blit the result of the grouped render operation.
*/
void set_render_with_alpha (double alpha);
double render_with_alpha () const {
return _render_with_alpha;
}
private:
double _render_with_alpha;
};
}