summaryrefslogtreecommitdiffstats
path: root/src/gui/opengl
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@digia.com>2014-02-25 11:03:31 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-26 12:58:00 +0100
commitf645dad757b23a21cbaf4449be96c75304d9f154 (patch)
tree64117e3f3bbf138e8365e310fff87fea049e5b38 /src/gui/opengl
parentf7f70c4a7ab343f22e695a3dd4a0803b4b32c7fd (diff)
Use a VAO in the texture glyph cache
Task-number: QTBUG-36993 Change-Id: Icc77035b582c804ed809ea3cd99c0048b34d41d2 Reviewed-by: Gunnar Sletta <gunnar.sletta@jollamobile.com> Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/gui/opengl')
-rw-r--r--src/gui/opengl/qopengltextureglyphcache.cpp39
-rw-r--r--src/gui/opengl/qopengltextureglyphcache_p.h4
2 files changed, 33 insertions, 10 deletions
diff --git a/src/gui/opengl/qopengltextureglyphcache.cpp b/src/gui/opengl/qopengltextureglyphcache.cpp
index c3c04000a9..3524c1cb1a 100644
--- a/src/gui/opengl/qopengltextureglyphcache.cpp
+++ b/src/gui/opengl/qopengltextureglyphcache.cpp
@@ -164,6 +164,19 @@ void QOpenGLTextureGlyphCache::createTextureData(int width, int height)
m_buffer.allocate(buf, sizeof(buf));
m_buffer.release();
}
+
+ if (!m_vao.isCreated())
+ m_vao.create();
+}
+
+void QOpenGLTextureGlyphCache::setupVertexAttribs()
+{
+ m_buffer.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_buffer.release();
}
void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height)
@@ -262,16 +275,19 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height)
m_blitProgram->bindAttributeLocation("textureCoordArray", QT_TEXTURE_COORDS_ATTR);
m_blitProgram->link();
+
+ if (m_vao.isCreated()) {
+ m_vao.bind();
+ setupVertexAttribs();
+ }
}
- 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));
+ if (m_vao.isCreated())
+ m_vao.bind();
+ else
+ setupVertexAttribs();
+ m_blitProgram->bind();
blitProgram = m_blitProgram;
} else {
@@ -301,9 +317,12 @@ void QOpenGLTextureGlyphCache::resizeTextureData(int width, int height)
glViewport(0, 0, pex->width, pex->height);
pex->updateClipScissorTest();
} else {
- m_blitProgram->disableAttributeArray(int(QT_VERTEX_COORDS_ATTR));
- m_blitProgram->disableAttributeArray(int(QT_TEXTURE_COORDS_ATTR));
- m_buffer.release();
+ if (m_vao.isCreated()) {
+ m_vao.release();
+ } else {
+ m_blitProgram->disableAttributeArray(int(QT_VERTEX_COORDS_ATTR));
+ m_blitProgram->disableAttributeArray(int(QT_TEXTURE_COORDS_ATTR));
+ }
}
}
diff --git a/src/gui/opengl/qopengltextureglyphcache_p.h b/src/gui/opengl/qopengltextureglyphcache_p.h
index 394c28f7ff..1e2c031018 100644
--- a/src/gui/opengl/qopengltextureglyphcache_p.h
+++ b/src/gui/opengl/qopengltextureglyphcache_p.h
@@ -58,6 +58,7 @@
#include <qopenglshaderprogram.h>
#include <qopenglfunctions.h>
#include <qopenglbuffer.h>
+#include <qopenglvertexarrayobject.h>
// #define QT_GL_TEXTURE_GLYPH_CACHE_DEBUG
@@ -153,6 +154,8 @@ public:
void clear();
private:
+ void setupVertexAttribs();
+
QOpenGLGlyphTexture *m_textureResource;
QOpenGL2PaintEngineExPrivate *pex;
@@ -165,6 +168,7 @@ private:
int m_serialNumber;
QOpenGLBuffer m_buffer;
+ QOpenGLVertexArrayObject m_vao;
};
QT_END_NAMESPACE