[librsvg: 1/3] Extract non-API logic from get_geometry_for_layer
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 1/3] Extract non-API logic from get_geometry_for_layer
- Date: Fri, 9 Oct 2020 19:57:01 +0000 (UTC)
commit 41a9165765c11979426cffeb7edf30d3b1fd76af
Author: Federico Mena Quintero <federico gnome org>
Date: Fri Oct 9 14:08:39 2020 -0500
Extract non-API logic from get_geometry_for_layer
rsvg_internals/src/handle.rs | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
---
diff --git a/rsvg_internals/src/handle.rs b/rsvg_internals/src/handle.rs
index 901e5bd9..9a6f78e8 100644
--- a/rsvg_internals/src/handle.rs
+++ b/rsvg_internals/src/handle.rs
@@ -155,18 +155,15 @@ impl Handle {
}
}
- pub fn get_geometry_for_layer(
+ fn geometry_for_layer(
&self,
- id: Option<&str>,
- viewport: &cairo::Rectangle,
+ node: Node,
+ viewport: Rect,
dpi: Dpi,
is_testing: bool,
- ) -> Result<(cairo::Rectangle, cairo::Rectangle), RenderingError> {
- let node = self.get_node_or_root(id)?;
+ ) -> Result<(Rect, Rect), RenderingError> {
let root = self.document.root();
- let viewport = Rect::from(*viewport);
-
let target = cairo::ImageSurface::create(cairo::Format::Rgb24, 1, 1)?;
let cr = cairo::Context::new(&target);
@@ -183,6 +180,21 @@ impl Handle {
let ink_rect = bbox.ink_rect.unwrap_or_default();
let logical_rect = bbox.rect.unwrap_or_default();
+ Ok((ink_rect, logical_rect))
+ }
+
+ pub fn get_geometry_for_layer(
+ &self,
+ id: Option<&str>,
+ viewport: &cairo::Rectangle,
+ dpi: Dpi,
+ is_testing: bool,
+ ) -> Result<(cairo::Rectangle, cairo::Rectangle), RenderingError> {
+ let viewport = Rect::from(*viewport);
+ let node = self.get_node_or_root(id)?;
+
+ let (ink_rect, logical_rect) = self.geometry_for_layer(node, viewport, dpi, is_testing)?;
+
Ok((
cairo::Rectangle::from(ink_rect),
cairo::Rectangle::from(logical_rect),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]