[MPlayer-cvslog] r32846 - in trunk/gui: mplayer/gui_common.c skin/font.c skin/font.h

ib subversion at mplayerhq.hu
Thu Feb 3 15:19:19 CET 2011


Author: ib
Date: Thu Feb  3 15:19:19 2011
New Revision: 32846

Log:
Remove useless format argument.

Because scrolling of dynamic labels depends on the length of the label text,
any other format than %s to render would be pointless.

Modified:
   trunk/gui/mplayer/gui_common.c
   trunk/gui/skin/font.c
   trunk/gui/skin/font.h

Modified: trunk/gui/mplayer/gui_common.c
==============================================================================
--- trunk/gui/mplayer/gui_common.c	Thu Feb  3 15:04:43 2011	(r32845)
+++ trunk/gui/mplayer/gui_common.c	Thu Feb  3 15:19:19 2011	(r32846)
@@ -294,14 +294,14 @@ void Render( wsTWindow * window,wItem * 
 	    3,item->pressed );
           break;
      case itSLabel:
-          image=fntRender( item,0,"%s",item->label );
+          image=fntRender( item,0,item->label );
           if ( image ) PutImage( image,item->x,item->y,1,0 );
      case itDLabel:
           {
            char * t = Translate( item->label );
            int    l = fntTextWidth( item->fontid,t );
            l=(l?l:item->width);
-           image=fntRender( item,l-(GetTimerMS() / 20)%l,"%s",t );
+           image=fntRender( item,l-(GetTimerMS() / 20)%l,t );
 	  }
           if ( image ) PutImage( image,item->x,item->y,1,0 );
           break;

Modified: trunk/gui/skin/font.c
==============================================================================
--- trunk/gui/skin/font.c	Thu Feb  3 15:04:43 2011	(r32845)
+++ trunk/gui/skin/font.c	Thu Feb  3 15:19:19 2011	(r32846)
@@ -232,34 +232,29 @@ int fntTextHeight( int id,char * str )
  return max;
 }
 
-txSample * fntRender( wItem * item,int px,const char * fmt,... )
+txSample * fntRender( wItem * item,int px,char * txt )
 {
- va_list         ap;
- unsigned char * u, p[512];
+ unsigned char * u;
  int 	         c, i, dx = 0, tw, fbw, iw, id, ofs;
  int 		 x,y,fh,fw,fyc,yc;
  uint32_t      * ibuf;
  uint32_t      * obuf;
  gboolean        utf8;
 
- va_start( ap,fmt );
- vsnprintf( p,512,fmt,ap );
- va_end( ap );
-
  iw=item->width;
  id=item->fontid;
 
  if ( ( !item )||
       ( !Fonts[id] )||
-      ( !p[0] )||
-      ( !fntTextWidth( id,p ) ) ) return NULL;
+      ( !txt[0] )||
+      ( !fntTextWidth( id,txt ) ) ) return NULL;
 
- tw=fntTextWidth( id,p );
+ tw=fntTextWidth( id,txt );
  fbw=Fonts[id]->Bitmap.Width;
 
  if ( item->Bitmap.Image == NULL )
   {
-   item->Bitmap.Height=item->height=fntTextHeight( id,p );
+   item->Bitmap.Height=item->height=fntTextHeight( id,txt );
    item->Bitmap.Width=item->width=iw;
    item->Bitmap.ImageSize=item->height * iw * 4;
    if ( !item->Bitmap.ImageSize ) return NULL;
@@ -278,16 +273,16 @@ txSample * fntRender( wItem * item,int p
     {
      default:
      case fntAlignLeft:   dx=0; break;
-     case fntAlignCenter: dx=( iw - fntTextWidth( id,p ) ) / 2; break;
-     case fntAlignRight:  dx=iw - fntTextWidth( id,p ); break;
+     case fntAlignCenter: dx=( iw - fntTextWidth( id,txt ) ) / 2; break;
+     case fntAlignRight:  dx=iw - fntTextWidth( id,txt ); break;
     }
 
   } else dx+=px;
 
  ofs=dx;
 
- utf8 = g_utf8_validate( p, -1, NULL);
- u = p;
+ utf8 = g_utf8_validate( txt, -1, NULL);
+ u = txt;
 
  while ( *u )
   {
@@ -315,9 +310,9 @@ txSample * fntRender( wItem * item,int p
  if ( ofs > 0 && tw > item->width )
   {
    dx=ofs;
-   u = p + strlen( p );
+   u = txt + strlen( txt );
 
-   while ( u > p )
+   while ( u > (unsigned char *) txt )
     {
      c = fntGetCharIndex( id, &u, utf8, -1 );
 

Modified: trunk/gui/skin/font.h
==============================================================================
--- trunk/gui/skin/font.h	Thu Feb  3 15:04:43 2011	(r32845)
+++ trunk/gui/skin/font.h	Thu Feb  3 15:19:19 2011	(r32846)
@@ -55,6 +55,6 @@ int  fntTextHeight( int id, char * str )
 int  fntTextWidth( int id, char * str );
 
 int        fntRead( char * path, char * fname );
-txSample * fntRender( wItem * item, int px, const char * fmt, ... );
+txSample * fntRender( wItem * item, int px, char * txt );
 
 #endif /* MPLAYER_GUI_FONT_H */


More information about the MPlayer-cvslog mailing list