[librsvg: 20/90] Replace the explicit bbox_stack by an implicit one



commit ef82e1388a2828b1f87087cf1a4f2bc98e6a0803
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Mar 11 15:23:16 2019 -0600

    Replace the explicit bbox_stack by an implicit one
    
    A bbox is just pushed in the case where we need a temporary surface
    for rendering (i.e. if there are filters/masks/etc.).  This new bbox
    has the affine relative to the temporary surface.

 rsvg_internals/src/drawing_ctx.rs | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/rsvg_internals/src/drawing_ctx.rs b/rsvg_internals/src/drawing_ctx.rs
index 85f2253a..73376731 100644
--- a/rsvg_internals/src/drawing_ctx.rs
+++ b/rsvg_internals/src/drawing_ctx.rs
@@ -106,7 +106,6 @@ pub struct DrawingCtx {
     view_box_stack: Rc<RefCell<Vec<ViewBox>>>,
 
     bbox: BoundingBox,
-    bbox_stack: Vec<BoundingBox>,
 
     drawsub_stack: Vec<RsvgNode>,
 
@@ -171,7 +170,6 @@ impl DrawingCtx {
             initial_cr: cr.clone(),
             view_box_stack: Rc::new(RefCell::new(view_box_stack)),
             bbox: BoundingBox::new(&cairo::Matrix::identity()),
-            bbox_stack: Vec::new(),
             drawsub_stack: Vec::new(),
             acquired_nodes: Rc::new(RefCell::new(Vec::new())),
             measuring,
@@ -450,7 +448,7 @@ impl DrawingCtx {
                 && clip_in_object_space.is_none()
                 && enable_background == EnableBackground::Accumulate);
 
-            if needs_temporary_surface {
+            let prev_bbox = if needs_temporary_surface {
                 let surface = self.create_surface_for_toplevel_viewport().map_err(|e| {
                     self.cr.restore();
                     e
@@ -462,9 +460,13 @@ impl DrawingCtx {
                 self.cr_stack.push(self.cr.clone());
                 self.cr = cr.clone();
 
-                self.bbox_stack.push(self.bbox);
+                let prev_bbox = self.bbox;
                 self.bbox = BoundingBox::new(&affine);
-            }
+
+                prev_bbox
+            } else {
+                self.bbox
+            };
 
             let mut res = draw_fn(self);
 
@@ -520,7 +522,7 @@ impl DrawingCtx {
                 }
 
                 let bbox = self.bbox;
-                self.bbox = self.bbox_stack.pop().unwrap();
+                self.bbox = prev_bbox;
                 self.bbox.insert(&bbox);
             }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]