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:
@@ -140,6 +140,9 @@ class ServerFont {
|
|||||||
|
|
||||||
float StringWidth(const char* string, int32 numBytes) const;
|
float StringWidth(const char* string, int32 numBytes) const;
|
||||||
|
|
||||||
|
bool Lock() const { return fStyle->Lock(); }
|
||||||
|
void Unlock() const { fStyle->Unlock(); }
|
||||||
|
|
||||||
FT_Face GetFTFace() const
|
FT_Face GetFTFace() const
|
||||||
{ return fStyle->GetFTFace(); };
|
{ return fStyle->GetFTFace(); };
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,36 @@ extend_by_stroke_width(BRect& rect, const DrawData* context)
|
|||||||
rect.InsetBy(inset, inset);
|
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
|
// constructor
|
||||||
DisplayDriverPainter::DisplayDriverPainter(HWInterface* interface)
|
DisplayDriverPainter::DisplayDriverPainter(HWInterface* interface)
|
||||||
: DisplayDriver(),
|
: DisplayDriver(),
|
||||||
@@ -1086,6 +1116,7 @@ DisplayDriverPainter::DrawString(const char* string, int32 length,
|
|||||||
{
|
{
|
||||||
// TODO: use delta
|
// TODO: use delta
|
||||||
if (Lock()) {
|
if (Lock()) {
|
||||||
|
FontLocker locker(d);
|
||||||
fPainter->SetDrawData(d);
|
fPainter->SetDrawData(d);
|
||||||
//bigtime_t now = system_time();
|
//bigtime_t now = system_time();
|
||||||
// TODO: BoundingBox is quite slow!! Optimizing it will be beneficial.
|
// TODO: BoundingBox is quite slow!! Optimizing it will be beneficial.
|
||||||
@@ -1120,6 +1151,7 @@ DisplayDriverPainter::StringWidth(const char* string, int32 length,
|
|||||||
// TODO: use delta
|
// TODO: use delta
|
||||||
float width = 0.0;
|
float width = 0.0;
|
||||||
if (Lock()) {
|
if (Lock()) {
|
||||||
|
FontLocker locker(d);
|
||||||
fPainter->SetDrawData(d);
|
fPainter->SetDrawData(d);
|
||||||
width = fPainter->StringWidth(string, length);
|
width = fPainter->StringWidth(string, length);
|
||||||
Unlock();
|
Unlock();
|
||||||
@@ -1134,6 +1166,7 @@ DisplayDriverPainter::StringWidth(const char* string, int32 length,
|
|||||||
escapement_delta* delta)
|
escapement_delta* delta)
|
||||||
{
|
{
|
||||||
// TODO: use delta
|
// TODO: use delta
|
||||||
|
FontLocker locker(&font);
|
||||||
static DrawData d;
|
static DrawData d;
|
||||||
d.SetFont(font);
|
d.SetFont(font);
|
||||||
return StringWidth(string, length, &d);
|
return StringWidth(string, length, &d);
|
||||||
@@ -1146,6 +1179,7 @@ DisplayDriverPainter::StringHeight(const char *string, int32 length,
|
|||||||
{
|
{
|
||||||
float height = 0.0;
|
float height = 0.0;
|
||||||
if (Lock()) {
|
if (Lock()) {
|
||||||
|
FontLocker locker(d);
|
||||||
fPainter->SetDrawData(d);
|
fPainter->SetDrawData(d);
|
||||||
static BPoint dummy(0.0, 0.0);
|
static BPoint dummy(0.0, 0.0);
|
||||||
height = fPainter->BoundingBox(string, length, dummy).Height();
|
height = fPainter->BoundingBox(string, length, dummy).Height();
|
||||||
@@ -1157,7 +1191,7 @@ DisplayDriverPainter::StringHeight(const char *string, int32 length,
|
|||||||
// Lock
|
// Lock
|
||||||
bool
|
bool
|
||||||
DisplayDriverPainter::Lock()
|
DisplayDriverPainter::Lock()
|
||||||
{
|
{
|
||||||
return fGraphicsCard->WriteLock();
|
return fGraphicsCard->WriteLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user