[librsvg: 2/3] pattern: respect fill-opacity



commit 1b3988e5d170fb64a1793cd4ae53f2ee35ae842e
Author: Sven Neumann <sven svenfoo org>
Date:   Wed Jan 29 16:18:22 2020 +0100

    pattern: respect fill-opacity
    
    Fixes #510

 rsvg_internals/src/pattern.rs | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
---
diff --git a/rsvg_internals/src/pattern.rs b/rsvg_internals/src/pattern.rs
index f6069158..a1c416de 100644
--- a/rsvg_internals/src/pattern.rs
+++ b/rsvg_internals/src/pattern.rs
@@ -226,7 +226,7 @@ impl AsPaintSource for ResolvedPattern {
         self,
         values: &ComputedValues,
         draw_ctx: &mut DrawingCtx,
-        _opacity: UnitInterval,
+        opacity: UnitInterval,
         bbox: &BoundingBox,
     ) -> Result<bool, RenderingError> {
         let node_with_children = if let Some(n) = self.children.node_with_children() {
@@ -357,11 +357,21 @@ impl AsPaintSource for ResolvedPattern {
 
         cr_pattern.set_matrix(caffine.into());
 
+        let UnitInterval(o) = opacity;
+        if o < 1.0 {
+            cr_pattern.push_group();
+        }
+
         let res =
             draw_ctx.with_discrete_layer(&node_with_children, pattern_values, false, &mut |dc| {
                 node_with_children.draw_children(&pattern_cascaded, dc, false)
             });
 
+        if o < 1.0 {
+            cr_pattern.pop_group_to_source();
+            cr_pattern.paint_with_alpha(o);
+        }
+
         // Return to the original coordinate system and rendering context
         draw_ctx.set_cairo_context(&cr_save);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]