diff options
Diffstat (limited to 'src/opengl')
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 29 | ||||
-rw-r--r-- | src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h | 4 |
2 files changed, 32 insertions, 1 deletions
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index fe6d15c..d6ddbfe 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -106,6 +106,11 @@ QGL2PaintEngineExPrivate::~QGL2PaintEngineExPrivate() e->data = 0; e->engine = 0; } + + if (elementIndicesVBOId != 0) { + glDeleteBuffers(1, &elementIndicesVBOId); + elementIndicesVBOId = 0; + } } void QGL2PaintEngineExPrivate::updateTextureFilter(GLenum target, GLenum wrapMode, bool smoothPixmapTransform, GLuint id) @@ -1400,6 +1405,8 @@ namespace { } +// #define QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO + void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyphType, QStaticTextItem *staticTextItem, bool includeMatrixInCache) @@ -1493,6 +1500,19 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp j += 4; } + +#if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO) + if (elementIndicesVBOId == 0) + glGenBuffers(1, &elementIndicesVBOId); + + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementIndicesVBOId); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, elementIndices.size() * sizeof(GLushort), + elementIndices.constData(), GL_STATIC_DRAW); +#endif + } else { +#if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO) + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementIndicesVBOId); +#endif } setVertexAttributePointer(QT_VERTEX_COORDS_ATTR, (GLfloat*)vertexCoordinates->data()); @@ -1570,7 +1590,11 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp updateTextureFilter(GL_TEXTURE_2D, GL_REPEAT, false); shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::MaskTexture), QT_MASK_TEXTURE_UNIT); +#if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO) + glDrawElements(GL_TRIANGLE_STRIP, 6 * staticTextItem->numGlyphs, GL_UNSIGNED_SHORT, 0); +#else glDrawElements(GL_TRIANGLE_STRIP, 6 * staticTextItem->numGlyphs, GL_UNSIGNED_SHORT, elementIndices.data()); +#endif shaderManager->setMaskType(QGLEngineShaderManager::SubPixelMaskPass2); @@ -1604,7 +1628,12 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp shaderManager->currentProgram()->setUniformValue(location(QGLEngineShaderManager::MaskTexture), QT_MASK_TEXTURE_UNIT); +#if defined(QT_OPENGL_DRAWCACHEDGLYPHS_INDEX_ARRAY_VBO) + glDrawElements(GL_TRIANGLE_STRIP, 6 * staticTextItem->numGlyphs, GL_UNSIGNED_SHORT, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); +#else glDrawElements(GL_TRIANGLE_STRIP, 6 * staticTextItem->numGlyphs, GL_UNSIGNED_SHORT, elementIndices.data()); +#endif if (includeMatrixInCache) s->matrix = old; diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 7108741..16682ce 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -177,7 +177,8 @@ public: snapToPixelGrid(false), addOffset(false), inverseScale(1), - lastMaskTextureUsed(0) + lastMaskTextureUsed(0), + elementIndicesVBOId(0) { } ~QGL2PaintEngineExPrivate(); @@ -269,6 +270,7 @@ public: QGL2PEXVertexArray vertexCoordinateArray; QGL2PEXVertexArray textureCoordinateArray; QVector<GLushort> elementIndices; + GLuint elementIndicesVBOId; QDataBuffer<GLfloat> opacityArray; GLfloat staticVertexCoordinateArray[8]; GLfloat staticTextureCoordinateArray[8]; |