[librsvg: 23/31] Shape now contains its resolved stroke_paint and fill_paint
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 23/31] Shape now contains its resolved stroke_paint and fill_paint
- Date: Thu, 3 Jun 2021 02:27:11 +0000 (UTC)
commit 23ff9f09e257ab3d654e66bc20ba164cf9c0d2d1
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Jun 2 20:05:21 2021 -0500
Shape now contains its resolved stroke_paint and fill_paint
Resolved, but not converted to user space. For that we need the bbox.
src/drawing_ctx.rs | 25 +++++--------------------
src/shapes.rs | 19 ++++++++++++++++++-
2 files changed, 23 insertions(+), 21 deletions(-)
---
diff --git a/src/drawing_ctx.rs b/src/drawing_ctx.rs
index f8cc599c..39881d13 100644
--- a/src/drawing_ctx.rs
+++ b/src/drawing_ctx.rs
@@ -1234,26 +1234,11 @@ impl DrawingCtx {
cr.set_fill_rule(cairo::FillRule::from(values.fill_rule()));
- let stroke_paint_source =
- values
- .stroke()
- .0
- .resolve(an, values.stroke_opacity().0, values.color().0);
-
- let fill_paint_source =
- values
- .fill()
- .0
- .resolve(an, values.fill_opacity().0, values.color().0);
-
path_helper.set()?;
- let bbox = compute_stroke_and_fill_box(&cr, &shape.stroke, &stroke_paint_source);
-
- let stroke_paint_source =
- stroke_paint_source.to_user_space(&bbox, view_params, values);
+ let bbox = compute_stroke_and_fill_box(&cr, &shape.stroke, &shape.stroke_paint);
- let fill_paint_source =
- fill_paint_source.to_user_space(&bbox, view_params, values);
+ let stroke_paint = shape.stroke_paint.to_user_space(&bbox, view_params, values);
+ let fill_paint = shape.fill_paint.to_user_space(&bbox, view_params, values);
if values.is_visible() {
for &target in &values.paint_order().targets {
@@ -1262,12 +1247,12 @@ impl DrawingCtx {
match target {
PaintTarget::Fill => {
path_helper.set()?;
- dc.fill(&cr, an, &fill_paint_source)?;
+ dc.fill(&cr, an, &fill_paint)?;
}
PaintTarget::Stroke => {
path_helper.set()?;
- dc.stroke(&cr, an, &stroke_paint_source)?;
+ dc.stroke(&cr, an, &stroke_paint)?;
}
PaintTarget::Markers => {
diff --git a/src/shapes.rs b/src/shapes.rs
index 6cf806b6..b3c7dc03 100644
--- a/src/shapes.rs
+++ b/src/shapes.rs
@@ -14,6 +14,7 @@ use crate::error::*;
use crate::layout::Stroke;
use crate::length::*;
use crate::node::{CascadedValues, Node};
+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;
@@ -34,6 +35,8 @@ pub struct Shape {
pub path: Rc<SvgPath>,
pub markers: Markers,
pub stroke: Stroke,
+ pub stroke_paint: PaintSource,
+ pub fill_paint: PaintSource,
}
impl ShapeDef {
@@ -63,11 +66,25 @@ macro_rules! impl_draw {
let shape_def = self.make_shape(¶ms);
let stroke = Stroke::new(values, ¶ms);
-
+
+ let stroke_paint = values.stroke().0.resolve(
+ acquired_nodes,
+ values.stroke_opacity().0,
+ values.color().0,
+ );
+
+ let fill_paint = values.fill().0.resolve(
+ acquired_nodes,
+ values.fill_opacity().0,
+ values.color().0,
+ );
+
let shape = Shape {
path: shape_def.path,
markers: shape_def.markers,
stroke,
+ stroke_paint,
+ fill_paint,
};
draw_ctx.draw_shape(&view_params, &shape, node, acquired_nodes, values, clipping)
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]