[librsvg: 22/26] NodeSvg: extract the operation of getting the viewport to its own function
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 22/26] NodeSvg: extract the operation of getting the viewport to its own function
- Date: Tue, 19 Feb 2019 02:49:53 +0000 (UTC)
commit 1656f6676bd9b7988fc0613cca4fbaa0a13580b2
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Feb 18 19:10:26 2019 -0600
NodeSvg: extract the operation of getting the viewport to its own function
rsvg_internals/src/structure.rs | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
---
diff --git a/rsvg_internals/src/structure.rs b/rsvg_internals/src/structure.rs
index 149bd6fc..aa851461 100644
--- a/rsvg_internals/src/structure.rs
+++ b/rsvg_internals/src/structure.rs
@@ -8,13 +8,13 @@ use aspect_ratio::*;
use attributes::Attribute;
use css::CssStyles;
use dpi::Dpi;
-use drawing_ctx::DrawingCtx;
+use drawing_ctx::{DrawingCtx, ViewParams};
use error::{AttributeResultExt, RenderingError};
use float_eq_cairo::ApproxEqCairo;
use length::*;
use node::*;
use parsers::{Parse, ParseValue};
-use properties::Overflow;
+use properties::{ComputedValues, Overflow};
use property_bag::{OwnedPropertyBag, PropertyBag};
use rect::RectangleExt;
use viewbox::*;
@@ -161,6 +161,20 @@ impl NodeSvg {
vbox: self.vbox.get(),
}
}
+
+ fn get_viewport(&self, values: &ComputedValues, params: &ViewParams) -> Rectangle {
+ let x = self.x.get();
+ let y = self.y.get();
+ let w = self.w.get();
+ let h = self.h.get();
+
+ Rectangle::new(
+ x.normalize(values, ¶ms),
+ y.normalize(values, ¶ms),
+ w.normalize(values, ¶ms),
+ h.normalize(values, ¶ms),
+ )
+ }
}
impl NodeTrait for NodeSvg {
@@ -223,13 +237,6 @@ impl NodeTrait for NodeSvg {
let params = draw_ctx.get_view_params();
- let viewport = Rectangle::new(
- self.x.get().normalize(values, ¶ms),
- self.y.get().normalize(values, ¶ms),
- self.w.get().normalize(values, ¶ms),
- self.h.get().normalize(values, ¶ms),
- );
-
let clip_mode = if !values.is_overflow() && node.get_parent().is_some() {
Some(ClipMode::ClipToViewport)
} else {
@@ -237,7 +244,7 @@ impl NodeTrait for NodeSvg {
};
draw_in_viewport(
- &viewport,
+ &self.get_viewport(values, ¶ms),
clip_mode,
self.vbox.get(),
self.preserve_aspect_ratio.get(),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]