changeset 6218:8cfddba867b4

fix text render chrash ...
author pontscho
date Tue, 28 May 2002 11:55:17 +0000
parents d2167f69a48b
children d43d0460cad5
files Gui/app.c Gui/app.h Gui/interface.c Gui/interface.h Gui/mplayer/mplayer.c Gui/mplayer/mplayer.h Gui/mplayer/mw.h Gui/mplayer/play.c Gui/mplayer/play.h Gui/mplayer/widgets.c Gui/mplayer/widgets.h Gui/skin/font.c Gui/skin/font.h Gui/skin/skin.c mplayer.c
diffstat 15 files changed, 77 insertions(+), 89 deletions(-) [+]
line wrap: on
line diff
--- a/Gui/app.c	Tue May 28 10:08:30 2002 +0000
+++ b/Gui/app.c	Tue May 28 11:55:17 2002 +0000
@@ -97,21 +97,17 @@
  return -1;
 }
 
-void appInit( int argc,char* argv[], char *envp[], void* disp )
+void appInit( void * disp )
 {
  skinDirInHome=get_path("Skin");
  skinMPlayerDir=DATADIR "/Skin";
  printf("SKIN dir 1: '%s'\n",skinDirInHome);
  printf("SKIN dir 2: '%s'\n",skinMPlayerDir);
- if ( !skinName )
-  {
-   if ( ( skinName=(char *)calloc( 1,7 ) ) == NULL ) { mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[config] Not enough memory.\n" ); exit( 1 ); }
-   strcpy( skinName,"default" );
-  }
+ if ( !skinName ) skinName=strdup( "default" );
  switch ( skinRead( skinName ) )
   {
    case -1: mp_msg( MSGT_GPLAYER,MSGL_ERR,MSGTR_SKIN_SKINCFG_SkinNotFound,skinName ); exit( 0 );
    case -2: mp_msg( MSGT_GPLAYER,MSGL_ERR,MSGTR_SKIN_SKINCFG_SkinCfgReadError,skinName ); exit( 0 );
   }
- mplInit( argc,argv,envp,disp ); // does gtk & ws initialization, create windows
+ mplInit( disp ); // does gtk & ws initialization, create windows
 }
--- a/Gui/app.h	Tue May 28 10:08:30 2002 +0000
+++ b/Gui/app.h	Tue May 28 11:55:17 2002 +0000
@@ -77,7 +77,7 @@
 extern char      * skinMPlayerDir;
 extern char      * skinName;
 
-extern void appInit( int argc,char* argv[], char *envp[], void* disp );
+extern void appInit( void * disp );
 extern void appInitStruct( listItems * item );
 extern void appClearItem( wItem * item );
 extern void appCopy( listItems * item1,listItems * item2 );
--- a/Gui/interface.c	Tue May 28 10:08:30 2002 +0000
+++ b/Gui/interface.c	Tue May 28 11:55:17 2002 +0000
@@ -21,10 +21,10 @@
 
 guiInterface_t guiIntfStruct;
 
-void guiInit( int argc,char* argv[], char *envp[] )
+void guiInit( void )
 {
  memset( &guiIntfStruct,0,sizeof( guiIntfStruct ) );
- appInit( argc,argv,envp,(void*)mDisplay );
+ appInit( (void*)mDisplay );
 }
 
 void guiDone( void )
--- a/Gui/interface.h	Tue May 28 10:08:30 2002 +0000
+++ b/Gui/interface.h	Tue May 28 11:55:17 2002 +0000
@@ -110,7 +110,7 @@
 
 extern char *get_path(char *filename); 
 
-extern void guiInit( int argc,char* argv[], char *envp[] );
+extern void guiInit( void );
 extern void guiDone( void );
 extern void guiGetEvent( int type,char * arg );
 extern void guiEventHandling( void );
--- a/Gui/mplayer/mplayer.c	Tue May 28 10:08:30 2002 +0000
+++ b/Gui/mplayer/mplayer.c	Tue May 28 11:55:17 2002 +0000
@@ -42,18 +42,18 @@
  if ( mplRedrawTimer == 0 ) mplEventHandling( evRedraw,0 );
 }
 
-void mplInit( int argc,char* argv[], char *envp[], void* disp )
+void mplInit( void * disp )
 {
  int i;
 
  // init fields of this struct to default values
- mplMPlayerInit( argc,argv,envp );
+ mplMPlayerInit();
 
  // fork() a process which runs gtkThreadProc()  [gtkPID]
- gtkInit( argc,argv,envp );
+ gtkInit();
 
  // opens X display, checks for extensions (XShape, DGA etc)
- wsXInit(disp);
+ wsXInit( disp );
 
  if ( ( mplDrawBuffer = (unsigned char *)calloc( 1,appMPlayer.main.Bitmap.ImageSize ) ) == NULL )
   {
--- a/Gui/mplayer/mplayer.h	Tue May 28 10:08:30 2002 +0000
+++ b/Gui/mplayer/mplayer.h	Tue May 28 11:55:17 2002 +0000
@@ -12,7 +12,7 @@
 extern int             mplMainAutoPlay;
 extern int             mplMiddleMenu;
 
-extern void mplInit( int argc,char* argv[], char *envp[], void* disp );
+extern void mplInit( void * disp );
 extern void mplEventHandling( int msg,float param );
 extern void mplTimerHandler( void );
 
--- a/Gui/mplayer/mw.h	Tue May 28 10:08:30 2002 +0000
+++ b/Gui/mplayer/mw.h	Tue May 28 11:55:17 2002 +0000
@@ -196,8 +196,6 @@
 // XFlush( wsDisplay );
 }
 
-#define IZE(x) printf("@@@ " x " @@@\n");
-
 extern void exit_player(char* how);
 extern int audio_id;
 extern int dvdsub_id;
@@ -307,30 +305,14 @@
         break;
 
    case evPlayList:
-        IZE("evPlayList");
         mplMainRender=1;
         gtkShow( evPlayList,NULL );
-#warning disabled old gtk code
-#if 0
-        if ( gtkVisiblePlayList )
-         {
-          btnModify( evPlayList,btnReleased );
-          gtkShMem->vs.window=evPlayList;
-          gtkSendMessage( evHideWindow );
-          gtkVisiblePlayList=0;
-         }
-         else
-          {
-           gtkSendMessage( evPlayList );
-           btnModify( evPlayList,btnPressed );
-           gtkVisiblePlayList=1;
-          }
-#endif
         break;
 
    case evSkinBrowser: gtkShow( evSkinBrowser,skinName ); break;
    case evAbout:       gtkShow( evAbout,NULL ); break;
    case evPreferences: gtkShow( evPreferences,NULL ); break;
+   case evEqualeaser:  gtkMessageBox( GTK_MB_WARNING,"Sorry, this feature not implemented ..." ); break;
 
    case evForward1min:      mplRelSeek( 60 );  break;
    case evBackward1min:     mplRelSeek( -60 ); break;
@@ -395,12 +377,14 @@
         mplRedrawTimer=mplRedrawTimerConst;
         break;
 // --- system events
+#ifdef MP_DEBUG
    case evNone:
         mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[mw] event none received.\n" );
         break;
    default:
         mp_msg( MSGT_GPLAYER,MSGL_STATUS,"[mw] unknown event received ( %d,%.2f ).\n",msg,param );
         break;
+#endif
   }
 }
 
--- a/Gui/mplayer/play.c	Tue May 28 10:08:30 2002 +0000
+++ b/Gui/mplayer/play.c	Tue May 28 11:55:17 2002 +0000
@@ -138,7 +138,7 @@
    }
 }
 
