From e7598ed521235911ec2d59eef215c93dafb19b01 Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Wed, 24 Apr 2024 00:52:18 +0530 Subject: [PATCH] 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: --- subprojects/gst-plugins-bad/ext/rsvg/gstrsvgdec.c | 4 ++++ subprojects/gst-plugins-bad/ext/rsvg/gstrsvgoverlay.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/subprojects/gst-plugins-bad/ext/rsvg/gstrsvgdec.c b/subprojects/gst-plugins-bad/ext/rsvg/gstrsvgdec.c index 6a9f6527d1..cc283fcf78 100644 --- a/subprojects/gst-plugins-bad/ext/rsvg/gstrsvgdec.c +++ b/subprojects/gst-plugins-bad/ext/rsvg/gstrsvgdec.c @@ -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); diff --git a/subprojects/gst-plugins-bad/ext/rsvg/gstrsvgoverlay.c b/subprojects/gst-plugins-bad/ext/rsvg/gstrsvgoverlay.c index 5d890e0dac..f03e6b702e 100644 --- a/subprojects/gst-plugins-bad/ext/rsvg/gstrsvgoverlay.c +++ b/subprojects/gst-plugins-bad/ext/rsvg/gstrsvgoverlay.c @@ -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);