[librsvg: 4/12] Move Shape to layout.rs
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 4/12] Move Shape to layout.rs
- Date: Thu, 3 Jun 2021 23:25:49 +0000 (UTC)
commit 5ab0f9fa69d62ba98e46e5bfc88246554958de56
Author: Federico Mena Quintero <federico gnome org>
Date: Thu Jun 3 12:16:00 2021 -0500
Move Shape to layout.rs
src/drawing_ctx.rs | 3 +--
src/layout.rs | 27 ++++++++++++++++++++++++++-
src/marker.rs | 3 +--
src/shapes.rs | 20 +-------------------
4 files changed, 29 insertions(+), 24 deletions(-)
---
diff --git a/src/drawing_ctx.rs b/src/drawing_ctx.rs
index e0badae2..2fbd4e4d 100644
--- a/src/drawing_ctx.rs
+++ b/src/drawing_ctx.rs
@@ -22,7 +22,7 @@ use crate::error::{AcquireError, ImplementationLimit, RenderingError};
use crate::filters::{self, FilterSpec};
use crate::float_eq_cairo::ApproxEqCairo;
use crate::gradient::{GradientVariant, SpreadMethod, UserSpaceGradient};
-use crate::layout::{StackingContext, Stroke};
+use crate::layout::{Shape, StackingContext, Stroke};
use crate::length::*;
use crate::marker;
use crate::node::{CascadedValues, Node, NodeBorrow, NodeDraw};
@@ -35,7 +35,6 @@ use crate::property_defs::{
StrokeLinecap, StrokeLinejoin, TextRendering,
};
use crate::rect::Rect;
-use crate::shapes::Shape;
use crate::surface_utils::{
shared_surface::ExclusiveImageSurface, shared_surface::SharedImageSurface,
shared_surface::SurfaceType,
diff --git a/src/layout.rs b/src/layout.rs
index b56a573c..d2d4cf80 100644
--- a/src/layout.rs
+++ b/src/layout.rs
@@ -2,15 +2,20 @@
//!
//! The idea is to take the DOM tree and produce a layout tree with SVG concepts.
+use std::rc::Rc;
+
use crate::coord_units::CoordUnits;
use crate::dasharray::Dasharray;
use crate::document::AcquiredNodes;
use crate::element::Element;
use crate::length::*;
use crate::node::*;
+use crate::paint_server::PaintSource;
+use crate::path_builder::Path;
use crate::properties::ComputedValues;
use crate::property_defs::{
- Filter, MixBlendMode, Opacity, StrokeDasharray, StrokeLinecap, StrokeLinejoin, StrokeMiterlimit,
+ ClipRule, FillRule, Filter, MixBlendMode, Opacity, PaintOrder, ShapeRendering, StrokeDasharray,
+ StrokeLinecap, StrokeLinejoin, StrokeMiterlimit,
};
use crate::transform::Transform;
use crate::unit_interval::UnitInterval;
@@ -49,6 +54,26 @@ pub struct Stroke {
pub dashes: Box<[f64]>,
}
+/// Paths and basic shapes resolved to a path.
+///
+/// Note that `stroke_paint` and `fill_paint` are not in user-space coordinates;
+/// they are just resolved to a `PaintSource`. Turning them to a `UserSpacePaintSource`
+/// involves knowing the bounding box of the path.
+pub struct Shape {
+ pub path: Rc<Path>,
+ pub is_visible: bool,
+ pub paint_order: PaintOrder,
+ pub stroke: Stroke,
+ pub stroke_paint: PaintSource,
+ pub fill_paint: PaintSource,
+ pub fill_rule: FillRule,
+ pub clip_rule: ClipRule,
+ pub shape_rendering: ShapeRendering,
+ pub marker_start: Option<Node>,
+ pub marker_mid: Option<Node>,
+ pub marker_end: Option<Node>,
+}
+
impl StackingContext {
pub fn new(
acquired_nodes: &mut AcquiredNodes<'_>,
diff --git a/src/marker.rs b/src/marker.rs
index 5abcc090..b3d8e953 100644
--- a/src/marker.rs
+++ b/src/marker.rs
@@ -14,13 +14,12 @@ use crate::drawing_ctx::DrawingCtx;
use crate::element::{Draw, ElementResult, SetAttributes};
use crate::error::*;
use crate::float_eq_cairo::ApproxEqCairo;
-use crate::layout::StackingContext;
+use crate::layout::{Shape, StackingContext};
use crate::length::*;
use crate::node::{CascadedValues, Node, NodeBorrow, NodeDraw};
use crate::parsers::{Parse, ParseValue};
use crate::path_builder::{arc_segment, ArcParameterization, CubicBezierCurve, Path, PathCommand};
use crate::rect::Rect;
-use crate::shapes::Shape;
use crate::transform::Transform;
use crate::viewbox::*;
use crate::xml::Attributes;
diff --git a/src/shapes.rs b/src/shapes.rs
index 576e2c3f..eb48a02a 100644
--- a/src/shapes.rs
+++ b/src/shapes.rs
@@ -12,14 +12,12 @@ use crate::drawing_ctx::DrawingCtx;
use crate::element::{Draw, ElementResult, SetAttributes};
use crate::error::*;
use crate::iri::Iri;
-use crate::layout::{StackingContext, Stroke};
+use crate::layout::{Shape, StackingContext, Stroke};
use crate::length::*;
use crate::node::{CascadedValues, Node, NodeBorrow};
-use crate::paint_server::PaintSource;
use crate::parsers::{optional_comma, Parse, ParseValue};
use crate::path_builder::{LargeArc, Path as SvgPath, PathBuilder, Sweep};
use crate::path_parser;
-use crate::property_defs::{ClipRule, FillRule, PaintOrder, ShapeRendering};
use crate::xml::Attributes;
#[derive(PartialEq)]
@@ -33,22 +31,6 @@ struct ShapeDef {
markers: Markers,
}
-// TODO: move Shape to layout.rs?
-pub struct Shape {
- pub path: Rc<SvgPath>,
- pub is_visible: bool,
- pub paint_order: PaintOrder,
- pub stroke: Stroke,
- pub stroke_paint: PaintSource,
- pub fill_paint: PaintSource,
- pub fill_rule: FillRule,
- pub clip_rule: ClipRule,
- pub shape_rendering: ShapeRendering,
- pub marker_start: Option<Node>,
- pub marker_mid: Option<Node>,
- pub marker_end: Option<Node>,
-}
-
impl ShapeDef {
fn new(path: Rc<SvgPath>, markers: Markers) -> ShapeDef {
ShapeDef { path, markers }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]