summaryrefslogtreecommitdiff
path: root/ext/gd/libgd/gdft.c
diff options
context:
space:
mode:
authorPierre Joye <pajoye@php.net>2007-04-04 00:44:38 +0000
committerPierre Joye <pajoye@php.net>2007-04-04 00:44:38 +0000
commit1cd4938ef55c25e3b7cbd8f32c3a357ea8abdb5d (patch)
tree8d24d5bead75b82a8d8b0f3437de7f50b7a8f949 /ext/gd/libgd/gdft.c
parent02f5db029d7479c82ea52c5cfd622d2dba9fe4ef (diff)
downloadphp-git-1cd4938ef55c25e3b7cbd8f32c3a357ea8abdb5d.tar.gz
- remove double lock (tween colors cache is created in each thread, the
cache mutex is already locked earlier) - #40858, other TS improvements for gd freetype cache management cache initialization and shutdown is now done in MINIT and MSHUTDOWN.
Diffstat (limited to 'ext/gd/libgd/gdft.c')
-rw-r--r--ext/gd/libgd/gdft.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/ext/gd/libgd/gdft.c b/ext/gd/libgd/gdft.c
index 499de8637b..414f5e28eb 100644
--- a/ext/gd/libgd/gdft.c
+++ b/ext/gd/libgd/gdft.c
@@ -698,10 +698,8 @@ static char * gdft_draw_bitmap (gdCache_head_t *tc_cache, gdImage * im, int fg,
} else {
/* find antialised color */
tc_key.bgcolor = *pixel;
- gdMutexLock(gdFontCacheMutex);
tc_elem = (tweencolor_t *) gdCacheGet(tc_cache, &tc_key);
*pixel = tc_elem->tweencolor;
- gdMutexUnlock(gdFontCacheMutex);
}
}
}
@@ -722,7 +720,6 @@ void gdFontCacheShutdown()
gdCacheDelete(fontCache);
fontCache = NULL;
gdMutexUnlock(gdFontCacheMutex);
- gdMutexShutdown(gdFontCacheMutex);
FT_Done_FreeType(library);
}
}
@@ -732,15 +729,23 @@ void gdFreeFontCache()
gdFontCacheShutdown();
}
+void gdFontCacheMutexSetup()
+{
+ gdMutexSetup(gdFontCacheMutex);
+}
+
+void gdFontCacheMutexShutdown()
+{
+ gdMutexShutdown(gdFontCacheMutex);
+}
+
int gdFontCacheSetup(void)
{
if (fontCache) {
/* Already set up */
return 0;
}
- gdMutexSetup(gdFontCacheMutex);
if (FT_Init_FreeType(&library)) {
- gdMutexShutdown(gdFontCacheMutex);
return -1;
}
fontCache = gdCacheCreate (FONTCACHESIZE, fontTest, fontFetch, fontRelease);
@@ -803,15 +808,16 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist, double ptsi
/***** initialize font library and font cache on first call ******/
+ gdMutexLock(gdFontCacheMutex);
if (!fontCache) {
if (gdFontCacheSetup() != 0) {
gdCacheDelete(tc_cache);
+ gdMutexUnlock(gdFontCacheMutex);
return "Failure to initialize font library";
}
}
/*****/
- gdMutexLock(gdFontCacheMutex);
/* get the font (via font cache) */
fontkey.fontlist = fontlist;
fontkey.library = &library;