Commit a222da2d authored by Francois Cartegnie's avatar Francois Cartegnie

freetype: directly refer to style from char

parent 5f7d9a68
...@@ -393,8 +393,8 @@ static int RenderYUVP( filter_t *p_filter, subpicture_region_t *p_region, ...@@ -393,8 +393,8 @@ static int RenderYUVP( filter_t *p_filter, subpicture_region_t *p_region,
/* Calculate text color components /* Calculate text color components
* Only use the first color */ * Only use the first color */
int i_alpha = (p_line->p_character[0].i_color >> 24) & 0xff; const int i_alpha = p_line->p_character[0].p_style->i_font_alpha;
YUVFromRGB( p_line->p_character[0].i_color, &i_y, &i_u, &i_v ); YUVFromRGB( p_line->p_character[0].p_style->i_font_color, &i_y, &i_u, &i_v );
/* Build palette */ /* Build palette */
fmt.p_palette->i_entries = 16; fmt.p_palette->i_entries = 16;
...@@ -717,7 +717,7 @@ static inline void RenderBackground( subpicture_region_t *p_region, ...@@ -717,7 +717,7 @@ static inline void RenderBackground( subpicture_region_t *p_region,
line_start = 0; line_start = 0;
/* Setup color for the background */ /* 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; int i_char_index = p_line->i_first_visible_char_index;
while( i_char_index <= p_line->i_last_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, ...@@ -725,7 +725,7 @@ static inline void RenderBackground( subpicture_region_t *p_region,
/* find last char having the same style */ /* find last char having the same style */
int i_seg_end = i_char_index; int i_seg_end = i_char_index;
while( i_seg_end < p_line->i_last_visible_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++; i_seg_end++;
} }
...@@ -736,8 +736,12 @@ static inline void RenderBackground( subpicture_region_t *p_region, ...@@ -736,8 +736,12 @@ static inline void RenderBackground( subpicture_region_t *p_region,
i_align_left - p_bbox->xMin; i_align_left - p_bbox->xMin;
uint8_t i_x, i_y, i_z; 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 line_character_t *p_char = &p_line->p_character[i_char_index];
const uint8_t i_alpha = (p_line->p_character[i_char_index].i_background_color >> 24) & 0xFF; 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 */ /* Render the actual background */
for( int dy = line_top; dy < line_bottom; dy++ ) for( int dy = line_top; dy < line_bottom; dy++ )
...@@ -748,7 +752,7 @@ static inline void RenderBackground( subpicture_region_t *p_region, ...@@ -748,7 +752,7 @@ static inline void RenderBackground( subpicture_region_t *p_region,
line_start = line_end; line_start = line_end;
i_char_index = i_seg_end + 1; 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, ...@@ -826,7 +830,7 @@ static inline int RenderAXYZ( filter_t *p_filter,
if( !p_glyph ) if( !p_glyph )
continue; continue;
i_a = (ch->i_color >> 24) & 0xff; i_a = ch->p_style->i_font_alpha;
uint32_t i_color; uint32_t i_color;
switch (g) { switch (g) {
case 0: case 0:
...@@ -838,7 +842,7 @@ static inline int RenderAXYZ( filter_t *p_filter, ...@@ -838,7 +842,7 @@ static inline int RenderAXYZ( filter_t *p_filter,
i_color = p_sys->p_style->i_outline_color; i_color = p_sys->p_style->i_outline_color;
break; break;
default: default:
i_color = ch->i_color; i_color = ch->p_style->i_font_color;
break; break;
} }
ExtractComponents( i_color, &i_x, &i_y, &i_z ); ExtractComponents( i_color, &i_x, &i_y, &i_z );
......
...@@ -922,6 +922,8 @@ static int LayoutLine( filter_t *p_filter, ...@@ -922,6 +922,8 @@ static int LayoutLine( filter_t *p_filter,
#endif #endif
line_character_t *p_ch = p_line->p_character + i_line_index; 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 = glyph_bitmaps_t *p_bitmaps =
p_paragraph->p_glyph_bitmaps + i_paragraph_index; p_paragraph->p_glyph_bitmaps + i_paragraph_index;
...@@ -1004,8 +1006,8 @@ static int LayoutLine( filter_t *p_filter, ...@@ -1004,8 +1006,8 @@ static int LayoutLine( filter_t *p_filter,
int i_line_offset = 0; int i_line_offset = 0;
int i_line_thickness = 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 = i_line_offset =
abs( FT_FLOOR( FT_MulFix( p_face->underline_position, abs( FT_FLOOR( FT_MulFix( p_face->underline_position,
...@@ -1015,7 +1017,7 @@ static int LayoutLine( filter_t *p_filter, ...@@ -1015,7 +1017,7 @@ static int LayoutLine( filter_t *p_filter,
abs( FT_CEIL( FT_MulFix( p_face->underline_thickness, abs( FT_CEIL( FT_MulFix( p_face->underline_thickness,
p_face->size->metrics.y_scale ) ) ); 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 /* Move the baseline to make it strikethrough instead of
* underline. That means that strikethrough takes precedence * underline. That means that strikethrough takes precedence
...@@ -1047,16 +1049,7 @@ static int LayoutLine( filter_t *p_filter, ...@@ -1047,16 +1049,7 @@ static int LayoutLine( filter_t *p_filter,
p_ch->p_glyph = ( FT_BitmapGlyph ) p_bitmaps->p_glyph; p_ch->p_glyph = ( FT_BitmapGlyph ) p_bitmaps->p_glyph;
p_ch->p_outline = ( FT_BitmapGlyph ) p_bitmaps->p_outline; p_ch->p_outline = ( FT_BitmapGlyph ) p_bitmaps->p_outline;
p_ch->p_shadow = ( FT_BitmapGlyph ) p_bitmaps->p_shadow; p_ch->p_shadow = ( FT_BitmapGlyph ) p_bitmaps->p_shadow;
p_ch->b_in_karaoke = (p_paragraph->pi_karaoke_bar[ i_paragraph_index ] != 0);
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->i_line_thickness = i_line_thickness; p_ch->i_line_thickness = i_line_thickness;
p_ch->i_line_offset = i_line_offset; p_ch->i_line_offset = i_line_offset;
......
...@@ -32,10 +32,10 @@ typedef struct ...@@ -32,10 +32,10 @@ typedef struct
FT_BitmapGlyph p_glyph; FT_BitmapGlyph p_glyph;
FT_BitmapGlyph p_outline; FT_BitmapGlyph p_outline;
FT_BitmapGlyph p_shadow; FT_BitmapGlyph p_shadow;
uint32_t i_color; /* ARGB color */ const text_style_t *p_style;
uint32_t i_background_color; /* ARGB background color */
int i_line_offset; /* underline/strikethrough offset */ int i_line_offset; /* underline/strikethrough offset */
int i_line_thickness; /* underline/strikethrough thickness */ int i_line_thickness; /* underline/strikethrough thickness */
bool b_in_karaoke;
} line_character_t; } line_character_t;
typedef struct line_desc_t line_desc_t; typedef struct line_desc_t line_desc_t;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment