[librsvg: 1/8] Reference-count the DrawingCtx.cr_stack
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 1/8] Reference-count the DrawingCtx.cr_stack
- Date: Thu, 6 May 2021 23:15:17 +0000 (UTC)
commit 4470034745e9d8b953febee973d6124e09d639f1
Author: Federico Mena Quintero <federico gnome org>
Date: Wed May 5 19:22:18 2021 -0500
Reference-count the DrawingCtx.cr_stack
I want to introduce nested drawing contexts, do to away with
push_cairo_context/pop_cairo_context.
src/drawing_ctx.rs | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/src/drawing_ctx.rs b/src/drawing_ctx.rs
index a1a620a4..640d880f 100644
--- a/src/drawing_ctx.rs
+++ b/src/drawing_ctx.rs
@@ -146,7 +146,7 @@ pub struct DrawingCtx {
dpi: Dpi,
- cr_stack: Vec<cairo::Context>,
+ cr_stack: Rc<RefCell<Vec<cairo::Context>>>,
cr: cairo::Context,
viewport_stack: Rc<RefCell<Vec<Viewport>>>,
@@ -261,7 +261,7 @@ impl DrawingCtx {
DrawingCtx {
initial_viewport,
dpi,
- cr_stack: Vec::new(),
+ cr_stack: Rc::new(RefCell::new(Vec::new())),
cr: cr.clone(),
viewport_stack: Rc::new(RefCell::new(viewport_stack)),
drawsub_stack,
@@ -304,13 +304,13 @@ impl DrawingCtx {
// Temporary hack while we unify surface/cr/affine creation
fn push_cairo_context(&mut self, cr: cairo::Context) {
- self.cr_stack.push(self.cr.clone());
+ self.cr_stack.borrow_mut().push(self.cr.clone());
self.cr = cr;
}
// Temporary hack while we unify surface/cr/affine creation
fn pop_cairo_context(&mut self) {
- self.cr = self.cr_stack.pop().unwrap();
+ self.cr = self.cr_stack.borrow_mut().pop().unwrap();
}
fn size_for_temporary_surface(&self) -> (i32, i32) {
@@ -647,7 +647,7 @@ impl DrawingCtx {
let affines = CompositingAffines::new(
affine_at_start,
saved_cr.draw_ctx.initial_transform_with_offset(),
- saved_cr.draw_ctx.cr_stack.len(),
+ saved_cr.draw_ctx.cr_stack.borrow().len(),
);
// Create temporary surface and its cr
@@ -1448,7 +1448,7 @@ impl DrawingCtx {
let mut surface = ExclusiveImageSurface::new(width, height, SurfaceType::SRgb)?;
surface.draw(&mut |cr| {
- for (depth, draw) in self.cr_stack.iter().enumerate() {
+ for (depth, draw) in self.cr_stack.borrow().iter().enumerate() {
let affines = CompositingAffines::new(
Transform::from(draw.get_matrix()),
self.initial_transform_with_offset(),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]