Connected the painter stuff to the temporary font lock work-around.

This seem to enhance the stability of the app_server by a magnitude (at least I can
now run apps like Installer and Media without an instant crash).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14549 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-10-28 09:52:26 +00:00
parent 0c7b6e66e8
commit 5030d60fe8
2 changed files with 38 additions and 1 deletions
+3
View File
@@ -140,6 +140,9 @@ class ServerFont {
float StringWidth(const char* string, int32 numBytes) const;
bool Lock() const { return fStyle->Lock(); }
void Unlock() const { fStyle->Unlock(); }
FT_Face GetFTFace() const
{ return fStyle->GetFTFace(); };
@@ -44,6 +44,36 @@ extend_by_stroke_width(BRect& rect, const DrawData* context)
rect.InsetBy(inset, inset);
}
class FontLocker {
public:
FontLocker(const DrawData* context)
:
fFont(&context->Font())
{
fFont->Lock();
}
FontLocker(const ServerFont* font)
:
fFont(font)
{
fFont->Lock();
}
~FontLocker()
{
fFont->Unlock();
}
private:
const ServerFont* fFont;
};
// pragma mark -
// constructor
DisplayDriverPainter::DisplayDriverPainter(HWInterface* interface)
: DisplayDriver(),
@@ -1086,6 +1116,7 @@ DisplayDriverPainter::DrawString(const char* string, int32 length,
{
// TODO: use delta
if (Lock()) {
FontLocker locker(d);
fPainter->SetDrawData(d);
//bigtime_t now = system_time();
// TODO: BoundingBox is quite slow!! Optimizing it will be beneficial.
@@ -1120,6 +1151,7 @@ DisplayDriverPainter::StringWidth(const char* string, int32 length,
// TODO: use delta
float width = 0.0;
if (Lock()) {
FontLocker locker(d);
fPainter->SetDrawData(d);
width = fPainter->StringWidth(string, length);
Unlock();
@@ -1134,6 +1166,7 @@ DisplayDriverPainter::StringWidth(const char* string, int32 length,
escapement_delta* delta)
{
// TODO: use delta
FontLocker locker(&font);
static DrawData d;
d.SetFont(font);
return StringWidth(string, length, &d);
@@ -1146,6 +1179,7 @@ DisplayDriverPainter::StringHeight(const char *string, int32 length,
{
float height = 0.0;
if (Lock()) {
FontLocker locker(d);
fPainter->SetDrawData(d);
static BPoint dummy(0.0, 0.0);
height = fPainter->BoundingBox(string, length, dummy).Height();
@@ -1157,7 +1191,7 @@ DisplayDriverPainter::StringHeight(const char *string, int32 length,
// Lock
bool
DisplayDriverPainter::Lock()
{
{
return fGraphicsCard->WriteLock();
}