[vlc-commits] text_style: fix alpha values

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 23:50:52 2015 +0200| [bb9834b5ff444ae990b6f42222acba652ab3dc26] | committer: Francois Cartegnie

text_style: fix alpha values

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

 include/vlc_text_style.h            |   23 ++++++++---------------
 modules/text_renderer/freetype.c    |    2 +-
 modules/text_renderer/text_layout.c |    2 +-
 src/misc/text_style.c               |   10 +++++-----
 4 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/include/vlc_text_style.h b/include/vlc_text_style.h
index 49c62f2..9996002 100644
--- a/include/vlc_text_style.h
+++ b/include/vlc_text_style.h
@@ -50,36 +50,29 @@ typedef struct
     int        i_font_size;       /**< The font size in pixels */
     int        i_font_color;      /**< The color of the text 0xRRGGBB
                                        (native endianness) */
-    uint8_t    i_font_alpha;      /**< The transparency of the text.
-                                       0x00 is fully opaque,
-                                       0xFF fully transparent */
+    uint8_t    i_font_alpha;      /**< The transparency of the text.*/
     int        i_spacing;         /**< The spaceing between glyphs in pixels */
 
     /* Outline */
     int        i_outline_color;   /**< The color of the outline 0xRRGGBB */
-    uint8_t    i_outline_alpha;   /**< The transparency of the outline.
-                                       0x00 is fully opaque,
-                                       0xFF fully transparent */
+    uint8_t    i_outline_alpha;   /**< The transparency of the outline */
     int        i_outline_width;   /**< The width of the outline in pixels */
 
     /* Shadow */
     int        i_shadow_color;    /**< The color of the shadow 0xRRGGBB */
-    uint8_t    i_shadow_alpha;    /**< The transparency of the shadow.
-                                        0x00 is fully opaque,
-                                        0xFF fully transparent */
+    uint8_t    i_shadow_alpha;    /**< The transparency of the shadow. */
     int        i_shadow_width;    /**< The width of the shadow in pixels */
 
     /* Background (and karaoke) */
     int        i_background_color;/**< The color of the background 0xRRGGBB */
-    uint8_t    i_background_alpha;/**< The transparency of the background.
-                                       0x00 is fully opaque,
-                                       0xFF fully transparent */
+    uint8_t    i_background_alpha;/**< The transparency of the background */
     int        i_karaoke_background_color;/**< Background color for karaoke 0xRRGGBB */
-    uint8_t    i_karaoke_background_alpha;/**< The transparency of the karaoke bg.
-                                       0x00 is fully opaque,
-                                       0xFF fully transparent */
+    uint8_t    i_karaoke_background_alpha;/**< The transparency of the karaoke bg */
 } text_style_t;
 
+#define STYLE_ALPHA_OPAQUE      0xFF
+#define STYLE_ALPHA_TRANSPARENT 0x00
+
 /* Features flags for \ref i_features */
 #define STYLE_NO_DEFAULTS               0x0
 #define STYLE_FULLY_SET                 0xFFFF
diff --git a/modules/text_renderer/freetype.c b/modules/text_renderer/freetype.c
index a80c36c..e11db31 100644
--- a/modules/text_renderer/freetype.c
+++ b/modules/text_renderer/freetype.c
@@ -792,7 +792,7 @@ static inline int RenderAXYZ( filter_t *p_filter,
 
     if (p_region->b_renderbg) {
         /* Render the background just under the text */
-        FillPicture( p_picture, 0x00, 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 {
diff --git a/modules/text_renderer/text_layout.c b/modules/text_renderer/text_layout.c
index ec7d1b4..1095521 100644
--- a/modules/text_renderer/text_layout.c
+++ b/modules/text_renderer/text_layout.c
@@ -853,7 +853,7 @@ static int LoadGlyphs( filter_t *p_filter, paragraph_t *p_paragraph,
                     p_bitmaps->p_outline = 0;
             }
 
-            if( p_filter->p_sys->p_style->i_shadow_alpha > 0 )
+            if( p_filter->p_sys->p_style->i_shadow_alpha != STYLE_ALPHA_TRANSPARENT )
                 p_bitmaps->p_shadow = p_bitmaps->p_outline ?
                                       p_bitmaps->p_outline : p_bitmaps->p_glyph;
 
diff --git a/src/misc/text_style.c b/src/misc/text_style.c
index 5d66788..37a6177 100644
--- a/src/misc/text_style.c
+++ b/src/misc/text_style.c
@@ -51,15 +51,15 @@ text_style_t *text_style_Create( int i_defaults )
     p_style->f_font_relsize = STYLE_DEFAULT_REL_FONT_SIZE;
     p_style->i_font_size = STYLE_DEFAULT_FONT_SIZE;
     p_style->i_font_color = 0xffffff;
-    p_style->i_font_alpha = 0xff;
+    p_style->i_font_alpha = STYLE_ALPHA_OPAQUE;
     p_style->i_outline_color = 0x000000;
-    p_style->i_outline_alpha = 0xff;
+    p_style->i_outline_alpha = STYLE_ALPHA_OPAQUE;
     p_style->i_shadow_color = 0x808080;
-    p_style->i_shadow_alpha = 0xff;
+    p_style->i_shadow_alpha = STYLE_ALPHA_OPAQUE;
     p_style->i_background_color = 0x000000;
-    p_style->i_background_alpha = 0xff;
+    p_style->i_background_alpha = STYLE_ALPHA_OPAQUE;
     p_style->i_karaoke_background_color = 0xffffff;
-    p_style->i_karaoke_background_alpha = 0xff;
+    p_style->i_karaoke_background_alpha = STYLE_ALPHA_OPAQUE;
     p_style->i_outline_width = 1;
     p_style->i_shadow_width = 0;
     p_style->i_spacing = -1;



More information about the vlc-commits mailing list