-void mplMPlayerInit( int argc,char* argv[], char *envp[] )
+void mplMPlayerInit( void )
 {
  guiIntfStruct.Balance=50.0f;
  guiIntfStruct.StreamType=-1;
--- a/Gui/mplayer/play.h	Tue May 28 10:08:30 2002 +0000
+++ b/Gui/mplayer/play.h	Tue May 28 11:55:17 2002 +0000
@@ -6,7 +6,7 @@
 
 #include "./mplayer.h"
 
-extern void mplMPlayerInit( int argc,char* argv[], char *envp[] );
+extern void mplMPlayerInit( void );
 
 extern void mplStop();
 extern void mplFullScreen( void );
--- a/Gui/mplayer/widgets.c	Tue May 28 10:08:30 2002 +0000
+++ b/Gui/mplayer/widgets.c	Tue May 28 11:55:17 2002 +0000
@@ -48,11 +48,14 @@
 
 // --- init & close gtk
 
-void gtkInit( int argc,char* argv[], char *envp[] )
+void gtkInit( void )
 {
+ int largc = 1;
+ char * largv[1] = { "asd" };
  mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[widget] init gtk ...\n" );
  gtk_set_locale();
- gtk_init( &argc,&argv );
+// gtk_init( &argc,&argv );
+ gtk_init( 0,NULL );
 // gdk_set_use_xshm( TRUE );
  
  gtkInited=1;
--- a/Gui/mplayer/widgets.h	Tue May 28 10:08:30 2002 +0000
+++ b/Gui/mplayer/widgets.h	Tue May 28 11:55:17 2002 +0000
@@ -37,7 +37,7 @@
 
 extern void widgetsCreate( void );
 
-extern void gtkInit( int argc,char* argv[], char *envp[] );
+extern void gtkInit( void );
 extern void gtkDone( void );
 
 extern int  gtkFillSkinList( gchar * dir );
--- a/Gui/skin/font.c	Tue May 28 10:08:30 2002 +0000
+++ b/Gui/skin/font.c	Tue May 28 11:55:17 2002 +0000
@@ -12,22 +12,31 @@
 
 int items;
 
-bmpFont * Fonts[25] = { NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
+bmpFont * Fonts[26] = { NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL };
 
 int fntAddNewFont( char * name )
 {
  int id;
- for( id=0;id<25;id++ ) if ( !Fonts[id] ) break;
- if ( ( Fonts[id]=malloc( sizeof( bmpFont ) ) ) == NULL ) return -1;
+ int i;
+
+ for( id=0;id<26;id++ )
+   if ( !Fonts[id] ) break;
+
+ if ( id == 25 ) return -2;
+
+ if ( ( Fonts[id]=calloc( 1,sizeof( bmpFont ) ) ) == NULL ) return -1;
+
  strcpy( Fonts[id]->name,name );
- memset( Fonts[id]->Fnt,-1,256 * sizeof( fntChar ) );
+ for ( i=0;i<256;i++ ) 
+   Fonts[id]->Fnt[i].x=Fonts[id]->Fnt[i].y=Fonts[id]->Fnt[i].sx=Fonts[id]->Fnt[i].sy=-1;
+
  return id;
 }
 
 void fntFreeFont( void )
 {
  int i;
- for( i=0;i<25;i++ )
+ for( i=0;i < 25;i++ )
   {
    if ( Fonts[i] )
     {
@@ -38,7 +47,7 @@
   }
 }
 
-int fntRead( char * path,char * fname,int id )
+int fntRead( char * path,char * fname )
 {
  FILE * f;
  unsigned char   tmp[512];
@@ -46,9 +55,14 @@
  unsigned char   command[32];
  unsigned char   param[256];
  int             c,linenumber = 0;
+ int             id = fntAddNewFont( fname );
+ 
+ if ( id < 0 ) return id;
 
  strcpy( tmp,path ); strcat( tmp,fname ); strcat( tmp,".fnt" );
- if ( ( f=fopen( tmp,"rt" ) ) == NULL ) return -1;
+ if ( ( f=fopen( tmp,"rt" ) ) == NULL ) 
+   { free( Fonts[id] ); return -3; }
+   
  while ( !feof( f ) )
   {
    fgets( tmp,255,f ); linenumber++;
@@ -56,14 +70,10 @@
    c=tmp[ strlen( tmp ) - 1 ]; if ( ( c == '\n' )||( c == '\r' ) ) tmp[ strlen( tmp ) - 1 ]=0;
    c=tmp[ strlen( tmp ) - 1 ]; if ( ( c == '\n' )||( c == '\r' ) ) tmp[ strlen( tmp ) - 1 ]=0;
    for ( c=0;c < (int)strlen( tmp );c++ )
-    if ( tmp[c] == ';' )
-     {
-      tmp[c]=0;
-      break;
-     }
-   if ( strlen( tmp ) == 0 ) continue;
+     if ( tmp[c] == ';' ) { tmp[c]=0; break; }
+   if ( !tmp[0] ) continue;
    ptmp=strdelspacesbeforecommand( tmp );
-   if ( strlen( ptmp ) == 0 ) continue;
+   if ( !tmp[0] ) continue;
    ptmp=strswap( ptmp,'\t',' ' );
    ptmp=strdelspaces( ptmp );
    cutItem( ptmp,command,'=',0 ); cutItem( ptmp,param,'=',1 );
@@ -84,10 +94,11 @@
        {
         strcpy( tmp,path ); strcat( tmp,param );
         mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[font] font imagefile: %s\n",tmp );
-        if ( skinBPRead( tmp,&Fonts[id]->Bitmap ) ) return -2;
+        if ( skinBPRead( tmp,&Fonts[id]->Bitmap ) ) return -4;
        }
      }
-  }
+   }
+
  return 0;
 }
 
@@ -95,8 +106,8 @@
 {
  int i;
  for ( i=0;i < 25;i++ )
-  if ( Fonts[i] )
-   if ( !strcmp( name,Fonts[i]->name ) ) return i;
+   if ( Fonts[i] )
+     if ( !strcmp( name,Fonts[i]->name ) ) return i;
  return -1;
 }
 
@@ -104,18 +115,25 @@
 {
  int size = 0;
  int i;
- if ( !Fonts[id] ) return 0;
- for ( i=0;i < (int)strlen( str );i++ )
-   if ( Fonts[id]->Fnt[ (int)str[i] ].sx != -1 ) size+=Fonts[id]->Fnt[ (int)str[i] ].sx;
+
+ if ( ( !Fonts[id] )||( !str[0] ) ) return 0;
+
+ for ( i=0;i < (unsigned int)strlen( str );i++ )
+   size+=( Fonts[id]->Fnt[ (unsigned char)str[i] ].sx == -1? Fonts[id]->Fnt[ 32 ].sx : Fonts[id]->Fnt[ (unsigned char)str[i] ].sx );
  return size;
 }
 
 int fntTextHeight( int id,char * str )
 {
  int max = 0,i;
- if ( !Fonts[id] ) return 0;
+
+ if ( ( !Fonts[id] )||( !str[0] ) ) return 0;
+
  for ( i=0;i < (int)strlen( str );i++ )
-   if ( Fonts[id]->Fnt[ (int)str[i] ].sy > max ) max=Fonts[id]->Fnt[ (int)str[i] ].sy;
+  {
+   int h = Fonts[id]->Fnt[ (unsigned char)str[i] ].sy;
+   if ( h > max ) max=h;
+  }
  return max;
 }
 
@@ -138,24 +156,21 @@
       ( !strlen( p ) )||
       ( !fntTextWidth( id,p ) )||
       ( (tmp=malloc( sizeof( txSample ) )) == NULL ) ) return NULL;
-
+      
  tmp->Width=fntTextWidth( id,p );
  tmp->Height=fntTextHeight( id,p );
  tmp->BPP=32;
  tmp->ImageSize=tmp->Width * tmp->Height * 4;
  if ( ( tmp->Image=malloc( tmp->ImageSize ) ) ==  NULL ) return NULL;
-
  obuf=(uint32_t *)tmp->Image;
  ibuf=(uint32_t *)Fonts[id]->Bitmap.Image;
  for ( i=0;i < (int)strlen( p );i++ )
   {
-   char c = p[i];
-   if ( Fonts[id]->Fnt[c].x == -1 ) c=32;
+   unsigned int c = (unsigned char)p[i];
+   if ( Fonts[id]->Fnt[c].sx == -1 ) c=32;
    for ( oy=0,y=Fonts[id]->Fnt[c].y;y < Fonts[id]->Fnt[c].y + Fonts[id]->Fnt[c].sy; y++,oy++ )
-    for ( ox=0,x=Fonts[id]->Fnt[c].x;x < Fonts[id]->Fnt[c].x + Fonts[id]->Fnt[c].sx; x++,ox++ )
-     {
-      obuf[ oy * tmp->Width + dx + ox ]=ibuf[ y * Fonts[id]->Bitmap.Width + x ];
-     }
+     for ( ox=0,x=Fonts[id]->Fnt[c].x;x < Fonts[id]->Fnt[c].x + Fonts[id]->Fnt[c].sx; x++,ox++ )
+       obuf[ oy * tmp->Width + dx + ox ]=ibuf[ y * Fonts[id]->Bitmap.Width + x ];
    dx+=Fonts[id]->Fnt[c].sx;
   }
 
--- a/Gui/skin/font.h	Tue May 28 10:08:30 2002 +0000
+++ b/Gui/skin/font.h	Tue May 28 11:55:17 2002 +0000
@@ -1,6 +1,6 @@
 
-#ifndef _MYFONT
-#define _MYFONT
+#ifndef _FONT_H
+#define _FONT_H
 
 #include "../bitmap/bitmap.h"
 
@@ -17,15 +17,14 @@
  char       name[128];
 } bmpFont;
 
