summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2023-02-24 13:02:10 +0100
committerLaszlo Agocs <laszlo.agocs@qt.io>2023-03-05 07:21:51 +0100
commite1d4583a0c47348b6dbdc8a90bb4b3e9f7cb198d (patch)
tree3d961fcc6994694927ecb7e2f401f59126086d95
parent6f96d1785f35520607eff4ace0086d17db7b432e (diff)
downloadqtbase-e1d4583a0c47348b6dbdc8a90bb4b3e9f7cb198d.tar.gz
GL paint engine: Fix drawPixmapFragments when using buffer objects
Until recently the buffer object-based code path (so not client-side pointers) was only hit with a core profile context. This changed at some point in 6.4 and later to support WebGL (that has no client-side pointers, unlike OpenGL ES 2.0 it is based on). Now buffer objects are preferred over client-side pointers, always. Problem is, drawPixmapFragment() was never functional on this code path, it seems. Expecting that transferMode() does all the uploadData() needed is wrong. transferMode() bails out if the mode is the same as before, and that's exactly what happens when an application calls drawPixmapFragments() on the painter twice, after each other. How exactly this works with client-side pointers is not fully clear, but presumably the data buffer address stays the same so all pointers passed in to the glVertexAttribPointer calls are valid, and it sources the data for each draw call (probably), thus the rendering is all correct even though only the first, not the second, drawPixmapFragment() led to calling uploadData() internally. Amends e487b07e18f1cb7ff126744be57b2ae1b9839c6c although this patch on its own is just as applicable pre-6.4 as well (to fix drawPixmapFragments when using a core profile context). Fixes: QTBUG-111416 Change-Id: I2ad358424e613192a51b99b937aef7660f5dbe08 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> (cherry picked from commit d6c5a2f9177f427d14aae64d111c172d1bf28b6c) Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
-rw-r--r--src/opengl/qopenglpaintengine.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/opengl/qopenglpaintengine.cpp b/src/opengl/qopenglpaintengine.cpp
index 062eaa6a53..f78ad26551 100644
--- a/src/opengl/qopenglpaintengine.cpp
+++ b/src/opengl/qopenglpaintengine.cpp
@@ -2133,6 +2133,10 @@ void QOpenGL2PaintEngineExPrivate::drawPixmapFragments(const QPainter::PixmapFra
transferMode(ImageOpacityArrayDrawingMode);
+ uploadData(QT_VERTEX_COORDS_ATTR, (GLfloat*)vertexCoordinateArray.data(), vertexCoordinateArray.vertexCount() * 2);
+ uploadData(QT_TEXTURE_COORDS_ATTR, (GLfloat*)textureCoordinateArray.data(), textureCoordinateArray.vertexCount() * 2);
+ uploadData(QT_OPACITY_ATTR, (GLfloat*)opacityArray.data(), opacityArray.size());
+
GLenum filterMode = q->state()->renderHints & QPainter::SmoothPixmapTransform ? GL_LINEAR : GL_NEAREST;
updateTexture(QT_IMAGE_TEXTURE_UNIT, pixmap, GL_CLAMP_TO_EDGE, filterMode);