freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Devel] Windows API vs. FreeType API, how to make FT API faster


From: Happy
Subject: [Devel] Windows API vs. FreeType API, how to make FT API faster
Date: Fri, 4 Apr 2003 12:06:28 +0800

Hi, everyone
 
I'm writing a program based on Freetype API, and I do a benchmark comparing to Windows API GetGlyphOutline, it seems that FT API is a little slower than WinAPI, following is a snippet to show the problem. On my machine, ther running result is :
 
ft_duration = 700ms
win_duration = 211ms
 
Anyone has a suggestion to make FT API faster?
 
Assume there are global variant, here I skip the initialization of them
**************************START OF CODE SNIPPET*****************************
int             num_glyph;    /** glyph number, about 1600 here*/
OO_UInt    glyphs_index;    /** Glyph indices array, all of them is different */
FT_Face    face;
 
/**********************
 * bench_ft is for FreeType API
 */
void bench_ft()
{
     double start, end, ft_duration;
     int i;
     start = clock();
     for(i=0; i<num_glyphs; i++){
          FT_Load_Glyph(face, glyph_index[i], FT_LOAD_DEFAULT|FT_LOAD_NO_BITMAP);
          FT_Render_Glyph(face->glyph, ft_render_mode_mono);
     }
     end = clock();
     ft_duration = start-end;
}
 
 
/**********************
 * bench_win is for Windows API
 */
void bench_win()
{
     double start, end, win_duration;
     int i;
     GLYPHMETRICS  gm2;
     DWORD SizeBuffer;
     MAT2 mat2;
     start = clock();
     for(int i=0; i< num_glyphs; i++){
          unsigned char* lpBuffer = NULL;
          SizeBuffer = GetGlyphOutline(m_dc,glyphs_index[i],GGO_BITMAP|GGO_GLYPH_INDEX,
                       &gm2,0,NULL,&mat2);
          if(SizeBuffer == GDI_ERROR)
                return;
 
          unsigned char* lpBuffer = (unsigned char* )malloc(SizeBuffer);
          if(!lpBuffer)
                return;
 
          GetGlyphOutline(m_dc,glyphs_index[i],GGO_BITMAP|GGO_GLYPH_INDEX,
                      &gm2,SizeBuffer,lpBuffer,&mat2);
     }
     end = clock();
     win_duration = start-end;

 }
**************************END OF CODE SNIPPET*****************************
 
Happy
4/4/2003

reply via email to

[Prev in Thread] Current Thread [Next in Thread]