[vlc-devel] [PATCH 4/4] freetype: apply sub-text-scale factor where possible

Rémi Denis-Courmont remi at remlab.net
Fri Aug 28 20:08:02 CEST 2015


On Friday 28 August 2015 20:01:31 Francois Cartegnie wrote:
> @@ -1225,6 +1241,13 @@ static int Create( vlc_object_t *p_this )
>      free( psz_fontfile );
>      free( psz_monofontfile );
> 
> +    atomic_init( &p_sys->i_scale_factor, var_InheritInteger( p_filter,
> "sub-text-scale") );
> +    if( p_filter->p_parent && p_filter->p_parent->p_parent )

WTH is this supposed to mean? Aside from layering violation, that is.

> +    {
> +        p_sys->b_callback = ( var_AddCallback(
> p_filter->p_parent->p_parent,
> +            "sub-text-scale", VarCallback,
> &p_sys->i_scale_factor ) == VLC_SUCCESS );

This is way too brittle. It´s a question of when, not if, it will break 
silently.

> +    }
> +
>      return VLC_SUCCESS;
> 
>  error:
> @@ -1259,6 +1282,12 @@ static void Destroy( vlc_object_t *p_this )
>      filter_t *p_filter = (filter_t *)p_this;
>      filter_sys_t *p_sys = p_filter->p_sys;
> 
> +    if( p_sys->b_callback )
> +    {
> +        var_DelCallback( p_filter->p_parent->p_parent, "sub-text-scale",
> +                         VarCallback, &p_sys->i_scale_factor );
> +    }
> +
>      faces_cache_t *p_cache = &p_sys->faces_cache;
>      for( int i = 0; i < p_cache->i_faces_count; ++i )
>      {
> diff --git a/modules/text_renderer/freetype.h
> b/modules/text_renderer/freetype.h index ae7c36f..901a62f 100644
> --- a/modules/text_renderer/freetype.h
> +++ b/modules/text_renderer/freetype.h
> @@ -29,6 +29,7 @@
>  #define VLC_FREETYPE_H
> 
>  #include <vlc_text_style.h>                                   /*
> text_style_t*/ +#include <vlc_atomic.h>
> 
>  typedef struct faces_cache_t
>  {
> @@ -52,6 +53,8 @@ struct filter_sys_t
> 
>      text_style_t  *p_default_style;
>      text_style_t  *p_forced_style;/* Renderer overridings */
> +    atomic_int     i_scale_factor;
> +    bool           b_callback;
> 
>      /* More styles... */
>      float          f_shadow_vector_x;

-- 
Rémi Denis-Courmont
http://www.remlab.net/



More information about the vlc-devel mailing list