[vlc-devel] [PATCH 2/9] freetype: remove layout code from freetype.c
Salah-Eddin Shaban
salshaaban at gmail.com
Mon Apr 20 21:15:31 CEST 2015
Yeah I was told about it :)
On 4/20/15, Hugo Beauzée-Luyssen <hugo at beauzee.fr> wrote:
> On Sat, Apr 18, 2015, at 07:56 PM, Salah-Eddin Shaban wrote:
>> ---
>> modules/text_renderer/freetype.c | 220
>> ---------------------------------------
>> 1 file changed, 220 deletions(-)
>>
>> diff --git a/modules/text_renderer/freetype.c
>> b/modules/text_renderer/freetype.c
>> index 8d314fe..a52b24c 100644
>> --- a/modules/text_renderer/freetype.c
>> +++ b/modules/text_renderer/freetype.c
>> @@ -48,18 +48,6 @@
>> #include FT_FREETYPE_H
>> #include FT_GLYPH_H
>> #include FT_STROKER_H
>> -#include FT_SYNTHESIS_H
>> -
>> -#define FT_FLOOR(X) ((X & -64) >> 6)
>> -#define FT_CEIL(X) (((X + 63) & -64) >> 6)
>> -#ifndef FT_MulFix
>> - #define FT_MulFix(v, s) (((v)*(s))>>16)
>> -#endif
>> -
>> -/* RTL */
>> -#if defined(HAVE_FRIBIDI)
>> -# include <fribidi/fribidi.h>
>> -#endif
>>
>> /* apple stuff */
>> #ifdef __APPLE__
>> @@ -236,64 +224,6 @@ vlc_module_begin ()
>> set_callbacks( Create, Destroy )
>> vlc_module_end ()
>>
>> -
>> -/*****************************************************************************
>> - * Local prototypes
>> -
>> *****************************************************************************/
>> -
>> -typedef struct
>> -{
>> - FT_BitmapGlyph p_glyph;
>> - FT_BitmapGlyph p_outline;
>> - FT_BitmapGlyph p_shadow;
>> - uint32_t i_color; /* ARGB color */
>> - int i_line_offset; /* underline/strikethrough
>> offset */
>> - int i_line_thickness; /* underline/strikethrough
>> thickness */
>> -} line_character_t;
>> -
>> -typedef struct line_desc_t line_desc_t;
>> -struct line_desc_t
>> -{
>> - line_desc_t *p_next;
>> -
>> - int i_width;
>> - int i_height;
>> - int i_base_line;
>> - int i_character_count;
>> - line_character_t *p_character;
>> -};
>> -
>> -/*****************************************************************************
>> - * filter_sys_t: freetype local data
>> -
>> *****************************************************************************
>> - * This structure is part of the video output thread descriptor.
>> - * It describes the freetype specific properties of an output thread.
>> -
>> *****************************************************************************/
>> -struct filter_sys_t
>> -{
>> - FT_Library p_library; /* handle to library */
>> - FT_Face p_face; /* handle to face object */
>> - FT_Stroker p_stroker; /* handle to path stroker object */
>> -
>> - xml_reader_t *p_xml; /* vlc xml parser */
>> -
>> - text_style_t style; /* Current Style */
>> -
>> - /* More styles... */
>> - float f_shadow_vector_x;
>> - float f_shadow_vector_y;
>> - int i_default_font_size;
>> -
>> - /* Attachments */
>> - input_attachment_t **pp_font_attachments;
>> - int i_font_attachments;
>> -
>> - char * (*pf_select) (filter_t *, const char* family,
>> - bool bold, bool italic, int size,
>> - int *index);
>> -
>> -};
>> -
>> /* */
>> static void YUVFromRGB( uint32_t i_argb,
>> uint8_t *pi_y, uint8_t *pi_u, uint8_t *pi_v )
>> @@ -908,52 +838,6 @@ static inline int RenderAXYZ( filter_t *p_filter,
>>
>>
>>
>> -static void FreeLine( line_desc_t *p_line )
>> -{
>> - for( int i = 0; i < p_line->i_character_count; i++ )
>> - {
>> - line_character_t *ch = &p_line->p_character[i];
>> - FT_Done_Glyph( (FT_Glyph)ch->p_glyph );
>> - if( ch->p_outline )
>> - FT_Done_Glyph( (FT_Glyph)ch->p_outline );
>> - if( ch->p_shadow )
>> - FT_Done_Glyph( (FT_Glyph)ch->p_shadow );
>> - }
>> -
>> - free( p_line->p_character );
>> - free( p_line );
>> -}
>> -
>> -static void FreeLines( line_desc_t *p_lines )
>> -{
>> - for( line_desc_t *p_line = p_lines; p_line != NULL; )
>> - {
>> - line_desc_t *p_next = p_line->p_next;
>> - FreeLine( p_line );
>> - p_line = p_next;
>> - }
>> -}
>> -
>> -static line_desc_t *NewLine( int i_count )
>> -{
>> - line_desc_t *p_line = malloc( sizeof(*p_line) );
>> -
>> - if( !p_line )
>> - return NULL;
>> -
>> - p_line->p_next = NULL;
>> - p_line->i_width = 0;
>> - p_line->i_base_line = 0;
>> - p_line->i_character_count = 0;
>> -
>> - p_line->p_character = calloc( i_count, sizeof(*p_line->p_character)
>> );
>> - if( !p_line->p_character )
>> - {
>> - free( p_line );
>> - return NULL;
>> - }
>> - return p_line;
>> -}
>>
>> static FT_Face LoadEmbeddedFace( filter_sys_t *p_sys, const text_style_t
>> *p_style )
>> {
>> @@ -1044,110 +928,6 @@ static FT_Face LoadFace( filter_t *p_filter,
>> return p_face;
>> }
>>
>> -static int GetGlyph( filter_t *p_filter,
>> - FT_Glyph *pp_glyph, FT_BBox *p_glyph_bbox,
>> - FT_Glyph *pp_outline, FT_BBox *p_outline_bbox,
>> - FT_Glyph *pp_shadow, FT_BBox *p_shadow_bbox,
>> -
>> - FT_Face p_face,
>> - int i_glyph_index,
>> - int i_style_flags,
>> - FT_Vector *p_pen,
>> - FT_Vector *p_pen_shadow )
>> -{
>> - if( FT_Load_Glyph( p_face, i_glyph_index, FT_LOAD_NO_BITMAP |
>> FT_LOAD_DEFAULT ) &&
>> - FT_Load_Glyph( p_face, i_glyph_index, FT_LOAD_DEFAULT ) )
>> - {
>> - msg_Err( p_filter, "unable to render text FT_Load_Glyph failed"
>> );
>> - return VLC_EGENERIC;
>> - }
>> -
>> - /* Do synthetic styling now that Freetype supports it;
>> - * ie. if the font we have loaded is NOT already in the
>> - * style that the tags want, then switch it on; if they
>> - * are then don't. */
>> - if ((i_style_flags & STYLE_BOLD) && !(p_face->style_flags &
>> FT_STYLE_FLAG_BOLD))
>> - FT_GlyphSlot_Embolden( p_face->glyph );
>> - if ((i_style_flags & STYLE_ITALIC) && !(p_face->style_flags &
>> FT_STYLE_FLAG_ITALIC))
>> - FT_GlyphSlot_Oblique( p_face->glyph );
>> -
>> - FT_Glyph glyph;
>> - if( FT_Get_Glyph( p_face->glyph, &glyph ) )
>> - {
>> - msg_Err( p_filter, "unable to render text FT_Get_Glyph failed"
>> );
>> - return VLC_EGENERIC;
>> - }
>> -
>> - FT_Glyph outline = NULL;
>> - if( p_filter->p_sys->p_stroker )
>> - {
>> - outline = glyph;
>> - if( FT_Glyph_StrokeBorder( &outline, p_filter->p_sys->p_stroker,
>> 0, 0 ) )
>> - outline = NULL;
>> - }
>> -
>> - FT_Glyph shadow = NULL;
>> - if( p_filter->p_sys->style.i_shadow_alpha > 0 )
>> - {
>> - shadow = outline ? outline : glyph;
>> - if( FT_Glyph_To_Bitmap( &shadow, FT_RENDER_MODE_NORMAL,
>> p_pen_shadow, 0 ) )
>> - {
>> - shadow = NULL;
>> - }
>> - else
>> - {
>> - FT_Glyph_Get_CBox( shadow, ft_glyph_bbox_pixels,
>> p_shadow_bbox );
>> - }
>> - }
>> - *pp_shadow = shadow;
>> -
>> - if( FT_Glyph_To_Bitmap( &glyph, FT_RENDER_MODE_NORMAL, p_pen, 1) )
>> - {
>> - FT_Done_Glyph( glyph );
>> - if( outline )
>> - FT_Done_Glyph( outline );
>> - if( shadow )
>> - FT_Done_Glyph( shadow );
>> - return VLC_EGENERIC;
>> - }
>> - FT_Glyph_Get_CBox( glyph, ft_glyph_bbox_pixels, p_glyph_bbox );
>> - *pp_glyph = glyph;
>> -
>> - if( outline )
>> - {
>> - FT_Glyph_To_Bitmap( &outline, FT_RENDER_MODE_NORMAL, p_pen, 1 );
>> - FT_Glyph_Get_CBox( outline, ft_glyph_bbox_pixels, p_outline_bbox
>> );
>> - }
>> - *pp_outline = outline;
>> -
>> - return VLC_SUCCESS;
>> -}
>> -
>> -static void FixGlyph( FT_Glyph glyph, FT_BBox *p_bbox, FT_Face face,
>> const FT_Vector *p_pen )
>> -{
>> - FT_BitmapGlyph glyph_bmp = (FT_BitmapGlyph)glyph;
>> - if( p_bbox->xMin >= p_bbox->xMax )
>> - {
>> - p_bbox->xMin = FT_CEIL(p_pen->x);
>> - p_bbox->xMax = FT_CEIL(p_pen->x + face->glyph->advance.x);
>> - glyph_bmp->left = p_bbox->xMin;
>> - }
>> - if( p_bbox->yMin >= p_bbox->yMax )
>> - {
>> - p_bbox->yMax = FT_CEIL(p_pen->y);
>> - p_bbox->yMin = FT_CEIL(p_pen->y + face->glyph->advance.y);
>> - glyph_bmp->top = p_bbox->yMax;
>> - }
>> -}
>> -
>> -static void BBoxEnlarge( FT_BBox *p_max, const FT_BBox *p )
>> -{
>> - p_max->xMin = __MIN(p_max->xMin, p->xMin);
>> - p_max->yMin = __MIN(p_max->yMin, p->yMin);
>> - p_max->xMax = __MAX(p_max->xMax, p->xMax);
>> - p_max->yMax = __MAX(p_max->yMax, p->yMax);
>> -}
>> -
>> static int ProcessLines( filter_t *p_filter,
>> line_desc_t **pp_lines,
>> FT_BBox *p_bbox,
>> --
>> 1.9.1
>>
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
>
> Hi,
>
> You should merge this with the commit that adds those lines again in
> some other file, rather than temporarly breaking the build.
>
> Regards,
>
> --
> Hugo Beauzée-Luyssen
> hugo at beauzee.fr
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
>
More information about the vlc-devel
mailing list