From d8ad9ac86dac9489b553e6416329308ae7d823d0 Mon Sep 17 00:00:00 2001 From: Jani Hautakangas Date: Mon, 11 Jan 2010 11:11:59 +0200 Subject: Fix for QTBUG-6408 QFontEngineS60::QFontEngineS60 called hundreds of times, taking up to 1ms each call. Use S60->ScreenDevice() to get/release fonts instead of create a new screen device each time. Task-number: QTBUG-6408 Reviewed-by: Jason Barron --- src/gui/text/qfontengine_s60.cpp | 36 +++++++----------------------------- src/gui/text/qfontengine_s60_p.h | 3 --- 2 files changed, 7 insertions(+), 32 deletions(-) diff --git a/src/gui/text/qfontengine_s60.cpp b/src/gui/text/qfontengine_s60.cpp index e279ad2..7fad188 100644 --- a/src/gui/text/qfontengine_s60.cpp +++ b/src/gui/text/qfontengine_s60.cpp @@ -45,12 +45,11 @@ #include #include "qimage.h" #include "qt_s60_p.h" -#include "qpixmap_s60_p.h" #include #include -#include -#include +#include +#include QT_BEGIN_NAMESPACE @@ -135,42 +134,21 @@ QFontEngineS60::QFontEngineS60(const QFontDef &request, const QFontEngineS60Exte { QFontEngine::fontDef = request; m_fontSizeInPixels = (request.pixelSize >= 0)? - request.pixelSize:pointsToPixels(request.pointSize); - - QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock); - - m_textRenderBitmap = q_check_ptr(new CFbsBitmap()); // CBase derived object needs check on new - const TSize bitmapSize(1, 1); // It is just a dummy bitmap that I need to keep the font alive (or maybe not) - qt_symbian_throwIfError(m_textRenderBitmap->Create(bitmapSize, EGray256)); - QT_TRAP_THROWING(m_textRenderBitmapDevice = CFbsBitmapDevice::NewL(m_textRenderBitmap)); - qt_symbian_throwIfError(m_textRenderBitmapDevice->CreateContext(m_textRenderBitmapGc)); - cache_cost = sizeof(QFontEngineS60) + bitmapSize.iHeight * bitmapSize.iWidth * 4; + request.pixelSize:pointsToPixels(request.pointSize); TFontSpec fontSpec(qt_QString2TPtrC(request.family), m_fontSizeInPixels); fontSpec.iFontStyle.SetBitmapType(EAntiAliasedGlyphBitmap); fontSpec.iFontStyle.SetPosture(request.style == QFont::StyleNormal?EPostureUpright:EPostureItalic); fontSpec.iFontStyle.SetStrokeWeight(request.weight > QFont::Normal?EStrokeWeightBold:EStrokeWeightNormal); - const TInt errorCode = m_textRenderBitmapDevice->GetNearestFontInPixels(m_font, fontSpec); + const TInt errorCode = S60->screenDevice()->GetNearestFontToDesignHeightInPixels(m_font, fontSpec); Q_ASSERT(errorCode == 0); - m_textRenderBitmapGc->UseFont(m_font); - - lock.relock(); + + cache_cost = sizeof(QFontEngineS60); } QFontEngineS60::~QFontEngineS60() { - QSymbianFbsHeapLock lock(QSymbianFbsHeapLock::Unlock); - - m_textRenderBitmapGc->DiscardFont(); - delete m_textRenderBitmapGc; - m_textRenderBitmapGc = NULL; - m_textRenderBitmapDevice->ReleaseFont(m_font); - delete m_textRenderBitmapDevice; - m_textRenderBitmapDevice = NULL; - delete m_textRenderBitmap; - m_textRenderBitmap = NULL; - - lock.relock(); + S60->screenDevice()->ReleaseFont(m_font); } bool QFontEngineS60::stringToCMap(const QChar *characters, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const diff --git a/src/gui/text/qfontengine_s60_p.h b/src/gui/text/qfontengine_s60_p.h index 9e22245..b21f1c8 100644 --- a/src/gui/text/qfontengine_s60_p.h +++ b/src/gui/text/qfontengine_s60_p.h @@ -126,9 +126,6 @@ private: QFixed glyphAdvance(HB_Glyph glyph) const; - CFbsBitmap *m_textRenderBitmap; - CFbsBitmapDevice *m_textRenderBitmapDevice; - CFbsBitGc *m_textRenderBitmapGc; CFont* m_font; const QFontEngineS60Extensions *m_extensions; qreal m_fontSizeInPixels; -- cgit v0.12