macOS: Disambiguate use of native handles in QCocoaGLContext
We only need the QVariant native handle when creating the context, so there's no need for a getter, and we then rename the NSOpenGLContext getter to match e.g. QCocoaScreen::nativeScreen(). Change-Id: I041e0eff39af9c8836d8ecd560ea07e92dc63e03 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io>
This commit is contained in:
parent
fed7876e20
commit
881078d7b5
@ -67,8 +67,7 @@ public:
|
|||||||
|
|
||||||
void windowWasHidden();
|
void windowWasHidden();
|
||||||
|
|
||||||
NSOpenGLContext *nsOpenGLContext() const;
|
NSOpenGLContext *nativeContext() const;
|
||||||
QVariant nativeHandle() const;
|
|
||||||
|
|
||||||
QFunctionPointer getProcAddress(const char *procName) override;
|
QFunctionPointer getProcAddress(const char *procName) override;
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ QCocoaGLContext::QCocoaGLContext(const QSurfaceFormat &format, QPlatformOpenGLCo
|
|||||||
}
|
}
|
||||||
m_context = context;
|
m_context = context;
|
||||||
[m_context retain];
|
[m_context retain];
|
||||||
m_shareContext = share ? static_cast<QCocoaGLContext *>(share)->nsOpenGLContext() : nil;
|
m_shareContext = share ? static_cast<QCocoaGLContext *>(share)->nativeContext() : nil;
|
||||||
updateSurfaceFormat();
|
updateSurfaceFormat();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ QCocoaGLContext::QCocoaGLContext(const QSurfaceFormat &format, QPlatformOpenGLCo
|
|||||||
if (m_format.renderableType() != QSurfaceFormat::OpenGL)
|
if (m_format.renderableType() != QSurfaceFormat::OpenGL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_shareContext = share ? static_cast<QCocoaGLContext *>(share)->nsOpenGLContext() : nil;
|
m_shareContext = share ? static_cast<QCocoaGLContext *>(share)->nativeContext() : nil;
|
||||||
|
|
||||||
if (m_shareContext) {
|
if (m_shareContext) {
|
||||||
// Allow sharing between 3.2 Core and 4.1 Core profile versions in
|
// Allow sharing between 3.2 Core and 4.1 Core profile versions in
|
||||||
@ -468,16 +468,11 @@ bool QCocoaGLContext::isSharing() const
|
|||||||
return m_shareContext != nil;
|
return m_shareContext != nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSOpenGLContext *QCocoaGLContext::nsOpenGLContext() const
|
NSOpenGLContext *QCocoaGLContext::nativeContext() const
|
||||||
{
|
{
|
||||||
return m_context;
|
return m_context;
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant QCocoaGLContext::nativeHandle() const
|
|
||||||
{
|
|
||||||
return QVariant::fromValue<QCocoaNativeContext>(QCocoaNativeContext(m_context));
|
|
||||||
}
|
|
||||||
|
|
||||||
QFunctionPointer QCocoaGLContext::getProcAddress(const char *procName)
|
QFunctionPointer QCocoaGLContext::getProcAddress(const char *procName)
|
||||||
{
|
{
|
||||||
return (QFunctionPointer)dlsym(RTLD_DEFAULT, procName);
|
return (QFunctionPointer)dlsym(RTLD_DEFAULT, procName);
|
||||||
|
@ -59,6 +59,8 @@
|
|||||||
#include <qpa/qplatformoffscreensurface.h>
|
#include <qpa/qplatformoffscreensurface.h>
|
||||||
#include <QtCore/qcoreapplication.h>
|
#include <QtCore/qcoreapplication.h>
|
||||||
|
|
||||||
|
#include <QtPlatformHeaders/qcocoanativecontext.h>
|
||||||
|
|
||||||
#include <QtGui/private/qcoregraphics_p.h>
|
#include <QtGui/private/qcoregraphics_p.h>
|
||||||
|
|
||||||
#ifdef QT_WIDGETS_LIB
|
#ifdef QT_WIDGETS_LIB
|
||||||
@ -361,7 +363,7 @@ QPlatformOpenGLContext *QCocoaIntegration::createPlatformOpenGLContext(QOpenGLCo
|
|||||||
QCocoaGLContext *glContext = new QCocoaGLContext(context->format(),
|
QCocoaGLContext *glContext = new QCocoaGLContext(context->format(),
|
||||||
context->shareHandle(),
|
context->shareHandle(),
|
||||||
context->nativeHandle());
|
context->nativeHandle());
|
||||||
context->setNativeHandle(glContext->nativeHandle());
|
context->setNativeHandle(QVariant::fromValue<QCocoaNativeContext>(glContext->nativeContext()));
|
||||||
return glContext;
|
return glContext;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -104,7 +104,7 @@ void *QCocoaNativeInterface::nativeResourceForWindow(const QByteArray &resourceS
|
|||||||
return static_cast<QCocoaWindow *>(window->handle())->m_view;
|
return static_cast<QCocoaWindow *>(window->handle())->m_view;
|
||||||
#ifndef QT_NO_OPENGL
|
#ifndef QT_NO_OPENGL
|
||||||
} else if (resourceString == "nsopenglcontext") {
|
} else if (resourceString == "nsopenglcontext") {
|
||||||
return static_cast<QCocoaWindow *>(window->handle())->currentContext()->nsOpenGLContext();
|
return static_cast<QCocoaWindow *>(window->handle())->currentContext()->nativeContext();
|
||||||
#endif
|
#endif
|
||||||
} else if (resourceString == "nswindow") {
|
} else if (resourceString == "nswindow") {
|
||||||
return static_cast<QCocoaWindow *>(window->handle())->nativeWindow();
|
return static_cast<QCocoaWindow *>(window->handle())->nativeWindow();
|
||||||
@ -228,10 +228,8 @@ void *QCocoaNativeInterface::cglContextForContext(QOpenGLContext* context)
|
|||||||
void *QCocoaNativeInterface::nsOpenGLContextForContext(QOpenGLContext* context)
|
void *QCocoaNativeInterface::nsOpenGLContextForContext(QOpenGLContext* context)
|
||||||
{
|
{
|
||||||
if (context) {
|
if (context) {
|
||||||
QCocoaGLContext *cocoaGLContext = static_cast<QCocoaGLContext *>(context->handle());
|
if (QCocoaGLContext *cocoaGLContext = static_cast<QCocoaGLContext *>(context->handle()))
|
||||||
if (cocoaGLContext) {
|
return cocoaGLContext->nativeContext();
|
||||||
return cocoaGLContext->nsOpenGLContext();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user