summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@gnome.org>2018-06-19 17:36:17 -0500
committerFederico Mena Quintero <federico@gnome.org>2018-06-19 17:36:27 -0500
commit8d7030936c3d00030c7887839e56b6142f8e7d85 (patch)
tree8d58791a51f1958b43ff288666790b3f9931adf8
parent4e243cc78494eb83b01402de49e9d7935537d5fb (diff)
downloadlibrsvg-8d7030936c3d00030c7887839e56b6142f8e7d85.tar.gz
with_discrete_layer(): Don't acquire the clip_node more than once
-rw-r--r--rsvg_internals/src/drawing_ctx.rs50
1 files changed, 16 insertions, 34 deletions
diff --git a/rsvg_internals/src/drawing_ctx.rs b/rsvg_internals/src/drawing_ctx.rs
index 495bb732..379d506f 100644
--- a/rsvg_internals/src/drawing_ctx.rs
+++ b/rsvg_internals/src/drawing_ctx.rs
@@ -238,14 +238,14 @@ pub fn with_discrete_layer(
let current_affine = original_cr.get_matrix();
- if let Some(acquired) =
+ let clip_node =
get_acquired_node_of_type(draw_ctx, clip_uri.map(String::as_ref), NodeType::ClipPath)
- {
- let node = acquired.get();
+ .and_then(|acquired| Some(acquired.get()));
- node.with_impl(|clip_path: &NodeClipPath| match clip_path.get_units() {
+ if let Some(ref clip_node) = clip_node {
+ clip_node.with_impl(|clip_path: &NodeClipPath| match clip_path.get_units() {
ClipPathUnits(CoordUnits::UserSpaceOnUse) => {
- clip_path.to_cairo_context(&node, &current_affine, draw_ctx);
+ late_clip = false;
}
ClipPathUnits(CoordUnits::ObjectBoundingBox) => {
@@ -254,6 +254,14 @@ pub fn with_discrete_layer(
});
}
+ if !late_clip {
+ if let Some(ref clip_node) = clip_node {
+ clip_node.with_impl(|clip_path: &NodeClipPath| {
+ clip_path.to_cairo_context(clip_node, &current_affine, draw_ctx);
+ });
+ }
+ }
+
if !(opacity == 1.0
&& filter.is_none()
&& mask.is_none()
@@ -292,26 +300,6 @@ pub fn with_discrete_layer(
draw_fn(&get_cairo_context(draw_ctx));
- if let Some(acquired) =
- get_acquired_node_of_type(draw_ctx, clip_uri.map(String::as_ref), NodeType::ClipPath)
- {
- let mut clip_path_units = ClipPathUnits::default();
-
- acquired.get().with_impl(|clip_path: &NodeClipPath| {
- clip_path_units = clip_path.get_units();
- });
-
- match clip_path_units {
- ClipPathUnits(CoordUnits::UserSpaceOnUse) => {
- late_clip = false;
- }
-
- ClipPathUnits(CoordUnits::ObjectBoundingBox) => {
- late_clip = true;
- }
- }
- }
-
if !(opacity == 1.0
&& filter.is_none()
&& mask.is_none()
@@ -373,15 +361,9 @@ pub fn with_discrete_layer(
cr.set_source_surface(&surface, xofs, yofs);
if late_clip {
- if let Some(acquired) = get_acquired_node_of_type(
- draw_ctx,
- clip_uri.map(String::as_ref),
- NodeType::ClipPath,
- ) {
- let node = acquired.get();
-
- node.with_impl(|clip_path: &NodeClipPath| {
- clip_path.to_cairo_context(&node, &current_affine, draw_ctx);
+ if let Some(ref clip_node) = clip_node {
+ clip_node.with_impl(|clip_path: &NodeClipPath| {
+ clip_path.to_cairo_context(clip_node, &current_affine, draw_ctx);
});
}
}