[librsvg] shapes: move draw_path method on drawing_ctx
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] shapes: move draw_path method on drawing_ctx
- Date: Mon, 6 Jan 2020 12:25:37 +0000 (UTC)
commit a70fe481f60906b9a76116781324f43e1369c4ef
Author: Paolo Borelli <pborelli gnome org>
Date: Mon Jan 6 13:22:51 2020 +0100
shapes: move draw_path method on drawing_ctx
rsvg_internals/src/drawing_ctx.rs | 37 +++++++++++++++++++++++++++++++++++++
rsvg_internals/src/shapes.rs | 37 +------------------------------------
2 files changed, 38 insertions(+), 36 deletions(-)
---
diff --git a/rsvg_internals/src/drawing_ctx.rs b/rsvg_internals/src/drawing_ctx.rs
index a90af76a..8833c2f5 100644
--- a/rsvg_internals/src/drawing_ctx.rs
+++ b/rsvg_internals/src/drawing_ctx.rs
@@ -18,8 +18,10 @@ use crate::error::{AcquireError, RenderingError};
use crate::filters;
use crate::gradient::{LinearGradient, RadialGradient};
use crate::limits;
+use crate::marker;
use crate::node::{CascadedValues, NodeDraw, NodeType, RsvgNode};
use crate::paint_server::{PaintServer, PaintSource};
+use crate::path_builder::*;
use crate::pattern::Pattern;
use crate::properties::ComputedValues;
use crate::property_defs::{
@@ -27,11 +29,13 @@ use crate::property_defs::{
StrokeLinejoin,
};
use crate::rect::{Rect, TransformRect};
+use crate::shapes::Markers;
use crate::structure::{ClipPath, Mask, Symbol, Use};
use crate::surface_utils::{shared_surface::SharedImageSurface, shared_surface::SurfaceType};
use crate::unit_interval::UnitInterval;
use crate::viewbox::ViewBox;
+
/// Holds values that are required to normalize `Length` values to a current viewport.
///
/// This struct is created by calling `DrawingCtx::push_view_box()` or
@@ -907,6 +911,39 @@ impl DrawingCtx {
res.and_then(|_: ()| Ok(bbox))
}
+ pub fn draw_path(
+ &mut self,
+ builder: &PathBuilder,
+ node: &RsvgNode,
+ values: &ComputedValues,
+ markers: Markers,
+ clipping: bool,
+ ) -> Result<BoundingBox, RenderingError> {
+ if !builder.is_empty() {
+ let bbox = self.with_discrete_layer(node, values, clipping, &mut |dc| {
+ let cr = dc.get_cairo_context();
+
+ builder.to_cairo(&cr)?;
+
+ if clipping {
+ cr.set_fill_rule(cairo::FillRule::from(values.clip_rule));
+ Ok(dc.empty_bbox())
+ } else {
+ cr.set_fill_rule(cairo::FillRule::from(values.fill_rule));
+ dc.stroke_and_fill(&cr, values)
+ }
+ })?;
+
+ if markers == Markers::Yes {
+ marker::render_markers_for_path_builder(builder, self, values, clipping)?;
+ }
+
+ Ok(bbox)
+ } else {
+ Ok(self.empty_bbox())
+ }
+ }
+
pub fn clip(&self, rect: Rect) {
let cr = self.get_cairo_context();
cr.rectangle(rect.x0, rect.y0, rect.width(), rect.height());
diff --git a/rsvg_internals/src/shapes.rs b/rsvg_internals/src/shapes.rs
index 9cdc0209..cbf51701 100644
--- a/rsvg_internals/src/shapes.rs
+++ b/rsvg_internals/src/shapes.rs
@@ -9,7 +9,6 @@ use crate::bbox::BoundingBox;
use crate::drawing_ctx::DrawingCtx;
use crate::error::*;
use crate::length::*;
-use crate::marker;
use crate::node::*;
use crate::parsers::{optional_comma, Parse, ParseValue};
use crate::path_builder::*;
@@ -18,39 +17,6 @@ use crate::properties::ComputedValues;
use crate::property_bag::PropertyBag;
use cssparser::{Parser, Token};
-fn render_path_builder(
- builder: &PathBuilder,
- draw_ctx: &mut DrawingCtx,
- node: &RsvgNode,
- values: &ComputedValues,
- markers: Markers,
- clipping: bool,
-) -> Result<BoundingBox, RenderingError> {
- if !builder.is_empty() {
- let bbox = draw_ctx.with_discrete_layer(node, values, clipping, &mut |dc| {
- let cr = dc.get_cairo_context();
-
- builder.to_cairo(&cr)?;
-
- if clipping {
- cr.set_fill_rule(cairo::FillRule::from(values.clip_rule));
- Ok(dc.empty_bbox())
- } else {
- cr.set_fill_rule(cairo::FillRule::from(values.fill_rule));
- dc.stroke_and_fill(&cr, values)
- }
- })?;
-
- if markers == Markers::Yes {
- marker::render_markers_for_path_builder(builder, draw_ctx, values, clipping)?;
- }
-
- Ok(bbox)
- } else {
- Ok(draw_ctx.empty_bbox())
- }
-}
-
#[derive(Copy, Clone, PartialEq)]
pub enum Markers {
No,
@@ -74,9 +40,8 @@ impl Shape {
draw_ctx: &mut DrawingCtx,
clipping: bool,
) -> Result<BoundingBox, RenderingError> {
- render_path_builder(
+ draw_ctx.draw_path(
&self.builder,
- draw_ctx,
node,
values,
self.markers,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]