Commit 353812ff authored by Francois Cartegnie's avatar Francois Cartegnie

freetype: change background rendering

background style was never applied when set to non text mode.
parent 9f43ceac
...@@ -424,10 +424,12 @@ static subpicture_t *Subtitle( decoder_t *p_dec, text_segment_t *p_segments, mti ...@@ -424,10 +424,12 @@ static subpicture_t *Subtitle( decoder_t *p_dec, text_segment_t *p_segments, mti
region itself gets aligned, but the text inside it does not */ region itself gets aligned, but the text inside it does not */
p_spu_sys->align = SUBPICTURE_ALIGN_LEAVETEXT; p_spu_sys->align = SUBPICTURE_ALIGN_LEAVETEXT;
p_spu_sys->p_segments = p_segments; p_spu_sys->p_segments = p_segments;
p_spu_sys->noregionbg = p_dec->p_sys->b_opaque; p_spu_sys->noregionbg = true;
p_spu_sys->gridmode = true; p_spu_sys->gridmode = true;
/* Set style defaults (will be added to segments if none set) */ /* Set style defaults (will be added to segments if none set) */
p_spu_sys->p_default_style->i_style_flags |= STYLE_MONOSPACED; p_spu_sys->p_default_style->i_style_flags |= STYLE_MONOSPACED;
if( p_dec->p_sys->b_opaque )
p_spu_sys->p_default_style->i_style_flags |= STYLE_BACKGROUND;
p_spu_sys->p_default_style->i_font_color = rgi_eia608_colors[EIA608_COLOR_DEFAULT]; p_spu_sys->p_default_style->i_font_color = rgi_eia608_colors[EIA608_COLOR_DEFAULT];
p_spu_sys->p_default_style->f_font_relsize = 100 / EIA608_SCREEN_ROWS * 3/4; p_spu_sys->p_default_style->f_font_relsize = 100 / EIA608_SCREEN_ROWS * 3/4;
p_spu_sys->p_default_style->i_features |= (STYLE_HAS_FONT_COLOR | STYLE_HAS_FLAGS); p_spu_sys->p_default_style->i_features |= (STYLE_HAS_FONT_COLOR | STYLE_HAS_FLAGS);
......
...@@ -442,9 +442,19 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block ) ...@@ -442,9 +442,19 @@ static subpicture_t *Decode( decoder_t *p_dec, block_t **pp_block )
subpicture_updater_sys_t *p_spu_sys = p_spu->updater.p_sys; subpicture_updater_sys_t *p_spu_sys = p_spu->updater.p_sys;
p_spu_sys->p_segments = text_segment_New( &p_text[offset] ); p_spu_sys->p_segments = text_segment_New( &p_text[offset] );
if( p_spu_sys->p_segments && b_opaque )
{
p_spu_sys->p_segments->style = text_style_Create( STYLE_NO_DEFAULTS );
if( p_spu_sys->p_segments->style )
{
/* Set text background */
p_spu_sys->p_segments->style->i_style_flags = STYLE_BACKGROUND;
p_spu_sys->p_segments->style->i_features |= STYLE_HAS_FLAGS;
}
}
p_spu_sys->align = i_align; p_spu_sys->align = i_align;
p_spu_sys->noregionbg = b_opaque; p_spu_sys->noregionbg = true;
#ifdef ZVBI_DEBUG #ifdef ZVBI_DEBUG
msg_Info( p_dec, "page %x-%x(%d)\n\"%s\"", p_page.pgno, p_page.subno, i_total, &p_text[offset] ); msg_Info( p_dec, "page %x-%x(%d)\n\"%s\"", p_page.pgno, p_page.subno, i_total, &p_text[offset] );
......
...@@ -735,21 +735,24 @@ static inline void RenderBackground( subpicture_region_t *p_region, ...@@ -735,21 +735,24 @@ static inline void RenderBackground( subpicture_region_t *p_region,
p_line->p_character[i_seg_end].p_glyph->bitmap.width + p_line->p_character[i_seg_end].p_glyph->bitmap.width +
i_align_left - p_bbox->xMin; i_align_left - p_bbox->xMin;
uint8_t i_x, i_y, i_z;
const line_character_t *p_char = &p_line->p_character[i_char_index]; 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 : if( p_char->p_style->i_style_flags & STYLE_BACKGROUND )
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 */
if( i_alpha != STYLE_ALPHA_TRANSPARENT )
{ {
for( int dy = line_top; dy < line_bottom; dy++ ) uint8_t i_x, i_y, i_z;
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 */
if( i_alpha != STYLE_ALPHA_TRANSPARENT )
{ {
for( int dx = line_start; dx < line_end; dx++ ) for( int dy = line_top; dy < line_bottom; dy++ )
BlendPixel( p_picture, dx, dy, i_alpha, i_x, i_y, i_z, 0xff ); {
for( int dx = line_start; dx < line_end; dx++ )
BlendPixel( p_picture, dx, dy, i_alpha, i_x, i_y, i_z, 0xff );
}
} }
} }
...@@ -796,8 +799,6 @@ static inline int RenderAXYZ( filter_t *p_filter, ...@@ -796,8 +799,6 @@ static inline int RenderAXYZ( filter_t *p_filter,
if (p_region->b_noregionbg) { if (p_region->b_noregionbg) {
/* Render the background just under the text */ /* Render the background just under the text */
FillPicture( p_picture, STYLE_ALPHA_TRANSPARENT, 0x00, 0x00, 0x00 ); FillPicture( p_picture, STYLE_ALPHA_TRANSPARENT, 0x00, 0x00, 0x00 );
RenderBackground(p_region, p_line_head, p_bbox, i_margin, p_picture, i_text_width,
ExtractComponents, BlendPixel);
} else { } else {
/* Render background under entire subpicture block */ /* Render background under entire subpicture block */
int i_background_color = var_InheritInteger( p_filter, "freetype-background-color" ); int i_background_color = var_InheritInteger( p_filter, "freetype-background-color" );
...@@ -805,6 +806,9 @@ static inline int RenderAXYZ( filter_t *p_filter, ...@@ -805,6 +806,9 @@ static inline int RenderAXYZ( filter_t *p_filter,
ExtractComponents( i_background_color, &i_x, &i_y, &i_z ); ExtractComponents( i_background_color, &i_x, &i_y, &i_z );
FillPicture( p_picture, i_a, i_x, i_y, i_z ); FillPicture( p_picture, i_a, i_x, i_y, i_z );
} }
/* Render text's background (from decoder) if any */
RenderBackground(p_region, p_line_head, p_bbox, i_margin, p_picture, i_text_width,
ExtractComponents, BlendPixel);
/* Render shadow then outline and then normal glyphs */ /* Render shadow then outline and then normal glyphs */
for( int g = 0; g < 3; g++ ) for( int g = 0; g < 3; g++ )
......
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