[librsvg: 50/90] compute_luminance_to_alpha(): Take a SharedImageSurface, not an ImageSurface



commit 65484a7f328d3081c16233402bae738e50de8336
Author: Federico Mena Quintero <federico gnome org>
Date:   Fri Mar 15 09:09:39 2019 -0600

    compute_luminance_to_alpha(): Take a SharedImageSurface, not an ImageSurface
    
    SharedImageSurface forces immutability and this function doesn't
    mutate the input surface, so don't take a mutable surface.

 rsvg_internals/src/mask.rs | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/rsvg_internals/src/mask.rs b/rsvg_internals/src/mask.rs
index a4d5697f..7072b6b0 100644
--- a/rsvg_internals/src/mask.rs
+++ b/rsvg_internals/src/mask.rs
@@ -137,7 +137,11 @@ impl NodeMask {
         }?;
 
         let Opacity(opacity) = values.opacity;
-        let mask_surface = compute_luminance_to_alpha(mask_content_surface, opacity)?;
+
+        let mask_content_surface =
+            SharedImageSurface::new(mask_content_surface, SurfaceType::SRgb)?;
+
+        let mask_surface = compute_luminance_to_alpha(&mask_content_surface, opacity)?;
 
         let cr = draw_ctx.get_cairo_context();
 
@@ -156,11 +160,9 @@ impl NodeMask {
 //
 // This is to get a mask suitable for use with cairo_mask_surface().
 fn compute_luminance_to_alpha(
-    surface: cairo::ImageSurface,
+    surface: &SharedImageSurface,
     opacity: UnitInterval,
 ) -> Result<cairo::ImageSurface, cairo::Status> {
-    let surface = SharedImageSurface::new(surface, SurfaceType::SRgb)?;
-
     let width = surface.width();
     let height = surface.height();
 
@@ -178,7 +180,7 @@ fn compute_luminance_to_alpha(
     {
         let mut output_data = output.get_data().unwrap();
 
-        for (x, y, pixel) in Pixels::new(&surface, bounds) {
+        for (x, y, pixel) in Pixels::new(surface, bounds) {
             output_data.set_pixel(output_stride, pixel.to_mask(opacity), x, y);
         }
     }


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