rsvg: Disable deprecations instead of porting to new librsvg API

`rsvg_handle_get_dimensions()` and `rsvg_handle_render_cairo()` are
deprecated, and the replacement librsvg functions as specified in the
migration guide are `rsvg_handle_get_intrinsic_size_in_pixels()` and
`rsvg_handle_render_document()`.

However, those are not drop-in replacements, and actually have
breaking semantics for our use-case:

1. `intrinsic_size_in_pixels()` requires SVGs to have width+height or
   the viewBox attribute, but `get_dimensions()` does not. It will
   calculate the geometry based on element extents recursively.
2. `render_cairo()` simply renders the SVG at its intrinsic size on
   the specified surface starting at the top-left, maintaining
   whatever transformations have been applied to the cairo surface,
   including distorted aspect ratio.
   However, `render_document()` does not do that, it is specifically
   for rendering at the specified aspect ratio inside the specified
   viewport, and if you specify a viewPort that does not match the
   aspect ratio of the SVG, librsvg will center it.

Matching the old behaviour with the new APIs is a lot of work for no
benefit. We'd be duplicating code that is already there in librsvg in
one case and undoing work that librsvg is doing in the other case.

The aspect ratio handling in this element is also kinda atrocious.
There is no option to scale the SVG while maintaining the aspect
ratio. Overall, element needs a rewrite.

Let's just disable deprecations. The API is not going anywhere.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6726>
This commit is contained in:
Nirbheek Chauhan 2024-04-24 00:52:18 +05:30 committed by GStreamer Marge Bot
parent 49f9a1e224
commit e7598ed521
2 changed files with 8 additions and 0 deletions

View file

@ -164,7 +164,9 @@ gst_rsvg_decode_image (GstRsvgDec * rsvg, GstBuffer * buffer,
return GST_FLOW_ERROR;
}
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
rsvg_handle_get_dimensions (handle, &dimension);
G_GNUC_END_IGNORE_DEPRECATIONS;
output_state = gst_video_decoder_get_output_state (decoder);
if ((output_state == NULL)
@ -276,7 +278,9 @@ gst_rsvg_decode_image (GstRsvgDec * rsvg, GstBuffer * buffer,
}
cairo_scale (cr, scalex, scaley);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
rsvg_handle_render_cairo (handle, cr);
G_GNUC_END_IGNORE_DEPRECATIONS;
g_object_unref (handle);
cairo_destroy (cr);

View file

@ -163,7 +163,9 @@ gst_rsvg_overlay_set_svg_data (GstRsvgOverlay * overlay, const gchar * data,
} else {
/* Get SVG dimension. */
RsvgDimensionData svg_dimension;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
rsvg_handle_get_dimensions (overlay->handle, &svg_dimension);
G_GNUC_END_IGNORE_DEPRECATIONS;
overlay->svg_width = svg_dimension.width;
overlay->svg_height = svg_dimension.height;
gst_base_transform_set_passthrough (btrans, FALSE);
@ -421,7 +423,9 @@ gst_rsvg_overlay_transform_frame_ip (GstVideoFilter * vfilter,
cairo_scale (cr, (double) applied_width / overlay->svg_width,
(double) applied_height / overlay->svg_height);
}
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
rsvg_handle_render_cairo (overlay->handle, cr);
G_GNUC_END_IGNORE_DEPRECATIONS;
GST_RSVG_UNLOCK (overlay);
cairo_destroy (cr);