[librsvg] DrawingCtx: Keep the whole stack of viewboxes in the view_box_stack
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] DrawingCtx: Keep the whole stack of viewboxes in the view_box_stack
- Date: Wed, 12 Sep 2018 11:54:41 +0000 (UTC)
commit 545c8a0b149f8fa7a81ac4bfb87659370bb47a37
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Sep 4 15:44:49 2018 -0500
DrawingCtx: Keep the whole stack of viewboxes in the view_box_stack
We used to keep the element at the top of the stack in a separate
field, which is a bit awkward.
rsvg_internals/src/drawing_ctx.rs | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
---
diff --git a/rsvg_internals/src/drawing_ctx.rs b/rsvg_internals/src/drawing_ctx.rs
index e45c4f28..e9753849 100644
--- a/rsvg_internals/src/drawing_ctx.rs
+++ b/rsvg_internals/src/drawing_ctx.rs
@@ -103,7 +103,6 @@ pub struct DrawingCtx<'a> {
surfaces_stack: Vec<cairo::ImageSurface>,
- vb: ViewBox,
view_box_stack: Vec<ViewBox>,
bbox: BoundingBox,
@@ -149,6 +148,9 @@ impl<'a> DrawingCtx<'a> {
affine.y0 -= rect.y;
cr.set_matrix(affine);
+ let mut view_box_stack = Vec::new();
+ view_box_stack.push(ViewBox::new(0.0, 0.0, vb_width, vb_height));
+
DrawingCtx {
rect,
dpi_x,
@@ -158,8 +160,7 @@ impl<'a> DrawingCtx<'a> {
cr: cr.clone(),
initial_cr: cr.clone(),
surfaces_stack: Vec::new(),
- vb: ViewBox::new(0.0, 0.0, vb_width, vb_height),
- view_box_stack: Vec::new(),
+ view_box_stack,
bbox: BoundingBox::new(&affine),
bbox_stack: Vec::new(),
drawsub_stack: Vec::new(),
@@ -214,23 +215,25 @@ impl<'a> DrawingCtx<'a> {
// push_view_box() / pop_view_box() pair. How do we make this
// safe?
pub fn get_view_params(&self) -> ViewParams {
+ let last = self.view_box_stack.len() - 1;
+
ViewParams {
dpi_x: self.dpi_x,
dpi_y: self.dpi_y,
- view_box_width: self.vb.0.width,
- view_box_height: self.vb.0.height,
+ view_box_width: self.view_box_stack[last].0.width,
+ view_box_height: self.view_box_stack[last].0.height,
}
}
pub fn push_view_box(&mut self, width: f64, height: f64) -> ViewParams {
- self.view_box_stack.push(self.vb);
- self.vb = ViewBox::new(0.0, 0.0, width, height);
+ self.view_box_stack
+ .push(ViewBox::new(0.0, 0.0, width, height));
self.get_view_params()
}
pub fn pop_view_box(&mut self) {
- self.vb = self.view_box_stack.pop().unwrap();
+ self.view_box_stack.pop();
}
pub fn insert_bbox(&mut self, bbox: &BoundingBox) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]