Commit ea761422 authored by Federico Mena Quintero's avatar Federico Mena Quintero

Merge branch 'render-element-to-viewport' into 'master'

New APIs around rendering/measuring layers vs. elements

Closes #448

See merge request !237
parents 6e6b2e9c 5ce94a59
Pipeline #100040 passed with stages
in 35 minutes and 14 seconds
......@@ -26,7 +26,6 @@ rsvg_handle_get_dimensions
rsvg_handle_get_dimensions_sub
rsvg_handle_get_position_sub
rsvg_handle_get_intrinsic_dimensions
rsvg_handle_get_geometry_for_element
rsvg_handle_has_sub
rsvg_handle_get_title
rsvg_handle_get_desc
......@@ -70,6 +69,11 @@ RSVG_TYPE_HANDLE_FLAGS
<SECTION>
<FILE>rsvg-cairo</FILE>
<TITLE>Using RSVG with cairo</TITLE>
rsvg_handle_render_document
rsvg_handle_get_geometry_for_layer
rsvg_handle_render_layer
rsvg_handle_get_geometry_for_element
rsvg_handle_render_element
rsvg_handle_render_cairo
rsvg_handle_render_cairo_sub
</SECTION>
......
......@@ -39,6 +39,41 @@ gboolean rsvg_handle_render_cairo (RsvgHandle *handle, cairo_t *cr);
RSVG_API
gboolean rsvg_handle_render_cairo_sub (RsvgHandle *handle, cairo_t *cr, const char *id);
RSVG_API
gboolean rsvg_handle_render_document (RsvgHandle *handle,
cairo_t *cr,
const RsvgRectangle *viewport,
GError **error);
RSVG_API
gboolean rsvg_handle_get_geometry_for_layer (RsvgHandle *handle,
const char *id,
const RsvgRectangle *viewport,
RsvgRectangle *out_ink_rect,
RsvgRectangle *out_logical_rect,
GError **error);
RSVG_API
gboolean rsvg_handle_render_layer (RsvgHandle *handle,
cairo_t *cr,
const char *id,
const RsvgRectangle *viewport,
GError **error);
RSVG_API
gboolean rsvg_handle_get_geometry_for_element (RsvgHandle *handle,
const char *id,
RsvgRectangle *out_ink_rect,
RsvgRectangle *out_logical_rect,
GError **error);
RSVG_API
gboolean rsvg_handle_render_element (RsvgHandle *handle,
cairo_t *cr,
const char *id,
const RsvgRectangle *element_viewport,
GError **error);
G_END_DECLS
#endif
......@@ -382,12 +382,32 @@ extern void rsvg_rust_handle_get_intrinsic_dimensions (RsvgHandle *handle,
RsvgLength *out_height,
gboolean *out_has_viewbox,
RsvgRectangle *out_viewbox);
extern gboolean rsvg_rust_handle_render_document (RsvgHandle *handle,
cairo_t *cr,
const RsvgRectangle *viewport,
GError **error);
extern gboolean rsvg_rust_handle_get_geometry_for_layer (RsvgHandle *handle,
const char *id,
const RsvgRectangle *viewport,
RsvgRectangle *out_ink_rect,
RsvgRectangle *out_logical_rect,
GError **error);
extern gboolean rsvg_rust_handle_render_layer (RsvgHandle *handle,
cairo_t *cr,
const char *id,
const RsvgRectangle *viewport,
GError **error);
extern gboolean rsvg_rust_handle_get_geometry_for_element (RsvgHandle *handle,
const char *id,
const RsvgRectangle *viewport,
RsvgRectangle *out_ink_rect,
RsvgRectangle *out_logical_rect,
GError **error);
extern gboolean rsvg_rust_handle_render_element (RsvgHandle *handle,
cairo_t *cr,
const char *id,
const RsvgRectangle *element_viewport,
GError **error);
/* Implemented in rsvg_internals/src/c_api.rs */
......@@ -912,7 +932,7 @@ rsvg_handle_get_dimensions (RsvgHandle *handle, RsvgDimensionData *dimension_dat
* "##foo" (hash <literal>foo</literal>) to get the geometry of the element that
* has an <literal>id="foo"</literal> attribute.
*
* Deprecated: 2.46. Use rsvg_handle_get_geometry_for_element() instead.
* Deprecated: 2.46. Use rsvg_handle_get_geometry_for_layer() instead.
*
* Since: 2.22
*/
......@@ -945,7 +965,7 @@ rsvg_handle_get_dimensions_sub (RsvgHandle *handle,
* "##foo" (hash <literal>foo</literal>) to get the geometry of the element that
* has an <literal>id="foo"</literal> attribute.
*
* Deprecated: 2.46. Use rsvg_handle_get_geometry_for_element() instead.
* Deprecated: 2.46. Use rsvg_handle_get_geometry_for_layer() instead.
*
* Since: 2.22
*/
......@@ -1224,7 +1244,43 @@ rsvg_handle_get_intrinsic_dimensions (RsvgHandle *handle,
}
/**
* rsvg_handle_get_geometry_for_element:
* rsvg_handle_render_document:
* @handle: An #RsvgHandle
* @cr: A Cairo context
* @viewport: Viewport size at which the whole SVG would be fitted.
* @error: (allow-none): a location to store a #GError, or %NULL
*
* Renders the whole SVG document fitted to a viewport.
*
* The @viewport gives the position and size at which the whole SVG
* document will be rendered.
*
* The @cr must be in a #CAIRO_STATUS_SUCCESS state, or this function will not
* render anything, and instead will return an error.
*
* API ordering: This function must be called on a fully-loaded @handle. See
* the section <link href="#API-ordering">API ordering</link> for details.
*
* Panics: this function will panic if the @handle is not fully-loaded.
*
* Since: 2.46
*/
gboolean
rsvg_handle_render_document (RsvgHandle *handle,
cairo_t *cr,
const RsvgRectangle *viewport,
GError **error)
{
g_return_val_if_fail (RSVG_IS_HANDLE (handle), FALSE);
g_return_val_if_fail (cr != NULL, FALSE);
g_return_val_if_fail (viewport != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
return rsvg_rust_handle_render_document (handle, cr, viewport, error);
}
/**
* rsvg_handle_get_geometry_for_layer:
* @handle: An #RsvgHandle
* @id: (nullable): An element's id within the SVG, starting with "##" (a single
* hash character), for example, "##layer1". This notation corresponds to a
......@@ -1266,25 +1322,188 @@ rsvg_handle_get_intrinsic_dimensions (RsvgHandle *handle,
* Since: 2.46
*/
gboolean
rsvg_handle_get_geometry_for_layer (RsvgHandle *handle,
const char *id,
const RsvgRectangle *viewport,
RsvgRectangle *out_ink_rect,
RsvgRectangle *out_logical_rect,
GError **error)
{
g_return_val_if_fail (RSVG_IS_HANDLE (handle), FALSE);
g_return_val_if_fail (viewport != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
return rsvg_rust_handle_get_geometry_for_layer (handle,
id,
viewport,
out_ink_rect,
out_logical_rect,
error);
}
/**
* rsvg_handle_render_layer:
* @handle: An #RsvgHandle
* @cr: A Cairo context
* @id: (nullable): An element's id within the SVG, starting with "##" (a single
* hash character), for example, "##layer1". This notation corresponds to a
* URL's fragment ID. Alternatively, pass %NULL to render the whole SVG document tree.
* @viewport: Viewport size at which the whole SVG would be fitted.
* @error: (allow-none): a location to store a #GError, or %NULL
*
* Renders a single SVG element in the same place as for a whole SVG document.
*
* This is equivalent to rsvg_handle_render_document(), but it renders only a
* single element and its children, as if they composed an individual layer in
* the SVG. The element is rendered with the same transformation matrix as it
* has within the whole SVG document. Applications can use this to re-render a
* single element and repaint it on top of a previously-rendered document, for
* example.
*
* Element IDs should look like an URL fragment identifier; for example, pass
* "##foo" (hash <literal>foo</literal>) to get the geometry of the element that
* has an <literal>id="foo"</literal> attribute.
*
* You can pass #NULL for the @id if you want to render all
* the elements in the SVG, i.e. to render everything from the
* root element.
*
* API ordering: This function must be called on a fully-loaded @handle. See
* the section <link href="#API-ordering">API ordering</link> for details.
*
* Panics: this function will panic if the @handle is not fully-loaded.
*
* Since: 2.46
*/
gboolean
rsvg_handle_render_layer (RsvgHandle *handle,
cairo_t *cr,
const char *id,
const RsvgRectangle *viewport,
GError **error)
{
g_return_val_if_fail (RSVG_IS_HANDLE (handle), FALSE);
g_return_val_if_fail (cr != NULL, FALSE);
g_return_val_if_fail (viewport != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
return rsvg_rust_handle_render_layer (handle, cr, id, viewport, error);
}
/**
* rsvg_handle_get_geometry_for_element:
* @handle: An #RsvgHandle
* @id: (nullable): An element's id within the SVG, starting with "##" (a single
* hash character), for example, "##layer1". This notation corresponds to a
* URL's fragment ID. Alternatively, pass %NULL to compute the geometry for the
* whole SVG.
* @out_ink_rect: (out)(optional): Place to store the ink rectangle of the element.
* @out_logical_rect: (out)(optional): Place to store the logical rectangle of the element.
* @error: (allow-none): a location to store a #GError, or %NULL
*
* Computes the ink rectangle and logical rectangle of a singe SVG element.
*
* While `rsvg_handle_get_geometry_for_layer` computes the geometry of an SVG element subtree with
* its transformation matrix, this other function will compute the element's geometry
* as if it were being rendered under an identity transformation by itself. That is,
* the resulting geometry is as if the element got extracted by itself from the SVG.
*
* This function is the counterpart to `rsvg_handle_render_element`.
*
* Element IDs should look like an URL fragment identifier; for example, pass
* "##foo" (hash <literal>foo</literal>) to get the geometry of the element that
* has an <literal>id="foo"</literal> attribute.
*
* The "ink rectangle" is the bounding box that would be painted
* for fully- stroked and filled elements.
*
* The "logical rectangle" just takes into account the unstroked
* paths and text outlines.
*
* Note that these bounds are not minimum bounds; for example,
* clipping paths are not taken into account.
*
* You can pass #NULL for the @id if you want to measure all
* the elements in the SVG, i.e. to measure everything from the
* root element.
*
* This operation is not constant-time, as it involves going through all
* the child elements.
*
* API ordering: This function must be called on a fully-loaded @handle. See
* the section <link href="#API-ordering">API ordering</link> for details.
*
* Panics: this function will panic if the @handle is not fully-loaded.
*
* Since: 2.46
*/
gboolean
rsvg_handle_get_geometry_for_element (RsvgHandle *handle,
const char *id,
const RsvgRectangle *viewport,
RsvgRectangle *out_ink_rect,
RsvgRectangle *out_logical_rect,
GError **error)
{
g_return_val_if_fail (RSVG_IS_HANDLE (handle), FALSE);
g_return_val_if_fail (viewport != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
return rsvg_rust_handle_get_geometry_for_element (handle,
id,
viewport,
out_ink_rect,
out_logical_rect,
error);
}
/**
* rsvg_handle_render_element:
* @handle: An #RsvgHandle
* @cr: A Cairo context
* @id: (nullable): An element's id within the SVG, starting with "##" (a single
* hash character), for example, "##layer1". This notation corresponds to a
* URL's fragment ID. Alternatively, pass %NULL to render the whole SVG document tree.
* @element_viewport: Viewport size in which to fit the element
* @error: (allow-none): a location to store a #GError, or %NULL
*
* Renders a single SVG element to a given viewport
*
* This function can be used to extract individual element subtrees and render them,
* scaled to a given @element_viewport. This is useful for applications which have
* reusable objects in an SVG and want to render them individually; for example, an
* SVG full of icons that are meant to be be rendered independently of each other.
*
* Element IDs should look like an URL fragment identifier; for example, pass
* "##foo" (hash <literal>foo</literal>) to get the geometry of the element that
* has an <literal>id="foo"</literal> attribute.
*
* You can pass #NULL for the @id if you want to render all
* the elements in the SVG, i.e. to render everything from the
* root element.
*
* The `element_viewport` gives the position and size at which the named element will
* be rendered. FIXME: mention proportional scaling.
*
* API ordering: This function must be called on a fully-loaded @handle. See
* the section <link href="#API-ordering">API ordering</link> for details.
*
* Panics: this function will panic if the @handle is not fully-loaded.
*
* Since: 2.46
*/
gboolean
rsvg_handle_render_element (RsvgHandle *handle,
cairo_t *cr,
const char *id,
const RsvgRectangle *element_viewport,
GError **error)
{
g_return_val_if_fail (RSVG_IS_HANDLE (handle), FALSE);
g_return_val_if_fail (cr != NULL, FALSE);
g_return_val_if_fail (element_viewport != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
return rsvg_rust_handle_render_element (handle, cr, id, element_viewport, error);
}
/**
* rsvg_handle_internal_set_testing:
* @handle: a #RsvgHandle
......
......@@ -206,12 +206,12 @@ void rsvg_handle_set_base_uri (RsvgHandle *handle, const char *base_uri)
RSVG_API
void rsvg_handle_get_dimensions (RsvgHandle *handle, RsvgDimensionData *dimension_data);
RSVG_DEPRECATED_FOR(rsvg_handle_get_geometry_for_element)
RSVG_DEPRECATED_FOR(rsvg_handle_get_geometry_for_layer)
gboolean rsvg_handle_get_dimensions_sub (RsvgHandle *handle,
RsvgDimensionData *dimension_data,
const char *id);
RSVG_DEPRECATED_FOR(rsvg_handle_get_geometry_for_element)
RSVG_DEPRECATED_FOR(rsvg_handle_get_geometry_for_layer)
gboolean rsvg_handle_get_position_sub (RsvgHandle *handle,
RsvgPositionData *position_data,
const char *id);
......@@ -280,14 +280,6 @@ void rsvg_handle_get_intrinsic_dimensions (RsvgHandle *handle,
gboolean *out_has_viewbox,
RsvgRectangle *out_viewbox);
RSVG_API
gboolean rsvg_handle_get_geometry_for_element (RsvgHandle *handle,
const char *id,
const RsvgRectangle *viewport,
RsvgRectangle *out_ink_rect,
RsvgRectangle *out_logical_rect,
GError **error);
/* GIO APIs */
/**
......
......@@ -34,9 +34,8 @@ fn main() {
let surface = cairo::ImageSurface::create(cairo::Format::ARgb32, width, height).unwrap();
let cr = cairo::Context::new(&surface);
renderer
.render_element_to_viewport(
.render_document(
&cr,
None,
&cairo::Rectangle {
x: 0.0,
y: 0.0,
......
......@@ -13,9 +13,8 @@ fn main() {
let surface = cairo::SvgSurface::new(width, height, output);
let cr = cairo::Context::new(&surface);
renderer
.render_element_to_viewport(
.render_document(
&cr,
None,
&cairo::Rectangle {
x: 0.0,
y: 0.0,
......
......@@ -374,6 +374,22 @@ impl<'a> CairoRenderer<'a> {
}
}
/// Renders the whole SVG document fitted to a viewport
///
/// The `viewport` gives the position and size at which the whole SVG
/// document will be rendered.
///
/// The `cr` must be in a `cairo::Status::Success` state, or this function
/// will not render anything, and instead will return
/// `RenderingError::Cairo` with the `cr`'s current error state.
pub fn render_document(
&self,
cr: &cairo::Context,
viewport: &cairo::Rectangle,
) -> Result<(), RenderingError> {
self.handle.0.render_document(cr, viewport, self.dpi, false)
}
/// Computes the (ink_rect, logical_rect) of an SVG element, as if
/// the SVG were rendered to a specific viewport.
///
......@@ -398,18 +414,37 @@ impl<'a> CairoRenderer<'a> {
/// the child elements.
///
/// FIXME: example
pub fn geometry_for_element(
pub fn geometry_for_layer(
&self,
id: Option<&str>,
viewport: &cairo::Rectangle,
) -> Result<(cairo::Rectangle, cairo::Rectangle), RenderingError> {
self.handle
.0
.get_geometry_for_element(id, viewport, self.dpi, false)
.get_geometry_for_layer(id, viewport, self.dpi, false)
.map(|(i, l)| (i.into(), l.into()))
}
pub fn render_element_to_viewport(
/// Renders a single SVG element in the same place as for a whole SVG document
///
/// This is equivalent to `render_document`, but renders only a single element and its
/// children, as if they composed an individual layer in the SVG. The element is
/// rendered with the same transformation matrix as it has within the whole SVG
/// document. Applications can use this to re-render a single element and repaint it
/// on top of a previously-rendered document, for example.
///
/// Note that the `id` must be a plain fragment identifier like `#foo`, with
/// a leading `#` character.
///
/// The `viewport` gives the position and size at which the whole SVG
/// document would be rendered. This function will effectively place the
/// whole SVG within that viewport, but only render the element given by
/// `id`.
///
/// The `cr` must be in a `cairo::Status::Success` state, or this function
/// will not render anything, and instead will return
/// `RenderingError::Cairo` with the `cr`'s current error state.
pub fn render_layer(
&self,
cr: &cairo::Context,
id: Option<&str>,
......@@ -417,6 +452,73 @@ impl<'a> CairoRenderer<'a> {
) -> Result<(), RenderingError> {
self.handle
.0
.render_element_to_viewport(cr, id, viewport, self.dpi, false)
.render_layer(cr, id, viewport, self.dpi, false)
}
/// Computes the (ink_rect, logical_rect) of a single SVG element
///
/// While `geometry_for_layer` computes the geometry of an SVG element subtree with
/// its transformation matrix, this other function will compute the element's geometry
/// as if it were being rendered under an identity transformation by itself. That is,
/// the resulting geometry is as if the element got extracted by itself from the SVG.
///
/// This function is the counterpart to `render_element`.
///
/// Element IDs should look like an URL fragment identifier; for
/// example, pass `Some("#foo")` to get the geometry of the
/// element that has an `id="foo"` attribute.
///
/// The "ink rectangle" is the bounding box that would be painted
/// for fully- stroked and filled elements.
///
/// The "logical rectangle" just takes into account the unstroked
/// paths and text outlines.
///
/// Note that these bounds are not minimum bounds; for example,
/// clipping paths are not taken into account.
///
/// You can pass `None` for the `id` if you want to measure all
/// the elements in the SVG, i.e. to measure everything from the
/// root element.
///
/// This operation is not constant-time, as it involves going through all
/// the child elements.
///
/// FIXME: example
pub fn geometry_for_element(
&self,
id: Option<&str>,
) -> Result<(cairo::Rectangle, cairo::Rectangle), RenderingError> {
self.handle
.0
.get_geometry_for_element(id, self.dpi, false)
.map(|(i, l)| (i.into(), l.into()))
}
/// Renders a single SVG element to a given viewport
///
/// This function can be used to extract individual element subtrees and render them,
/// scaled to a given `element_viewport`. This is useful for applications which have
/// reusable objects in an SVG and want to render them individually; for example, an
/// SVG full of icons that are meant to be be rendered independently of each other.
///
/// Note that the `id` must be a plain fragment identifier like `#foo`, with
/// a leading `#` character.
///
/// The `element_viewport` gives the position and size at which the named element will
/// be rendered. FIXME: mention proportional scaling.
///
/// The `cr` must be in a `cairo::Status::Success` state, or this function
/// will not render anything, and instead will return
/// `RenderingError::Cairo` with the `cr`'s current error state.
pub fn render_element(
&self,
cr: &cairo::Context,
id: Option<&str>,
element_viewport: &cairo::Rectangle,
) -> Result<(), RenderingError> {
self.handle
.0
.render_element(cr, id, element_viewport, self.dpi, false)
}
}
use librsvg::{DefsLookupErrorKind, HrefError, RenderingError};
use cairo;
use librsvg::{CairoRenderer, DefsLookupErrorKind, HrefError, RenderingError};
use rsvg_internals::surface_utils::shared_surface::{SharedImageSurface, SurfaceType};
mod utils;
use self::utils::load_svg;
use self::utils::{compare_to_surface, load_svg};
#[test]
fn has_element_with_id_works() {
......@@ -37,3 +40,141 @@ fn has_element_with_id_works() {
))
);
}
#[test]
fn render_layer() {
let svg = load_svg(
br##"<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
<rect id="foo" x="10" y="10" width="30" height="30" fill="#00ff00"/>
<rect id="bar" x="20" y="20" width="30" height="30" fill="#0000ff"/>
</svg>
"##,
);
let renderer = CairoRenderer::new(&svg);
let output = cairo::ImageSurface::create(cairo::Format::ARgb32, 300, 300).unwrap();
let res = {
let cr = cairo::Context::new(&output);
let viewport = cairo::Rectangle {
x: 100.0,
y: 100.0,
width: 100.0,
height: 100.0,
};
renderer.render_layer(&cr, Some("#bar"), &viewport)
};
let output_surf = res
.and_then(|_| Ok(SharedImageSurface::new(output, SurfaceType::SRgb).unwrap()))
.unwrap();
let reference_surf = cairo::ImageSurface::create(cairo::Format::ARgb32, 300, 300).unwrap();
{
let cr = cairo::Context::new(&reference_surf);
cr.translate(100.0, 100.0);
cr.rectangle(20.0, 20.0, 30.0, 30.0);
cr.set_source_rgba(0.0, 0.0, 1.0, 1.0);
cr.fill();
}
let reference_surf = SharedImageSurface::new(reference_surf, SurfaceType::SRgb).unwrap();
compare_to_surface(&output_surf, &reference_surf, "render_layer");
}
#[test]
fn untransformed_element() {
// This has a rectangle inside a transformed group. The rectangle
// inherits its stroke-width from the group.
//
// The idea is that we'll be able to extract the geometry of the rectangle
// as if it were not transformed by its ancestors, but still retain the
// cascade from the ancestors.
let svg = load_svg(
br##"<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100">
<g transform="rotate(45)" stroke-width="10" stroke="#000000">
<rect id="foo" x="10" y="20" width="30" height="40" fill="#0000ff"/>
</g>
</svg>
"##,
);
let renderer = CairoRenderer::new(&svg);
/* Measuring */
let (ink_r, logical_r) = renderer
.geometry_for_element(Some("#foo"))
.unwrap();
assert_eq!(
ink_r,
cairo::Rectangle {
x: 0.0,
y: 0.0,
width: 40.0,
height: 50.0,
}
);
assert_eq!(
logical_r,
cairo::Rectangle {
x: 5.0,
y: 5.0,
width: 30.0,
height: 40.0,
}
);
/* Rendering */
let output = cairo::ImageSurface::create(cairo::Format::ARgb32, 300, 300).unwrap();
let res = {
let cr = cairo::Context::new(&output);
let viewport = cairo::Rectangle {
x: 100.0,
y: 100.0,
width: 100.0,
height: 100.0,
};
renderer.render_element(&cr, Some("#foo"), &viewport)
};
let output_surf =
res.and_then(|_| Ok(SharedImageSurface::new(output, SurfaceType::SRgb).unwrap())).unwrap();
let reference_surf = cairo::ImageSurface::create(cairo::Format::ARgb32, 300, 300).unwrap();
{
let cr = cairo::Context::new(&reference_surf);
cr.translate(100.0, 100.0);
cr.rectangle(10.0, 10.0, 60.0, 80.0);
cr.set_source_rgba(0.0, 0.0, 1.0, 1.0);
cr.fill_preserve();
cr.set_line_width(20.0);
cr.set_source_rgba(0.0, 0.0, 0.0, 1.0);
cr.stroke();
}
let reference_surf = SharedImageSurface::new(reference_surf, SurfaceType::SRgb).unwrap();
compare_to_surface(
&output_surf,
&reference_surf,
"untransformed_element",
);
}
......@@ -74,7 +74,7 @@ fn root_geometry_with_percent_viewport() {
height: 100.0,
};
let (ink_r, logical_r) = renderer.geometry_for_element(None, &viewport).unwrap();
let (ink_r, logical_r) = renderer.geometry_for_layer(None, &viewport).unwrap();
let rect = cairo::Rectangle {
x: 10.0,
......@@ -87,7 +87,7 @@ fn root_geometry_with_percent_viewport() {
}
#[test]
fn element_geometry_with_percent_viewport() {
fn layer_geometry_with_percent_viewport() {
let svg = load_svg(
br#"<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%">
......@@ -106,7 +106,7 @@ fn element_geometry_with_percent_viewport() {
};
let (ink_r, logical_r) = renderer
.geometry_for_element(Some("#foo"), &viewport)
.geometry_for_layer(Some("#foo"), &viewport)
.unwrap();
let rect = cairo::Rectangle {
......@@ -120,7 +120,7 @@ fn element_geometry_with_percent_viewport() {
}
#[test]
fn element_geometry_viewport_viewbox() {
fn layer_geometry_viewport_viewbox() {
let svg = load_svg(
br#"<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="100" height="400" viewBox="0 0 100 400">
......@@ -140,7 +140,7 @@ fn element_geometry_viewport_viewbox() {
};
let (ink_r, logical_r) = renderer
.geometry_for_element(Some("#two"), &viewport)
.geometry_for_layer(Some("#two"), &viewport)
.unwrap();
let rect = cairo::Rectangle {
......@@ -154,7 +154,7 @@ fn element_geometry_viewport_viewbox() {
}