X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fmisc%2Fsvg.c;h=c68941b12cd1999af3d7045385474d1c1fe234b7;hb=cbc66ff62b56b1dea3ba99b9b0f1a28659773427;hp=0abff45b256a4eb86243912859863ff6c6ce8d99;hpb=fb0afd835b540329a371bbc911f46d19b6a053f3;p=vlc diff --git a/modules/misc/svg.c b/modules/misc/svg.c index 0abff45b25..c68941b12c 100644 --- a/modules/misc/svg.c +++ b/modules/misc/svg.c @@ -27,10 +27,16 @@ #include /* malloc( ), free( ) */ #include +#include +#include +#include +#include +#include +#include + #ifdef HAVE_SYS_TYPES_H # include #endif -#include #ifdef HAVE_UNISTD_H # include @@ -38,12 +44,8 @@ # include #endif -#include -#include -#include "vlc_osd.h" -#include "vlc_block.h" -#include "vlc_filter.h" - +#include +#include #include /* g_object_unref( ) */ #include @@ -56,7 +58,7 @@ static int Create ( vlc_object_t * ); static void Destroy ( vlc_object_t * ); static int RenderText( filter_t *p_filter, subpicture_region_t *p_region_out, subpicture_region_t *p_region_in ); - +static char *svg_GetTemplate( vlc_object_t *p_this ); /***************************************************************************** * Module descriptor @@ -143,10 +145,11 @@ static int Create( vlc_object_t *p_this ) p_sys->i_height = p_filter->fmt_out.video.i_height; p_filter->pf_render_text = RenderText; + p_filter->pf_render_html = NULL; p_filter->p_sys = p_sys; /* MUST call this before any RSVG funcs */ - g_type_init (); + rsvg_init( ); return VLC_SUCCESS; } @@ -234,6 +237,7 @@ static void Destroy( vlc_object_t *p_this ) free( p_sys->psz_template ); free( p_sys ); + rsvg_term( ); } /***************************************************************************** @@ -261,7 +265,7 @@ static int Render( filter_t *p_filter, subpicture_region_t *p_region, if( p_svg->p_rendition == NULL ) { svg_RenderPicture( p_filter, p_svg ); - if( ! p_svg ) + if( ! p_svg->p_rendition ) { msg_Err( p_filter, "Cannot render SVG" ); return VLC_EGENERIC; @@ -397,22 +401,37 @@ static void svg_RenderPicture( filter_t *p_filter, RsvgHandle *p_handle; GError *error = NULL; + p_svg->p_rendition = NULL; + p_handle = rsvg_handle_new(); + if( !p_handle ) + { + msg_Err( p_filter, "Error creating SVG reader: %s", error->message ); + return; + } + rsvg_handle_set_size_callback( p_handle, svg_SizeCallback, p_filter, NULL ); - rsvg_handle_write( p_handle, - ( guchar* )p_svg->psz_text, strlen( p_svg->psz_text ) + 1, - &error ); - if( error != NULL ) + if( ! rsvg_handle_write( p_handle, + ( guchar* )p_svg->psz_text, strlen( p_svg->psz_text ), + &error ) ) { msg_Err( p_filter, "error while rendering SVG: %s\n", error->message ); + g_object_unref( G_OBJECT( p_handle ) ); + return; + } + + if( ! rsvg_handle_close( p_handle, &error ) ) + { + msg_Err( p_filter, "error while rendering SVG (close): %s\n", error->message ); + g_object_unref( G_OBJECT( p_handle ) ); return; } - rsvg_handle_close( p_handle, &error ); p_svg->p_rendition = rsvg_handle_get_pixbuf( p_handle ); - rsvg_handle_free( p_handle ); + + g_object_unref( G_OBJECT( p_handle ) ); }