[librsvg: 1/12] render_markers_for_shape - renamed from _for_path, and pass the whole Shape




commit a55259a70984c50a887a1019538d0127f182db94
Author: Federico Mena Quintero <federico gnome org>
Date:   Thu Jun 3 11:19:29 2021 -0500

    render_markers_for_shape - renamed from _for_path, and pass the whole Shape
    
    This lets the function avoid re-normalizing the stroke width, as it is
    already in the shape.stroke.

 src/drawing_ctx.rs |  8 ++------
 src/marker.rs      | 16 ++++++----------
 src/shapes.rs      |  2 +-
 3 files changed, 9 insertions(+), 17 deletions(-)
---
diff --git a/src/drawing_ctx.rs b/src/drawing_ctx.rs
index 68a3c66a..3c746676 100644
--- a/src/drawing_ctx.rs
+++ b/src/drawing_ctx.rs
@@ -1262,12 +1262,8 @@ impl DrawingCtx {
                             PaintTarget::Markers => {
                                 if shape.markers == Markers::Yes {
                                     path_helper.unset();
-                                    marker::render_markers_for_path(
-                                        &shape.path,
-                                        dc,
-                                        an,
-                                        values,
-                                        clipping,
+                                    marker::render_markers_for_shape(
+                                        shape, dc, an, values, clipping,
                                     )?;
                                 }
                             }
diff --git a/src/marker.rs b/src/marker.rs
index 25f21fbf..338fef76 100644
--- a/src/marker.rs
+++ b/src/marker.rs
@@ -22,6 +22,7 @@ use crate::parsers::{Parse, ParseValue};
 use crate::path_builder::{arc_segment, ArcParameterization, CubicBezierCurve, Path, PathCommand};
 use crate::properties::ComputedValues;
 use crate::rect::Rect;
+use crate::shapes::Shape;
 use crate::transform::Transform;
 use crate::viewbox::*;
 use crate::xml::Attributes;
@@ -610,19 +611,14 @@ where
     emit_fn(marker_type, x, y, orient)
 }
 
-pub fn render_markers_for_path(
-    path: &Path,
+pub fn render_markers_for_shape(
+    shape: &Shape,
     draw_ctx: &mut DrawingCtx,
     acquired_nodes: &mut AcquiredNodes<'_>,
     values: &ComputedValues,
     clipping: bool,
 ) -> Result<BoundingBox, RenderingError> {
-    let view_params = draw_ctx.get_view_params();
-    let params = NormalizeParams::new(values, &view_params);
-
-    let line_width = values.stroke_width().0.to_user(&params);
-
-    if line_width.approx_eq_cairo(0.0) {
+    if shape.stroke.width.approx_eq_cairo(0.0) {
         return Ok(draw_ctx.empty_bbox());
     }
 
@@ -635,7 +631,7 @@ pub fn render_markers_for_path(
     }
 
     emit_markers_for_path(
-        path,
+        &shape.path,
         draw_ctx.empty_bbox(),
         &mut |marker_type: MarkerType, x: f64, y: f64, computed_angle: Angle| {
             if let Iri::Resource(ref marker) = match marker_type {
@@ -650,7 +646,7 @@ pub fn render_markers_for_path(
                     x,
                     y,
                     computed_angle,
-                    line_width,
+                    shape.stroke.width,
                     clipping,
                 )
             } else {
diff --git a/src/shapes.rs b/src/shapes.rs
index aa67c200..12a3483c 100644
--- a/src/shapes.rs
+++ b/src/shapes.rs
@@ -44,7 +44,7 @@ pub struct Shape {
     pub fill_rule: FillRule,
     pub clip_rule: ClipRule,
     pub shape_rendering: ShapeRendering,
-    // TODO: resolve the markers here, to avoid passing ComputedValues to render_markers_for_path()
+    // TODO: resolve the markers here, to avoid passing ComputedValues to render_markers_for_shape()
 }
 
 impl ShapeDef {


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