[librsvg: 1/3] drawing_ctx: make CompositingAffines private to the module



commit 0199885286f35a41a1dc10da6058d219a4f0c8ad
Author: Paolo Borelli <pborelli gnome org>
Date:   Thu Dec 26 21:27:42 2019 +0100

    drawing_ctx: make CompositingAffines private to the module
    
    The generate_cairo_mask function only needs one affine, not the
    whole CompositingAffines struct. I also decided to multiply
    the affines in the caller instead of calling transform() on the
    cr, since I believe that is clearer.

 rsvg_internals/src/drawing_ctx.rs | 8 ++++++--
 rsvg_internals/src/mask.rs        | 7 +++----
 2 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/rsvg_internals/src/drawing_ctx.rs b/rsvg_internals/src/drawing_ctx.rs
index 4e8eac81..e6fa8846 100644
--- a/rsvg_internals/src/drawing_ctx.rs
+++ b/rsvg_internals/src/drawing_ctx.rs
@@ -487,12 +487,16 @@ impl DrawingCtx {
                     if let Some(fragment) = mask {
                         if let Ok(acquired) = dc.acquire_node(fragment, &[NodeType::Mask]) {
                             let mask_node = acquired.get();
+                            let mask_affine = cairo::Matrix::multiply(
+                                &mask_node.borrow().get_transform(),
+                                &affines.for_temporary_surface,
+                            );
 
                             res = res.and_then(|bbox| {
                                 mask_node
                                     .borrow()
                                     .get_impl::<Mask>()
-                                    .generate_cairo_mask(&mask_node, &affines, dc, &bbox)
+                                    .generate_cairo_mask(&mask_node, mask_affine, dc, &bbox)
                                     .and_then(|mask_surf| {
                                         if let Some(surf) = mask_surf {
                                             dc.cr.set_matrix(affines.compositing);
@@ -886,7 +890,7 @@ impl DrawingCtx {
 }
 
 #[derive(Debug)]
-pub struct CompositingAffines {
+struct CompositingAffines {
     pub outside_temporary_surface: cairo::Matrix,
     pub initial: cairo::Matrix,
     pub for_temporary_surface: cairo::Matrix,
diff --git a/rsvg_internals/src/mask.rs b/rsvg_internals/src/mask.rs
index 746b83ff..018ddd98 100644
--- a/rsvg_internals/src/mask.rs
+++ b/rsvg_internals/src/mask.rs
@@ -5,7 +5,7 @@ use markup5ever::{expanded_name, local_name, namespace_url, ns};
 
 use crate::bbox::BoundingBox;
 use crate::coord_units::CoordUnits;
-use crate::drawing_ctx::{CompositingAffines, DrawingCtx};
+use crate::drawing_ctx::DrawingCtx;
 use crate::error::RenderingError;
 use crate::length::*;
 use crate::node::{CascadedValues, NodeDraw, NodeResult, NodeTrait, RsvgNode};
@@ -47,7 +47,7 @@ impl Mask {
     pub fn generate_cairo_mask(
         &self,
         mask_node: &RsvgNode,
-        affines: &CompositingAffines,
+        affine: cairo::Matrix,
         draw_ctx: &mut DrawingCtx,
         bbox: &BoundingBox,
     ) -> Result<Option<cairo::ImageSurface>, RenderingError> {
@@ -88,8 +88,7 @@ impl Mask {
         // reference to the surface before we access the pixels
         {
             let mask_cr = cairo::Context::new(&mask_content_surface);
-            mask_cr.set_matrix(affines.for_temporary_surface);
-            mask_cr.transform(mask_node.borrow().get_transform());
+            mask_cr.set_matrix(affine);
 
             draw_ctx.push_cairo_context(mask_cr);
 


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