[librsvg: 17/31] PaintSource::to_user_space - take a ViewParams, not the whole DrawingCtx
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 17/31] PaintSource::to_user_space - take a ViewParams, not the whole DrawingCtx
- Date: Thu, 3 Jun 2021 02:27:11 +0000 (UTC)
commit f1965aee8c6b10b12ea655341ace2236e10c9d39
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Jun 2 18:45:20 2021 -0500
PaintSource::to_user_space - take a ViewParams, not the whole DrawingCtx
src/drawing_ctx.rs | 18 ++++++++++--------
src/gradient.rs | 2 +-
src/paint_server.rs | 28 ++++++++++++++++------------
src/pattern.rs | 2 +-
4 files changed, 28 insertions(+), 22 deletions(-)
---
diff --git a/src/drawing_ctx.rs b/src/drawing_ctx.rs
index 90162318..d244ae93 100644
--- a/src/drawing_ctx.rs
+++ b/src/drawing_ctx.rs
@@ -1164,6 +1164,7 @@ impl DrawingCtx {
&mut self,
cr: &cairo::Context,
acquired_nodes: &mut AcquiredNodes<'_>,
+ view_params: &ViewParams,
values: &ComputedValues,
bbox: &BoundingBox,
) -> Result<(), RenderingError> {
@@ -1171,7 +1172,7 @@ impl DrawingCtx {
.stroke()
.0
.resolve(acquired_nodes, values.stroke_opacity().0, values.color().0)
- .to_user_space(bbox, self, values);
+ .to_user_space(bbox, view_params, values);
self.set_paint_source(&paint_source, acquired_nodes)
.map(|had_paint_server| {
@@ -1187,6 +1188,7 @@ impl DrawingCtx {
&mut self,
cr: &cairo::Context,
acquired_nodes: &mut AcquiredNodes<'_>,
+ view_params: &ViewParams,
values: &ComputedValues,
bbox: &BoundingBox,
) -> Result<(), RenderingError> {
@@ -1194,7 +1196,7 @@ impl DrawingCtx {
.fill()
.0
.resolve(acquired_nodes, values.fill_opacity().0, values.color().0)
- .to_user_space(bbox, self, values);
+ .to_user_space(bbox, view_params, values);
self.set_paint_source(&paint_source, acquired_nodes)
.map(|had_paint_server| {
@@ -1243,8 +1245,8 @@ impl DrawingCtx {
cr.set_antialias(cairo::Antialias::from(values.shape_rendering()));
+ let view_params = dc.get_view_params();
let stroke = {
- let view_params = dc.get_view_params();
let params = NormalizeParams::new(values, &view_params);
Stroke::new(values, ¶ms)
};
@@ -1269,9 +1271,9 @@ impl DrawingCtx {
if values.is_visible() {
if target == PaintTarget::Stroke {
- dc.stroke(&cr, an, values, &bbox)?;
+ dc.stroke(&cr, an, &view_params, values, &bbox)?;
} else {
- dc.fill(&cr, an, values, &bbox)?;
+ dc.fill(&cr, an, &view_params, values, &bbox)?;
}
}
}
@@ -1393,8 +1395,8 @@ impl DrawingCtx {
cr.set_antialias(cairo::Antialias::from(values.text_rendering()));
+ let view_params = saved_cr.draw_ctx.get_view_params();
{
- let view_params = saved_cr.draw_ctx.get_view_params();
let params = NormalizeParams::new(values, &view_params);
let stroke = Stroke::new(values, ¶ms);
@@ -1420,7 +1422,7 @@ impl DrawingCtx {
.fill()
.0
.resolve(acquired_nodes, values.fill_opacity().0, values.color().0)
- .to_user_space(&bbox, saved_cr.draw_ctx, values);
+ .to_user_space(&bbox, &view_params, values);
saved_cr
.draw_ctx
@@ -1440,7 +1442,7 @@ impl DrawingCtx {
.stroke()
.0
.resolve(acquired_nodes, values.stroke_opacity().0, values.color().0)
- .to_user_space(&bbox, saved_cr.draw_ctx, values);
+ .to_user_space(&bbox, &view_params, values);
saved_cr
.draw_ctx
diff --git a/src/gradient.rs b/src/gradient.rs
index fa61796d..f91bd465 100644
--- a/src/gradient.rs
+++ b/src/gradient.rs
@@ -8,7 +8,7 @@ use markup5ever::{
use crate::bbox::BoundingBox;
use crate::coord_units::CoordUnits;
use crate::document::{AcquiredNodes, NodeId, NodeStack};
-use crate::drawing_ctx::{DrawingCtx, ViewParams};
+use crate::drawing_ctx::ViewParams;
use crate::element::{Draw, Element, ElementResult, SetAttributes};
use crate::error::*;
use crate::href::{is_href, set_href};
diff --git a/src/paint_server.rs b/src/paint_server.rs
index 3fa6812d..f58cf0b1 100644
--- a/src/paint_server.rs
+++ b/src/paint_server.rs
@@ -4,7 +4,7 @@ use cssparser::Parser;
use crate::bbox::BoundingBox;
use crate::document::{AcquiredNodes, NodeId};
-use crate::drawing_ctx::{DrawingCtx, ViewParams};
+use crate::drawing_ctx::ViewParams;
use crate::element::Element;
use crate::error::{AcquireError, NodeIdError, ParseError, ValueErrorKind};
use crate::gradient::{ResolvedGradient, UserSpaceGradient};
@@ -200,17 +200,21 @@ impl PaintSource {
PaintSource::None => UserSpacePaintSource::None,
PaintSource::SolidColor(c) => UserSpacePaintSource::SolidColor(c),
- PaintSource::Gradient(ref g, c) => match (g.to_user_space(bbox, current_params, values), c) {
- (Some(gradient), c) => UserSpacePaintSource::Gradient(gradient, c),
- (None, Some(c)) => UserSpacePaintSource::SolidColor(c),
- (None, None) => UserSpacePaintSource::None,
- },
-
- PaintSource::Pattern(ref p, c) => match (p.to_user_space(bbox, current_params, values), c) {
- (Some(pattern), c) => UserSpacePaintSource::Pattern(pattern, c),
- (None, Some(c)) => UserSpacePaintSource::SolidColor(c),
- (None, None) => UserSpacePaintSource::None,
- },
+ PaintSource::Gradient(ref g, c) => {
+ match (g.to_user_space(bbox, current_params, values), c) {
+ (Some(gradient), c) => UserSpacePaintSource::Gradient(gradient, c),
+ (None, Some(c)) => UserSpacePaintSource::SolidColor(c),
+ (None, None) => UserSpacePaintSource::None,
+ }
+ }
+
+ PaintSource::Pattern(ref p, c) => {
+ match (p.to_user_space(bbox, current_params, values), c) {
+ (Some(pattern), c) => UserSpacePaintSource::Pattern(pattern, c),
+ (None, Some(c)) => UserSpacePaintSource::SolidColor(c),
+ (None, None) => UserSpacePaintSource::None,
+ }
+ }
}
}
}
diff --git a/src/pattern.rs b/src/pattern.rs
index 63316a01..42f87941 100644
--- a/src/pattern.rs
+++ b/src/pattern.rs
@@ -6,7 +6,7 @@ use crate::aspect_ratio::*;
use crate::bbox::BoundingBox;
use crate::coord_units::CoordUnits;
use crate::document::{AcquiredNodes, NodeId, NodeStack};
-use crate::drawing_ctx::{DrawingCtx, ViewParams};
+use crate::drawing_ctx::ViewParams;
use crate::element::{Draw, Element, ElementResult, SetAttributes};
use crate::error::*;
use crate::href::{is_href, set_href};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]