[librsvg: 31/90] clip_path.rs: use DrawingCtx.with_saved_matrix()
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 31/90] clip_path.rs: use DrawingCtx.with_saved_matrix()
- Date: Tue, 26 Mar 2019 19:14:40 +0000 (UTC)
commit 5ae67731f21697778923f9fd0089ff2d6be9f18b
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Mar 13 18:02:26 2019 -0600
clip_path.rs: use DrawingCtx.with_saved_matrix()
rsvg_internals/src/clip_path.rs | 48 ++++++++++++++++++++++-------------------
1 file changed, 26 insertions(+), 22 deletions(-)
---
diff --git a/rsvg_internals/src/clip_path.rs b/rsvg_internals/src/clip_path.rs
index 0e76aaec..fa0e2310 100644
--- a/rsvg_internals/src/clip_path.rs
+++ b/rsvg_internals/src/clip_path.rs
@@ -39,31 +39,35 @@ impl NodeClipPath {
let clip_units = self.units.get();
- let cr = draw_ctx.get_cairo_context();
- let save_affine = cr.get_matrix();
-
- cr.set_matrix(*affine_before_clip);
-
- if clip_units == ClipPathUnits(CoordUnits::ObjectBoundingBox) {
- if bbox.rect.is_none() {
- // The node being clipped is empty / doesn't have a
- // bounding box, so there's nothing to clip!
- return Ok(());
+ draw_ctx.with_saved_matrix(&mut |dc| {
+ let cr = dc.get_cairo_context();
+ cr.set_matrix(*affine_before_clip);
+
+ if clip_units == ClipPathUnits(CoordUnits::ObjectBoundingBox) {
+ if bbox.rect.is_none() {
+ // The node being clipped is empty / doesn't have a
+ // bounding box, so there's nothing to clip!
+ return Ok(());
+ }
+
+ let rect = bbox.rect.as_ref().unwrap();
+
+ cr.transform(cairo::Matrix::new(
+ rect.width,
+ 0.0,
+ 0.0,
+ rect.height,
+ rect.x,
+ rect.y,
+ ))
}
- let rect = bbox.rect.as_ref().unwrap();
-
- cr.transform(cairo::Matrix::new(rect.width, 0.0, 0.0, rect.height, rect.x, rect.y))
- }
-
- // here we don't push a layer because we are clipping
- let res = node.draw_children(&cascaded, draw_ctx, true);
-
- cr.set_matrix(save_affine);
-
- cr.clip();
+ // here we don't push a layer because we are clipping
+ let res = node.draw_children(&cascaded, dc, true);
- res
+ cr.clip();
+ res
+ })
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]