Move QQnxGLContext::ms_eglDisplay to the integration object
In part, this is a continuation of https://codereview.qt-project.org/c/qt/qtbase/+/227953. It also paves the way toward implementing the EglDisplay integration resource needed by QtWayland. For the code that's being moved around and modified, switch from !QT_NO_OPENGL to QT_CONFIG(opengl). Change-Id: I5046e8caf5df7cf326f8e697d7d41cf802250414 Reviewed-by: Dan Cape <dcape@qnx.com> Reviewed-by: Samuli Piippo <samuli.piippo@qt.io>bb10
parent
318a991907
commit
e076965542
|
|
@ -58,8 +58,6 @@
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
EGLDisplay QQnxGLContext::ms_eglDisplay = EGL_NO_DISPLAY;
|
||||
|
||||
static QEGLPlatformContext::Flags makeFlags()
|
||||
{
|
||||
QEGLPlatformContext::Flags result = 0;
|
||||
|
|
@ -71,7 +69,8 @@ static QEGLPlatformContext::Flags makeFlags()
|
|||
}
|
||||
|
||||
QQnxGLContext::QQnxGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share)
|
||||
: QEGLPlatformContext(format, share, ms_eglDisplay, 0, QVariant(), makeFlags())
|
||||
: QEGLPlatformContext(format, share, QQnxIntegration::instance()->eglDisplay(), 0, QVariant(),
|
||||
makeFlags())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -79,28 +78,6 @@ QQnxGLContext::~QQnxGLContext()
|
|||
{
|
||||
}
|
||||
|
||||
void QQnxGLContext::initializeContext()
|
||||
{
|
||||
qGLContextDebug();
|
||||
|
||||
// Initialize connection to EGL
|
||||
ms_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
if (Q_UNLIKELY(ms_eglDisplay == EGL_NO_DISPLAY))
|
||||
qFatal("QQnxGLContext: failed to obtain EGL display: %x", eglGetError());
|
||||
|
||||
EGLBoolean eglResult = eglInitialize(ms_eglDisplay, 0, 0);
|
||||
if (Q_UNLIKELY(eglResult != EGL_TRUE))
|
||||
qFatal("QQnxGLContext: failed to initialize EGL display, err=%d", eglGetError());
|
||||
}
|
||||
|
||||
void QQnxGLContext::shutdownContext()
|
||||
{
|
||||
qGLContextDebug();
|
||||
|
||||
// Close connection to EGL
|
||||
eglTerminate(ms_eglDisplay);
|
||||
}
|
||||
|
||||
EGLSurface QQnxGLContext::eglSurfaceForPlatformSurface(QPlatformSurface *surface)
|
||||
{
|
||||
QQnxEglWindow *window = static_cast<QQnxEglWindow *>(surface);
|
||||
|
|
|
|||
|
|
@ -58,19 +58,12 @@ public:
|
|||
QQnxGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share);
|
||||
virtual ~QQnxGLContext();
|
||||
|
||||
static void initializeContext();
|
||||
static void shutdownContext();
|
||||
|
||||
bool makeCurrent(QPlatformSurface *surface) override;
|
||||
void swapBuffers(QPlatformSurface *surface) override;
|
||||
void doneCurrent() override;
|
||||
|
||||
protected:
|
||||
EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) override;
|
||||
|
||||
private:
|
||||
//Can be static because different displays returne the same handle
|
||||
static EGLDisplay ms_eglDisplay;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -170,6 +170,9 @@ QQnxIntegration::QQnxIntegration(const QStringList ¶mList)
|
|||
#if QT_CONFIG(draganddrop)
|
||||
, m_drag(new QSimpleDrag())
|
||||
#endif
|
||||
#if QT_CONFIG(opengl)
|
||||
, m_eglDisplay(EGL_NO_DISPLAY)
|
||||
#endif
|
||||
{
|
||||
ms_instance = this;
|
||||
m_options = parseOptions(paramList);
|
||||
|
|
@ -195,9 +198,8 @@ QQnxIntegration::QQnxIntegration(const QStringList ¶mList)
|
|||
QMetaObject::invokeMethod(m_navigatorEventNotifier, "start", Qt::QueuedConnection);
|
||||
#endif
|
||||
|
||||
#if !defined(QT_NO_OPENGL)
|
||||
// Initialize global OpenGL resources
|
||||
QQnxGLContext::initializeContext();
|
||||
#if QT_CONFIG(opengl)
|
||||
createEglDisplay();
|
||||
#endif
|
||||
|
||||
// Create/start event thread
|
||||
|
|
@ -284,9 +286,8 @@ QQnxIntegration::~QQnxIntegration()
|
|||
// Close connection to QNX composition manager
|
||||
screen_destroy_context(m_screenContext);
|
||||
|
||||
#if !defined(QT_NO_OPENGL)
|
||||
// Cleanup global OpenGL resources
|
||||
QQnxGLContext::shutdownContext();
|
||||
#if QT_CONFIG(opengl)
|
||||
destroyEglDisplay();
|
||||
#endif
|
||||
|
||||
#if QT_CONFIG(qqnx_pps)
|
||||
|
|
@ -741,4 +742,28 @@ bool QQnxIntegration::supportsNavigatorEvents() const
|
|||
return m_navigator != 0;
|
||||
}
|
||||
|
||||
#if QT_CONFIG(opengl)
|
||||
void QQnxIntegration::createEglDisplay()
|
||||
{
|
||||
qIntegrationDebug();
|
||||
|
||||
// Initialize connection to EGL
|
||||
m_eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
if (Q_UNLIKELY(m_eglDisplay == EGL_NO_DISPLAY))
|
||||
qFatal("QQnxiIntegration: failed to obtain EGL display: %x", eglGetError());
|
||||
|
||||
EGLBoolean eglResult = eglInitialize(m_eglDisplay, 0, 0);
|
||||
if (Q_UNLIKELY(eglResult != EGL_TRUE))
|
||||
qFatal("QQnxIntegration: failed to initialize EGL display, err=%d", eglGetError());
|
||||
}
|
||||
|
||||
void QQnxIntegration::destroyEglDisplay()
|
||||
{
|
||||
qIntegrationDebug();
|
||||
|
||||
// Close connection to EGL
|
||||
eglTerminate(m_eglDisplay);
|
||||
}
|
||||
#endif
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -46,6 +46,10 @@
|
|||
|
||||
#include <screen/screen.h>
|
||||
|
||||
#if QT_CONFIG(opengl)
|
||||
#include <EGL/egl.h>
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QQnxScreenEventThread;
|
||||
|
|
@ -96,7 +100,8 @@ public:
|
|||
QPlatformWindow *createPlatformWindow(QWindow *window) const override;
|
||||
QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const override;
|
||||
|
||||
#if !defined(QT_NO_OPENGL)
|
||||
#if QT_CONFIG(opengl)
|
||||
EGLDisplay eglDisplay() const { return m_eglDisplay; }
|
||||
QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const override;
|
||||
#endif
|
||||
|
||||
|
|
@ -175,6 +180,12 @@ private:
|
|||
|
||||
Options m_options;
|
||||
|
||||
#if QT_CONFIG(opengl)
|
||||
EGLDisplay m_eglDisplay;
|
||||
void createEglDisplay();
|
||||
void destroyEglDisplay();
|
||||
#endif
|
||||
|
||||
static QQnxIntegration *ms_instance;
|
||||
|
||||
friend class QQnxWindow;
|
||||
|
|
|
|||
Loading…
Reference in New Issue