summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@theqtcompany.com>2015-05-22 14:17:04 +0300
committerMiikka Heikkinen <miikka.heikkinen@theqtcompany.com>2015-05-26 12:06:56 +0000
commit1cdd823e77c33b67bdc8fec7081899a3d54701fd (patch)
tree337d692c4349297265d9f4022218d231dc566e28
parentc5f36c3c53b1f554de3b6628eedccec93c33b77c (diff)
Fix context sharing on android
The context version doesn't match surface version on some android platforms. Fix the issue by forcing context format 2.0 on ES2. Change-Id: I973246352f2e51acf22e622bdec51ce6574612fd Task-number: QTBUG-42455 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@theqtcompany.com>
-rw-r--r--src/imports/qtcanvas3d/canvas3d.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/imports/qtcanvas3d/canvas3d.cpp b/src/imports/qtcanvas3d/canvas3d.cpp
index efcf8bd..bfebb38 100644
--- a/src/imports/qtcanvas3d/canvas3d.cpp
+++ b/src/imports/qtcanvas3d/canvas3d.cpp
@@ -340,7 +340,11 @@ QJSValue Canvas::getContext(const QString &type, const QVariantMap &options)
// Create the offscreen surface
QSurfaceFormat surfaceFormat = m_glContextShare->format();
- if (!m_isOpenGLES2) {
+
+ if (m_isOpenGLES2) {
+ // Some devices report wrong version, so force 2.0 on ES2
+ surfaceFormat.setVersion(2, 0);
+ } else {
surfaceFormat.setSwapBehavior(QSurfaceFormat::SingleBuffer);
surfaceFormat.setSwapInterval(0);
}
@@ -748,10 +752,17 @@ QSGNode *Canvas::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data)
if (!m_glContextQt) {
m_glContextQt = window()->openglContext();
m_isOpenGLES2 = m_glContextQt->isOpenGLES();
- if (!m_isOpenGLES2 || m_glContextQt->format().majorVersion() >= 3)
+
+ QSurfaceFormat surfaceFormat = m_glContextQt->format();
+ // Some devices report wrong version, so force 2.0 on ES2
+ if (m_isOpenGLES2)
+ surfaceFormat.setVersion(2, 0);
+
+ if (!m_isOpenGLES2 || surfaceFormat.majorVersion() >= 3)
m_maxSamples = 4;
+
m_glContextShare = new QOpenGLContext;
- m_glContextShare->setFormat(m_glContextQt->format());
+ m_glContextShare->setFormat(surfaceFormat);
m_glContextShare->setShareContext(m_glContextQt);
QSurface *surface = m_glContextQt->surface();
m_glContextQt->doneCurrent();