From e2f4d1dc15dc6664246780e51eb7664d023c0a07 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Thu, 7 Aug 2003 02:56:36 +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 34b05d47..fef9b8f2 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. + Mon Aug 4 01:12:35 2003 Soeren Sandmann * tools/gen-script-for-lang.c (get_script_name): Fix C99 variable diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10 index 34b05d47..fef9b8f2 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. + Mon Aug 4 01:12:35 2003 Soeren Sandmann * tools/gen-script-for-lang.c (get_script_name): Fix C99 variable diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4 index 34b05d47..fef9b8f2 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. + Mon Aug 4 01:12:35 2003 Soeren Sandmann * tools/gen-script-for-lang.c (get_script_name): Fix C99 variable diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6 index 34b05d47..fef9b8f2 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. + Mon Aug 4 01:12:35 2003 Soeren Sandmann * tools/gen-script-for-lang.c (get_script_name): Fix C99 variable diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8 index 34b05d47..fef9b8f2 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. + Mon Aug 4 01:12:35 2003 Soeren Sandmann * tools/gen-script-for-lang.c (get_script_name): Fix C99 variable diff --git a/modules/basic/basic-win32.c b/modules/basic/basic-win32.c index 9e00139c..82c8b88c 100644 --- a/modules/basic/basic-win32.c +++ b/modules/basic/basic-win32.c @@ -107,14 +107,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 @@ -264,6 +271,8 @@ swap_range (PangoGlyphString *glyphs, #ifdef BASIC_WIN32_DEBUGGING +#if 0 + static char * charset_name (int charset) { @@ -298,6 +307,8 @@ charset_name (int charset) } } +#endif + static char * lang_name (int lang) { @@ -904,14 +915,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; @@ -972,6 +982,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 @@ -993,7 +1032,9 @@ basic_engine_shape (PangoEngineShape *engine, #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 @@ -1088,8 +1129,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")) && @@ -1101,12 +1141,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