[vlc-commits] Add text_segment_NewInheritStyle

Jean-Baptiste Kempf git at videolan.org
Tue Jul 28 16:01:57 CEST 2015


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Mon Jul 27 20:54:26 2015 +0200| [1cc34d8ae49df873a72a7f9fce75918426f7fe78] | committer: Jean-Baptiste Kempf

Add text_segment_NewInheritStyle

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1cc34d8ae49df873a72a7f9fce75918426f7fe78
---

 include/vlc_text_style.h |   10 ++++++++++
 src/libvlccore.sym       |    1 +
 src/misc/text_style.c    |   16 ++++++++++++++++
 3 files changed, 27 insertions(+)

diff --git a/include/vlc_text_style.h b/include/vlc_text_style.h
index 6d9280e..dcb38e8 100644
--- a/include/vlc_text_style.h
+++ b/include/vlc_text_style.h
@@ -140,6 +140,16 @@ VLC_API void text_style_Delete( text_style_t * );
 VLC_API text_segment_t *text_segment_New( const char * );
 
 /**
+ * This function will create a new text segment and duplicates the style passed as argument
+ *
+ * You should use text_segment_ChainDelete to destroy it, to clean all
+ * the linked segments, or text_segment_Delete to free a specic one
+ *
+ * This doesn't initialize the text.
+ */
+VLC_API text_segment_t *text_segment_NewInheritStyle( const text_style_t* p_style );
+
+/**
  * Delete a text segment and its content.
  *
  * This assumes the segment is not part of a chain
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 3749a5b..d62d9ac 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -419,6 +419,7 @@ subpicture_region_Copy
 subpicture_region_Delete
 subpicture_region_New
 text_segment_New
+text_segment_NewInheritStyle
 text_segment_Delete
 text_segment_ChainDelete
 text_segment_Copy
diff --git a/src/misc/text_style.c b/src/misc/text_style.c
index 8e7e8a2..2241938 100644
--- a/src/misc/text_style.c
+++ b/src/misc/text_style.c
@@ -105,6 +105,22 @@ text_segment_t *text_segment_New( const char *psz_text )
     return segment;
 }
 
+text_segment_t *text_segment_NewInheritStyle( const text_style_t* p_style )
+{
+    if ( !p_style )
+        return NULL; //FIXME: Allow this, even if it is an alias to text_segment_New( NULL ) ?
+    text_segment_t* p_segment = text_segment_New( NULL );
+    if ( unlikely( !p_segment ) )
+        return NULL;
+    p_segment->style = text_style_Duplicate( p_style );
+    if ( unlikely( !p_segment->style ) )
+    {
+        text_segment_Delete( p_segment );
+        return NULL;
+    }
+    return p_segment;
+}
+
 void text_segment_Delete( text_segment_t* segment )
 {
     if ( segment != NULL )



More information about the vlc-commits mailing list