summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorSergio Martins <sergio.martins.qnx@kdab.com>2013-02-07 19:59:11 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-02-08 17:24:42 +0100
commitafb216fb47cc3a828513bcf7d279a8d865f44741 (patch)
treee2b05b4c8c87ef077e3f37521082a8d5e32e63ac /src/plugins
parent56b5acb2a858d0eb276ecc06d63caa7275f44dd7 (diff)
QNX: Don't let eglMakeCurrent() fail when using two contexts.
When calling eglMakeCurrent(), egl config and window format must match, otherwise it fails with EGL_BAD_MATCH. egl config and window format were static variables, this could lead to a context setting the window format in the ctor but, at the time of creating a surface, another context had changed the window format. elg config and window format are now member variables. This is the same approach taken in Qt5. Change-Id: I4fa0bc59273b856c1eaf43fafd15b551363f2fe2 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/blackberry/qbbglcontext.cpp31
-rw-r--r--src/plugins/platforms/blackberry/qbbglcontext.h6
2 files changed, 8 insertions, 29 deletions
diff --git a/src/plugins/platforms/blackberry/qbbglcontext.cpp b/src/plugins/platforms/blackberry/qbbglcontext.cpp
index 93930200ec..81ff0161d5 100644
--- a/src/plugins/platforms/blackberry/qbbglcontext.cpp
+++ b/src/plugins/platforms/blackberry/qbbglcontext.cpp
@@ -53,8 +53,6 @@
QT_BEGIN_NAMESPACE
EGLDisplay QBBGLContext::sEglDisplay = EGL_NO_DISPLAY;
-EGLConfig QBBGLContext::sEglConfig = 0;
-QPlatformWindowFormat QBBGLContext::sWindowFormat;
QBBGLContext::QBBGLContext(QBBWindow* platformWindow)
: QPlatformGLContext(),
@@ -127,18 +125,18 @@ QBBGLContext::QBBGLContext(QBBWindow* platformWindow)
format.setBlueBufferSize(blueSize);
// select EGL config based on requested window format
- sEglConfig = q_configFromQPlatformWindowFormat(sEglDisplay, format);
- if (sEglConfig == 0) {
+ mEglConfig = q_configFromQPlatformWindowFormat(sEglDisplay, format);
+ if (mEglConfig == 0) {
qFatal("QBB: failed to find EGL config");
}
- mEglContext = eglCreateContext(sEglDisplay, sEglConfig, EGL_NO_CONTEXT, contextAttrs());
+ mEglContext = eglCreateContext(sEglDisplay, mEglConfig, EGL_NO_CONTEXT, contextAttrs());
if (mEglContext == EGL_NO_CONTEXT) {
qFatal("QBB: failed to create EGL context, err=%d", eglGetError());
}
// query/cache window format of selected EGL config
- sWindowFormat = qt_qPlatformWindowFormatFromConfig(sEglDisplay, sEglConfig);
+ mWindowFormat = qt_qPlatformWindowFormatFromConfig(sEglDisplay, mEglConfig);
}
QBBGLContext::~QBBGLContext()
@@ -175,25 +173,6 @@ void QBBGLContext::initialize()
#else
EGLint renderableType = EGL_OPENGL_ES_BIT;
#endif
-
- // get EGL config compatible with window
- EGLint numConfig;
- EGLint configAttrs[] = { EGL_BUFFER_SIZE, 32,
- EGL_ALPHA_SIZE, 8,
- EGL_RED_SIZE, 8,
- EGL_GREEN_SIZE, 8,
- EGL_BLUE_SIZE, 8,
- EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
- EGL_RENDERABLE_TYPE, renderableType,
- EGL_NONE };
- eglResult = eglChooseConfig(sEglDisplay, configAttrs, &sEglConfig, 1, &numConfig);
- if (eglResult != EGL_TRUE || numConfig == 0) {
- qFatal("QBB: failed to find EGL config, err=%d, numConfig=%d", eglGetError(), numConfig);
- }
-
- // query/cache window format
- sWindowFormat = qt_qPlatformWindowFormatFromConfig(sEglDisplay, sEglConfig);
- sWindowFormat.setWindowApi(QPlatformWindowFormat::OpenGL);
}
void QBBGLContext::shutdown()
@@ -344,7 +323,7 @@ void QBBGLContext::createSurface()
#endif
// create EGL surface
- mEglSurface = eglCreateWindowSurface(sEglDisplay, sEglConfig, (EGLNativeWindowType)mPlatformWindow->winId(), NULL);
+ mEglSurface = eglCreateWindowSurface(sEglDisplay, mEglConfig, (EGLNativeWindowType)mPlatformWindow->winId(), NULL);
if (mEglSurface == EGL_NO_SURFACE) {
qFatal("QBB: failed to create EGL surface, err=%d", eglGetError());
}
diff --git a/src/plugins/platforms/blackberry/qbbglcontext.h b/src/plugins/platforms/blackberry/qbbglcontext.h
index 6a93c1f1ac..73825e97ff 100644
--- a/src/plugins/platforms/blackberry/qbbglcontext.h
+++ b/src/plugins/platforms/blackberry/qbbglcontext.h
@@ -66,16 +66,16 @@ public:
virtual void swapBuffers();
virtual void* getProcAddress(const QString& procName);
- virtual QPlatformWindowFormat platformWindowFormat() const { return sWindowFormat; }
+ virtual QPlatformWindowFormat platformWindowFormat() const { return mWindowFormat; }
void resizeSurface(const QSize &size);
QSize surfaceSize() const { return mSurfaceSize; }
private:
static EGLDisplay sEglDisplay;
- static EGLConfig sEglConfig;
- static QPlatformWindowFormat sWindowFormat;
+ QPlatformWindowFormat mWindowFormat;
+ EGLConfig mEglConfig;
QBBWindow *mPlatformWindow;
EGLContext mEglContext;
EGLSurface mEglSurface;