summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Barron <jbarron@trolltech.com>2010-02-26 12:47:45 (GMT)
committerJason Barron <jbarron@trolltech.com>2010-07-12 07:03:09 (GMT)
commit8c6bfd9f2d34822e39812c07e821fa17ab3fdcb2 (patch)
tree6aa897a6c31bf8eb9611b039fc83f2b48a8a627e /src
parent940930dd8102511e6890ed661cf3d2dd88c2e1f4 (diff)
downloadQt-8c6bfd9f2d34822e39812c07e821fa17ab3fdcb2.zip
Qt-8c6bfd9f2d34822e39812c07e821fa17ab3fdcb2.tar.gz
Qt-8c6bfd9f2d34822e39812c07e821fa17ab3fdcb2.tar.bz2
Ensure glyphs are upright instead of upside-down.
The OpenVG paint engine traditionally takes glyph images from the alphaMapForGlyph() function which returns the glyph image in the upright projection. When it constructs a VGImage from this image, it passes a positive data stride which will read the top scanline of the source image into the bottom scanline of the VGImage due to the VG coordinate system. It then uses the path transform where the 'sy' value of the matrix is set to -1 and this re-inverts everything when drawing. With the Symbian based glyph cache, the VGImage is constructed from a RSgImage which is a hardware resource and compensates for the coordinate system used by VG and GL at the time it is created. In the case of the hardware glyph cache, the glyph image is read into the RSgImage using a negative data stride so it does not need to be inverted when drawn. To allow for this, introduce a flag which indicates that the 'sy' entry of the matrix should be flipped such that the glyph is drawn normally. Also in this patch is a change to the glyph origin which now uses the bottom of the glyph metric bounding rect instead of the top due to orientation of the glyph inside the VGImage. Reviewed-by: Alessandro Portale
Diffstat (limited to 'src')
-rw-r--r--src/openvg/qpaintengine_vg.cpp6
-rw-r--r--src/openvg/qvg_symbian.cpp7
-rw-r--r--src/openvg/qvgfontglyphcache_p.h3
3 files changed, 15 insertions, 1 deletions
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp
index 01c7a7e..4992ef5 100644
--- a/src/openvg/qpaintengine_vg.cpp
+++ b/src/openvg/qpaintengine_vg.cpp
@@ -3272,6 +3272,7 @@ QVGFontGlyphCache::QVGFontGlyphCache()
{
font = vgCreateFont(0);
scaleX = scaleY = 0.0;
+ invertedGlyphs = false;
memset(cachedGlyphsMask, 0, sizeof(cachedGlyphsMask));
}
@@ -3430,6 +3431,11 @@ void QVGPaintEngine::drawStaticTextItem(QStaticTextItem *textItem)
#if defined(QVG_NO_IMAGE_GLYPHS)
glyphTransform.scale(glyphCache->scaleX, glyphCache->scaleY);
#endif
+
+ // Some glyph caches can create the VGImage upright
+ if (glyphCache->invertedGlyphs)
+ glyphTransform.scale(1, -1);
+
d->setTransform(VG_MATRIX_GLYPH_USER_TO_SURFACE, glyphTransform);
// Add the glyphs from the text item into the glyph cache.
diff --git a/src/openvg/qvg_symbian.cpp b/src/openvg/qvg_symbian.cpp
index e6086d0..8c954e6 100644
--- a/src/openvg/qvg_symbian.cpp
+++ b/src/openvg/qvg_symbian.cpp
@@ -322,6 +322,11 @@ void* QVGPixmapData::toNativeType(NativeType type)
return 0;
}
+QSymbianVGFontGlyphCache::QSymbianVGFontGlyphCache() : QVGFontGlyphCache()
+{
+ invertedGlyphs = true;
+}
+
void QSymbianVGFontGlyphCache::cacheGlyphs(QVGPaintEnginePrivate *d,
const QTextItemInt &ti,
const QVarLengthArray<glyph_t> &glyphs)
@@ -359,7 +364,7 @@ void QSymbianVGFontGlyphCache::cacheGlyphs(QVGPaintEnginePrivate *d,
VGfloat origin[2];
VGfloat escapement[2];
origin[0] = -glyphBounds.iTl.iX + 0.5f;
- origin[1] = -glyphBounds.iTl.iY + 0.5f;
+ origin[1] = glyphBounds.iBr.iY + 0.5f;
escapement[0] = metrics.HorizAdvance();
escapement[1] = 0;
vgSetGlyphToImage(font, iter.GlyphCode(), vgImage, origin, escapement);
diff --git a/src/openvg/qvgfontglyphcache_p.h b/src/openvg/qvgfontglyphcache_p.h
index ee11082..8f25322 100644
--- a/src/openvg/qvgfontglyphcache_p.h
+++ b/src/openvg/qvgfontglyphcache_p.h
@@ -74,6 +74,7 @@ public:
VGFont font;
VGfloat scaleX;
VGfloat scaleY;
+ bool invertedGlyphs;
uint cachedGlyphsMask[256 / 32];
QSet<glyph_t> cachedGlyphs;
@@ -82,6 +83,8 @@ public:
#if defined(Q_OS_SYMBIAN)
class QSymbianVGFontGlyphCache : public QVGFontGlyphCache
{
+public:
+ QSymbianVGFontGlyphCache();
void cacheGlyphs(QVGPaintEnginePrivate *d,
const QTextItemInt &ti,
const QVarLengthArray<glyph_t> &glyphs);