[vlc-commits] freetype: directly refer to style from char
Francois Cartegnie
git at videolan.org
Mon Aug 24 22:45:44 CEST 2015
vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sun Aug 23 21:06:59 2015 +0200| [a222da2d7657f40eb0cb1cbb3aee0bbe749568de] | committer: Francois Cartegnie
freetype: directly refer to style from char
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a222da2d7657f40eb0cb1cbb3aee0bbe749568de
---
modules/text_renderer/freetype.c | 22 +++++++++++++---------
modules/text_renderer/text_layout.c | 19 ++++++-------------
modules/text_renderer/text_layout.h | 4 ++--
3 files changed, 21 insertions(+), 24 deletions(-)
diff --git a/modules/text_renderer/freetype.c b/modules/text_renderer/freetype.c
index ba8a824..a80c36c 100644
--- a/modules/text_renderer/freetype.c
+++ b/modules/text_renderer/freetype.c
@@ -393,8 +393,8 @@ static int RenderYUVP( filter_t *p_filter, subpicture_region_t *p_region,
/* Calculate text color components
* Only use the first color */
- int i_alpha = (p_line->p_character[0].i_color >> 24) & 0xff;
- YUVFromRGB( p_line->p_character[0].i_color, &i_y, &i_u, &i_v );
+ const int i_alpha = p_line->p_character[0].p_style->i_font_alpha;
+ YUVFromRGB( p_line->p_character[0].p_style->i_font_color, &i_y, &i_u, &i_v );
/* Build palette */
fmt.p_palette->i_entries = 16;
@@ -717,7 +717,7 @@ static inline void RenderBackground( subpicture_region_t *p_region,
line_start = 0;
/* Setup color for the background */
- uint32_t i_prev_color = p_line->p_character[p_line->i_first_visible_char_index].i_background_color;
+ const text_style_t *p_prev_style = p_line->p_character[p_line->i_first_visible_char_index].p_style;
int i_char_index = p_line->i_first_visible_char_index;
while( i_char_index <= p_line->i_last_visible_char_index )
@@ -725,7 +725,7 @@ static inline void RenderBackground( subpicture_region_t *p_region,
/* find last char having the same style */
int i_seg_end = i_char_index;
while( i_seg_end < p_line->i_last_visible_char_index &&
- i_prev_color == p_line->p_character[i_seg_end].i_background_color )
+ p_prev_style == p_line->p_character[i_seg_end].p_style )
{
i_seg_end++;
}
@@ -736,8 +736,12 @@ static inline void RenderBackground( subpicture_region_t *p_region,
i_align_left - p_bbox->xMin;
uint8_t i_x, i_y, i_z;
- ExtractComponents( p_line->p_character[i_char_index].i_background_color, &i_x, &i_y, &i_z );
- const uint8_t i_alpha = (p_line->p_character[i_char_index].i_background_color >> 24) & 0xFF;
+ const line_character_t *p_char = &p_line->p_character[i_char_index];
+ ExtractComponents( p_char->b_in_karaoke ? p_char->p_style->i_karaoke_background_color :
+ p_char->p_style->i_background_color,
+ &i_x, &i_y, &i_z );
+ const uint8_t i_alpha = p_char->b_in_karaoke ? p_char->p_style->i_karaoke_background_alpha:
+ p_char->p_style->i_background_alpha;
/* Render the actual background */
for( int dy = line_top; dy < line_bottom; dy++ )
@@ -748,7 +752,7 @@ static inline void RenderBackground( subpicture_region_t *p_region,
line_start = line_end;
i_char_index = i_seg_end + 1;
- i_prev_color = p_line->p_character->i_background_color;
+ p_prev_style = p_line->p_character->p_style;
}
}
@@ -826,7 +830,7 @@ static inline int RenderAXYZ( filter_t *p_filter,
if( !p_glyph )
continue;
- i_a = (ch->i_color >> 24) & 0xff;
+ i_a = ch->p_style->i_font_alpha;
uint32_t i_color;
switch (g) {
case 0:
@@ -838,7 +842,7 @@ static inline int RenderAXYZ( filter_t *p_filter,
i_color = p_sys->p_style->i_outline_color;
break;
default:
- i_color = ch->i_color;
+ i_color = ch->p_style->i_font_color;
break;
}
ExtractComponents( i_color, &i_x, &i_y, &i_z );
diff --git a/modules/text_renderer/text_layout.c b/modules/text_renderer/text_layout.c
index b775dfc..ec7d1b4 100644
--- a/modules/text_renderer/text_layout.c
+++ b/modules/text_renderer/text_layout.c
@@ -922,6 +922,8 @@ static int LayoutLine( filter_t *p_filter,
#endif
line_character_t *p_ch = p_line->p_character + i_line_index;
+ p_ch->p_style = p_paragraph->pp_styles[ i_paragraph_index ];
+
glyph_bitmaps_t *p_bitmaps =
p_paragraph->p_glyph_bitmaps + i_paragraph_index;
@@ -1004,8 +1006,8 @@ static int LayoutLine( filter_t *p_filter,
int i_line_offset = 0;
int i_line_thickness = 0;
- const text_style_t *p_glyph_style = p_paragraph->pp_styles[ i_paragraph_index ];
- if( p_glyph_style->i_style_flags & (STYLE_UNDERLINE | STYLE_STRIKEOUT) )
+
+ if( p_ch->p_style->i_style_flags & (STYLE_UNDERLINE | STYLE_STRIKEOUT) )
{
i_line_offset =
abs( FT_FLOOR( FT_MulFix( p_face->underline_position,
@@ -1015,7 +1017,7 @@ static int LayoutLine( filter_t *p_filter,
abs( FT_CEIL( FT_MulFix( p_face->underline_thickness,
p_face->size->metrics.y_scale ) ) );
- if( p_glyph_style->i_style_flags & STYLE_STRIKEOUT )
+ if( p_ch->p_style->i_style_flags & STYLE_STRIKEOUT )
{
/* Move the baseline to make it strikethrough instead of
* underline. That means that strikethrough takes precedence
@@ -1047,16 +1049,7 @@ static int LayoutLine( filter_t *p_filter,
p_ch->p_glyph = ( FT_BitmapGlyph ) p_bitmaps->p_glyph;
p_ch->p_outline = ( FT_BitmapGlyph ) p_bitmaps->p_outline;
p_ch->p_shadow = ( FT_BitmapGlyph ) p_bitmaps->p_shadow;
-
- bool b_karaoke = p_paragraph->pi_karaoke_bar[ i_paragraph_index ] != 0;
- p_ch->i_color = b_karaoke ?
- (uint32_t) p_glyph_style->i_karaoke_background_color
- | (uint32_t) p_glyph_style->i_karaoke_background_alpha << 24
- : (uint32_t) p_glyph_style->i_font_color
- | (uint32_t) p_glyph_style->i_font_alpha << 24;
-
- p_ch->i_background_color = ( uint32_t ) p_glyph_style->i_background_color
- | p_glyph_style->i_background_alpha << 24;
+ p_ch->b_in_karaoke = (p_paragraph->pi_karaoke_bar[ i_paragraph_index ] != 0);
p_ch->i_line_thickness = i_line_thickness;
p_ch->i_line_offset = i_line_offset;
diff --git a/modules/text_renderer/text_layout.h b/modules/text_renderer/text_layout.h
index d5bbd69..ff55830 100644
--- a/modules/text_renderer/text_layout.h
+++ b/modules/text_renderer/text_layout.h
@@ -32,10 +32,10 @@ typedef struct
FT_BitmapGlyph p_glyph;
FT_BitmapGlyph p_outline;
FT_BitmapGlyph p_shadow;
- uint32_t i_color; /* ARGB color */
- uint32_t i_background_color; /* ARGB background color */
+ const text_style_t *p_style;
int i_line_offset; /* underline/strikethrough offset */
int i_line_thickness; /* underline/strikethrough thickness */
+ bool b_in_karaoke;
} line_character_t;
typedef struct line_desc_t line_desc_t;
More information about the vlc-commits
mailing list