summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoaglcontext.mm
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoaglcontext.mm')
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.mm41
1 files changed, 15 insertions, 26 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
index c049ca60f2..c2fcb6cdbc 100644
--- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
@@ -45,7 +45,6 @@
#include "qcocoascreen.h"
#include <qdebug.h>
-#include <QtPlatformHeaders/qcocoanativecontext.h>
#include <dlfcn.h>
static inline QByteArray getGlString(GLenum param)
@@ -65,30 +64,23 @@ QCocoaGLContext::QCocoaGLContext(QOpenGLContext *context)
{
}
-void QCocoaGLContext::initialize()
+QCocoaGLContext::QCocoaGLContext(NSOpenGLContext *nativeContext)
+ : QPlatformOpenGLContext()
{
- QVariant nativeHandle = context()->nativeHandle();
- if (!nativeHandle.isNull()) {
- if (!nativeHandle.canConvert<QCocoaNativeContext>()) {
- qCWarning(lcQpaOpenGLContext, "QOpenGLContext native handle must be a QCocoaNativeContext");
- return;
- }
- m_context = nativeHandle.value<QCocoaNativeContext>().context();
- if (!m_context) {
- qCWarning(lcQpaOpenGLContext, "QCocoaNativeContext's NSOpenGLContext cannot be null");
- return;
- }
-
- [m_context retain];
-
- // Note: We have no way of knowing whether the NSOpenGLContext was created with the
- // share context as reported by the QOpenGLContext, but we just have to trust that
- // it was. It's okey, as the only thing we're using it for is to report isShared().
- if (QPlatformOpenGLContext *shareContext = context()->shareHandle())
- m_shareContext = static_cast<QCocoaGLContext *>(shareContext)->nativeContext();
+ m_context = [nativeContext retain];
+}
- updateSurfaceFormat();
- return;
+void QCocoaGLContext::initialize()
+{
+ if (m_context) {
+ // Note: We have no way of knowing whether the NSOpenGLContext was created with the
+ // share context as reported by the QOpenGLContext, but we just have to trust that
+ // it was. It's okey, as the only thing we're using it for is to report isShared().
+ if (QPlatformOpenGLContext *shareContext = context()->shareHandle())
+ m_shareContext = static_cast<QCocoaGLContext *>(shareContext)->nativeContext();
+
+ updateSurfaceFormat();
+ return;
}
// ----------- Default case, we own the NSOpenGLContext -----------
@@ -139,9 +131,6 @@ void QCocoaGLContext::initialize()
return;
}
- // The native handle should reflect the underlying context, even if we created it
- context()->setNativeHandle(QVariant::fromValue<QCocoaNativeContext>(m_context));
-
// --------------------- Set NSOpenGLContext properties ---------------------
const GLint interval = m_format.swapInterval() >= 0 ? m_format.swapInterval() : 1;