From c411a4ea9f23a55037b2f338b4e8baa9d156a620 Mon Sep 17 00:00:00 2001 From: Guenter Bartsch Date: Sat, 8 Dec 2001 00:37:38 +0000 Subject: osd fonts and interface update CVS patchset: 1174 CVS date: 2001/12/08 00:37:38 --- src/libsputext/xine_decoder.c | 40 ++-- src/xine-engine/osd.c | 418 ++++++++++++++++++++++++++-------------- src/xine-engine/osd.h | 260 +++++++++++-------------- src/xine-engine/video_overlay.h | 6 +- 4 files changed, 411 insertions(+), 313 deletions(-) (limited to 'src') diff --git a/src/libsputext/xine_decoder.c b/src/libsputext/xine_decoder.c index 3a50adf21..056b76038 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.5 2001/12/02 21:59:33 guenter Exp $ + * $Id: xine_decoder.c,v 1.6 2001/12/08 00:37:38 guenter Exp $ * * code based on mplayer module: * @@ -50,7 +50,7 @@ #define ERR (void *)-1 #define SUB_MAX_TEXT 5 -#define LINE_HEIGHT 20 +#define LINE_HEIGHT 30 typedef struct { @@ -87,6 +87,7 @@ typedef struct sputext_decoder_s { int format; /* constants see below */ subtitle_t *previous_aqt_sub ; + osd_renderer_t *renderer; osd_object_t *osd; char *font; @@ -749,20 +750,20 @@ static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) { this->width = buf->decoder_info[1]; - this->osd = osd_open (this->xine->osd_renderer, - this->width, - SUB_MAX_TEXT * LINE_HEIGHT); + this->renderer = this->xine->osd_renderer; + this->osd = this->renderer->new_object (this->renderer, + this->width, + SUB_MAX_TEXT * LINE_HEIGHT); - osd_renderer_load_font (this->xine->osd_renderer, this->font); - osd_set_font (this->osd, this->font); + this->renderer->set_font (this->osd, this->font, 16); y = buf->decoder_info[2] - (SUB_MAX_TEXT * LINE_HEIGHT) - 5; - osd_set_position (this->osd, 0, y); + this->renderer->set_position (this->osd, 0, y); - osd_render_text (this->osd, 0, 0, "sputext decoder"); - osd_show (this->osd, 0); - osd_hide (this->osd, 300000); + this->renderer->render_text (this->osd, 0, 0, "sputext decoder"); + this->renderer->show (this->osd, 0); + this->renderer->hide (this->osd, 300000); this->fd = (FILE *) buf->content; @@ -839,23 +840,23 @@ static void spudec_decode_data (spu_decoder_t *this_gen, buf_element_t *buf) { if (subtitle) { int line, y; - osd_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, LINE_HEIGHT * SUB_MAX_TEXT - 1, 0); y = (SUB_MAX_TEXT - subtitle->lines) * LINE_HEIGHT; for (line=0; linelines; line++) { int w,h,x; - osd_get_text_size( this->osd, subtitle->text[line], - & w, &h); + this->renderer->get_text_size( this->osd, subtitle->text[line], + &w, &h); x = (this->width - w) / 2; - osd_render_text (this->osd, x, y + line*20, subtitle->text[line]); + this->renderer->render_text (this->osd, x, y + line*20, subtitle->text[line]); } - osd_show (this->osd, pts ); - osd_hide (this->osd, pts_end); + this->renderer->show (this->osd, pts ); + this->renderer->hide (this->osd, pts_end); } @@ -868,7 +869,7 @@ static void spudec_close (spu_decoder_t *this_gen) { sputext_decoder_t *this = (sputext_decoder_t *) this_gen; if (this->osd) { - osd_close (this->osd); + this->renderer->free_object (this->osd); this->osd = NULL; } @@ -900,10 +901,9 @@ spu_decoder_t *init_spu_decoder_plugin (int iface_version, xine_t *xine) { this->spu_decoder.priority = 1; this->xine = xine; - this->font = xine->config->register_string(xine->config, "codec.spu_font", - "vga", + "sans", "font for avi subtitles", NULL, NULL, NULL); diff --git a/src/xine-engine/osd.c b/src/xine-engine/osd.c index 96b550275..f18443c78 100644 --- a/src/xine-engine/osd.c +++ b/src/xine-engine/osd.c @@ -20,15 +20,18 @@ * OSD stuff (text and graphic primitives) */ -#define __OSD_C__ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include #include #include #include +#include +#include #include "events.h" -#include "video_overlay.h" #include "xine_internal.h" #include "video_out/alphablend.h" #include "xine-engine/bswap.h" @@ -36,9 +39,9 @@ #include "video_out.h" #include "osd.h" -/* + #define LOG_DEBUG 1 -*/ + #ifdef MAX #undef MAX @@ -50,60 +53,73 @@ #endif #define MIN(a,b) ( (a) < (b) ) ? (a) : (b) -/* - initialize the osd rendering engine -*/ - -osd_renderer_t *osd_renderer_init( video_overlay_instance_t *video_overlay ) -{ - osd_renderer_t *this; - - this = xine_xmalloc(sizeof(osd_renderer_t)); - this->video_overlay = video_overlay; - this->event.object.overlay = xine_xmalloc( sizeof(vo_overlay_t) ); +struct osd_object_s { + osd_object_t *next; + osd_renderer_t *renderer; - pthread_mutex_init (&this->osd_mutex, NULL); - -#ifdef LOG_DEBUG - printf("osd_renderer_init %p\n", this); -#endif + int width, height; /* work area dimentions */ + uint8_t *area; /* work area */ + int display_x,display_y; /* where to display it in screen */ - return this; -} - -void osd_renderer_exit( osd_renderer_t *this ) -{ - - while( this->osds ) - osd_close( this->osds ); - - while( this->fonts ) - osd_renderer_unload_font( this, this->fonts->name ); - - free(this); -} + /* clipping box inside work area */ + int x1, y1; + int x2, y2; + + uint32_t color[16]; /* color lookup table */ + uint8_t trans[16]; /* mixer key table */ + int32_t handle; + + osd_font_t *font; +}; + +typedef struct osd_fontchar_s { + uint16_t code; + uint16_t width; + uint16_t height; + uint8_t *bmp; +} osd_fontchar_t; + +struct osd_font_s { + char name[40]; + uint16_t version; + uint16_t size; + uint16_t num_fontchars; + osd_fontchar_t *fontchar; + osd_font_t *next; +}; /* - open a new osd object. this will allocated an empty (all zero) drawing - area where graphic primitives may be used. - It is ok to specify big width and height values. The render will keep - track of the smallest changed area to not generate too big overlays. - A default palette is initialized (i sugest keeping color 0 as transparent - for the sake of simplicity) -*/ + * open a new osd object. this will allocated an empty (all zero) drawing + * area where graphic primitives may be used. + * It is ok to specify big width and height values. The render will keep + * track of the smallest changed area to not generate too big overlays. + * A default palette is initialized (i sugest keeping color 0 as transparent + * for the sake of simplicity) + */ -osd_object_t *osd_open(osd_renderer_t *this, int width, int height) -{ +static osd_object_t *osd_new_object (osd_renderer_t *this, int width, int height) { + osd_object_t *osd; static clut_t default_color[] = { - CLUT_Y_CR_CB_INIT(0x00, 0x00, 0x00), - CLUT_Y_CR_CB_INIT(0x80, 0x80, 0x80), - CLUT_Y_CR_CB_INIT(0xff, 0x90, 0x00), - CLUT_Y_CR_CB_INIT(0xff, 0x80, 0x80) + CLUT_Y_CR_CB_INIT(0x00, 0x00, 0x00), + CLUT_Y_CR_CB_INIT(0x00, 0x80, 0x80), + CLUT_Y_CR_CB_INIT(0x8d, 0x7f, 0x85), + CLUT_Y_CR_CB_INIT(0xc9, 0x7f, 0x85), + CLUT_Y_CR_CB_INIT(0x00, 0x00, 0x00), + CLUT_Y_CR_CB_INIT(0x00, 0x00, 0x00), + CLUT_Y_CR_CB_INIT(0x00, 0x00, 0x00) + + /* + CLUT_Y_CR_CB_INIT(0x19, 0x7e, 0x89), + CLUT_Y_CR_CB_INIT(0x32, 0x7c, 0x93), + CLUT_Y_CR_CB_INIT(0x4b, 0x7b, 0x9c), + CLUT_Y_CR_CB_INIT(0x64, 0x79, 0xa6), + CLUT_Y_CR_CB_INIT(0x7d, 0x78, 0xaf) + */ }; - static uint8_t default_trans[] = {0, 7, 15, 15}; + static uint8_t default_trans[] = {0, 10, 12, 15, 15, 15, 15}; pthread_mutex_lock (&this->osd_mutex); @@ -136,46 +152,13 @@ osd_object_t *osd_open(osd_renderer_t *this, int width, int height) } -/* - free osd object -*/ - -void osd_close(osd_object_t *osd_to_close) -{ - osd_renderer_t *this = osd_to_close->renderer; - osd_object_t *osd, *last; - - if( osd_to_close->handle >= 0 ) - osd_hide(osd_to_close,0); - - pthread_mutex_lock (&this->osd_mutex); - - last = NULL; - osd = this->osds; - while( osd ) { - if ( osd == osd_to_close ) { - free( osd->area ); - - if( last ) - last->next = osd->next; - else - this->osds = osd->next; - free( osd ); - break; - } - last = osd; - osd = osd->next; - } - pthread_mutex_unlock (&this->osd_mutex); -} - /* - send the osd to be displayed at given pts (0=now) - the object is not changed. there may be subsequent drawing on it. -*/ -int osd_show(osd_object_t *osd, uint32_t vpts ) -{ + * send the osd to be displayed at given pts (0=now) + * the object is not changed. there may be subsequent drawing on it. + */ +static int osd_show (osd_object_t *osd, uint32_t vpts ) { + osd_renderer_t *this = osd->renderer; rle_elem_t rle, *rle_p=0; int x, y, spare; @@ -259,11 +242,11 @@ int osd_show(osd_object_t *osd, uint32_t vpts ) } /* - send event to hide osd at given pts (0=now) - the object is not changed. there may be subsequent drawing on it. -*/ -int osd_hide(osd_object_t *osd, uint32_t vpts ) -{ + * send event to hide osd at given pts (0=now) + * the object is not changed. there may be subsequent drawing on it. + */ +static int osd_hide (osd_object_t *osd, uint32_t vpts) { + osd_renderer_t *this = osd->renderer; #ifdef LOG_DEBUG @@ -291,12 +274,12 @@ int osd_hide(osd_object_t *osd, uint32_t vpts ) } /* - Bresenham line implementation on osd object -*/ + * Bresenham line implementation on osd object + */ -void osd_line(osd_object_t *osd, - int x1, int y1, int x2, int y2, int color ) -{ +static void osd_line (osd_object_t *osd, + int x1, int y1, int x2, int y2, int color) { + uint8_t *c; int dx, dy, t, inc, d, inc1, inc2; @@ -375,12 +358,12 @@ void osd_line(osd_object_t *osd, /* - filled retangle -*/ + * filled retangle + */ + +static void osd_filled_rect (osd_object_t *osd, + int x1, int y1, int x2, int y2, int color) { -void osd_filled_rect(osd_object_t *osd, - int x1, int y1, int x2, int y2, int color ) -{ int x, y, dx, dy; #ifdef LOG_DEBUG @@ -406,31 +389,31 @@ void osd_filled_rect(osd_object_t *osd, } /* - set palette (color and transparency) -*/ + * set palette (color and transparency) + */ + +static void osd_set_palette(osd_object_t *osd, uint32_t *color, uint8_t *trans ) { -void osd_set_palette(osd_object_t *osd, uint32_t *color, uint8_t *trans ) -{ memcpy(osd->color, color, sizeof(osd->color)); memcpy(osd->trans, trans, sizeof(osd->trans)); } /* - get palette (color and transparency) -*/ + * get palette (color and transparency) + */ + +static void osd_get_palette (osd_object_t *osd, uint32_t *color, uint8_t *trans) { -void osd_get_palette(osd_object_t *osd, uint32_t *color, uint8_t *trans ) -{ memcpy(color, osd->color, sizeof(osd->color)); memcpy(trans, osd->trans, sizeof(osd->trans)); } /* - set position were overlay will be blended -*/ + * set position were overlay will be blended + */ + +static void osd_set_position (osd_object_t *osd, int x, int y) { -void osd_set_position(osd_object_t *osd, int x, int y ) -{ osd->display_x = x; osd->display_y = y; } @@ -444,24 +427,18 @@ static uint16_t gzread_i16(gzFile *fp) { /* load bitmap font into osd engine - returns the internal font name to be used with other functions - FIXME: check if font is already loaded! */ -char * osd_renderer_load_font(osd_renderer_t *this, char *name) -{ - gzFile *fp; - osd_font_t *font = NULL; - char *filename; - int i, ret = 0; +static void osd_renderer_load_font(osd_renderer_t *this, char *filename) { + + gzFile *fp; + osd_font_t *font = NULL; + int i, ret = 0; #ifdef LOG_DEBUG - printf("osd_renderer_load_font %p name=%s\n", this, name ); + printf("osd: renderer_load_font %p name=%s\n", this, filename ); #endif - filename = malloc(strlen(name)+200); - sprintf(filename,"%s/%s.xinefont.gz",XINE_SKINDIR, name); - pthread_mutex_lock (&this->osd_mutex); /* load quick & dirt font format */ @@ -472,12 +449,13 @@ char * osd_renderer_load_font(osd_renderer_t *this, char *name) gzread(fp, font->name, sizeof(font->name) ); font->version = gzread_i16(fp); + font->size = gzread_i16(fp); font->num_fontchars = gzread_i16(fp); font->fontchar = malloc( sizeof(osd_fontchar_t) * font->num_fontchars ); #ifdef LOG_DEBUG - printf("font %s %d\n",font->name, font->num_fontchars); + printf("osd: font %s %d\n",font->name, font->num_fontchars); #endif for( i = 0; i < font->num_fontchars; i++ ) { font->fontchar[i].code = gzread_i16(fp); @@ -487,17 +465,24 @@ char * osd_renderer_load_font(osd_renderer_t *this, char *name) if( gzread(fp,font->fontchar[i].bmp, font->fontchar[i].width*font->fontchar[i].height) <= 0 ) break; -#ifdef LOG_DEBUG - printf("char[%d] %dx%d\n",font->fontchar[i].code,font->fontchar[i].width,font->fontchar[i].height); -#endif } if( i == font->num_fontchars ) { ret = 1; +#ifdef LOG_DEBUG + printf("osd: font %s loading ok\n",font->name); +#endif + font->next = this->fonts; this->fonts = font; } else { + +#ifdef LOG_DEBUG + printf("osd: font %s loading failed (%d < %d)\n",font->name, + i, font->num_fontchars); +#endif + while( --i >= 0 ) { free(font->fontchar[i].bmp); } @@ -509,19 +494,13 @@ char * osd_renderer_load_font(osd_renderer_t *this, char *name) } pthread_mutex_unlock (&this->osd_mutex); - free(filename); - - if( ret ) - return font->name; - else - return NULL; } /* - unload font -*/ -int osd_renderer_unload_font(osd_renderer_t *this, char *fontname ) -{ + * unload font + */ +static int osd_renderer_unload_font(osd_renderer_t *this, char *fontname ) { + osd_font_t *font, *last; osd_object_t *osd; int i, ret = 0; @@ -569,10 +548,11 @@ int osd_renderer_unload_font(osd_renderer_t *this, char *fontname ) set the font of osd object */ -int osd_set_font( osd_object_t *osd, char *fontname ) -{ +static int osd_set_font( osd_object_t *osd, char *fontname, int size) { + osd_renderer_t *this = osd->renderer; osd_font_t *font; + int best = 0; int ret = 0; #ifdef LOG_DEBUG @@ -585,9 +565,16 @@ int osd_set_font( osd_object_t *osd, char *fontname ) font = this->fonts; while( font ) { - if( !strcmp(font->name, fontname) ) { + + if( !strcmp(font->name, fontname) && (size>=font->size) + && (bestsize)) { ret = 1; osd->font = font; + best = font->size; +#ifdef LOG_DEBUG + printf ("osd_set_font: font->name=%s, size=%d\n", font->name, font->size); +#endif + } font = font->next; } @@ -598,11 +585,11 @@ int osd_set_font( osd_object_t *osd, char *fontname ) /* - render text on x,y position (8 bits version) - no \n yet -*/ -int osd_render_text( osd_object_t *osd, int x1, int y1, char *text ) -{ + * render text on x,y position (8 bits version) + * no \n yet + */ +static int osd_render_text (osd_object_t *osd, int x1, int y1, char *text) { + osd_renderer_t *this = osd->renderer; osd_font_t *font; int i, y; @@ -658,8 +645,8 @@ int osd_render_text( osd_object_t *osd, int x1, int y1, char *text ) /* get width and height of how text will be renderized */ -int osd_get_text_size( osd_object_t *osd, char *text, int *width, int *height ) -{ +static int osd_get_text_size(osd_object_t *osd, char *text, int *width, int *height) { + osd_renderer_t *this = osd->renderer; osd_font_t *font; int i; @@ -695,3 +682,136 @@ int osd_get_text_size( osd_object_t *osd, char *text, int *width, int *height ) return 1; } +static void osd_load_fonts (osd_renderer_t *this, char *path) { + DIR *dir; + char pathname [1024]; + +#ifdef LOG_DEBUG + printf ("osd: load_fonts, path=%s\n", path); +#endif + + dir = opendir (path) ; + + if (dir) { + + struct dirent *entry; + +#ifdef LOG_DEBUG + printf ("osd: load_fonts, %s opened\n", path); +#endif + + while ((entry = readdir (dir)) != NULL) { + int len; + + len = strlen (entry->d_name); + + if ( (len>12) && !strncmp (&entry->d_name[len-12], ".xinefont.gz", 12)) { + +#ifdef LOG_DEBUG + printf ("osd: trying to load font >%s< (ending >%s<)\n", + entry->d_name,&entry->d_name[len-12]); +#endif + + sprintf (pathname, "%s/%s", path, entry->d_name); + + osd_renderer_load_font (this, pathname); + + } + } + } +} + +/* + * free osd object + */ + +static void osd_free_object (osd_object_t *osd_to_close) { + + osd_renderer_t *this = osd_to_close->renderer; + osd_object_t *osd, *last; + + if( osd_to_close->handle >= 0 ) + osd_hide(osd_to_close,0); + + pthread_mutex_lock (&this->osd_mutex); + + last = NULL; + osd = this->osds; + while( osd ) { + if ( osd == osd_to_close ) { + free( osd->area ); + + if( last ) + last->next = osd->next; + else + this->osds = osd->next; + free( osd ); + break; + } + last = osd; + osd = osd->next; + } + pthread_mutex_unlock (&this->osd_mutex); +} + +static void osd_renderer_close (osd_renderer_t *this) { + + while( this->osds ) + osd_free_object ( this->osds ); + + while( this->fonts ) + osd_renderer_unload_font( this, this->fonts->name ); + + free(this); +} + +/* + * initialize the osd rendering engine + */ + +osd_renderer_t *osd_renderer_init( video_overlay_instance_t *video_overlay ) { + + osd_renderer_t *this; + char str[1024]; + + this = xine_xmalloc(sizeof(osd_renderer_t)); + this->video_overlay = video_overlay; + this->event.object.overlay = xine_xmalloc( sizeof(vo_overlay_t) ); + + pthread_mutex_init (&this->osd_mutex, NULL); + +#ifdef LOG_DEBUG + printf("osd: osd_renderer_init %p\n", this); +#endif + + /* + * load available fonts + */ + + osd_load_fonts (this, XINE_FONTDIR); + + sprintf (str, "%s/.xine/fonts", xine_get_homedir ()); + + osd_load_fonts (this, str); + + + /* + * 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; + + return this; +} diff --git a/src/xine-engine/osd.h b/src/xine-engine/osd.h index 2e27faf93..f22924492 100644 --- a/src/xine-engine/osd.h +++ b/src/xine-engine/osd.h @@ -1,159 +1,133 @@ -#ifndef __OSD_H__ -#define __OSD_H__ - -#ifdef __OSD_C__ +/* + * Copyright (C) 2000-2001 the xine project + * + * This file is part of xine, a unix video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * OSD stuff (text and graphic primitives) + */ + +#ifndef HAVE_OSD_H +#define HAVE_OSD_H + +#include "video_overlay.h" typedef struct osd_object_s osd_object_t; + typedef struct osd_renderer_s osd_renderer_t; -typedef struct osd_fontchar_s osd_fontchar_t; typedef struct osd_font_s osd_font_t; -struct osd_object_s { - osd_object_t *next; - osd_renderer_t *renderer; +struct osd_renderer_s { - int width, height; /* work area dimentions */ - uint8_t *area; /* work area */ - int display_x,display_y; /* where to display it in screen */ + /* + * open a new osd object. this will allocated an empty (all zero) drawing + * area where graphic primitives may be used. + * It is ok to specify big width and height values. The render will keep + * track of the smallest changed area to not generate too big overlays. + * A default palette is initialized (i sugest keeping color 0 as transparent + * for the sake of simplicity) + */ + osd_object_t* (*new_object) (osd_renderer_t *this, int width, int height); + + /* + * free osd object + */ + void (*free_object) (osd_object_t *osd_to_close); + + + /* + * send the osd to be displayed at given pts (0=now) + * the object is not changed. there may be subsequent drawing on it. + */ + int (*show) (osd_object_t *osd, uint32_t vpts ); + + /* + * send event to hide osd at given pts (0=now) + * the object is not changed. there may be subsequent drawing on it. + */ + int (*hide) (osd_object_t *osd, uint32_t vpts ); + + /* + * Bresenham line implementation on osd object + */ + void (*line) (osd_object_t *osd, + int x1, int y1, int x2, int y2, int color ); - /* clipping box inside work area */ - int x1, y1; - int x2, y2; + /* + * filled retangle + */ + void (*filled_rect) (osd_object_t *osd, + int x1, int y1, int x2, int y2, int color ); + + /* + * set palette (color and transparency) + */ + void (*set_palette) (osd_object_t *osd, uint32_t *color, uint8_t *trans ); + + /* + * get palette (color and transparency) + */ + void (*get_palette) (osd_object_t *osd, uint32_t *color, + uint8_t *trans); + + /* + * set position were overlay will be blended + */ + void (*set_position) (osd_object_t *osd, int x, int y); + + /* + * set the font of osd object + */ + + int (*set_font) (osd_object_t *osd, char *fontname, int size); + + + /* + * render text on x,y position (8 bits version) + * no \n yet + */ + int (*render_text) (osd_object_t *osd, int x1, int y1, + char *text); + + /* + * get width and height of how text will be renderized + */ + int (*get_text_size) (osd_object_t *osd, char *text, + int *width, int *height); + + /* + * close osd rendering engine + * loaded fonts are unloaded + * osd objects are closed + */ + void (*close) (osd_renderer_t *this); - uint32_t color[16]; /* color lookup table */ - uint8_t trans[16]; /* mixer key table */ - - int32_t handle; - - osd_font_t *font; -}; - - -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; -}; - -struct osd_fontchar_s { - uint16_t code; - uint16_t width; - uint16_t height; - uint8_t *bmp; -}; + /* private stuff */ -struct osd_font_s { - char name[40]; - uint16_t version; - uint16_t num_fontchars; - osd_fontchar_t *fontchar; - osd_font_t *next; + pthread_mutex_t osd_mutex; + video_overlay_instance_t *video_overlay; + video_overlay_event_t event; + osd_object_t *osds; + osd_font_t *fonts; }; -#else - -typedef void osd_object_t; -typedef void osd_renderer_t; - -#endif - /* - initialize the osd rendering engine -*/ + * initialize the osd rendering engine + */ osd_renderer_t *osd_renderer_init( video_overlay_instance_t *video_overlay ); -/* close osd rendering engine - loaded fonts are unloaded - osd objects are closed -*/ -void osd_renderer_exit( osd_renderer_t *this ); - -/* - open a new osd object. this will allocated an empty (all zero) drawing - area where graphic primitives may be used. - It is ok to specify big width and height values. The render will keep - track of the smallest changed area to not generate too big overlays. - A default palette is initialized (i sugest keeping color 0 as transparent - for the sake of simplicity) -*/ -osd_object_t *osd_open(osd_renderer_t *this, int width, int height); - - -/* - free osd object -*/ -void osd_close(osd_object_t *osd_to_close); - - -/* - send the osd to be displayed at given pts (0=now) - the object is not changed. there may be subsequent drawing on it. -*/ -int osd_show(osd_object_t *osd, uint32_t vpts ); - -/* - send event to hide osd at given pts (0=now) - the object is not changed. there may be subsequent drawing on it. -*/ -int osd_hide(osd_object_t *osd, uint32_t vpts ); - -/* - Bresenham line implementation on osd object -*/ -void osd_line(osd_object_t *osd, - int x1, int y1, int x2, int y2, int color ); - -/* - filled retangle -*/ -void osd_filled_rect(osd_object_t *osd, - int x1, int y1, int x2, int y2, int color ); - -/* - set palette (color and transparency) -*/ -void osd_set_palette(osd_object_t *osd, uint32_t *color, uint8_t *trans ); - -/* - get palette (color and transparency) -*/ -void osd_get_palette(osd_object_t *osd, uint32_t *color, uint8_t *trans ); - -/* - set position were overlay will be blended -*/ -void osd_set_position(osd_object_t *osd, int x, int y ); - -/* - load bitmap font into osd engine -*/ -char * osd_renderer_load_font(osd_renderer_t *this, char *name); - -/* - unload font -*/ -int osd_renderer_unload_font(osd_renderer_t *this, char *name ); - -/* - set the font of osd object -*/ - -int osd_set_font( osd_object_t *osd, char *fontname ); - - -/* - render text on x,y position (8 bits version) - no \n yet -*/ -int osd_render_text( osd_object_t *osd, int x1, int y1, char *text ); - -/* - get width and height of how text will be renderized -*/ -int osd_get_text_size( osd_object_t *osd, char *text, int *width, int *height ); - - #endif diff --git a/src/xine-engine/video_overlay.h b/src/xine-engine/video_overlay.h index 6cd3c4670..f11588c00 100644 --- a/src/xine-engine/video_overlay.h +++ b/src/xine-engine/video_overlay.h @@ -17,10 +17,13 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: video_overlay.h,v 1.1 2001/11/28 22:19:11 miguelfreitas Exp $ + * $Id: video_overlay.h,v 1.2 2001/12/08 00:37:38 guenter Exp $ * */ +#ifndef HAVE_VIDEO_OVERLAY_H +#define HAVE_VIDEO_OVERLAY_H + #include "xine_internal.h" #include "video_out/alphablend.h" #include "xine-engine/bswap.h" @@ -64,3 +67,4 @@ typedef struct video_overlay_event_s { video_overlay_object_t object; /* The image data. */ } video_overlay_event_t; +#endif -- cgit v1.2.3