summaryrefslogtreecommitdiffstats
path: root/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-10-05 08:58:50 (GMT)
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2010-10-05 09:02:40 (GMT)
commit17e1f24b84ea4cbfab53cbd8d66963f744eb1d66 (patch)
treed6829997b6e5c0e6a8c7b430af48da2e758568de /src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp
parent892961bdb06199606ef92b3ab364175a1709c378 (diff)
downloadQt-17e1f24b84ea4cbfab53cbd8d66963f744eb1d66.zip
Qt-17e1f24b84ea4cbfab53cbd8d66963f744eb1d66.tar.gz
Qt-17e1f24b84ea4cbfab53cbd8d66963f744eb1d66.tar.bz2
Work around OpenGL driver reading arrays asyncronously
Some drivers, e.g. the Nvidia driver on Windows, will sometimes read the coordinate arrays asyncronously, which causes a crash if they are allocated on the stack. Reviewed-by: Kim
Diffstat (limited to 'src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp')
-rw-r--r--src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp46
1 files changed, 22 insertions, 24 deletions
diff --git a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp
index 3f10454..9a15260 100644
--- a/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp
+++ b/src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp
@@ -64,6 +64,24 @@ QGLTextureGlyphCache::QGLTextureGlyphCache(const QGLContext *context, QFontEngin
qDebug(" -> QGLTextureGlyphCache() %p for context %p.", this, ctx);
#endif
setContext(context);
+
+ m_vertexCoordinateArray[0] = -1.0f;
+ m_vertexCoordinateArray[1] = -1.0f;
+ m_vertexCoordinateArray[2] = 1.0f;
+ m_vertexCoordinateArray[3] = -1.0f;
+ m_vertexCoordinateArray[4] = 1.0f;
+ m_vertexCoordinateArray[5] = 1.0f;
+ m_vertexCoordinateArray[6] = -1.0f;
+ m_vertexCoordinateArray[7] = 1.0f;
+
+ m_textureCoordinateArray[0] = 0.0f;
+ m_textureCoordinateArray[1] = 0.0f;
+ m_textureCoordinateArray[2] = 1.0f;
+ m_textureCoordinateArray[3] = 0.0f;
+ m_textureCoordinateArray[4] = 1.0f;
+ m_textureCoordinateArray[5] = 1.0f;
+ m_textureCoordinateArray[6] = 0.0f;
+ m_textureCoordinateArray[7] = 1.0f;
}
QGLTextureGlyphCache::~QGLTextureGlyphCache()
@@ -183,26 +201,6 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height)
glViewport(0, 0, oldWidth, oldHeight);
- GLfloat vertexCoordinateArray[8];
- vertexCoordinateArray[0] = -1.0f;
- vertexCoordinateArray[1] = -1.0f;
- vertexCoordinateArray[2] = 1.0f;
- vertexCoordinateArray[3] = -1.0f;
- vertexCoordinateArray[4] = 1.0f;
- vertexCoordinateArray[5] = 1.0f;
- vertexCoordinateArray[6] = -1.0f;
- vertexCoordinateArray[7] = 1.0f;
-
- GLfloat textureCoordinateArray[8];
- textureCoordinateArray[0] = 0.0f;
- textureCoordinateArray[1] = 0.0f;
- textureCoordinateArray[2] = 1.0f;
- textureCoordinateArray[3] = 0.0f;
- textureCoordinateArray[4] = 1.0f;
- textureCoordinateArray[5] = 1.0f;
- textureCoordinateArray[6] = 0.0f;
- textureCoordinateArray[7] = 1.0f;
-
QGLShaderProgram *blitProgram = 0;
if (pex == 0) {
if (m_blitProgram == 0) {
@@ -236,8 +234,8 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height)
m_blitProgram->link();
}
- glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, vertexCoordinateArray);
- glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinateArray);
+ glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, m_vertexCoordinateArray);
+ glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, m_textureCoordinateArray);
m_blitProgram->bind();
QGLContextPrivate* ctx_d = const_cast<QGLContextPrivate *>(ctx->d_func());
@@ -247,8 +245,8 @@ void QGLTextureGlyphCache::resizeTextureData(int width, int height)
blitProgram = m_blitProgram;
} else {
- pex->setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, vertexCoordinateArray);
- pex->setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, textureCoordinateArray);
+ pex->setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, m_vertexCoordinateArray);
+ pex->setVertexAttributePointer(QT_TEXTURE_COORDS_ATTR, m_textureCoordinateArray);
pex->shaderManager->useBlitProgram();
blitProgram = pex->shaderManager->blitProgram();