From 2ef8e66ffd61e18a2ce6933cc3b8d53f954b2a4a Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Tue, 4 Aug 2020 09:26:14 +0200 Subject: Fix not working acceleration on Mac MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ø Reviewed-by: Michael Brüning --- src/core/macos_context_type_helper.h | 1 + src/core/macos_context_type_helper.mm | 5 +++++ src/core/ozone/gl_share_context_qt.cpp | 7 ++++++- 3 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src') 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 #include #include +#if defined(Q_OS_MACOS) +#include "macos_context_type_helper.h" +#endif #if QT_CONFIG(opengl) #include #include @@ -55,6 +58,8 @@ QtShareGLContext::QtShareGLContext(QOpenGLContext *qtContext) QOpenGLContext *context = QOpenGLContext::globalShareContext(); #if defined(Q_OS_MACOS) auto *ctx = context->platformInterface(); + if (ctx) + m_handle = cglContext(ctx->nativeContext()); #endif #if defined(Q_OS_WIN) auto *ctx = context->platformInterface(); @@ -62,7 +67,7 @@ QtShareGLContext::QtShareGLContext(QOpenGLContext *qtContext) #if defined(Q_OS_LINUX) auto *ctx = context->platformInterface(); #endif - if (ctx) + if (ctx && !m_handle) m_handle = (void *)ctx->nativeContext(); #if QT_CONFIG(egl) if (!m_handle) { -- cgit v1.2.3