[librsvg: 11/27] DrawingCtx.get_paint_source_surface - rename from get_paint_server_surface; compute the paint source




commit c37fe88ec032be09b6b05c94c1d216d2fb3bd741
Author: Federico Mena Quintero <federico gnome org>
Date:   Thu Mar 4 19:56:08 2021 -0600

    DrawingCtx.get_paint_source_surface - rename from get_paint_server_surface; compute the paint source in 
its caller
    
    Its only caller is the filters code.

 src/drawing_ctx.rs     | 31 +++++++++-----------------
 src/filters/context.rs | 60 ++++++++++++++++++++++++++++++--------------------
 2 files changed, 46 insertions(+), 45 deletions(-)
---
diff --git a/src/drawing_ctx.rs b/src/drawing_ctx.rs
index 8d442ba8..c57d495f 100644
--- a/src/drawing_ctx.rs
+++ b/src/drawing_ctx.rs
@@ -1172,39 +1172,28 @@ impl DrawingCtx {
     }
 
     /// Computes and returns a surface corresponding to the given paint server.
-    pub fn get_paint_server_surface(
+    pub fn get_paint_source_surface(
         &mut self,
         width: i32,
         height: i32,
         acquired_nodes: &mut AcquiredNodes<'_>,
-        paint_server: &PaintServer,
+        paint_source: &UserSpacePaintSource,
         opacity: UnitInterval,
-        bbox: &BoundingBox,
         current_color: cssparser::RGBA,
-        values: &ComputedValues,
     ) -> Result<SharedImageSurface, cairo::Status> {
         let mut surface = ExclusiveImageSurface::new(width, height, SurfaceType::SRgb)?;
 
         surface.draw(&mut |cr| {
             // FIXME: we are ignoring any error
 
-            if let Ok(resolved) = paint_server.resolve(acquired_nodes) {
-                let paint_source = resolved.to_user_space(bbox, self, values);
-
-                let _ = self.with_cairo_context(cr, &mut |dc| {
-                    dc.set_paint_source(
-                        &paint_source,
-                        opacity,
-                        current_color,
-                        acquired_nodes,
-                    )
-                        .map(|had_paint_server| {
-                            if had_paint_server {
-                                cr.paint();
-                            }
-                        })
-                });
-            }
+            let _ = self.with_cairo_context(cr, &mut |dc| {
+                dc.set_paint_source(paint_source, opacity, current_color, acquired_nodes)
+                    .map(|had_paint_server| {
+                        if had_paint_server {
+                            cr.paint();
+                        }
+                    })
+            });
 
             Ok(())
         })?;
diff --git a/src/filters/context.rs b/src/filters/context.rs
index 34bd6213..53507fa0 100644
--- a/src/filters/context.rs
+++ b/src/filters/context.rs
@@ -287,33 +287,45 @@ impl FilterContext {
                 })
                 .map(FilterInput::StandardInput),
 
-            Input::FillPaint => draw_ctx
-                .get_paint_server_surface(
-                    self.source_surface.width(),
-                    self.source_surface.height(),
-                    acquired_nodes,
-                    &values.fill().0,
-                    values.fill_opacity().0,
+            Input::FillPaint => {
+                let fill_paint_source = values.fill().0.resolve(acquired_nodes)?.to_user_space(
                     &self.node_bbox,
-                    values.color().0,
-                    &values,
-                )
-                .map_err(FilterError::CairoError)
-                .map(FilterInput::StandardInput),
+                    draw_ctx,
+                    values,
+                );
+
+                draw_ctx
+                    .get_paint_source_surface(
+                        self.source_surface.width(),
+                        self.source_surface.height(),
+                        acquired_nodes,
+                        &fill_paint_source,
+                        values.fill_opacity().0,
+                        values.color().0,
+                    )
+                    .map_err(FilterError::CairoError)
+                    .map(FilterInput::StandardInput)
+            }
 
-            Input::StrokePaint => draw_ctx
-                .get_paint_server_surface(
-                    self.source_surface.width(),
-                    self.source_surface.height(),
-                    acquired_nodes,
-                    &values.stroke().0,
-                    values.stroke_opacity().0,
+            Input::StrokePaint => {
+                let stroke_paint_source = values.stroke().0.resolve(acquired_nodes)?.to_user_space(
                     &self.node_bbox,
-                    values.color().0,
-                    &values,
-                )
-                .map_err(FilterError::CairoError)
-                .map(FilterInput::StandardInput),
+                    draw_ctx,
+                    values,
+                );
+
+                draw_ctx
+                    .get_paint_source_surface(
+                        self.source_surface.width(),
+                        self.source_surface.height(),
+                        acquired_nodes,
+                        &stroke_paint_source,
+                        values.stroke_opacity().0,
+                        values.color().0,
+                    )
+                    .map_err(FilterError::CairoError)
+                    .map(FilterInput::StandardInput)
+            }
 
             Input::FilterOutput(ref name) => self
                 .previous_results


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