[librsvg: 3/5] Use the transform from an element's ComputedValues everywhere
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 3/5] Use the transform from an element's ComputedValues everywhere
- Date: Tue, 3 Aug 2021 23:28:28 +0000 (UTC)
commit 0e98ad1249fef56fc5b814847a4df4e24bc5f538
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Aug 3 17:19:17 2021 -0500
Use the transform from an element's ComputedValues everywhere
The transform is no longer stored in the element itself; now it can be
properly made part of the properties.
Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/575>
src/drawing_ctx.rs | 13 +++++--------
src/element.rs | 10 ----------
src/image.rs | 2 +-
src/properties.rs | 12 ++++++------
src/shapes.rs | 2 +-
src/structure.rs | 8 ++++----
src/text.rs | 2 +-
7 files changed, 18 insertions(+), 31 deletions(-)
---
diff --git a/src/drawing_ctx.rs b/src/drawing_ctx.rs
index af647c94..b72060f9 100644
--- a/src/drawing_ctx.rs
+++ b/src/drawing_ctx.rs
@@ -520,12 +520,10 @@ impl DrawingCtx {
let units = borrow_element_as!(node, ClipPath).get_units();
if let Ok(transform) = bbox.rect_to_transform(units) {
- let node_transform = node
- .borrow_element()
- .get_transform()
- .post_transform(&transform);
-
let cascaded = CascadedValues::new_from_node(node);
+ let values = cascaded.get();
+
+ let node_transform = values.transform().post_transform(&transform);
let orig_transform = self.get_transform();
self.cr.transform(node_transform.into());
@@ -589,7 +587,7 @@ impl DrawingCtx {
let mask_element = mask_node.borrow_element();
- let mask_transform = mask_element.get_transform().post_transform(&transform);
+ let mask_transform = values.transform().post_transform(&transform);
let mask_content_surface = self.create_surface_for_toplevel_viewport()?;
@@ -1621,8 +1619,7 @@ impl DrawingCtx {
let orig_transform = self.get_transform();
- self.cr
- .transform(node.borrow_element().get_transform().into());
+ self.cr.transform(values.transform().into());
let use_element = node.borrow_element();
diff --git a/src/element.rs b/src/element.rs
index 4a281baf..7c132b11 100644
--- a/src/element.rs
+++ b/src/element.rs
@@ -192,12 +192,6 @@ impl<T: SetAttributes + Draw> ElementInner<T> {
.unwrap_or(true)
}
- // TODO for madds: this function will go away, because we want code to be doing
- // values.transform() instead.
- fn get_transform(&self) -> Transform {
- self.specified_values.get_transform()
- }
-
// TODO for madds: this whole function will go away, as the transform attribute will be
// handled automatically by set_presentation_attributes() below.
fn set_transform_attribute(&mut self) -> Result<(), ElementError> {
@@ -537,10 +531,6 @@ impl Element {
call_inner!(self, get_cond, user_language)
}
- pub fn get_transform(&self) -> Transform {
- call_inner!(self, get_transform)
- }
-
pub fn apply_style_declaration(&mut self, declaration: &Declaration, origin: Origin) {
call_inner!(self, apply_style_declaration, declaration, origin)
}
diff --git a/src/image.rs b/src/image.rs
index 39834417..95e48a24 100644
--- a/src/image.rs
+++ b/src/image.rs
@@ -101,7 +101,7 @@ impl Draw for Image {
};
let elt = node.borrow_element();
- let stacking_ctx = StackingContext::new(acquired_nodes, &elt, elt.get_transform(), values);
+ let stacking_ctx = StackingContext::new(acquired_nodes, &elt, values.transform(), values);
draw_ctx.draw_image(&image, &stacking_ctx, acquired_nodes, values, clipping)
}
diff --git a/src/properties.rs b/src/properties.rs
index 2e1d73ac..510efd7c 100644
--- a/src/properties.rs
+++ b/src/properties.rs
@@ -109,6 +109,12 @@ impl Default for SpecifiedValues {
}
impl ComputedValues {
+ // TODO for madds: this function will go away, to be replaced by the one generated
+ // automatically by the macros.
+ pub fn transform(&self) -> Transform {
+ self.transform
+ }
+
pub fn is_overflow(&self) -> bool {
matches!(self.overflow(), Overflow::Auto | Overflow::Visible)
}
@@ -445,12 +451,6 @@ impl SpecifiedValues {
self.transform = transform;
}
- // TODO for madds: this function will go away; it's just a getter
- // used by ElementInner::get_transform()
- pub fn get_transform(&self) -> Transform {
- self.transform
- }
-
fn property_index(&self, id: PropertyId) -> Option<usize> {
let v = self.indices[id.as_usize()];
diff --git a/src/shapes.rs b/src/shapes.rs
index 15b0a423..7d261474 100644
--- a/src/shapes.rs
+++ b/src/shapes.rs
@@ -130,7 +130,7 @@ macro_rules! impl_draw {
let elt = node.borrow_element();
let stacking_ctx =
- StackingContext::new(acquired_nodes, &elt, elt.get_transform(), values);
+ StackingContext::new(acquired_nodes, &elt, values.transform(), values);
draw_ctx.draw_shape(
&view_params,
diff --git a/src/structure.rs b/src/structure.rs
index e6ab541b..b9439863 100644
--- a/src/structure.rs
+++ b/src/structure.rs
@@ -35,7 +35,7 @@ impl Draw for Group {
let values = cascaded.get();
let elt = node.borrow_element();
- let stacking_ctx = StackingContext::new(acquired_nodes, &elt, elt.get_transform(), values);
+ let stacking_ctx = StackingContext::new(acquired_nodes, &elt, values.transform(), values);
draw_ctx.with_discrete_layer(
&stacking_ctx,
@@ -76,7 +76,7 @@ impl Draw for Switch {
let values = cascaded.get();
let elt = node.borrow_element();
- let stacking_ctx = StackingContext::new(acquired_nodes, &elt, elt.get_transform(), values);
+ let stacking_ctx = StackingContext::new(acquired_nodes, &elt, values.transform(), values);
draw_ctx.with_discrete_layer(
&stacking_ctx,
@@ -264,7 +264,7 @@ impl Draw for Svg {
let values = cascaded.get();
let elt = node.borrow_element();
- let stacking_ctx = StackingContext::new(acquired_nodes, &elt, elt.get_transform(), values);
+ let stacking_ctx = StackingContext::new(acquired_nodes, &elt, values.transform(), values);
draw_ctx.with_discrete_layer(
&stacking_ctx,
@@ -540,7 +540,7 @@ impl Draw for Link {
let values = cascaded.get();
let elt = node.borrow_element();
- let stacking_ctx = StackingContext::new(acquired_nodes, &elt, elt.get_transform(), values);
+ let stacking_ctx = StackingContext::new(acquired_nodes, &elt, values.transform(), values);
draw_ctx.with_discrete_layer(
&stacking_ctx,
diff --git a/src/text.rs b/src/text.rs
index c83991b0..932f63a2 100644
--- a/src/text.rs
+++ b/src/text.rs
@@ -533,7 +533,7 @@ impl Draw for Text {
let elt = node.borrow_element();
- let stacking_ctx = StackingContext::new(acquired_nodes, &elt, elt.get_transform(), values);
+ let stacking_ctx = StackingContext::new(acquired_nodes, &elt, values.transform(), values);
draw_ctx.with_discrete_layer(
&stacking_ctx,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]