[librsvg: 1/2] Cleanup for "pattern: respect fill-opacity"
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 1/2] Cleanup for "pattern: respect fill-opacity"
- Date: Sat, 1 Feb 2020 19:12:06 +0000 (UTC)
commit 47de7a1b7ca3f191bb808bea203059f62de66c5f
Author: Sven Neumann <sven svenfoo org>
Date: Fri Jan 31 23:00:58 2020 +0100
Cleanup for "pattern: respect fill-opacity"
This is a follow-up for #510. Moves drawing code to a function so
that the check for fill-opacity only has to be done once.
rsvg_internals/src/pattern.rs | 30 +++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)
---
diff --git a/rsvg_internals/src/pattern.rs b/rsvg_internals/src/pattern.rs
index e583437f..671f2da8 100644
--- a/rsvg_internals/src/pattern.rs
+++ b/rsvg_internals/src/pattern.rs
@@ -344,26 +344,30 @@ impl AsPaintSource for ResolvedPattern {
draw_ctx.set_cairo_context(&cr_pattern);
// Set up transformations to be determined by the contents units
-
- // Draw everything
- let pattern_cascaded = CascadedValues::new_from_node(&node_with_children);
- let pattern_values = pattern_cascaded.get();
-
cr_pattern.set_matrix(caffine.into());
- let UnitInterval(o) = opacity;
- if o < 1.0 {
- cr_pattern.push_group();
+ // Declare a drawing function
+ fn draw_children(
+ ctx: &mut DrawingCtx,
+ node: &RsvgNode,
+ ) -> Result<BoundingBox, RenderingError> {
+ let pattern_cascaded = CascadedValues::new_from_node(&node);
+ let pattern_values = pattern_cascaded.get();
+ ctx.with_discrete_layer(&node, pattern_values, false, &mut |dc| {
+ node.draw_children(&pattern_cascaded, dc, false)
+ })
}
- let res =
- draw_ctx.with_discrete_layer(&node_with_children, pattern_values, false, &mut |dc| {
- node_with_children.draw_children(&pattern_cascaded, dc, false)
- });
-
+ // Draw everything
+ let res;
+ let UnitInterval(o) = opacity;
if o < 1.0 {
+ cr_pattern.push_group();
+ res = draw_children(draw_ctx, &node_with_children);
cr_pattern.pop_group_to_source();
cr_pattern.paint_with_alpha(o);
+ } else {
+ res = draw_children(draw_ctx, &node_with_children);
}
// Return to the original coordinate system and rendering context
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]