-extern fntChar    Fnt[256];
 extern txSample   Bitmap;
-extern bmpFont  * Fonts[25];
+extern bmpFont  * Fonts[26];
 
 extern int  fntAddNewFont( char * name );
 extern void fntFreeFont( void );
 extern int  fntFindID( char * name );
 
-extern int        fntRead( char * path,char * fname,int id );
+extern int        fntRead( char * path,char * fname );
 extern txSample * fntRender( int id,int px,int sx,char * fmt,... );
 
 #endif
--- a/Gui/skin/skin.c	Tue May 28 10:08:30 2002 +0000
+++ b/Gui/skin/skin.c	Tue May 28 11:55:17 2002 +0000
@@ -29,8 +29,6 @@
  va_start( ap,format );
  vsnprintf( p,512,format,ap );
  va_end( ap );
-// message( False,"[skin] error in skin config file on line %d: %s",linenumber,p );
-// message( False,MSGTR_SKIN_ERRORMESSAGE,linenumber,p );
  mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_SKIN_ERRORMESSAGE,linenumber,p );
 }
 
@@ -414,21 +412,14 @@
  defList->NumberOfItems++;
  item=&defList->Items[ defList->NumberOfItems ];
  item->type=itFont;
- item->fontid=fntAddNewFont( name );
+ item->fontid=fntRead( path,name );
  switch ( item->fontid )
   {
    case -1: ERRORMESSAGE( MSGTR_SKIN_FONT_NotEnoughtMemory ); return 1;
    case -2: ERRORMESSAGE( MSGTR_SKIN_FONT_TooManyFontsDeclared ); return 1;
+   case -3: ERRORMESSAGE( MSGTR_SKIN_FONT_FontFileNotFound ); return 1;
+   case -4: ERRORMESSAGE( MSGTR_SKIN_FONT_FontImageNotFound ); return 1;
   }
-
- mp_dbg( MSGT_GPLAYER,MSGL_DBG2,"[skin]  id: %s ( %d )\n",id,item->fontid );
-
- switch ( fntRead( path,name,item->fontid ) )
-  {
-   case -1: ERRORMESSAGE( MSGTR_SKIN_FONT_FontFileNotFound ); return 1;
-   case -2: ERRORMESSAGE( MSGTR_SKIN_FONT_FontImageNotFound ); return 1;
-  }
-
  return 0;
 }
 
--- a/mplayer.c	Tue May 28 10:08:30 2002 +0000
+++ b/mplayer.c	Tue May 28 11:55:17 2002 +0000
@@ -775,7 +775,7 @@
 
 #ifdef HAVE_NEW_GUI
   if(use_gui){
-       guiInit( argc,argv,envp );
+       guiInit();
        inited_flags|=INITED_GUI;
        guiGetEvent( guiCEvent,(char *)((gui_no_filename) ? 0 : 1) );
   }