[vlc-commits] freetype: change background rendering

Francois Cartegnie git at videolan.org
Mon Aug 24 22:45:44 CEST 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Aug 24 11:19:28 2015 +0200| [353812ffe38e033601ad04718e515e9e8b0fdde6] | committer: Francois Cartegnie

freetype: change background rendering

background style was never applied when set to non text mode.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=353812ffe38e033601ad04718e515e9e8b0fdde6
---

 modules/codec/cc.c               |    4 +++-
 modules/codec/zvbi.c             |   12 +++++++++++-
 modules/text_renderer/freetype.c |   32 ++++++++++++++++++--------------
 3 files changed, 32 insertions(+), 16 deletions(-)

diff --git a/modules/codec/cc.c b/modules/codec/cc.c
index 721dcff..9e75688 100644
--- a/modules/codec/cc.c
+++ b/modules/codec/cc.c
@@ -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 */
     p_spu_sys->align = SUBPICTURE_ALIGN_LEAVETEXT;
     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;
     /* Set style defaults (will be added to segments if none set) */
     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->f_font_relsize = 100 / EIA608_SCREEN_ROWS * 3/4;
     p_spu_sys->p_default_style->i_features |= (STYLE_HAS_FONT_COLOR | STYLE_HAS_FLAGS);
diff --git a/modules/codec/zvbi.c b/modules/codec/zvbi.c
index 4ed0626..4d4eaa2 100644
--- a/modules/codec/zvbi.c
+++ b/modules/codec/zvbi.c
@@ -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;
         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->noregionbg = b_opaque;
+        p_spu_sys->noregionbg = true;
 
 #ifdef ZVBI_DEBUG
         msg_Info( p_dec, "page %x-%x(%d)\n\"%s\"", p_page.pgno, p_page.subno, i_total, &p_text[offset] );
diff --git a/modules/text_renderer/freetype.c b/modules/text_renderer/freetype.c
index dccb8b2..47268b2 100644
--- a/modules/text_renderer/freetype.c
+++ b/modules/text_renderer/freetype.c
@@ -735,21 +735,24 @@ static inline void RenderBackground( subpicture_region_t *p_region,
                            p_line->p_character[i_seg_end].p_glyph->bitmap.width +
                            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];
-            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 )
+            if( p_char->p_style->i_style_flags & STYLE_BACKGROUND )
             {
-                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++ )
-                        BlendPixel( p_picture, dx, dy, i_alpha, i_x, i_y, i_z, 0xff );
+                    for( int dy = line_top; dy < line_bottom; dy++ )
+                    {
+                        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,
     if (p_region->b_noregionbg) {
         /* Render the background just under the text */
         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 {
         /* Render background under entire subpicture block */
         int i_background_color = var_InheritInteger( p_filter, "freetype-background-color" );
@@ -805,6 +806,9 @@ static inline int RenderAXYZ( filter_t *p_filter,
         ExtractComponents( i_background_color, &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 */
     for( int g = 0; g < 3; g++ )



More information about the vlc-commits mailing list