[librsvg: 72/90] Compute all of the affines in the same place
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 72/90] Compute all of the affines in the same place
- Date: Tue, 26 Mar 2019 19:18:07 +0000 (UTC)
commit a44837e45f152c1953cf79f33740b0d93f63ed2b
Author: Federico Mena Quintero <federico gnome org>
Date: Thu Mar 21 18:42:03 2019 -0600
Compute all of the affines in the same place
rsvg_internals/src/drawing_ctx.rs | 42 +++++++++++++++++++++++++++------------
1 file changed, 29 insertions(+), 13 deletions(-)
---
diff --git a/rsvg_internals/src/drawing_ctx.rs b/rsvg_internals/src/drawing_ctx.rs
index 2031ef67..ab2b1227 100644
--- a/rsvg_internals/src/drawing_ctx.rs
+++ b/rsvg_internals/src/drawing_ctx.rs
@@ -463,6 +463,8 @@ impl DrawingCtx {
&& enable_background == EnableBackground::Accumulate);
if needs_temporary_surface {
+ // Compute our assortment of affines
+
let stack_was_empty = dc.cr_stack.len() == 0;
let affine = if stack_was_empty {
@@ -472,14 +474,6 @@ impl DrawingCtx {
cairo::Matrix::multiply(&affine_at_start, &initial_inverse)
};
- let cr = if filter.is_some() {
- cairo::Context::new(&dc.create_surface_for_toplevel_viewport()?)
- } else {
- cairo::Context::new(
- &dc.create_similar_surface_for_toplevel_viewport(&dc.cr.get_target())?,
- )
- };
-
let temporary_affine = if stack_was_empty {
let initial_inverse = dc.initial_affine_with_offset().try_invert().unwrap();
let untransformed = cairo::Matrix::multiply(&affine, &initial_inverse);
@@ -488,17 +482,37 @@ impl DrawingCtx {
affine_at_start
};
+ let paint_affine = if stack_was_empty {
+ dc.initial_affine_with_offset()
+ } else {
+ cairo::Matrix::identity()
+ };
+
+ // Create temporary surface and its cr
+
+ let cr = if filter.is_some() {
+ cairo::Context::new(&dc.create_surface_for_toplevel_viewport()?)
+ } else {
+ cairo::Context::new(
+ &dc.create_similar_surface_for_toplevel_viewport(&dc.cr.get_target())?,
+ )
+ };
+
cr.set_matrix(temporary_affine);
dc.cr_stack.push(dc.cr.clone());
dc.cr = cr;
+ // Create temporary bbox with the cr's affine
+
let prev_bbox = dc.bbox;
dc.bbox = BoundingBox::new(&temporary_affine);
let mut res = draw_fn(dc);
+ // Filter
+
let source_surface = if let Some(filter_uri) = filter {
let child_surface =
cairo::ImageSurface::from(dc.cr.get_target()).unwrap();
@@ -512,18 +526,18 @@ impl DrawingCtx {
dc.cr = dc.cr_stack.pop().unwrap();
- let paint_affine = if stack_was_empty {
- dc.initial_affine_with_offset()
- } else {
- cairo::Matrix::identity()
- };
+ // Set temporary surface as source
dc.cr.set_matrix(paint_affine);
dc.cr.set_source_surface(&source_surface, 0.0, 0.0);
+ // Clip
+
dc.cr.set_matrix(affine);
dc.clip_to_node(&clip_in_object_space)?;
+ // Mask
+
if let Some(mask) = mask {
if let Some(acquired) =
dc.get_acquired_node_of_type(Some(mask), NodeType::Mask)
@@ -544,6 +558,8 @@ impl DrawingCtx {
);
}
} else {
+ // No mask, so composite the temporary surface
+
dc.cr.set_matrix(paint_affine);
if opacity < 1.0 {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]