summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/text/qfontengine_s60_p.h2
-rw-r--r--src/openvg/qpaintengine_vg.cpp4
-rw-r--r--src/openvg/qvg_symbian.cpp75
-rw-r--r--src/openvg/qvgfontglyphcache_p.h2
4 files changed, 61 insertions, 22 deletions
diff --git a/src/gui/text/qfontengine_s60_p.h b/src/gui/text/qfontengine_s60_p.h
index 9400d55..d65f13b 100644
--- a/src/gui/text/qfontengine_s60_p.h
+++ b/src/gui/text/qfontengine_s60_p.h
@@ -54,7 +54,7 @@
//
#include "qconfig.h"
-#include "qfontengine_p.h"
+#include <private/qfontengine_p.h>
#include "qsize.h"
#include <openfont.h>
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp
index 564b390..01c7a7e 100644
--- a/src/openvg/qpaintengine_vg.cpp
+++ b/src/openvg/qpaintengine_vg.cpp
@@ -3406,7 +3406,11 @@ void QVGPaintEngine::drawStaticTextItem(QStaticTextItem *textItem)
if (it != d->fontCache.constEnd()) {
glyphCache = it.value();
} else {
+#ifdef Q_OS_SYMBIAN
+ glyphCache = new QSymbianVGFontGlyphCache();
+#else
glyphCache = new QVGFontGlyphCache();
+#endif
if (glyphCache->font == VG_INVALID_HANDLE) {
qWarning("QVGPaintEngine::drawTextItem: OpenVG fonts are not supported by the OpenVG engine");
delete glyphCache;
diff --git a/src/openvg/qvg_symbian.cpp b/src/openvg/qvg_symbian.cpp
index 09962f6..e6086d0 100644
--- a/src/openvg/qvg_symbian.cpp
+++ b/src/openvg/qvg_symbian.cpp
@@ -45,16 +45,17 @@
#ifdef QT_SYMBIAN_SUPPORTS_SGIMAGE
#include <private/qt_s60_p.h>
#include <fbs.h>
+#include <gdi.h>
#include <sgresource/sgimage.h>
typedef EGLImageKHR (*pfnEglCreateImageKHR)(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, EGLint*);
typedef EGLBoolean (*pfnEglDestroyImageKHR)(EGLDisplay, EGLImageKHR);
typedef VGImage (*pfnVgCreateEGLImageTargetKHR)(VGeglImageKHR);
-#endif
-
-#if 1//defined(SYMBIAN_GDI_GLYPHDATA) && defined(QT_SYMBIAN_SUPPORTS_SGIMAGE)
+#ifdef SYMBIAN_GDI_GLYPHDATA // defined in gdi.h
+#define QT_SYMBIAN_HARDWARE_GLYPH_CACHE
#include <graphics/glyphdataiterator.h>
#include <private/qfontengine_s60_p.h>
#endif
+#endif
QT_BEGIN_NAMESPACE
@@ -319,32 +320,66 @@ void* QVGPixmapData::toNativeType(NativeType type)
return reinterpret_cast<void*>(bitmap);
}
return 0;
-#endif
}
void QSymbianVGFontGlyphCache::cacheGlyphs(QVGPaintEnginePrivate *d,
const QTextItemInt &ti,
const QVarLengthArray<glyph_t> &glyphs)
{
+#ifdef QT_SYMBIAN_HARDWARE_GLYPH_CACHE
QFontEngineS60 *fontEngine = static_cast<QFontEngineS60*>(ti.fontEngine);
- CFont *font = fontEngine->m_font;
+ CFont *cfont = fontEngine->m_activeFont;
+
+// QVarLengthArray<glyph_t, 256> adjustedGlyphs(glyphs);
+// for (int i = 0; i < glyphs.count(); ++i)
+// adjustedGlyphs[i] |= 0x80000000;
RGlyphDataIterator iter;
- int err = iter.Open(*font, glyphs.data(), glyphs.count());
-
-// for (; err == KErrNone; err = iter.Next()) {
-// const RSgImage& image = iter.Image();
-// const TRect& rect = iter.Rect();
-// const TOpenFontCharMetrics& metrics = iter.Metrics();
-//
-// QPixmap pix = QPixmap::fromSymbianRSgImage(*image);
-//
-// }
-// iter.Close();
-//
-// if (err != KErrNotFound) {
-// // Handle the error...
-// }
+ int err = iter.Open(*cfont, (const unsigned int*)glyphs.constData(), glyphs.count());
+
+ if (err == KErrNotSupported || err == KErrInUse) { // Fallback in possibly supported error cases
+ iter.Close();
+ qWarning("Falling back to default QVGFontGlyphCache");
+ return QVGFontGlyphCache::cacheGlyphs(d, ti, glyphs);
+ }
+
+ for (; err == KErrNone; err = iter.Next()) {
+ // Skip this glyph if we have already cached it before.
+ const unsigned int glyph = iter.GlyphCode();
+ if (((glyph < 256) && ((cachedGlyphsMask[glyph / 32] & (1 << (glyph % 32))) != 0))
+ || cachedGlyphs.contains(glyph))
+ continue;
+
+ const RSgImage& image = iter.Image();
+ const TOpenFontCharMetrics& metrics = iter.Metrics();
+
+ TRect glyphBounds;
+ metrics.GetHorizBounds(glyphBounds);
+ VGImage vgImage = sgImageToVGImage(0, image);
+ VGfloat origin[2];
+ VGfloat escapement[2];
+ origin[0] = -glyphBounds.iTl.iX + 0.5f;
+ origin[1] = -glyphBounds.iTl.iY + 0.5f;
+ escapement[0] = metrics.HorizAdvance();
+ escapement[1] = 0;
+ vgSetGlyphToImage(font, iter.GlyphCode(), vgImage, origin, escapement);
+ vgDestroyImage(vgImage);
+
+ // Add to cache
+ if (glyph < 256)
+ cachedGlyphsMask[glyph / 32] |= (1 << (glyph % 32));
+ else
+ cachedGlyphs.insert(glyph);
+ }
+ iter.Close();
+
+ if (err == KErrNoMemory || err == KErrNoGraphicsMemory)
+ qWarning("Not enough memory to cache glyph");
+ else if (err != KErrNotFound)
+ qWarning("Received error %d from glyph cache", err);
+#else
+ QVGFontGlyphCache::cacheGlyphs(d, ti, glyphs);
+#endif
}
QT_END_NAMESPACE
diff --git a/src/openvg/qvgfontglyphcache_p.h b/src/openvg/qvgfontglyphcache_p.h
index 4ba07ba..ee11082 100644
--- a/src/openvg/qvgfontglyphcache_p.h
+++ b/src/openvg/qvgfontglyphcache_p.h
@@ -79,7 +79,7 @@ public:
QSet<glyph_t> cachedGlyphs;
};
-#if defined( Q_OS_SYMBIAN)
+#if defined(Q_OS_SYMBIAN)
class QSymbianVGFontGlyphCache : public QVGFontGlyphCache
{
void cacheGlyphs(QVGPaintEnginePrivate *d,