summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar@trolltech.com>2010-01-04 11:51:29 (GMT)
committerGunnar Sletta <gunnar@trolltech.com>2010-01-04 11:51:29 (GMT)
commitd6d9c2ab41a2ecc6f038e6cb0f800d080f052147 (patch)
treecf3945b573c285fd356c0cbcc3edf01e4af84a74
parent1a1f781e7f6be2e62be91b082ee798b8854ad920 (diff)
parent1e7922262c29ba29a70226cf8894645f46df3ca2 (diff)
downloadQt-d6d9c2ab41a2ecc6f038e6cb0f800d080f052147.zip
Qt-d6d9c2ab41a2ecc6f038e6cb0f800d080f052147.tar.gz
Qt-d6d9c2ab41a2ecc6f038e6cb0f800d080f052147.tar.bz2
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.6
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp47
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h2
2 files changed, 44 insertions, 5 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index 0f8e945..a41d439 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -589,19 +589,28 @@ void QGL2PaintEngineExPrivate::updateMatrix()
const GLfloat wfactor = 2.0f / width;
const GLfloat hfactor = -2.0f / height;
+ GLfloat dx = transform.dx();
+ GLfloat dy = transform.dy();
+
+ // Non-integer translates can have strange effects for some rendering operations such as
+ // anti-aliased text rendering. In such cases, we snap the translate to the pixel grid.
+ if (snapToPixelGrid && transform.type() == QTransform::TxTranslate) {
+ // 0.50 needs to rounded down to 0.0 for consistency with raster engine:
+ dx = ceilf(dx - 0.5f);
+ dy = ceilf(dy - 0.5f);
+ }
if (addOffset) {
- pmvMatrix[2][0] = (wfactor * (transform.dx() + 0.49f)) - transform.m33();
- pmvMatrix[2][1] = (hfactor * (transform.dy() + 0.49f)) + transform.m33();
- } else {
- pmvMatrix[2][0] = (wfactor * transform.dx()) - transform.m33();
- pmvMatrix[2][1] = (hfactor * transform.dy()) + transform.m33();
+ dx += 0.49f;
+ dy += 0.49f;
}
pmvMatrix[0][0] = (wfactor * transform.m11()) - transform.m13();
pmvMatrix[1][0] = (wfactor * transform.m21()) - transform.m23();
+ pmvMatrix[2][0] = (wfactor * dx) - transform.m33();
pmvMatrix[0][1] = (hfactor * transform.m12()) + transform.m13();
pmvMatrix[1][1] = (hfactor * transform.m22()) + transform.m23();
+ pmvMatrix[2][1] = (hfactor * dy) + transform.m33();
pmvMatrix[0][2] = transform.m13();
pmvMatrix[1][2] = transform.m23();
pmvMatrix[2][2] = transform.m33();
@@ -699,6 +708,11 @@ void QGL2PaintEngineExPrivate::drawTexture(const QGLRect& dest, const QGLRect& s
matrixDirty = true;
}
+ if (snapToPixelGrid) {
+ snapToPixelGrid = false;
+ matrixDirty = true;
+ }
+
if (prepareForDraw(opaque))
shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::ImageTexture), QT_IMAGE_TEXTURE_UNIT);
@@ -856,6 +870,11 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path)
matrixDirty = true;
}
+ if (snapToPixelGrid) {
+ snapToPixelGrid = false;
+ matrixDirty = true;
+ }
+
// Might need to call updateMatrix to re-calculate inverseScale
if (matrixDirty)
updateMatrix();
@@ -1249,6 +1268,11 @@ void QGL2PaintEngineExPrivate::stroke(const QVectorPath &path, const QPen &pen)
matrixDirty = true;
}
+ if (snapToPixelGrid) {
+ snapToPixelGrid = false;
+ matrixDirty = true;
+ }
+
const Qt::PenStyle penStyle = qpen_style(pen);
const QBrush &penBrush = qpen_brush(pen);
const bool opaque = penBrush.isOpaque() && s->opacity > 0.99;
@@ -1519,6 +1543,10 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, QFontEngineGly
addOffset = false;
matrixDirty = true;
}
+ if (!snapToPixelGrid) {
+ snapToPixelGrid = true;
+ matrixDirty = true;
+ }
QBrush pensBrush = q->state()->pen.brush();
setBrush(pensBrush);
@@ -1637,6 +1665,11 @@ void QGL2PaintEngineExPrivate::drawPixmaps(const QDrawPixmaps::Data *drawingData
matrixDirty = true;
}
+ if (snapToPixelGrid) {
+ snapToPixelGrid = false;
+ matrixDirty = true;
+ }
+
bool allOpaque = true;
for (int i = 0; i < dataCount; ++i) {
@@ -1918,6 +1951,10 @@ void QGL2PaintEngineExPrivate::writeClip(const QVectorPath &path, uint value)
addOffset = false;
matrixDirty = true;
}
+ if (snapToPixelGrid) {
+ snapToPixelGrid = false;
+ matrixDirty = true;
+ }
if (matrixDirty)
updateMatrix();
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
index 9a5c447..7d5cb52 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
@@ -167,6 +167,7 @@ public:
width(0), height(0),
ctx(0),
useSystemClip(true),
+ snapToPixelGrid(false),
addOffset(false),
inverseScale(1)
{ }
@@ -260,6 +261,7 @@ public:
GLfloat staticVertexCoordinateArray[8];
GLfloat staticTextureCoordinateArray[8];
+ bool snapToPixelGrid;
bool addOffset; // When enabled, adds a 0.49,0.49 offset to matrix in updateMatrix
GLfloat pmvMatrix[3][3];
GLfloat inverseScale;