summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@digia.com>2013-01-22 17:05:09 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-24 18:34:11 +0100
commita71c7fce8ac536212d78b525a8a76e5c130362ca (patch)
treeacd3ffa0348d6953270313bb72c2bec061b62adc /src
parentd0c360fd88760372f4f67219440ee17a11023d98 (diff)
Don't assume m11/m22 represents the scale of a QTransform
We can still assume it when pulling out the scale of the glyph cache, since we limit it to scaling, but when computing the scale from the current matrix we have to decompose it. We always use a positive scale in the glyph-cache, and let the drawing code take care of any flipping of the coordinates. Change-Id: Ie3c4f2d91008a9be8f89bef29c15d80b23fb8a82 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/opengl/qopenglpaintengine.cpp8
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp8
2 files changed, 14 insertions, 2 deletions
diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp
index 875fe4b4fb..68d9ad0a24 100644
--- a/src/gui/opengl/qopenglpaintengine.cpp
+++ b/src/gui/opengl/qopenglpaintengine.cpp
@@ -1073,6 +1073,8 @@ bool QOpenGL2PaintEngineExPrivate::prepareForCachedGlyphDraw(const QFontEngineGl
{
Q_Q(QOpenGL2PaintEngineEx);
+ Q_ASSERT(cache.transform().type() <= QTransform::TxScale);
+
QTransform &transform = q->state()->matrix;
transform.scale(1.0 / cache.transform().m11(), 1.0 / cache.transform().m22());
bool ret = prepareForDraw(false);
@@ -1557,7 +1559,11 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type
// We allow scaling, so that the glyph-cache will contain glyphs with the
// appropriate resolution in the case of displays with a device-pixel-ratio != 1.
- QTransform transform = QTransform::fromScale(s->matrix.m11(), s->matrix.m22());
+ QTransform transform = s->matrix.type() < QTransform::TxRotate ?
+ QTransform::fromScale(qAbs(s->matrix.m11()), qAbs(s->matrix.m22())) :
+ QTransform::fromScale(
+ QVector2D(s->matrix.m11(), s->matrix.m12()).length(),
+ QVector2D(s->matrix.m21(), s->matrix.m22()).length());
QOpenGLTextureGlyphCache *cache =
(QOpenGLTextureGlyphCache *) fe->glyphCache(cacheKey, glyphType, transform);
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index 8489daf794..b6da578f26 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -1090,6 +1090,8 @@ bool QGL2PaintEngineExPrivate::prepareForCachedGlyphDraw(const QFontEngineGlyphC
{
Q_Q(QGL2PaintEngineEx);
+ Q_ASSERT(cache.transform().type() <= QTransform::TxScale);
+
QTransform &transform = q->state()->matrix;
transform.scale(1.0 / cache.transform().m11(), 1.0 / cache.transform().m22());
bool ret = prepareForDraw(false);
@@ -1594,7 +1596,11 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp
// We allow scaling, so that the glyph-cache will contain glyphs with the
// appropriate resolution in the case of displays with a device-pixel-ratio != 1.
- QTransform transform = QTransform::fromScale(s->matrix.m11(), s->matrix.m22());
+ QTransform transform = s->matrix.type() < QTransform::TxRotate ?
+ QTransform::fromScale(qAbs(s->matrix.m11()), qAbs(s->matrix.m22())) :
+ QTransform::fromScale(
+ QVector2D(s->matrix.m11(), s->matrix.m12()).length(),
+ QVector2D(s->matrix.m21(), s->matrix.m22()).length());
QFontEngine *fe = staticTextItem->fontEngine();
QGLTextureGlyphCache *cache =