[librsvg: 18/90] Pass the bbox of the node being filtered to the filters; don't extract it from the DrawingCtx
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 18/90] Pass the bbox of the node being filtered to the filters; don't extract it from the DrawingCtx
- Date: Tue, 26 Mar 2019 19:13:34 +0000 (UTC)
commit d87504e63d8e549f67f02badfe355480d17c78f8
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Mar 11 15:04:23 2019 -0600
Pass the bbox of the node being filtered to the filters; don't extract it from the DrawingCtx
rsvg_internals/src/bbox.rs | 2 +-
rsvg_internals/src/drawing_ctx.rs | 2 +-
rsvg_internals/src/filters/context.rs | 11 ++++-------
rsvg_internals/src/filters/mod.rs | 3 +++
4 files changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/rsvg_internals/src/bbox.rs b/rsvg_internals/src/bbox.rs
index b8338333..4c76b805 100644
--- a/rsvg_internals/src/bbox.rs
+++ b/rsvg_internals/src/bbox.rs
@@ -3,7 +3,7 @@ use cairo::MatrixTrait;
use crate::rect::RectangleExt;
-#[derive(Debug, Copy, Clone, PartialEq)]
+#[derive(Debug, Copy, Clone)]
pub struct BoundingBox {
pub affine: cairo::Matrix,
pub rect: Option<cairo::Rectangle>, // without stroke
diff --git a/rsvg_internals/src/drawing_ctx.rs b/rsvg_internals/src/drawing_ctx.rs
index fd7b317d..c9966a1e 100644
--- a/rsvg_internals/src/drawing_ctx.rs
+++ b/rsvg_internals/src/drawing_ctx.rs
@@ -543,7 +543,7 @@ impl DrawingCtx {
if !filter_node.is_in_error() {
// FIXME: deal with out of memory here
- filters::render(&filter_node, values, child_surface, self)
+ filters::render(&filter_node, values, child_surface, self, self.bbox)
} else {
Ok(child_surface.clone())
}
diff --git a/rsvg_internals/src/filters/context.rs b/rsvg_internals/src/filters/context.rs
index 643d3507..f2c28468 100644
--- a/rsvg_internals/src/filters/context.rs
+++ b/rsvg_internals/src/filters/context.rs
@@ -101,13 +101,13 @@ impl FilterContext {
computed_from_node_being_filtered: &ComputedValues,
source_surface: SharedImageSurface,
draw_ctx: &mut DrawingCtx,
+ node_bbox: BoundingBox,
) -> Self {
let cr_affine = draw_ctx.get_cairo_context().get_matrix();
- let bbox = draw_ctx.get_bbox().clone();
// The rect can be empty (for example, if the filter is applied to an empty group).
// However, with userSpaceOnUse it's still possible to create images with a filter.
- let bbox_rect = bbox.rect.unwrap_or(cairo::Rectangle {
+ let bbox_rect = node_bbox.rect.unwrap_or(cairo::Rectangle {
x: 0.0,
y: 0.0,
width: 0.0,
@@ -151,7 +151,7 @@ impl FilterContext {
Self {
node: filter_node.clone(),
- node_bbox: bbox,
+ node_bbox,
computed_from_node_being_filtered: computed_from_node_being_filtered.clone(),
source_surface,
last_result: None,
@@ -332,15 +332,12 @@ impl FilterContext {
let cr = cairo::Context::new(&surface);
draw_ctx.set_cairo_context(&cr);
- let bbox = draw_ctx.get_bbox().clone();
- assert!(bbox == self.node_bbox);
-
// FIXME: we are ignoring the following error; propagate it upstream
let _ = draw_ctx
.set_source_paint_server(
paint_server,
&opacity,
- &bbox,
+ &self.node_bbox,
&self.computed_from_node_being_filtered.color.0,
)
.and_then(|had_paint_server| {
diff --git a/rsvg_internals/src/filters/mod.rs b/rsvg_internals/src/filters/mod.rs
index ca8d1063..7b3137ce 100644
--- a/rsvg_internals/src/filters/mod.rs
+++ b/rsvg_internals/src/filters/mod.rs
@@ -6,6 +6,7 @@ use cairo::{self, MatrixTrait};
use owning_ref::RcRef;
use crate::attributes::Attribute;
+use crate::bbox::BoundingBox;
use crate::coord_units::CoordUnits;
use crate::drawing_ctx::DrawingCtx;
use crate::error::{RenderingError, ValueErrorKind};
@@ -233,6 +234,7 @@ pub fn render(
computed_from_node_being_filtered: &ComputedValues,
source: &cairo::ImageSurface,
draw_ctx: &mut DrawingCtx,
+ node_bbox: BoundingBox,
) -> Result<cairo::ImageSurface, RenderingError> {
let filter_node = &*filter_node;
assert_eq!(filter_node.get_type(), NodeType::Filter);
@@ -257,6 +259,7 @@ pub fn render(
computed_from_node_being_filtered,
source_surface,
draw_ctx,
+ node_bbox,
);
// If paffine is non-invertible, we won't draw anything. Also bbox combining in bounds
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]