diff options
author | Miguel Freitas <miguelfreitas@users.sourceforge.net> | 2001-12-13 18:32:15 +0000 |
---|---|---|
committer | Miguel Freitas <miguelfreitas@users.sourceforge.net> | 2001-12-13 18:32:15 +0000 |
commit | f3292571b669481493326ba1eef7092ff7150953 (patch) | |
tree | 73441e4e4f3e1bcfb3ebcb2e75901698bd697e02 | |
parent | 2cef1b987e79f12650dd9fd8bc8005c9fa06030b (diff) | |
download | xine-lib-f3292571b669481493326ba1eef7092ff7150953.tar.gz xine-lib-f3292571b669481493326ba1eef7092ff7150953.tar.bz2 |
osd fonts update (better looking fonts with on-the-fly color and font face changing)
CVS patchset: 1235
CVS date: 2001/12/13 18:32:15
21 files changed, 351 insertions, 133 deletions
diff --git a/misc/fonts/cetus-16.xinefont.gz b/misc/fonts/cetus-16.xinefont.gz Binary files differindex a1d36941d..ffa62e443 100644 --- a/misc/fonts/cetus-16.xinefont.gz +++ b/misc/fonts/cetus-16.xinefont.gz diff --git a/misc/fonts/cetus-20.xinefont.gz b/misc/fonts/cetus-20.xinefont.gz Binary files differindex c262e0190..f52fad39e 100644 --- a/misc/fonts/cetus-20.xinefont.gz +++ b/misc/fonts/cetus-20.xinefont.gz diff --git a/misc/fonts/cetus-24.xinefont.gz b/misc/fonts/cetus-24.xinefont.gz Binary files differindex 9a7e3dec3..ec48cb37c 100644 --- a/misc/fonts/cetus-24.xinefont.gz +++ b/misc/fonts/cetus-24.xinefont.gz diff --git a/misc/fonts/cetus-32.xinefont.gz b/misc/fonts/cetus-32.xinefont.gz Binary files differindex abeba9d91..aa3122ab6 100644 --- a/misc/fonts/cetus-32.xinefont.gz +++ b/misc/fonts/cetus-32.xinefont.gz diff --git a/misc/fonts/mono-16.xinefont.gz b/misc/fonts/mono-16.xinefont.gz Binary files differindex 230d1cf0c..fe6033585 100644 --- a/misc/fonts/mono-16.xinefont.gz +++ b/misc/fonts/mono-16.xinefont.gz diff --git a/misc/fonts/mono-20.xinefont.gz b/misc/fonts/mono-20.xinefont.gz Binary files differindex 1df0d23d6..51fc93ed6 100644 --- a/misc/fonts/mono-20.xinefont.gz +++ b/misc/fonts/mono-20.xinefont.gz diff --git a/misc/fonts/mono-24.xinefont.gz b/misc/fonts/mono-24.xinefont.gz Binary files differindex 70e6d5257..e096f22ef 100644 --- a/misc/fonts/mono-24.xinefont.gz +++ b/misc/fonts/mono-24.xinefont.gz diff --git a/misc/fonts/mono-32.xinefont.gz b/misc/fonts/mono-32.xinefont.gz Binary files differindex fd774ecbe..3eb4ac0c2 100644 --- a/misc/fonts/mono-32.xinefont.gz +++ b/misc/fonts/mono-32.xinefont.gz diff --git a/misc/fonts/sans-16.xinefont.gz b/misc/fonts/sans-16.xinefont.gz Binary files differindex 246ac1a4d..d1a97a63e 100644 --- a/misc/fonts/sans-16.xinefont.gz +++ b/misc/fonts/sans-16.xinefont.gz diff --git a/misc/fonts/sans-20.xinefont.gz b/misc/fonts/sans-20.xinefont.gz Binary files differindex cfb283749..eccdfbba8 100644 --- a/misc/fonts/sans-20.xinefont.gz +++ b/misc/fonts/sans-20.xinefont.gz diff --git a/misc/fonts/sans-24.xinefont.gz b/misc/fonts/sans-24.xinefont.gz Binary files differindex 75d7c376d..69f9ac09b 100644 --- a/misc/fonts/sans-24.xinefont.gz +++ b/misc/fonts/sans-24.xinefont.gz diff --git a/misc/fonts/sans-32.xinefont.gz b/misc/fonts/sans-32.xinefont.gz Binary files differindex 2cab7f729..f43fdcf26 100644 --- a/misc/fonts/sans-32.xinefont.gz +++ b/misc/fonts/sans-32.xinefont.gz diff --git a/misc/fonts/serif-16.xinefont.gz b/misc/fonts/serif-16.xinefont.gz Binary files differindex 92a9eb54e..d190fc4f8 100644 --- a/misc/fonts/serif-16.xinefont.gz +++ b/misc/fonts/serif-16.xinefont.gz diff --git a/misc/fonts/serif-20.xinefont.gz b/misc/fonts/serif-20.xinefont.gz Binary files differindex 9082c6209..4465a3638 100644 --- a/misc/fonts/serif-20.xinefont.gz +++ b/misc/fonts/serif-20.xinefont.gz diff --git a/misc/fonts/serif-24.xinefont.gz b/misc/fonts/serif-24.xinefont.gz Binary files differindex 8e105dc0f..bd157a082 100644 --- a/misc/fonts/serif-24.xinefont.gz +++ b/misc/fonts/serif-24.xinefont.gz diff --git a/misc/fonts/serif-32.xinefont.gz b/misc/fonts/serif-32.xinefont.gz Binary files differindex 612d35c79..83ce71a1a 100644 --- a/misc/fonts/serif-32.xinefont.gz +++ b/misc/fonts/serif-32.xinefont.gz diff --git a/misc/xine-fontconv.c b/misc/xine-fontconv.c index 884337c2f..d3fe7ff3e 100644 --- a/misc/xine-fontconv.c +++ b/misc/xine-fontconv.c @@ -30,8 +30,7 @@ * xine-fontconv font.ttf fontname * * begin : Sat Dec 1 2001 - * copyright : (C) 2001 by miguel - * email : miguel@mf + * copyright : (C) 2001 by Miguel Freitas */ #include <stdio.h> @@ -84,7 +83,7 @@ void print_bitmap (FT_Bitmap *bitmap) { for( y = 0; y < bitmap->rows; y++ ) { for( x = 0; x < bitmap->width; x++ ) { - if( bitmap->buffer[y*bitmap->width+x] ) + if( bitmap->buffer[y*bitmap->width+x] > 1 ) printf("%02x ", bitmap->buffer[y*bitmap->width+x] ); else printf(" "); @@ -110,73 +109,91 @@ void destroy_bitmap (FT_Bitmap * bitmap) { } -void add_final_bitmap (FT_Bitmap *dst, FT_Bitmap *src, int left, int top) { - +/* + This function is called to blend a slightly deslocated + version of the bitmap. This will produce the border effect. + Note that the displacement may be smaller than 1 pixel + as the bitmap is generated in freetype 1/64 units. + This border is antialiased to the background. +*/ +void add_border_bitmap( FT_Bitmap *dst, FT_Bitmap *src, int left, int top ) +{ int x,y; + int x1, y1; + int dstpos, srcpos; - for (y = 0; y < src->rows; y++) { - for ( x = 0; x < src->width; x++) { - - int x1, y1; - int dstpos, srcpos; - int x2, y2; - - + for( y = 0; y < src->rows; y++ ) { + for( x = 0; x < src->width; x++ ) { + srcpos = y * src->width + x; + x1 = x + left; - if (x1 < 0 || x1 >= dst->width) + if( x1 < 0 || x1 >= dst->width ) continue; y1 = y + top; - if (y1 < 0 || y1 >= dst->rows) + if( y1 < 0 || y1 >= dst->rows ) continue; dstpos = y1 * dst->width + x1; - - x2 = x; y2 = y; - - srcpos = y2 * src->width + x2; - if (src->buffer[srcpos]) - dst->buffer[dstpos] = 3; - else { - int count; - int i,j; - count = 0; - - for (i=-1; i<2; i++) { - for (j=-1; j<2; j++) { - - x2 = x+i; y2 = y+j; - - if ( (x2 >0 ) && (y2 > 0) - &&(x2 < src->width) - && (y2 < src->rows)) { - srcpos = y2 * src->width + x2; - if (src->buffer[srcpos]) - count++; - } - } - } - if (count) - dst->buffer[dstpos] = 2; - - } + src->buffer[srcpos] /= 51; + if( src->buffer[srcpos] > dst->buffer[dstpos] ) + dst->buffer[dstpos] = src->buffer[srcpos]; } } +} - +/* + Blend the final version of bitmap (the foreground color) over the + already generated border. It will be antialiased to the border. + + Final palette will be: + + 0: not used by font, always transparent + 1: font background, usually transparent, may be used to implement + translucid boxes where the font will be printed. + 2-5: transition between background and border (usually only alpha + value changes). + 6: font border. if the font is to be displayed without border this + will probably be adjusted to font background or near. + 7-9: transition between border and foreground + 10: font color (foreground) +*/ +void add_final_bitmap( FT_Bitmap *dst, FT_Bitmap *src, int left, int top ) +{ + int x,y; + int x1, y1; + int dstpos, srcpos; - for (y = 0; y < dst->rows; y++) { - for (x = 0; x < dst->width; x++) { - int dstpos = y * dst->width + x; - if (dst->buffer[dstpos]<2) - dst->buffer[dstpos]=1; + for( y = 0; y < src->rows; y++ ) { + for( x = 0; x < src->width; x++ ) { + srcpos = y * src->width + x; + + x1 = x + left; + if( x1 < 0 || x1 >= dst->width ) + continue; + + y1 = y + top; + if( y1 < 0 || y1 >= dst->rows ) + continue; + + dstpos = y1 * dst->width + x1; + src->buffer[srcpos] /= 52; + if( src->buffer[srcpos] ) + dst->buffer[dstpos] = src->buffer[srcpos] + 5; } } - + for( y = 0; y < dst->rows; y++ ) { + for( x = 0; x < dst->width; x++ ) { + dstpos = y * dst->width + x; + dst->buffer[dstpos]++; + } + } + } -void render_font (FT_Face face, char *fontname, int size) { + +void render_font (FT_Face face, char *fontname, int size, int thickness) { char filename[1024]; FT_Bitmap *out_bitmap; @@ -187,9 +204,14 @@ void render_font (FT_Face face, char *fontname, int size) { FT_BitmapGlyph glyph_bitmap; FT_Vector origin; int max_bearing_y = 0; - int c; - int thickness; + int c, i; + + static int border_pos[9][2] = { + {-1,0},{1,0},{0,-1},{0,1}, + {-1,-1},{1,-1},{-1,1},{1,1}, {0,0} + }; + /* * generate filename, open file */ @@ -221,10 +243,12 @@ void render_font (FT_Face face, char *fontname, int size) { return; } - thickness = 64; + if( !thickness ) + thickness = size * 64 / 30; /* - * calc max bearing + * calc max bearing y. + * this is needed to align all bitmaps by the upper position. */ for (c = 32; c < 256; c++) { @@ -251,45 +275,51 @@ void render_font (FT_Face face, char *fontname, int size) { gzwrite (fp, &font, 40+6); for (c = 32; c < 256; c++) { - - glyph_index = FT_Get_Char_Index( face, c ); + for( i=0; i < 9; i++ ) { + + glyph_index = FT_Get_Char_Index( face, c ); + + if (glyph_index) { + + error = FT_Load_Glyph( face, /* handle to face object */ + glyph_index, /* glyph index */ + FT_LOAD_DEFAULT ); /* load flags */ + + if (!error) { + error = FT_Get_Glyph( face->glyph, &glyph ); - if (glyph_index) { - - error = FT_Load_Glyph( face, /* handle to face object */ - glyph_index, /* glyph index */ - FT_LOAD_DEFAULT ); /* load flags */ - - if (!error) { - - error = FT_Get_Glyph( face->glyph, &glyph ); - - - out_bitmap = create_bitmap( f266CeilToInt(face->glyph->metrics.horiAdvance + thickness), - f266CeilToInt((max_bearing_y<<6) - face->glyph->metrics.horiBearingY + - face->glyph->metrics.height + thickness) ); - - origin.x = thickness; - origin.y = thickness; - - error = FT_Glyph_To_Bitmap( &glyph, ft_render_mode_normal, &origin, 1 ); - if (error) { - printf("error generating bitmap [%d]\n",c); - return; - } - - glyph_bitmap = (FT_BitmapGlyph)glyph; - - - add_final_bitmap (out_bitmap, &glyph_bitmap->bitmap, glyph_bitmap->left, - max_bearing_y - glyph_bitmap->top); - - FT_Done_Glyph( glyph ); + if( i == 0 ) { + out_bitmap = create_bitmap( f266CeilToInt(face->glyph->metrics.horiAdvance), + f266CeilToInt((max_bearing_y<<6) - face->glyph->metrics.horiBearingY + + face->glyph->metrics.height + thickness) ); + } + + origin.x = thickness + border_pos[i][0]*thickness; + origin.y = thickness + border_pos[i][1]*thickness; + + error = FT_Glyph_To_Bitmap( &glyph, ft_render_mode_normal, &origin, 1 ); + if (error) { + printf("error generating bitmap [%d]\n",c); + return; + } + + glyph_bitmap = (FT_BitmapGlyph)glyph; + + if( i < 8 ) + add_border_bitmap( out_bitmap, &glyph_bitmap->bitmap, glyph_bitmap->left, + max_bearing_y - glyph_bitmap->top ); + else + add_final_bitmap( out_bitmap, &glyph_bitmap->bitmap, glyph_bitmap->left, + max_bearing_y - glyph_bitmap->top ); + + FT_Done_Glyph( glyph ); + } } } - - printf("[%d] bitmap width: %d height: %d\n", c, out_bitmap->width, out_bitmap->rows ); - + printf("[%c:%d] bitmap width: %d height: %d\n", c, c, out_bitmap->width, out_bitmap->rows ); + /* + print_bitmap(out_bitmap); + */ fontchar.code = c; fontchar.width = out_bitmap->width; fontchar.height = out_bitmap->rows; @@ -307,6 +337,7 @@ int main(int argc, char *argv[]) { int len; FT_Library library; FT_Face face; + int thickness = 0; /* * command line parsing @@ -338,16 +369,16 @@ int main(int argc, char *argv[]) { return 1; } - render_font (face, argv[2], 16); - render_font (face, argv[2], 20); - render_font (face, argv[2], 24); - render_font (face, argv[2], 32); + render_font (face, argv[2], 16, thickness); + render_font (face, argv[2], 20, thickness); + render_font (face, argv[2], 24, thickness); + render_font (face, argv[2], 32, thickness); /* * some rgb -> yuv conversion, * can be used to calc new palettes */ - + /* { float f; for (f=1.0; f<6.0; f+=1.0) { @@ -364,7 +395,7 @@ int main(int argc, char *argv[]) { printf ("CLUT_Y_CR_CB_INIT(0x%x, 0x%x, 0x%x),\n", (int) Y, (int) Cr, (int) Cb); } } - + */ return 0; } diff --git a/src/libsputext/xine_decoder.c b/src/libsputext/xine_decoder.c index 83d18e8d6..7c342b0d8 100644 --- a/src/libsputext/xine_decoder.c +++ b/src/libsputext/xine_decoder.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine_decoder.c,v 1.7 2001/12/09 00:01:17 guenter Exp $ + * $Id: xine_decoder.c,v 1.8 2001/12/13 18:32:15 miguelfreitas Exp $ * * code based on mplayer module: * @@ -50,7 +50,6 @@ #define ERR (void *)-1 #define SUB_MAX_TEXT 5 -#define LINE_HEIGHT 30 typedef struct { @@ -62,7 +61,7 @@ typedef struct { char *text[SUB_MAX_TEXT]; osd_object_t *osd; - + } subtitle_t; @@ -79,6 +78,8 @@ typedef struct sputext_decoder_s { float mpsub_position; int width; /* frame width */ + int font_size; + int line_height; int uses_time; int errs; subtitle_t *subtitles; @@ -750,14 +751,28 @@ static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) { this->width = buf->decoder_info[1]; + /* trying to make better sized fonts... + another idea would be changing font size just + if we detect the text line wont fit. + */ + this->font_size = 16; + if( this->width >= 320 ) + this->font_size = 20; + if( this->width >= 384 ) + this->font_size = 24; + if( this->width >= 512 ) + this->font_size = 32; + this->line_height = this->font_size + 10; + this->renderer = this->xine->osd_renderer; this->osd = this->renderer->new_object (this->renderer, this->width, - SUB_MAX_TEXT * LINE_HEIGHT); + SUB_MAX_TEXT * this->line_height); - this->renderer->set_font (this->osd, this->font, 16); + + this->renderer->set_font (this->osd, this->font, this->font_size); - y = buf->decoder_info[2] - (SUB_MAX_TEXT * LINE_HEIGHT) - 5; + y = buf->decoder_info[2] - (SUB_MAX_TEXT * this->line_height) - 5; this->renderer->set_position (this->osd, 0, y); @@ -846,21 +861,22 @@ static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) { if (subtitle) { int line, y; - this->renderer->filled_rect (this->osd, 0, 0, this->width-1, LINE_HEIGHT * SUB_MAX_TEXT - 1, 0); + this->renderer->filled_rect (this->osd, 0, 0, this->width-1, this->line_height * SUB_MAX_TEXT - 1, 0); - y = (SUB_MAX_TEXT - subtitle->lines) * LINE_HEIGHT; + y = (SUB_MAX_TEXT - subtitle->lines) * this->line_height; for (line=0; line<subtitle->lines; line++) { int w,h,x; this->renderer->get_text_size( this->osd, subtitle->text[line], &w, &h); - + x = (this->width - w) / 2; - this->renderer->render_text (this->osd, x, y + line*20, subtitle->text[line]); + this->renderer->render_text (this->osd, x, y + line*this->line_height, subtitle->text[line]); } + this->renderer->set_text_palette (this->osd, -1); this->renderer->show (this->osd, pts ); this->renderer->hide (this->osd, pts_end); @@ -891,6 +907,16 @@ static char *spudec_get_id(void) { return "sputext"; } +static void update_osd_font(void *this_gen, cfg_entry_t *entry) +{ + sputext_decoder_t *this = (sputext_decoder_t *)this_gen; + + this->font = entry->str_value; + + this->renderer->set_font (this->osd, this->font, this->font_size); + printf("libsputext: spu_font = %s\n", this->font ); +} + spu_decoder_t *init_spu_decoder_plugin (int iface_version, xine_t *xine) { sputext_decoder_t *this ; @@ -904,7 +930,7 @@ spu_decoder_t *init_spu_decoder_plugin (int iface_version, xine_t *xine) { this = (sputext_decoder_t *) xine_xmalloc (sizeof (sputext_decoder_t)); - this->spu_decoder.interface_version = 4; + this->spu_decoder.interface_version = iface_version; this->spu_decoder.can_handle = spudec_can_handle; this->spu_decoder.init = spudec_init; this->spu_decoder.decode_data = spudec_decode_data; @@ -917,7 +943,7 @@ spu_decoder_t *init_spu_decoder_plugin (int iface_version, xine_t *xine) { "codec.spu_font", "sans", "font for avi subtitles", - NULL, NULL, NULL); + NULL, update_osd_font, this); return (spu_decoder_t *) this; } diff --git a/src/xine-engine/osd.c b/src/xine-engine/osd.c index 7035399e8..59a4a2e25 100644 --- a/src/xine-engine/osd.c +++ b/src/xine-engine/osd.c @@ -20,6 +20,8 @@ * OSD stuff (text and graphic primitives) */ +#define __OSD_C__ + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -102,6 +104,7 @@ static osd_object_t *osd_new_object (osd_renderer_t *this, int width, int height osd_object_t *osd; +#if 0 static clut_t default_color[] = { CLUT_Y_CR_CB_INIT(0x00, 0x00, 0x00), CLUT_Y_CR_CB_INIT(0x00, 0x80, 0x80), @@ -120,6 +123,7 @@ static osd_object_t *osd_new_object (osd_renderer_t *this, int width, int height */ }; static uint8_t default_trans[] = {0, 10, 12, 15, 15, 15, 15}; +#endif pthread_mutex_lock (&this->osd_mutex); @@ -137,8 +141,8 @@ static osd_object_t *osd_new_object (osd_renderer_t *this, int width, int height osd->x2 = 0; osd->y2 = 0; - memcpy(osd->color, default_color, sizeof(default_color)); - memcpy(osd->trans, default_trans, sizeof(default_trans)); + memcpy(osd->color, textpalettes_color[0], sizeof(textpalettes_color[0])); + memcpy(osd->trans, textpalettes_trans[0], sizeof(textpalettes_trans[0])); osd->handle = -1; @@ -399,6 +403,23 @@ static void osd_set_palette(osd_object_t *osd, uint32_t *color, uint8_t *trans ) } /* + * set on existing text palette + * (-1 to set user specified palette) + */ + +static void osd_set_text_palette(osd_object_t *osd, int palette_number ) { + + if( palette_number < 0 ) + palette_number = osd->renderer->textpalette; + + memcpy(osd->color, textpalettes_color[palette_number], + sizeof(textpalettes_color[palette_number])); + memcpy(osd->trans, textpalettes_trans[palette_number], + sizeof(textpalettes_trans[palette_number])); +} + + +/* * get palette (color and transparency) */ @@ -662,7 +683,7 @@ static int osd_get_text_size(osd_object_t *osd, char *text, int *width, int *hei *width = 0; *height = 0; - while( *text ) { + while( font && *text ) { for( i = 0; i < font->num_fontchars; i++ ) { if( font->fontchar[i].code == *text ) @@ -765,17 +786,28 @@ static void osd_renderer_close (osd_renderer_t *this) { free(this); } + +static void update_text_palette(void *this_gen, cfg_entry_t *entry) +{ + osd_renderer_t *this = (osd_renderer_t *)this_gen; + + this->textpalette = entry->num_value; + printf("osd: text palette will be %s\n", textpalettes_str[this->textpalette] ); +} + + /* * initialize the osd rendering engine */ -osd_renderer_t *osd_renderer_init( video_overlay_instance_t *video_overlay ) { +osd_renderer_t *osd_renderer_init( video_overlay_instance_t *video_overlay, config_values_t *config ) { osd_renderer_t *this; char str[1024]; this = xine_xmalloc(sizeof(osd_renderer_t)); this->video_overlay = video_overlay; + this->config = config; this->event.object.overlay = xine_xmalloc( sizeof(vo_overlay_t) ); pthread_mutex_init (&this->osd_mutex, NULL); @@ -794,24 +826,29 @@ osd_renderer_t *osd_renderer_init( video_overlay_instance_t *video_overlay ) { osd_load_fonts (this, str); - + this->textpalette = config->register_enum (config, "misc.osd_text_palette", 0, + textpalettes_str, + "Palette (foreground-border-background) to use on subtitles", + NULL, update_text_palette, this); + /* * set up function pointer */ - this->new_object = osd_new_object; - this->free_object = osd_free_object; - this->show = osd_show; - this->hide = osd_hide; - this->set_palette = osd_set_palette; - this->get_palette = osd_get_palette; - this->set_position = osd_set_position; - this->set_font = osd_set_font; - this->line = osd_line; - this->filled_rect = osd_filled_rect; - this->render_text = osd_render_text; - this->get_text_size = osd_get_text_size; - this->close = osd_renderer_close; + this->new_object = osd_new_object; + this->free_object = osd_free_object; + this->show = osd_show; + this->hide = osd_hide; + this->set_palette = osd_set_palette; + this->set_text_palette = osd_set_text_palette; + this->get_palette = osd_get_palette; + this->set_position = osd_set_position; + this->set_font = osd_set_font; + this->line = osd_line; + this->filled_rect = osd_filled_rect; + this->render_text = osd_render_text; + this->get_text_size = osd_get_text_size; + this->close = osd_renderer_close; return this; } diff --git a/src/xine-engine/osd.h b/src/xine-engine/osd.h index f22924492..33086e869 100644 --- a/src/xine-engine/osd.h +++ b/src/xine-engine/osd.h @@ -24,6 +24,7 @@ #define HAVE_OSD_H #include "video_overlay.h" +#include "video_out/alphablend.h" typedef struct osd_object_s osd_object_t; @@ -78,6 +79,12 @@ struct osd_renderer_s { void (*set_palette) (osd_object_t *osd, uint32_t *color, uint8_t *trans ); /* + * set on existing text palette + * (-1 to set used specified palette) + */ + void (*set_text_palette) (osd_object_t *osd, int palette_number ); + + /* * get palette (color and transparency) */ void (*get_palette) (osd_object_t *osd, uint32_t *color, @@ -120,14 +127,130 @@ struct osd_renderer_s { pthread_mutex_t osd_mutex; video_overlay_instance_t *video_overlay; video_overlay_event_t event; - osd_object_t *osds; - osd_font_t *fonts; + osd_object_t *osds; /* instances of osd */ + osd_font_t *fonts; /* loaded fonts */ + int textpalette; /* default textpalette */ + + config_values_t *config; + }; /* * initialize the osd rendering engine */ -osd_renderer_t *osd_renderer_init( video_overlay_instance_t *video_overlay ); +osd_renderer_t *osd_renderer_init( video_overlay_instance_t *video_overlay, config_values_t *config ); + + + +/* + * Defined palettes for rendering osd text + * (more can be added later) + */ + +#define NUMBER_OF_TEXT_PALETTES 4 +#define TEXTPALETTE_WHITE_BLACK_TRANSPARENT 0 +#define TEXTPALETTE_WHITE_NONE_TRANSLUCID 1 +#define TEXTPALETTE_WHITE_NONE_TRANSPUCID 2 +#define TEXTPALETTE_YELLOW_BLACK_TRANSPARENT 3 + +#ifdef __OSD_C__ + +/* This text descriptions are used for config screen */ +static char *textpalettes_str[NUMBER_OF_TEXT_PALETTES+1] = { + "white-black-transparent", + "white-none-transparent", + "white-none-translucid", + "yellow-black-transparent", + NULL}; + + +/* + Palette entries as used by osd fonts: + + 0: not used by font, always transparent + 1: font background, usually transparent, may be used to implement + translucid boxes where the font will be printed. + 2-5: transition between background and border (usually only alpha + value changes). + 6: font border. if the font is to be displayed without border this + will probably be adjusted to font background or near. + 7-9: transition between border and foreground + 10: font color (foreground) +*/ + +/* + The palettes below were made by hand, ie, i just throw + values that seemed to do the transitions i wanted. + This can surelly be improved a lot. [Miguel] +*/ + +static clut_t textpalettes_color[NUMBER_OF_TEXT_PALETTES][11] = { +/* white, black border, transparent */ + { + CLUT_Y_CR_CB_INIT(0x00, 0x00, 0x00), //0 + CLUT_Y_CR_CB_INIT(0x00, 0x80, 0x80), //1 + CLUT_Y_CR_CB_INIT(0x00, 0x80, 0x80), //2 + CLUT_Y_CR_CB_INIT(0x00, 0x80, 0x80), //3 + CLUT_Y_CR_CB_INIT(0x00, 0x80, 0x80), //4 + CLUT_Y_CR_CB_INIT(0x00, 0x80, 0x80), //5 + CLUT_Y_CR_CB_INIT(0x00, 0x80, 0x80), //6 + CLUT_Y_CR_CB_INIT(0x40, 0x80, 0x80), //7 + CLUT_Y_CR_CB_INIT(0x80, 0x80, 0x80), //8 + CLUT_Y_CR_CB_INIT(0xc0, 0x80, 0x80), //9 + CLUT_Y_CR_CB_INIT(0xff, 0x80, 0x80), //10 + }, + /* white, no border, transparent */ + { + CLUT_Y_CR_CB_INIT(0x00, 0x00, 0x00), //0 + CLUT_Y_CR_CB_INIT(0xff, 0x80, 0x80), //1 + CLUT_Y_CR_CB_INIT(0xff, 0x80, 0x80), //2 + CLUT_Y_CR_CB_INIT(0xff, 0x80, 0x80), //3 + CLUT_Y_CR_CB_INIT(0xff, 0x80, 0x80), //4 + CLUT_Y_CR_CB_INIT(0xff, 0x80, 0x80), //5 + CLUT_Y_CR_CB_INIT(0xff, 0x80, 0x80), //6 + CLUT_Y_CR_CB_INIT(0xff, 0x80, 0x80), //7 + CLUT_Y_CR_CB_INIT(0xff, 0x80, 0x80), //8 + CLUT_Y_CR_CB_INIT(0xff, 0x80, 0x80), //9 + CLUT_Y_CR_CB_INIT(0xff, 0x80, 0x80), //10 + }, + /* white, no border, translucid */ + { + CLUT_Y_CR_CB_INIT(0x00, 0x00, 0x00), //0 + CLUT_Y_CR_CB_INIT(0x80, 0x80, 0x80), //1 + CLUT_Y_CR_CB_INIT(0x80, 0x80, 0x80), //2 + CLUT_Y_CR_CB_INIT(0x80, 0x80, 0x80), //3 + CLUT_Y_CR_CB_INIT(0x80, 0x80, 0x80), //4 + CLUT_Y_CR_CB_INIT(0x80, 0x80, 0x80), //5 + CLUT_Y_CR_CB_INIT(0x80, 0x80, 0x80), //6 + CLUT_Y_CR_CB_INIT(0xa0, 0x80, 0x80), //7 + CLUT_Y_CR_CB_INIT(0xc0, 0x80, 0x80), //8 + CLUT_Y_CR_CB_INIT(0xe0, 0x80, 0x80), //9 + CLUT_Y_CR_CB_INIT(0xff, 0x80, 0x80), //10 + }, + /* yellow, black border, transparent */ + { + CLUT_Y_CR_CB_INIT(0x00, 0x00, 0x00), //0 + CLUT_Y_CR_CB_INIT(0x00, 0x80, 0x80), //1 + CLUT_Y_CR_CB_INIT(0x00, 0x80, 0x80), //2 + CLUT_Y_CR_CB_INIT(0x00, 0x80, 0x80), //3 + CLUT_Y_CR_CB_INIT(0x00, 0x80, 0x80), //4 + CLUT_Y_CR_CB_INIT(0x00, 0x80, 0x80), //5 + CLUT_Y_CR_CB_INIT(0x00, 0x80, 0x80), //6 + CLUT_Y_CR_CB_INIT(0x40, 0x84, 0x60), //7 + CLUT_Y_CR_CB_INIT(0xd0, 0x88, 0x40), //8 + CLUT_Y_CR_CB_INIT(0xe0, 0x8a, 0x00), //9 + CLUT_Y_CR_CB_INIT(0xff, 0x90, 0x00), //10 + }, +}; + +static uint8_t textpalettes_trans[NUMBER_OF_TEXT_PALETTES][11] = { + {0, 0, 3, 6, 8, 10, 12, 14, 15, 15, 15 }, + {0, 0, 0, 0, 0, 0, 2, 6, 9, 12, 15 }, + {0, 8, 9, 10, 11, 12, 13, 14, 15, 15, 15 }, + {0, 0, 3, 6, 8, 10, 12, 14, 15, 15, 15 }, +}; + +#endif /* __OSD_C__ */ #endif diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index 79ea1142f..36ca880d0 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xine.c,v 1.89 2001/12/13 00:52:01 f1rmb Exp $ + * $Id: xine.c,v 1.90 2001/12/13 18:32:16 miguelfreitas Exp $ * * top-level xine functions * @@ -478,10 +478,11 @@ xine_t *xine_init (vo_driver_t *vo, this->video_out = vo_new_instance (vo, this->metronom); video_decoder_init (this); - this->osd_renderer = osd_renderer_init( this->video_out->overlay_source ); + this->osd_renderer = osd_renderer_init( this->video_out->overlay_source, config ); this->osd = this->osd_renderer->new_object (this->osd_renderer, 300, 100); this->osd_renderer->set_font (this->osd, "cetus", 24); + this->osd_renderer->set_text_palette (this->osd, TEXTPALETTE_WHITE_BLACK_TRANSPARENT ); this->osd_renderer->set_position (this->osd, 10,10); if(ao) |