summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Klocek <michal.klocek@qt.io>2020-08-04 09:26:14 +0200
committerMichal Klocek <michal.klocek@qt.io>2020-08-05 14:00:57 +0200
commit2ef8e66ffd61e18a2ce6933cc3b8d53f954b2a4a (patch)
treea4edcb81466d3b30456724b2cd962e0ef5406d23
parent3ece9910a6b29fd6061c8fa3cf5f69970a93ca58 (diff)
Fix not working acceleration on Mac
Since 6ff79478a in base we no longer are able to query for 'cqlcontextobj' add helper call for CGLContextObj. Change-Id: Ie1992ab7a0e525c2c6b5f9a67ce354a493e993e8 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Michael Brüning <michael.bruning@qt.io>
-rw-r--r--src/core/macos_context_type_helper.h1
-rw-r--r--src/core/macos_context_type_helper.mm5
-rw-r--r--src/core/ozone/gl_share_context_qt.cpp7
3 files changed, 12 insertions, 1 deletions
diff --git a/src/core/macos_context_type_helper.h b/src/core/macos_context_type_helper.h
index d234a2bff..a7b989bc3 100644
--- a/src/core/macos_context_type_helper.h
+++ b/src/core/macos_context_type_helper.h
@@ -39,4 +39,5 @@
#ifndef MACOS_CONTEXT_TYPE_HELPER_H_
#define MACOS_CONTEXT_TYPE_HELPER_H_
bool isCurrentContextSoftware();
+void* cglContext(NSOpenGLContext*);
#endif // MACOS_CONTEXT_TYPE_HELPER_H_
diff --git a/src/core/macos_context_type_helper.mm b/src/core/macos_context_type_helper.mm
index c814d2849..4c9302482 100644
--- a/src/core/macos_context_type_helper.mm
+++ b/src/core/macos_context_type_helper.mm
@@ -47,3 +47,8 @@ bool isCurrentContextSoftware()
[NSOpenGLContext.currentContext getValues:&rendererID forParameter:NSOpenGLContextParameterCurrentRendererID];
return (rendererID & kCGLRendererIDMatchingMask) == kCGLRendererGenericFloatID;
}
+
+void* cglContext(NSOpenGLContext *nsOpenGLContext)
+{
+ return [nsOpenGLContext CGLContextObj];
+}
diff --git a/src/core/ozone/gl_share_context_qt.cpp b/src/core/ozone/gl_share_context_qt.cpp
index dbfb7848f..669652057 100644
--- a/src/core/ozone/gl_share_context_qt.cpp
+++ b/src/core/ozone/gl_share_context_qt.cpp
@@ -41,6 +41,9 @@
#include <QtGui/qtgui-config.h>
#include <qpa/qplatformnativeinterface.h>
#include <QtGui/qopenglcontext_platform.h>
+#if defined(Q_OS_MACOS)
+#include "macos_context_type_helper.h"
+#endif
#if QT_CONFIG(opengl)
#include <QOpenGLContext>
#include <QOpenGLExtraFunctions>
@@ -55,6 +58,8 @@ QtShareGLContext::QtShareGLContext(QOpenGLContext *qtContext)
QOpenGLContext *context = QOpenGLContext::globalShareContext();
#if defined(Q_OS_MACOS)
auto *ctx = context->platformInterface<QPlatformInterface::QCocoaGLContext>();
+ if (ctx)
+ m_handle = cglContext(ctx->nativeContext());
#endif
#if defined(Q_OS_WIN)
auto *ctx = context->platformInterface<QPlatformInterface::QWGLContext>();
@@ -62,7 +67,7 @@ QtShareGLContext::QtShareGLContext(QOpenGLContext *qtContext)
#if defined(Q_OS_LINUX)
auto *ctx = context->platformInterface<QPlatformInterface::QGLXContext>();
#endif
- if (ctx)
+ if (ctx && !m_handle)
m_handle = (void *)ctx->nativeContext();
#if QT_CONFIG(egl)
if (!m_handle) {