[librsvg: 21/27] Don't cache resolved gradients anymore




commit 1bf2f6ad8b07917afb46106c8d1906a9fdaacdfd
Author: Federico Mena Quintero <federico gnome org>
Date:   Fri Mar 5 14:36:29 2021 -0600

    Don't cache resolved gradients anymore
    
    We will resolve the stroke/fill opacity directly into the gradient.
    Since this is different for each invocation of the gradient (for the
    stroke *or* fill *or* the current color at each element's cascade), we
    cannot keep a single cached copy of the resolved gradient.
    
    Maybe this will become possible again if we ever cache
    UserSpacePaintSource in a render tree or something.

 src/gradient.rs | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)
---
diff --git a/src/gradient.rs b/src/gradient.rs
index f31d9ac6..c8881ff1 100644
--- a/src/gradient.rs
+++ b/src/gradient.rs
@@ -4,7 +4,6 @@ use cssparser::Parser;
 use markup5ever::{
     expanded_name, local_name, namespace_url, ns, ExpandedName, LocalName, Namespace,
 };
-use once_cell::sync::OnceCell;
 
 use crate::bbox::BoundingBox;
 use crate::coord_units::CoordUnits;
@@ -308,8 +307,6 @@ struct Common {
     spread: Option<SpreadMethod>,
 
     fallback: Option<NodeId>,
-
-    resolved: OnceCell<ResolvedGradient>,
 }
 
 /// Node for the <linearGradient> element
@@ -594,7 +591,7 @@ macro_rules! impl_gradient {
                 }
             }
 
-            fn init_resolved(
+            pub fn resolve(
                 &self,
                 node: &Node,
                 acquired_nodes: &mut AcquiredNodes<'_>,
@@ -633,17 +630,6 @@ macro_rules! impl_gradient {
 
                 Ok(gradient.into_resolved())
             }
-
-            pub fn resolve(
-                &self,
-                node: &Node,
-                acquired_nodes: &mut AcquiredNodes<'_>,
-            ) -> Result<ResolvedGradient, AcquireError> {
-                self.common
-                    .resolved
-                    .get_or_try_init(|| self.init_resolved(node, acquired_nodes))
-                    .map(|r| r.clone())
-            }
         }
     };
 }


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