[librsvg: 18/31] draw_shape: compute the bbox as early as possible
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 18/31] draw_shape: compute the bbox as early as possible
- Date: Thu, 3 Jun 2021 02:27:11 +0000 (UTC)
commit 9fa029b8ac1cf1c7625d59b0229ac040eaed2ef9
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Jun 2 18:57:31 2021 -0500
draw_shape: compute the bbox as early as possible
There's no need to compute it at the last possible moment just to
avoid unsetting the path in case the paint-order has the markers
before stroke/fill - that's an uncommon case.
src/drawing_ctx.rs | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
---
diff --git a/src/drawing_ctx.rs b/src/drawing_ctx.rs
index d244ae93..16a8f36b 100644
--- a/src/drawing_ctx.rs
+++ b/src/drawing_ctx.rs
@@ -1255,8 +1255,9 @@ impl DrawingCtx {
cr.set_fill_rule(cairo::FillRule::from(values.fill_rule()));
- let mut bounding_box: Option<BoundingBox> = None;
- path_helper.unset();
+ path_helper.set()?;
+ let stroke_paint = values.stroke().0;
+ let bbox = compute_stroke_and_fill_box(&cr, &stroke, &stroke_paint);
for &target in &values.paint_order().targets {
// fill and stroke operations will preserve the path.
@@ -1264,10 +1265,6 @@ impl DrawingCtx {
match target {
PaintTarget::Fill | PaintTarget::Stroke => {
path_helper.set()?;
- let bbox = bounding_box.get_or_insert_with(|| {
- let stroke_paint = values.stroke().0;
- compute_stroke_and_fill_box(&cr, &stroke, &stroke_paint)
- });
if values.is_visible() {
if target == PaintTarget::Stroke {
@@ -1286,7 +1283,7 @@ impl DrawingCtx {
}
path_helper.unset();
- Ok(bounding_box.unwrap())
+ Ok(bbox)
},
)
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]