Added a temporary work-around to lift the FreeType problem we're seeing a bit:

Turns out we are using a single FT_Face object for a given font size throughout the
app_server - but the FT_Face object is not designed for a multi-threaded access, AFAICT.
For example, it only has a single glyph slot, that we were using from different threads.
This fix does not cover the renderer, however, which also uses that shared object; IOW
even though it will crash less often it will still crash because of this.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14543 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-10-27 16:33:35 +00:00
parent 0b3dc403c8
commit c2a52d2836
2 changed files with 47 additions and 11 deletions
+2 -1
View File
@@ -31,6 +31,7 @@
#include <Rect.h> #include <Rect.h>
#include <Font.h> #include <Font.h>
#include <List.h> #include <List.h>
#include <Locker.h>
#include <ft2build.h> #include <ft2build.h>
#include FT_FREETYPE_H #include FT_FREETYPE_H
#include "SharedObject.h" #include "SharedObject.h"
@@ -83,7 +84,7 @@ typedef struct
FontStyle objects help abstract a lot of the font engine details while FontStyle objects help abstract a lot of the font engine details while
still offering plenty of information the style in question. still offering plenty of information the style in question.
*/ */
class FontStyle : public SharedObject { class FontStyle : public SharedObject, public BLocker {
public: public:
FontStyle(const char* filepath, FontStyle(const char* filepath,
FT_Face face); FT_Face face);
+44 -9
View File
@@ -89,6 +89,33 @@ is_white_space(uint16 glyph)
// #pragma mark - // #pragma mark -
class FaceGetter {
public:
FaceGetter(FontStyle *style)
:
fStyle(style)
{
style->Lock();
}
~FaceGetter()
{
fStyle->Unlock();
}
FT_Face Face()
{
return fStyle->GetFTFace();
}
private:
FontStyle *fStyle;
};
// #pragma mark -
/*! /*!
\brief Constructor \brief Constructor
\param style Style object to which the ServerFont belongs \param style Style object to which the ServerFont belongs
@@ -241,7 +268,7 @@ ServerFont::SetFamilyAndStyle(uint16 familyID, uint16 styleID)
FontStyle* style = NULL; FontStyle* style = NULL;
if (gFontServer->Lock()) { if (gFontServer->Lock()) {
style = gFontServer->GetStyle(familyID, styleID); style = gFontServer->GetStyle(familyID, styleID);
gFontServer->Unlock(); gFontServer->Unlock();
} }
@@ -290,7 +317,8 @@ ServerFont::GetGlyphShapes(const char charArray[], int32 numChars) const
funcs.conic_to = ConicToFunc; funcs.conic_to = ConicToFunc;
funcs.cubic_to = CubicToFunc; funcs.cubic_to = CubicToFunc;
FT_Face face = fStyle->GetFTFace(); FaceGetter getter(fStyle);
FT_Face face = getter.Face();
if (!face) if (!face)
return NULL; return NULL;
@@ -340,7 +368,8 @@ ServerFont::GetHasGlyphs(const char charArray[], int32 numChars, bool hasArray[]
if (!fStyle || !charArray || numChars <= 0 || !hasArray) if (!fStyle || !charArray || numChars <= 0 || !hasArray)
return; return;
FT_Face face = fStyle->GetFTFace(); FaceGetter getter(fStyle);
FT_Face face = getter.Face();
if (!face) if (!face)
return; return;
@@ -381,7 +410,8 @@ ServerFont::GetEdges(const char charArray[], int32 numChars, edge_info edgeArray
if (!fStyle || !charArray || numChars <= 0 || !edgeArray) if (!fStyle || !charArray || numChars <= 0 || !edgeArray)
return; return;
FT_Face face = fStyle->GetFTFace(); FaceGetter getter(fStyle);
FT_Face face = getter.Face();
if (!face) if (!face)
return; return;
@@ -428,7 +458,8 @@ ServerFont::GetEscapements(const char charArray[], int32 numChars,
if (!fStyle || !charArray || numChars <= 0 || !offsetArray) if (!fStyle || !charArray || numChars <= 0 || !offsetArray)
return NULL; return NULL;
FT_Face face = fStyle->GetFTFace(); FaceGetter getter(fStyle);
FT_Face face = getter.Face();
if (!face) if (!face)
return NULL; return NULL;
@@ -484,7 +515,8 @@ ServerFont::GetEscapements(const char charArray[], int32 numChars,
if (!fStyle || !charArray || numChars <= 0) if (!fStyle || !charArray || numChars <= 0)
return false; return false;
FT_Face face = fStyle->GetFTFace(); FaceGetter getter(fStyle);
FT_Face face = getter.Face();
if (!face) if (!face)
return false; return false;
@@ -531,7 +563,8 @@ ServerFont::GetBoundingBoxesAsString(const char charArray[], int32 numChars, BRe
if (!fStyle || !charArray || numChars <= 0 || !rectArray) if (!fStyle || !charArray || numChars <= 0 || !rectArray)
return false; return false;
FT_Face face = fStyle->GetFTFace(); FaceGetter getter(fStyle);
FT_Face face = getter.Face();
if (!face) if (!face)
return false; return false;
@@ -590,7 +623,8 @@ ServerFont::GetBoundingBoxesForStrings(char *charArray[], int32 lengthArray[],
if (!fStyle || !charArray || !lengthArray|| numStrings <= 0 || !rectArray || !deltaArray) if (!fStyle || !charArray || !lengthArray|| numStrings <= 0 || !rectArray || !deltaArray)
return false; return false;
FT_Face face = fStyle->GetFTFace(); FaceGetter getter(fStyle);
FT_Face face = getter.Face();
if (!face) if (!face)
return false; return false;
@@ -612,7 +646,8 @@ ServerFont::StringWidth(const char* string, int32 numBytes) const
if (!fStyle || !string || numBytes <= 0) if (!fStyle || !string || numBytes <= 0)
return 0.0; return 0.0;
FT_Face face = fStyle->GetFTFace(); FaceGetter getter(fStyle);
FT_Face face = getter.Face();
if (!face) if (!face)
return 0.0; return 0.0;