Author: pbartok
Date: 2005-03-30 03:40:13 -0500 (Wed, 30 Mar 2005)
New Revision: 42365
Modified:
trunk/libgdiplus/cairo/ChangeLog
trunk/libgdiplus/cairo/src/cairo_font.c
trunk/libgdiplus/cairo/src/cairo_ft_font.c
trunk/libgdiplus/cairo/src/cairo_xlib_surface.c
trunk/libgdiplus/src/ChangeLog
trunk/libgdiplus/src/font.c
trunk/libgdiplus/src/general.c
Log:
2005-03-30 Peter Bartok <[EMAIL PROTECTED]>
* font.c: Added locking for font cache
* general.c: Grab DPIs on startup, avoid potential race condition
with multiple threads using gdiplus and trying to get dpi
2005-03-30 Peter Bartok <[EMAIL PROTECTED]>
* src/cairo_font.c: Implemented locking
* src/cairo_ft_font.c: Implemented locking
* src/cairo_xlib_surface.c: Implemented locking
Modified: trunk/libgdiplus/cairo/ChangeLog
===================================================================
--- trunk/libgdiplus/cairo/ChangeLog 2005-03-30 08:12:22 UTC (rev 42364)
+++ trunk/libgdiplus/cairo/ChangeLog 2005-03-30 08:40:13 UTC (rev 42365)
@@ -1,3 +1,9 @@
+2005-03-30 Peter Bartok <[EMAIL PROTECTED]>
+
+ * src/cairo_font.c: Implemented locking
+ * src/cairo_ft_font.c: Implemented locking
+ * src/cairo_xlib_surface.c: Implemented locking
+
2005-03-22 Raja R Harinath <[EMAIL PROTECTED]>
* test/Makefile.am (INCLUDES): Work with srcdir != builddir.
Modified: trunk/libgdiplus/cairo/src/cairo_font.c
===================================================================
--- trunk/libgdiplus/cairo/src/cairo_font.c 2005-03-30 08:12:22 UTC (rev
42364)
+++ trunk/libgdiplus/cairo/src/cairo_font.c 2005-03-30 08:40:13 UTC (rev
42365)
@@ -35,6 +35,7 @@
*/
#include "cairoint.h"
+#include <pthread.h>
/* First we implement a global font cache for named fonts. */
@@ -151,16 +152,18 @@
_font_cache_destroy_cache
};
+static pthread_mutex_t fontcachelock = PTHREAD_MUTEX_INITIALIZER;
+
static void
_lock_global_font_cache (void)
{
- /* FIXME: implement locking. */
+ pthread_mutex_lock(&fontcachelock);
}
static void
_unlock_global_font_cache (void)
{
- /* FIXME: implement locking. */
+ pthread_mutex_unlock(&fontcachelock);
}
static cairo_cache_t *
@@ -481,16 +484,18 @@
_image_glyph_cache_destroy_cache
};
+static pthread_mutex_t imgcachelock = PTHREAD_MUTEX_INITIALIZER;
+
void
_cairo_lock_global_image_glyph_cache()
{
- /* FIXME: implement locking. */
+ pthread_mutex_lock(&imgcachelock);
}
void
_cairo_unlock_global_image_glyph_cache()
{
- /* FIXME: implement locking. */
+ pthread_mutex_unlock(&imgcachelock);
}
static cairo_cache_t *
Modified: trunk/libgdiplus/cairo/src/cairo_ft_font.c
===================================================================
--- trunk/libgdiplus/cairo/src/cairo_ft_font.c 2005-03-30 08:12:22 UTC (rev
42364)
+++ trunk/libgdiplus/cairo/src/cairo_ft_font.c 2005-03-30 08:40:13 UTC (rev
42365)
@@ -25,6 +25,7 @@
#include "cairoint.h"
#include "cairo-ft.h"
+#include <pthread.h>
#include <fontconfig/fontconfig.h>
#include <fontconfig/fcfreetype.h>
@@ -223,8 +224,9 @@
cairo_ft_cache_entry_t *entry;
entry = malloc (sizeof (cairo_ft_cache_entry_t));
- if (entry == NULL)
+ if (entry == NULL) {
return CAIRO_STATUS_NO_MEMORY;
+ }
entry->key.pattern = FcPatternDuplicate (k->pattern);
if (!entry->key.pattern) {
@@ -267,17 +269,18 @@
};
static ft_cache_t *_global_ft_cache = NULL;
+static pthread_mutex_t ftcachelock = PTHREAD_MUTEX_INITIALIZER;
static void
_lock_global_ft_cache (void)
{
- /* FIXME: Perform locking here. */
+ pthread_mutex_lock(&ftcachelock);
}
static void
_unlock_global_ft_cache (void)
{
- /* FIXME: Perform locking here. */
+ pthread_mutex_unlock(&ftcachelock);
}
static cairo_cache_t *
Modified: trunk/libgdiplus/cairo/src/cairo_xlib_surface.c
===================================================================
--- trunk/libgdiplus/cairo/src/cairo_xlib_surface.c 2005-03-30 08:12:22 UTC
(rev 42364)
+++ trunk/libgdiplus/cairo/src/cairo_xlib_surface.c 2005-03-30 08:40:13 UTC
(rev 42365)
@@ -36,6 +36,7 @@
#include "cairoint.h"
#include "cairo-xlib.h"
+#include <pthread.h>
void
cairo_set_target_drawable (cairo_t *cr,
@@ -957,16 +958,18 @@
static glyphset_cache_t *
_xlib_glyphset_caches = NULL;
+static pthread_mutex_t glyphcachelock = PTHREAD_MUTEX_INITIALIZER;
+
static void
_lock_xlib_glyphset_caches (void)
{
- /* FIXME: implement locking */
+ pthread_mutex_lock(&glyphcachelock);
}
static void
_unlock_xlib_glyphset_caches (void)
{
- /* FIXME: implement locking */
+ pthread_mutex_unlock(&glyphcachelock);
}
static glyphset_cache_t *
Modified: trunk/libgdiplus/src/ChangeLog
===================================================================
--- trunk/libgdiplus/src/ChangeLog 2005-03-30 08:12:22 UTC (rev 42364)
+++ trunk/libgdiplus/src/ChangeLog 2005-03-30 08:40:13 UTC (rev 42365)
@@ -1,3 +1,9 @@
+2005-03-30 Peter Bartok <[EMAIL PROTECTED]>
+
+ * font.c: Added locking for font cache
+ * general.c: Grab DPIs on startup, avoid potential race condition
+ with multiple threads using gdiplus and trying to get dpi
+
2005-03-29 Peter Bartok <[EMAIL PROTECTED]>
* bitmap.c: Removed set_pixel_bgra() and get_pixel_bgra() functions,
Modified: trunk/libgdiplus/src/font.c
===================================================================
--- trunk/libgdiplus/src/font.c 2005-03-30 08:12:22 UTC (rev 42364)
+++ trunk/libgdiplus/src/font.c 2005-03-30 08:40:13 UTC (rev 42365)
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2004 Ximian
+ * Copyright (c) 2004-2005 Novell, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
copy of this software
* and associated documentation files (the "Software"), to deal in the
Software without restriction,
@@ -24,6 +25,7 @@
#include <math.h>
#include <glib.h>
#include <freetype/tttables.h>
+#include <pthread.h>
/* Generic fonts families */
@@ -46,7 +48,11 @@
#define MAX_CACHED_FONTS 128
static GpCachedFont cached_fonts [MAX_CACHED_FONTS];
static int cached_fonts_index = 0;
+static pthread_mutex_t fontcache_mutex = PTHREAD_MUTEX_INITIALIZER;
+#define LOCK_FONTCACHE pthread_mutex_lock(&fontcache_mutex)
+#define UNLOCK_FONTCACHE pthread_mutex_unlock(&fontcache_mutex)
+
/* Family and collections font functions */
void
@@ -614,8 +620,12 @@
int i;
/* Loop all the cached fonts */
- for (i = 0; i < cached_fonts_index; i++)
+
+ LOCK_FONTCACHE;
+ for (i = 0; i < cached_fonts_index; i++) {
gdip_release_font (cached_fonts[i].font);
+ }
+ UNLOCK_FONTCACHE;
}
@@ -637,7 +647,9 @@
gdip_unitConversion (unit, UnitPixel, emSize, &sizeInPixels);
+
/* Is it already in the cache */
+ LOCK_FONTCACHE;
for (i = 0; i < cached_fonts_index; i++) {
if (sizeInPixels != cached_fonts[i].sizeInPixels)
continue;
@@ -654,8 +666,10 @@
/* Found in cache */
*font = cached_fonts[i].font;
cached_fonts[i].refcount++;
+ UNLOCK_FONTCACHE;
return Ok;
}
+ UNLOCK_FONTCACHE;
result = (GpFont *) GdipAlloc (sizeof (GpFont));
result->sizeInPixels = sizeInPixels;
@@ -677,6 +691,7 @@
return Ok;
/* Cache entry */
+ LOCK_FONTCACHE;
if (cached_fonts_index < MAX_CACHED_FONTS) {
strcpy (cached_fonts[cached_fonts_index].szFamily, (const char
*)str);
cached_fonts[cached_fonts_index].sizeInPixels = sizeInPixels;
@@ -699,6 +714,7 @@
cached_fonts[i].refcount = 1;
}
}
+ UNLOCK_FONTCACHE;
return Ok;
}
@@ -723,14 +739,17 @@
return InvalidParameter;
/* Is is in the cache */
+ LOCK_FONTCACHE;
for (i = 0; i < cached_fonts_index; i++) {
if (font != cached_fonts[i].font)
continue;
/* Found in cache */
cached_fonts[i].refcount--;
+ UNLOCK_FONTCACHE;
return Ok;
}
+ UNLOCK_FONTCACHE;
gdip_release_font (font);
return Ok;
Modified: trunk/libgdiplus/src/general.c
===================================================================
--- trunk/libgdiplus/src/general.c 2005-03-30 08:12:22 UTC (rev 42364)
+++ trunk/libgdiplus/src/general.c 2005-03-30 08:40:13 UTC (rev 42365)
@@ -53,6 +53,7 @@
{
initCodecList ();
*token = 1;
+ gdip_get_display_dpi();
return Ok;
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches