summaryrefslogtreecommitdiffstats
path: root/src/opengl
diff options
context:
space:
mode:
authorSamuel Rødal <sroedal@trolltech.com>2009-09-29 09:00:57 (GMT)
committerSamuel Rødal <sroedal@trolltech.com>2009-10-06 15:46:19 (GMT)
commit27c2df52128e32c785239dbc9322a4b7beb0078c (patch)
treed32d74936db51f538c384d2fd45bc3f2c8d688fd /src/opengl
parent9dbcdc00239abbaf899f04fc5ecc2bdb885ad08d (diff)
downloadQt-27c2df52128e32c785239dbc9322a4b7beb0078c.zip
Qt-27c2df52128e32c785239dbc9322a4b7beb0078c.tar.gz
Qt-27c2df52128e32c785239dbc9322a4b7beb0078c.tar.bz2
Changed GL 2 engine render text implementation to use glDepthRange().
This frees all the current dependencies on the depth uniform.
Diffstat (limited to 'src/opengl')
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp41
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h5
2 files changed, 30 insertions, 16 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index ab38c24..859ffe1 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -898,11 +898,14 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path)
prepareForDraw(currentBrush->isOpaque());
-#ifndef QT_OPENGL_ES_2
if (inRenderText)
- shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Depth), zValueForRenderText());
-#endif
+ prepareDepthRangeForRenderText();
+
composite(vertexCoordinateArray.boundingRect());
+
+ if (inRenderText)
+ restoreDepthRangeForRenderText();
+
glStencilMask(0);
updateClipScissorTest();
@@ -1138,7 +1141,7 @@ void QGL2PaintEngineExPrivate::drawVertexArrays(QGL2PEXVertexArray& vertexArray,
glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR);
}
-float QGL2PaintEngineExPrivate::zValueForRenderText() const
+void QGL2PaintEngineExPrivate::prepareDepthRangeForRenderText()
{
#ifndef QT_OPENGL_ES_2
// Get the z translation value from the model view matrix and
@@ -1146,9 +1149,19 @@ float QGL2PaintEngineExPrivate::zValueForRenderText() const
// and z-far = 1, which is used in QGLWidget::renderText()
GLdouble model[4][4];
glGetDoublev(GL_MODELVIEW_MATRIX, &model[0][0]);
- return -2 * model[3][2] - 1;
-#else
- return 0;
+ float deviceZ = -2 * model[3][2] - 1;
+
+ glGetFloatv(GL_DEPTH_RANGE, depthRange);
+ float windowZ = depthRange[0] + (deviceZ + 1) * 0.5 * (depthRange[1] - depthRange[0]);
+
+ glDepthRange(windowZ, windowZ);
+#endif
+}
+
+void QGL2PaintEngineExPrivate::restoreDepthRangeForRenderText()
+{
+#ifndef QT_OPENGL_ES_2
+ glDepthRange(depthRange[0], depthRange[1]);
#endif
}
@@ -1406,6 +1419,9 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, QFontEngineGly
QBrush pensBrush = q->state()->pen.brush();
setBrush(&pensBrush);
+ if (inRenderText)
+ prepareDepthRangeForRenderText();
+
if (glyphType == QFontEngineGlyphCache::Raster_RGBMask) {
// Subpixel antialiasing without gamma correction
@@ -1458,10 +1474,6 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, QFontEngineGly
glBindTexture(GL_TEXTURE_2D, cache->texture());
updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, false);
-#ifndef QT_OPENGL_ES_2
- if (inRenderText)
- shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Depth), zValueForRenderText());
-#endif
shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::MaskTexture), QT_MASK_TEXTURE_UNIT);
glDrawArrays(GL_TRIANGLES, 0, 6 * glyphs.size());
@@ -1492,12 +1504,11 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(const QPointF &p, QFontEngineGly
glBindTexture(GL_TEXTURE_2D, cache->texture());
updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, false);
-#ifndef QT_OPENGL_ES_2
- if (inRenderText)
- shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::Depth), zValueForRenderText());
-#endif
shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::MaskTexture), QT_MASK_TEXTURE_UNIT);
glDrawArrays(GL_TRIANGLES, 0, 6 * glyphs.size());
+
+ if (inRenderText)
+ restoreDepthRangeForRenderText();
}
void QGL2PaintEngineEx::drawPixmaps(const QDrawPixmaps::Data *drawingData, int dataCount, const QPixmap &pixmap, QDrawPixmaps::DrawingHints hints)
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
index bfc6a3f..662911f 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h
@@ -197,7 +197,8 @@ public:
inline void useSimpleShader();
- float zValueForRenderText() const;
+ void prepareDepthRangeForRenderText();
+ void restoreDepthRangeForRenderText();
static QGLEngineShaderManager* shaderManagerForEngine(QGL2PaintEngineEx *engine) { return engine->d_func()->shaderManager; }
@@ -258,6 +259,8 @@ public:
bool needsSync;
bool inRenderText;
+ GLfloat depthRange[2];
+
float textureInvertedY;
QScopedPointer<QPixmapFilter> convolutionFilter;