[librsvg] Move the viewport-is-zero-sized check to viewport_to_viewbox_transform()
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] Move the viewport-is-zero-sized check to viewport_to_viewbox_transform()
- Date: Mon, 4 Mar 2019 16:03:16 +0000 (UTC)
commit 6ff5220cc37c1ebc07e75d45b380af6df4483ca1
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Mar 4 09:41:59 2019 -0600
Move the viewport-is-zero-sized check to viewport_to_viewbox_transform()
Maybe we can remove draw_in_viewport() soon?
rsvg_internals/src/aspect_ratio.rs | 10 ++++++++++
rsvg_internals/src/viewport.rs | 11 -----------
2 files changed, 10 insertions(+), 11 deletions(-)
---
diff --git a/rsvg_internals/src/aspect_ratio.rs b/rsvg_internals/src/aspect_ratio.rs
index 77d8c185..1d0b9769 100644
--- a/rsvg_internals/src/aspect_ratio.rs
+++ b/rsvg_internals/src/aspect_ratio.rs
@@ -155,6 +155,16 @@ impl AspectRatio {
vbox: Option<ViewBox>,
viewport: &cairo::Rectangle,
) -> Option<cairo::Matrix> {
+ // width or height set to 0 disables rendering of the element
+ // https://www.w3.org/TR/SVG/struct.html#SVGElementWidthAttribute
+ // https://www.w3.org/TR/SVG/struct.html#UseElementWidthAttribute
+ // https://www.w3.org/TR/SVG/struct.html#ImageElementWidthAttribute
+ // https://www.w3.org/TR/SVG/painting.html#MarkerWidthAttribute
+
+ if viewport.width.approx_eq_cairo(&0.0) || viewport.height.approx_eq_cairo(&0.0) {
+ return None;
+ }
+
// the preserveAspectRatio attribute is only used if viewBox is specified
// https://www.w3.org/TR/SVG/coords.html#PreserveAspectRatioAttribute
if let Some(vbox) = vbox {
diff --git a/rsvg_internals/src/viewport.rs b/rsvg_internals/src/viewport.rs
index 679d5e14..8f1c202e 100644
--- a/rsvg_internals/src/viewport.rs
+++ b/rsvg_internals/src/viewport.rs
@@ -3,7 +3,6 @@ use cairo::Rectangle;
use aspect_ratio::AspectRatio;
use drawing_ctx::DrawingCtx;
use error::RenderingError;
-use float_eq_cairo::ApproxEqCairo;
use node::RsvgNode;
use properties::ComputedValues;
use viewbox::*;
@@ -25,16 +24,6 @@ pub fn draw_in_viewport(
clipping: bool,
draw_fn: &mut FnMut(&mut DrawingCtx) -> Result<(), RenderingError>,
) -> Result<(), RenderingError> {
- // width or height set to 0 disables rendering of the element
- // https://www.w3.org/TR/SVG/struct.html#SVGElementWidthAttribute
- // https://www.w3.org/TR/SVG/struct.html#UseElementWidthAttribute
- // https://www.w3.org/TR/SVG/struct.html#ImageElementWidthAttribute
- // https://www.w3.org/TR/SVG/painting.html#MarkerWidthAttribute
-
- if viewport.width.approx_eq_cairo(&0.0) || viewport.height.approx_eq_cairo(&0.0) {
- return Ok(());
- }
-
draw_ctx.with_discrete_layer(node, values, clipping, &mut |dc| {
let _params = dc.push_new_viewport(vbox, viewport, preserve_aspect_ratio, clip_mode);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]