[librsvg: 9/13] StackingContext: store the filter property




commit 63a9113ed4d26ebd87a114ad9b08e9f053a5cb80
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue May 11 14:49:01 2021 -0500

    StackingContext: store the filter property

 src/drawing_ctx.rs | 15 +++------------
 src/layout.rs      | 23 +++++++++++++++++------
 2 files changed, 20 insertions(+), 18 deletions(-)
---
diff --git a/src/drawing_ctx.rs b/src/drawing_ctx.rs
index 132ed5a1..a772b179 100644
--- a/src/drawing_ctx.rs
+++ b/src/drawing_ctx.rs
@@ -624,15 +624,6 @@ impl DrawingCtx {
             let clip_uri = clip_path_value.0.get();
             let mask = mask_value.0.get();
 
-            let filters = if node.is_element() {
-                match *node.borrow_element() {
-                    Element::Mask(_) => Filter::None,
-                    _ => values.filter(),
-                }
-            } else {
-                values.filter()
-            };
-
             let Opacity(UnitInterval(opacity)) = stacking_ctx.opacity;
 
             let affine_at_start = saved_cr.draw_ctx.get_transform();
@@ -653,7 +644,7 @@ impl DrawingCtx {
 
             let is_opaque = approx_eq!(f64, opacity, 1.0);
             let needs_temporary_surface = !(is_opaque
-                && filters == Filter::None
+                && stacking_ctx.filter == Filter::None
                 && mask.is_none()
                 && values.mix_blend_mode() == MixBlendMode::Normal
                 && clip_in_object_space.is_none());
@@ -669,7 +660,7 @@ impl DrawingCtx {
 
                 // Create temporary surface and its cr
 
-                let cr = match filters {
+                let cr = match stacking_ctx.filter {
                     Filter::None => cairo::Context::new(
                         &saved_cr
                             .draw_ctx
@@ -708,7 +699,7 @@ impl DrawingCtx {
                     (
                         temporary_draw_ctx.run_filters(
                             surface_to_filter,
-                            &filters,
+                            &stacking_ctx.filter,
                             acquired_nodes,
                             &node_name,
                             values,
diff --git a/src/layout.rs b/src/layout.rs
index 829131fb..bc3b4495 100644
--- a/src/layout.rs
+++ b/src/layout.rs
@@ -4,7 +4,7 @@
 
 use crate::element::Element;
 use crate::properties::ComputedValues;
-use crate::property_defs::Opacity;
+use crate::property_defs::{Filter, Opacity};
 use crate::transform::Transform;
 use crate::unit_interval::UnitInterval;
 
@@ -24,6 +24,7 @@ use crate::unit_interval::UnitInterval;
 pub struct StackingContext {
     pub transform: Transform,
     pub opacity: Opacity,
+    pub filter: Filter,
 }
 
 impl StackingContext {
@@ -33,16 +34,26 @@ impl StackingContext {
         values: &ComputedValues,
     ) -> StackingContext {
         let opacity;
+        let filter;
 
         match *element {
-            // The opacity property does not apply to masks, so we pass 1.0 here.
-            //
             // "The opacity, filter and display properties do not apply to the mask element"
             // https://drafts.fxtf.org/css-masking-1/#MaskElement
-            Element::Mask(_) => opacity = Opacity(UnitInterval::clamp(1.0)),
-            _ => opacity = values.opacity(),
+            Element::Mask(_) => {
+                opacity = Opacity(UnitInterval::clamp(1.0));
+                filter = Filter::None;
+            }
+
+            _ => {
+                opacity = values.opacity();
+                filter = values.filter();
+            }
         }
 
-        StackingContext { transform, opacity }
+        StackingContext {
+            transform,
+            opacity,
+            filter,
+        }
     }
 }


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