Skip to content

Commit

Permalink
Remove transform method from NodeExt
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurenzV committed Oct 14, 2023
1 parent 0e468d2 commit 2dca4df
Showing 1 changed file with 8 additions and 23 deletions.
31 changes: 8 additions & 23 deletions crates/usvg-tree/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,16 +732,6 @@ impl NodeKind {
NodeKind::Text(ref e) => e.id.as_str(),
}
}

/// Returns node's transform.
pub fn transform(&self) -> Transform {
match self {
NodeKind::Group(ref e) => e.transform,
NodeKind::Path(_) => Transform::default(),
NodeKind::Image(_) => Transform::default(),
NodeKind::Text(_) => Transform::default(),
}
}
}

/// A group container.
Expand Down Expand Up @@ -1209,12 +1199,6 @@ pub trait NodeExt {
/// will be returned.
fn id(&self) -> std::cell::Ref<str>;

/// Returns node's transform.
///
/// If a current node doesn't support transformation - a default
/// transform will be returned.
fn transform(&self) -> Transform;

/// Returns node's absolute transform.
///
/// If a current node doesn't support transformation - a default
Expand Down Expand Up @@ -1263,15 +1247,12 @@ impl NodeExt for Node {
std::cell::Ref::map(self.borrow(), |v| v.id())
}

#[inline]
fn transform(&self) -> Transform {
self.borrow().transform()
}

fn abs_transform(&self) -> Transform {
let mut ts_list = Vec::new();
for p in self.ancestors() {
ts_list.push(p.transform());
if let NodeKind::Group(ref group) = *p.borrow() {
ts_list.push(group.transform);
}
}

let mut abs_ts = Transform::default();
Expand Down Expand Up @@ -1307,7 +1288,11 @@ fn calc_node_bbox(node: &Node, ts: Transform) -> Option<BBox> {
let mut bbox = BBox::default();

for child in node.children() {
let child_transform = ts.pre_concat(child.transform());
let child_transform = if let NodeKind::Group(ref group) = *child.borrow() {
ts.pre_concat(group.transform)
} else {
ts
};
if let Some(c_bbox) = calc_node_bbox(&child, child_transform) {
bbox = bbox.expand(c_bbox);
}
Expand Down

0 comments on commit 2dca4df

Please sign in to comment.