rsvgdec: Fix uses of librsvg functions deprecated since 2.52

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6613>
This commit is contained in:
L. E. Segovia 2024-04-11 19:54:45 -03:00 committed by GStreamer Marge Bot
parent 5d876ff774
commit b8db473955
2 changed files with 39 additions and 5 deletions

View file

@ -156,8 +156,12 @@ gst_rsvg_decode_image (GstRsvgDec * rsvg, GstBuffer * buffer,
cairo_surface_t *surface;
RsvgHandle *handle;
GError *error = NULL;
RsvgDimensionData dimension;
#if LIBRSVG_MAJOR_VERSION > (2) || (LIBRSVG_MAJOR_VERSION == (2) && LIBRSVG_MINOR_VERSION > (52))
RsvgRectangle viewport;
#else
gdouble scalex, scaley;
#endif
GstRsvgDimension dimension;
GstMapInfo minfo;
GstVideoFrame vframe;
GstVideoCodecState *output_state;
@ -174,8 +178,12 @@ gst_rsvg_decode_image (GstRsvgDec * rsvg, GstBuffer * buffer,
g_error_free (error);
return GST_FLOW_ERROR;
}
#if LIBRSVG_MAJOR_VERSION > (2) || (LIBRSVG_MAJOR_VERSION == (2) && LIBRSVG_MINOR_VERSION > (52))
rsvg_handle_get_intrinsic_size_in_pixels (handle, &dimension.width,
&dimension.height);
#else
rsvg_handle_get_dimensions (handle, &dimension);
#endif
output_state = gst_video_decoder_get_output_state (decoder);
if ((output_state == NULL)
@ -191,8 +199,9 @@ gst_rsvg_decode_image (GstRsvgDec * rsvg, GstBuffer * buffer,
gst_pad_peer_query_caps (GST_VIDEO_DECODER_SRC_PAD (rsvg), templ_caps);
GST_DEBUG_OBJECT (rsvg,
"Trying to negotiate for SVG resolution %ux%u with downstream caps %"
GST_PTR_FORMAT, dimension.width, dimension.height, peer_caps);
"Trying to negotiate for SVG resolution %" G_GUINT64_FORMAT "x %"
G_GUINT64_FORMAT " with downstream caps %" GST_PTR_FORMAT,
(guint64) dimension.width, (guint64) dimension.height, peer_caps);
source_caps = gst_caps_make_writable (g_steal_pointer (&templ_caps));
gst_caps_set_simple (source_caps, "width", G_TYPE_INT, dimension.width,
@ -274,6 +283,21 @@ gst_rsvg_decode_image (GstRsvgDec * rsvg, GstBuffer * buffer,
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 1.0);
#if LIBRSVG_MAJOR_VERSION > (2) || (LIBRSVG_MAJOR_VERSION == (2) && LIBRSVG_MINOR_VERSION > (52))
viewport.x = 0;
viewport.y = 0;
viewport.width = GST_VIDEO_INFO_WIDTH (&output_state->info);
viewport.height = GST_VIDEO_INFO_HEIGHT (&output_state->info);
if (!rsvg_handle_render_document (handle, cr, &viewport, &error)) {
GST_ERROR_OBJECT (rsvg, "Failed to render SVG image: %s", error->message);
g_error_free (error);
g_object_unref (handle);
cairo_destroy (cr);
cairo_surface_destroy (surface);
gst_video_codec_state_unref (output_state);
return GST_FLOW_ERROR;
}
#else
scalex = scaley = 1.0;
if (GST_VIDEO_INFO_WIDTH (&output_state->info) != dimension.width) {
scalex =
@ -288,6 +312,7 @@ gst_rsvg_decode_image (GstRsvgDec * rsvg, GstBuffer * buffer,
cairo_scale (cr, scalex, scaley);
rsvg_handle_render_cairo (handle, cr);
#endif
g_object_unref (handle);
cairo_destroy (cr);

View file

@ -44,6 +44,15 @@ G_BEGIN_DECLS
typedef struct _GstRsvgDec GstRsvgDec;
typedef struct _GstRsvgDecClass GstRsvgDecClass;
#if LIBRSVG_MAJOR_VERSION > (2) || (LIBRSVG_MAJOR_VERSION == (2) && LIBRSVG_MINOR_VERSION > (52))
typedef struct
{
gdouble width, height;
} GstRsvgDimension;
#else
typedef RsvgDimensionData GstRsvgDimension;
#endif
struct _GstRsvgDec
{
GstVideoDecoder decoder;
@ -57,7 +66,7 @@ struct _GstRsvgDec
guint64 frame_count;
GstVideoCodecState *input_state;
RsvgDimensionData dimension;
GstRsvgDimension dimension;
GstSegment segment;
gboolean need_newsegment;