From 6d14ccae6d532a8560da05cdc85d7646ea2744e6 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 5 Feb 2010 12:57:52 +0100 Subject: Recreate cached vertex arrays for QStaticText when drawn to new context If you draw the QStaticText object to a new QGLWidget, then we need to recreate the VBOs (if the vertex arrays are cached.) It would be possible to share this across contexts, which can be implemented later as an extra optimization for switching between different target devices. --- src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index aec2ade..ed0f708 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -1345,9 +1345,17 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp QVector indices; #endif - if (staticTextItem->userData == 0 - || staticTextItem->userData->type != QStaticTextUserData::OpenGLUserData - || staticTextItem->userDataNeedsUpdate) { + bool recreateVertexArrays = false; + if (staticTextItem->userDataNeedsUpdate) + recreateVertexArrays = true; + else if (staticTextItem->userData == 0) + recreateVertexArrays = true; + else if (staticTextItem->userData->type != QStaticTextUserData::OpenGLUserData) + recreateVertexArrays = true; + else if (static_cast(staticTextItem->userData)->ctx != ctx) + recreateVertexArrays = true; + + if (recreateVertexArrays) { vertexCoordinateArray.clear(); textureCoordinateArray.clear(); -- cgit v0.12