Changed Font's mutex to become a static mutex shared between all instances of Font.

This ensures single threaded access of the freetype plugin.
This commit is contained in:
Robert Osfield 2007-09-01 15:24:22 +00:00
parent 13faad13e8
commit 3304646c4c
4 changed files with 12 additions and 10 deletions

View File

@ -164,7 +164,7 @@ public:
typedef OpenThreads::Mutex FontMutex;
/** Get the mutex that enables the serialization of calls to this font.*/
FontMutex* getSerializeFontCallsMutex() const { return &_serializeFontCallsMutex; }
static FontMutex* getSerializeFontCallsMutex();
protected:

View File

@ -30,6 +30,12 @@ static osg::ApplicationUsageProxy Font_e0(osg::ApplicationUsage::ENVIRONMENTAL_V
static OpenThreads::Mutex s_FontFileMutex;
Font::FontMutex* osgText::Font::getSerializeFontCallsMutex()
{
static OpenThreads::Mutex s_FontCallsMutex;
return &s_FontCallsMutex;
}
std::string osgText::findFontFile(const std::string& str)
{
// try looking in OSGFILEPATH etc first for fonts.

View File

@ -464,7 +464,7 @@ void Text::computeGlyphRepresentation()
return;
}
OpenThreads::ScopedLock<Font::FontMutex> lock(*(activefont->getSerializeFontCallsMutex()));
OpenThreads::ScopedLock<Font::FontMutex> lock(*(Font::getSerializeFontCallsMutex()));
// initialize bounding box, it will be expanded during glyph position calculation
_textBB.init();

View File

@ -213,11 +213,10 @@ BEGIN_OBJECT_REFLECTOR(osgText::Font)
__void__releaseGLObjects__osg_State_P1,
"If State is non-zero, this function releases OpenGL objects for the specified graphics context. ",
"Otherwise, releases OpenGL objexts for all graphics contexts. ");
I_Method0(osgText::Font::FontMutex *, getSerializeFontCallsMutex,
Properties::NON_VIRTUAL,
__FontMutex_P1__getSerializeFontCallsMutex,
"Get the mutex that enables the serialization of calls to this font. ",
"");
I_StaticMethod0(osgText::Font::FontMutex *, getSerializeFontCallsMutex,
__FontMutex_P1__getSerializeFontCallsMutex_S,
"Get the mutex that enables the serialization of calls to this font. ",
"");
I_ProtectedMethod4(void, addGlyph, IN, unsigned int, width, IN, unsigned int, height, IN, unsigned int, charcode, IN, osgText::Font::Glyph *, glyph,
Properties::NON_VIRTUAL,
Properties::NON_CONST,
@ -248,9 +247,6 @@ BEGIN_OBJECT_REFLECTOR(osgText::Font)
I_SimpleProperty(osg::Texture::FilterMode, MinFilterHint,
__osg_Texture_FilterMode__getMinFilterHint,
__void__setMinFilterHint__osg_Texture_FilterMode);
I_SimpleProperty(osgText::Font::FontMutex *, SerializeFontCallsMutex,
__FontMutex_P1__getSerializeFontCallsMutex,
0);
I_SimpleProperty(osg::StateSet *, StateSet,
__osg_StateSet_P1__getStateSet,
__void__setStateSet__osg_StateSet_P1);