summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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