summaryrefslogtreecommitdiffstats
path: root/src/gui/opengl/qopengltextureglyphcache.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-02-24 16:40:00 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-26 12:58:00 +0100
commit357363dd51e885447202fc753792a49b5812539a (patch)
treeb0a8752e4accb78467beb968bb94add448ec2cea /src/gui/opengl/qopengltextureglyphcache.cpp
parenta2f79b0d0f2373179998dd226bc5a86ad31f4e7e (diff)
Texture glyph cache: Use a vbo
It is not going to work with core profile otherwise. This fixes one of the several problems that make native text rendering in Quick impossible with OpenGL core profile. The GL2 paint engine path is not changed, that continues to use client side pointers. Task-number: QTBUG-36993 Change-Id: Icfbd6efc894a79a3a84568fb792c1cb6692469cb Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com>
Diffstat (limited to 'src/gui/opengl/qopengltextureglyphcache.cpp')
-rw-r--r--src/gui/opengl/qopengltextureglyphcache.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/gui/opengl/qopengltextureglyphcache.cpp b/src/gui/opengl/qopengltextureglyphcache.cpp
index ba1fa8f486..f1bf944d7b 100644
--- a/src/gui/opengl/qopengltextureglyphcache.cpp
+++ b/src/gui/opengl/qopengltextureglyphcache.cpp
@@ -58,6 +58,7 @@ QOpenGLTextureGlyphCache::QOpenGLTextureGlyphCache(QFontEngine::GlyphFormat form
, m_blitProgram(0)
, m_filterMode(Nearest)
, m_serialNumber(qopengltextureglyphcache_serial_number.fetchAndAddRelaxed(1))
+ , m_buffer(QOpenGLBuffer::VertexBuffer)
{
#ifdef QT_GL_TEXTURE_GLYPH_CACHE_DEBUG
qDebug(" -> QOpenGLTextureGlyphCache() %p for context %p.", this, QOpenGLContext::currentContext());
@@ -139,6 +140,18 @@ void QOpenGLTextureGlyphCache::createTextureData(int width, int height)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
m_filterMode = Nearest;
+
+ if (!m_buffer.isCreated()) {
+ m_buffer.create();
+ m_buffer.bind();
+ static GLfloat buf[sizeof(m_vertexCoordinateArray) + sizeof(m_textureCoordinateArray)];
+ memcpy(buf, m_vertexCoordinateArray, sizeof(m_vertexCoordinateArray));
+ memcpy(buf + (sizeof(m_vertexCoordinateArray) / sizeof(GLfloat)),
+ m_textureCoordinateArray,
+ sizeof(m_textureCoordinateArray));
+ m_buffer.allocate(buf, sizeof(buf));
+ m_buffer.release();
+ }
}
void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height)
@@ -239,10 +252,10 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height)
m_blitProgram->link();
}
- funcs.glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, m_vertexCoordinateArray);
- funcs.glVertexAttribPointer(QT_TEXTURE_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, m_textureCoordinateArray);
-
+ m_buffer.bind();
m_blitProgram->bind();
+ m_blitProgram->setAttributeBuffer(int(QT_VERTEX_COORDS_ATTR), GL_FLOAT, 0, 2);
+ m_blitProgram->setAttributeBuffer(int(QT_TEXTURE_COORDS_ATTR), GL_FLOAT, sizeof(m_vertexCoordinateArray), 2);
m_blitProgram->enableAttributeArray(int(QT_VERTEX_COORDS_ATTR));
m_blitProgram->enableAttributeArray(int(QT_TEXTURE_COORDS_ATTR));
m_blitProgram->disableAttributeArray(int(QT_OPACITY_ATTR));
@@ -278,6 +291,7 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height)
} else {
m_blitProgram->disableAttributeArray(int(QT_VERTEX_COORDS_ATTR));
m_blitProgram->disableAttributeArray(int(QT_TEXTURE_COORDS_ATTR));
+ m_buffer.release();
}
}