]> git.sesse.net Git - vlc/commitdiff
freetype: don't load/unload xml-module on every RenderHtml call
authorIlkka Ollakka <ileoo@videolan.org>
Mon, 3 Aug 2009 21:23:45 +0000 (00:23 +0300)
committerIlkka Ollakka <ileoo@videolan.org>
Mon, 3 Aug 2009 21:23:45 +0000 (00:23 +0300)
modules/misc/freetype.c

index 5450bb7142f3f8eaec832193fd31d62a809e68b1..0058a4bff867680524f8189b1ac31d5108ff55c0 100644 (file)
@@ -270,6 +270,7 @@ struct filter_sys_t
     char*          psz_fontfamily;
     bool           b_fontconfig_ok;
     FcConfig      *p_fontconfig;
+    xml_t         *p_xml;
 #endif
 
     input_attachment_t **pp_font_attachments;
@@ -311,6 +312,7 @@ static int Create( vlc_object_t *p_this )
         return VLC_ENOMEM;
  #ifdef HAVE_FONTCONFIG
     p_sys->psz_fontfamily = NULL;
+    p_sys->p_xml = NULL;
 #endif
     p_sys->p_face = 0;
     p_sys->p_library = 0;
@@ -476,6 +478,7 @@ static void Destroy( vlc_object_t *p_this )
 
 #ifdef HAVE_FONTCONFIG
     FontBuilderDetach( p_filter, p_sys->p_fontbuilder );
+    xml_Delete( p_sys->p_xml );
     free( p_sys->psz_fontfamily );
 #endif
 
@@ -2286,7 +2289,6 @@ static int RenderHtml( filter_t *p_filter, subpicture_region_t *p_region_out,
 {
     int          rv = VLC_SUCCESS;
     stream_t     *p_sub = NULL;
-    xml_t        *p_xml = NULL;
     xml_reader_t *p_xml_reader = NULL;
 
     if( !p_region_in || !p_region_in->psz_html )
@@ -2301,12 +2303,12 @@ static int RenderHtml( filter_t *p_filter, subpicture_region_t *p_region_out,
                               true );
     if( p_sub )
     {
-        p_xml = xml_Create( p_filter );
-        if( p_xml )
+        if( !p_filter->p_sys->p_xml ) p_filter->p_sys->p_xml = xml_Create( p_filter );
+        if( p_filter->p_sys->p_xml )
         {
             bool b_karaoke = false;
 
-            p_xml_reader = xml_ReaderCreate( p_xml, p_sub );
+            p_xml_reader = xml_ReaderCreate( p_filter->p_sys->p_xml, p_sub );
             if( p_xml_reader )
             {
                 /* Look for Root Node */
@@ -2330,7 +2332,7 @@ static int RenderHtml( filter_t *p_filter, subpicture_region_t *p_region_out,
                     {
                         /* Only text and karaoke tags are supported */
                         msg_Dbg( p_filter, "Unsupported top-level tag '%s' ignored.", psz_node );
-                        xml_ReaderDelete( p_xml, p_xml_reader );
+                        xml_ReaderDelete( p_filter->p_sys->p_xml, p_xml_reader );
                         p_xml_reader = NULL;
                         rv = VLC_EGENERIC;
                     }
@@ -2401,9 +2403,8 @@ static int RenderHtml( filter_t *p_filter, subpicture_region_t *p_region_out,
                 }
                 FreeLines( p_lines );
 
-                xml_ReaderDelete( p_xml, p_xml_reader );
+                xml_ReaderDelete( p_filter->p_sys->p_xml, p_xml_reader );
             }
-            xml_Delete( p_xml );
         }
         stream_Delete( p_sub );
     }