From a4204dc3f893323a89fdc1b11e49b9ad6c334edc Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Thu, 7 Aug 2003 02:48:22 +0000 Subject: New function. Uses the Uniscribe ScriptIsSimple() function to check if 2003-08-05 Tor Lillqvist * modules/basic/basic-win32.c (text_is_simple): New function. Uses the Uniscribe ScriptIsSimple() function to check if Uniscribe shaping is needed for a piece of text. (basic_engine_shape): Use it, to avoid calling Uniscribe to shape non-complex text. Produces dramatic speedup according to tests by Hans Breuer. (init_uniscribe): No need for the PANGO_WIN32_NO_UNISCRIBE environment variable any longer. --- ChangeLog | 13 +++++++++++ ChangeLog.pre-1-10 | 13 +++++++++++ ChangeLog.pre-1-4 | 13 +++++++++++ ChangeLog.pre-1-6 | 13 +++++++++++ ChangeLog.pre-1-8 | 13 +++++++++++ modules/basic/basic-win32.c | 57 +++++++++++++++++++++++++++++++++++++++------ 6 files changed, 115 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index f395385c..1102ceff 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2003-08-05 Tor Lillqvist + + * modules/basic/basic-win32.c (text_is_simple): New function. Uses + the Uniscribe ScriptIsSimple() function to check if Uniscribe + shaping is needed for a piece of text. + + (basic_engine_shape): Use it, to avoid calling Uniscribe to shape + non-complex text. Produces dramatic speedup according to tests by + Hans Breuer. + + (init_uniscribe): No need for the PANGO_WIN32_NO_UNISCRIBE + environment variable any longer. + Tue Jul 29 09:58:13 2003 Owen Taylor * pango/opentype/ftxgdef.c (Check_Property): Rewrite diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10 index f395385c..1102ceff 100644 --- a/ChangeLog.pre-1-10 +++ b/ChangeLog.pre-1-10 @@ -1,3 +1,16 @@ +2003-08-05 Tor Lillqvist + + * modules/basic/basic-win32.c (text_is_simple): New function. Uses + the Uniscribe ScriptIsSimple() function to check if Uniscribe + shaping is needed for a piece of text. + + (basic_engine_shape): Use it, to avoid calling Uniscribe to shape + non-complex text. Produces dramatic speedup according to tests by + Hans Breuer. + + (init_uniscribe): No need for the PANGO_WIN32_NO_UNISCRIBE + environment variable any longer. + Tue Jul 29 09:58:13 2003 Owen Taylor * pango/opentype/ftxgdef.c (Check_Property): Rewrite diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4 index f395385c..1102ceff 100644 --- a/ChangeLog.pre-1-4 +++ b/ChangeLog.pre-1-4 @@ -1,3 +1,16 @@ +2003-08-05 Tor Lillqvist + + * modules/basic/basic-win32.c (text_is_simple): New function. Uses + the Uniscribe ScriptIsSimple() function to check if Uniscribe + shaping is needed for a piece of text. + + (basic_engine_shape): Use it, to avoid calling Uniscribe to shape + non-complex text. Produces dramatic speedup according to tests by + Hans Breuer. + + (init_uniscribe): No need for the PANGO_WIN32_NO_UNISCRIBE + environment variable any longer. + Tue Jul 29 09:58:13 2003 Owen Taylor * pango/opentype/ftxgdef.c (Check_Property): Rewrite diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6 index f395385c..1102ceff 100644 --- a/ChangeLog.pre-1-6 +++ b/ChangeLog.pre-1-6 @@ -1,3 +1,16 @@ +2003-08-05 Tor Lillqvist + + * modules/basic/basic-win32.c (text_is_simple): New function. Uses + the Uniscribe ScriptIsSimple() function to check if Uniscribe + shaping is needed for a piece of text. + + (basic_engine_shape): Use it, to avoid calling Uniscribe to shape + non-complex text. Produces dramatic speedup according to tests by + Hans Breuer. + + (init_uniscribe): No need for the PANGO_WIN32_NO_UNISCRIBE + environment variable any longer. + Tue Jul 29 09:58:13 2003 Owen Taylor * pango/opentype/ftxgdef.c (Check_Property): Rewrite diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8 index f395385c..1102ceff 100644 --- a/ChangeLog.pre-1-8 +++ b/ChangeLog.pre-1-8 @@ -1,3 +1,16 @@ +2003-08-05 Tor Lillqvist + + * modules/basic/basic-win32.c (text_is_simple): New function. Uses + the Uniscribe ScriptIsSimple() function to check if Uniscribe + shaping is needed for a piece of text. + + (basic_engine_shape): Use it, to avoid calling Uniscribe to shape + non-complex text. Produces dramatic speedup according to tests by + Hans Breuer. + + (init_uniscribe): No need for the PANGO_WIN32_NO_UNISCRIBE + environment variable any longer. + Tue Jul 29 09:58:13 2003 Owen Taylor * pango/opentype/ftxgdef.c (Check_Property): Rewrite diff --git a/modules/basic/basic-win32.c b/modules/basic/basic-win32.c index 1b5cf8b2..10362ee8 100644 --- a/modules/basic/basic-win32.c +++ b/modules/basic/basic-win32.c @@ -103,14 +103,21 @@ typedef HRESULT (WINAPI *pScriptPlace) (HDC, typedef HRESULT (WINAPI *pScriptFreeCache) (SCRIPT_CACHE *); +typedef HRESULT (WINAPI *pScriptIsComplex) (WCHAR *, + int, + DWORD); + static pScriptGetProperties script_get_properties; static pScriptItemize script_itemize; static pScriptShape script_shape; static pScriptPlace script_place; static pScriptFreeCache script_free_cache; +static pScriptIsComplex script_is_complex; +#ifdef BASIC_WIN32_DEBUGGING static const SCRIPT_PROPERTIES **scripts; static int nscripts; +#endif #endif @@ -260,6 +267,8 @@ swap_range (PangoGlyphString *glyphs, #ifdef BASIC_WIN32_DEBUGGING +#if 0 + static char * charset_name (int charset) { @@ -294,6 +303,8 @@ charset_name (int charset) } } +#endif + static char * lang_name (int lang) { @@ -834,14 +845,13 @@ uniscribe_shape (PangoFont *font, wchar_t *wtext; int wlen, i; gboolean retval = TRUE; - GError *error; HGDIOBJ old_font = NULL; HFONT hfont = NULL; LOGFONT *lf; SCRIPT_CACHE script_cache[100]; wtext = (wchar_t *) g_convert (text, length, "UTF-16LE", "UTF-8", - NULL, &wlen, &error); + NULL, &wlen, NULL); if (wtext == NULL) return FALSE; @@ -902,6 +912,35 @@ uniscribe_shape (PangoFont *font, return retval; } +static gboolean +text_is_simple (const char *text, + gint length) +{ + gboolean retval; + wchar_t *wtext; + int wlen; + + wtext = (wchar_t *) g_convert (text, length, "UTF-16LE", "UTF-8", + NULL, &wlen, NULL); + + if (wtext == NULL) + return TRUE; + + wlen /= 2; + + retval = ((*script_is_complex) (wtext, wlen, SIC_COMPLEX) == S_FALSE); + + g_free (wtext); + +#ifdef BASIC_WIN32_DEBUGGING + if (pango_win32_debug) + printf ("text_is_simple: %.*s (%d chars): %s\n", + MIN (length, 10), text, wlen, retval ? "YES" : "NO"); +#endif + + return retval; +} + #endif /* HAVE_USP10_H */ static void @@ -922,7 +961,9 @@ basic_engine_shape (PangoFont *font, #ifdef HAVE_USP10_H - if (have_uniscribe && uniscribe_shape (font, text, length, analysis, glyphs)) + if (have_uniscribe && + !text_is_simple (text, length) && + uniscribe_shape (font, text, length, analysis, glyphs)) return; #endif @@ -1040,8 +1081,7 @@ init_uniscribe (void) have_uniscribe = FALSE; - if (getenv ("PANGO_WIN32_NO_UNISCRIBE") == NULL && - (usp10_dll = LoadLibrary ("usp10.dll")) != NULL) + if ((usp10_dll = LoadLibrary ("usp10.dll")) != NULL) { (script_get_properties = (pScriptGetProperties) GetProcAddress (usp10_dll, "ScriptGetProperties")) && @@ -1053,12 +1093,15 @@ init_uniscribe (void) GetProcAddress (usp10_dll, "ScriptPlace")) && (script_free_cache = (pScriptFreeCache) GetProcAddress (usp10_dll, "ScriptFreeCache")) && - (have_uniscribe = TRUE); + (script_is_complex = (pScriptIsComplex) + GetProcAddress (usp10_dll, "ScriptIsComplex")) && + (have_uniscribe = TRUE); } if (have_uniscribe) { +#ifdef BASIC_WIN32_DEBUGGING (*script_get_properties) (&scripts, &nscripts); - +#endif font_cache = pango_win32_font_map_get_font_cache (pango_win32_font_map_for_display ()); -- cgit v1.2.1