summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <[email protected]>2012-05-29 15:23:25 +0200
committerQt by Nokia <[email protected]>2012-06-05 18:48:00 +0200
commite1774d202912b5d053872f242c61d964a5d69450 (patch)
tree2db13710c7d5979e5b49639b9ed5ef3f566a2beb
parent7d28f7772cd8f5aad63359ed0b9c57c12923dc85 (diff)
Verify the surfaceType before activating the GL context
Verify that the surfaceType() of the QPlatformContext is of type OpenGLSurface before making the context active. Make it possible to get the QSurface from a QPlatformSurface, make QPlatformWindow use that to access the QWindow. Remove the setSurfaceType call from the eglfs plugin as this hiding a problem. Change-Id: I08906da052e066bb1f1f042030643c6389ab17d7 Reviewed-by: Samuel Rødal <[email protected]> Reviewed-by: Girish Ramakrishnan <[email protected]>
-rw-r--r--src/gui/kernel/qplatformsurface.h6
-rw-r--r--src/gui/kernel/qplatformsurface_qpa.cpp6
-rw-r--r--src/gui/kernel/qplatformwindow_qpa.cpp16
-rw-r--r--src/platformsupport/eglconvenience/qeglplatformcontext.cpp2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.mm2
-rw-r--r--src/plugins/platforms/kms/qkmscontext.cpp2
-rw-r--r--src/plugins/platforms/openwfd/qopenwfdglcontext.cpp2
-rw-r--r--src/plugins/platforms/qnx/qqnxglcontext.cpp2
-rw-r--r--src/plugins/platforms/windows/qwindowsglcontext.cpp3
-rw-r--r--src/plugins/platforms/xcb/qglxintegration.cpp2
10 files changed, 25 insertions, 18 deletions
diff --git a/src/gui/kernel/qplatformsurface.h b/src/gui/kernel/qplatformsurface.h
index a10ae6f1e55..b902f9b1f61 100644
--- a/src/gui/kernel/qplatformsurface.h
+++ b/src/gui/kernel/qplatformsurface.h
@@ -66,12 +66,12 @@ public:
virtual ~QPlatformSurface();
virtual QSurfaceFormat format() const = 0;
- QSurface::SurfaceClass surfaceClass() const;
+ QSurface *surface() const;
private:
- explicit QPlatformSurface(QSurface::SurfaceClass type);
+ explicit QPlatformSurface(QSurface *surface);
- QSurface::SurfaceClass m_type;
+ QSurface *m_surface;
friend class QPlatformWindow;
};
diff --git a/src/gui/kernel/qplatformsurface_qpa.cpp b/src/gui/kernel/qplatformsurface_qpa.cpp
index 50cdd68ab65..464c971b98c 100644
--- a/src/gui/kernel/qplatformsurface_qpa.cpp
+++ b/src/gui/kernel/qplatformsurface_qpa.cpp
@@ -57,12 +57,12 @@ QPlatformSurface::~QPlatformSurface()
}
-QSurface::SurfaceClass QPlatformSurface::surfaceClass() const
+QSurface *QPlatformSurface::surface() const
{
- return m_type;
+ return m_surface;
}
-QPlatformSurface::QPlatformSurface(QSurface::SurfaceClass type) : m_type(type)
+QPlatformSurface::QPlatformSurface(QSurface *surface) : m_surface(surface)
{
}
diff --git a/src/gui/kernel/qplatformwindow_qpa.cpp b/src/gui/kernel/qplatformwindow_qpa.cpp
index 4e464d78383..01254966f04 100644
--- a/src/gui/kernel/qplatformwindow_qpa.cpp
+++ b/src/gui/kernel/qplatformwindow_qpa.cpp
@@ -49,7 +49,6 @@ QT_BEGIN_NAMESPACE
class QPlatformWindowPrivate
{
- QWindow *window;
QRect rect;
friend class QPlatformWindow;
};
@@ -59,11 +58,10 @@ class QPlatformWindowPrivate
*/
QPlatformWindow::QPlatformWindow(QWindow *window)
- : QPlatformSurface(QSurface::Window)
+ : QPlatformSurface(window)
, d_ptr(new QPlatformWindowPrivate)
{
Q_D(QPlatformWindow);
- d->window = window;
d->rect = window->geometry();
}
@@ -79,8 +77,7 @@ QPlatformWindow::~QPlatformWindow()
*/
QWindow *QPlatformWindow::window() const
{
- Q_D(const QPlatformWindow);
- return d->window;
+ return static_cast<QWindow *>(m_surface);
}
/*!
@@ -88,8 +85,7 @@ QWindow *QPlatformWindow::window() const
*/
QPlatformWindow *QPlatformWindow::parent() const
{
- Q_D(const QPlatformWindow);
- return d->window->parent() ? d->window->parent()->handle() : 0;
+ return window()->parent() ? window()->parent()->handle() : 0;
}
/*!
@@ -97,8 +93,7 @@ QPlatformWindow *QPlatformWindow::parent() const
*/
QPlatformScreen *QPlatformWindow::screen() const
{
- Q_D(const QPlatformWindow);
- return d->window->screen()->handle();
+ return window()->screen()->handle();
}
/*!
@@ -170,8 +165,7 @@ Qt::WindowFlags QPlatformWindow::setWindowFlags(Qt::WindowFlags flags)
bool QPlatformWindow::isExposed() const
{
- Q_D(const QPlatformWindow);
- return d->window->isVisible();
+ return window()->isVisible();
}
/*!
diff --git a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp
index d8ee9962152..2e7baa0e1d6 100644
--- a/src/platformsupport/eglconvenience/qeglplatformcontext.cpp
+++ b/src/platformsupport/eglconvenience/qeglplatformcontext.cpp
@@ -71,6 +71,8 @@ QEGLPlatformContext::QEGLPlatformContext(const QSurfaceFormat &format, QPlatform
bool QEGLPlatformContext::makeCurrent(QPlatformSurface *surface)
{
+ Q_ASSERT(surface->surface()->surfaceType() == QSurface::OpenGLSurface);
+
#ifdef QEGL_EXTRA_DEBUG
qWarning("QEglContext::makeCurrent: %p\n",this);
#endif
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
index 637678c19ec..0292e02ff1d 100644
--- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
@@ -86,6 +86,8 @@ void QCocoaGLContext::swapBuffers(QPlatformSurface *surface)
bool QCocoaGLContext::makeCurrent(QPlatformSurface *surface)
{
+ Q_ASSERT(surface->surface()->surfaceType() == QSurface::OpenGLSurface);
+
QCocoaAutoReleasePool pool;
QWindow *window = static_cast<QCocoaWindow *>(surface)->window();
diff --git a/src/plugins/platforms/kms/qkmscontext.cpp b/src/plugins/platforms/kms/qkmscontext.cpp
index e5fd10af648..85e0edeed70 100644
--- a/src/plugins/platforms/kms/qkmscontext.cpp
+++ b/src/plugins/platforms/kms/qkmscontext.cpp
@@ -80,6 +80,8 @@ bool QKmsContext::isValid() const
bool QKmsContext::makeCurrent(QPlatformSurface *surface)
{
+ Q_ASSERT(surface->surface()->surfaceType() == QSurface::OpenGLSurface);
+
EGLDisplay display = m_device->eglDisplay();
QPlatformWindow *window = static_cast<QPlatformWindow *>(surface);
diff --git a/src/plugins/platforms/openwfd/qopenwfdglcontext.cpp b/src/plugins/platforms/openwfd/qopenwfdglcontext.cpp
index 1304b9aad84..a7a6b11f2c8 100644
--- a/src/plugins/platforms/openwfd/qopenwfdglcontext.cpp
+++ b/src/plugins/platforms/openwfd/qopenwfdglcontext.cpp
@@ -57,6 +57,8 @@ QSurfaceFormat QOpenWFDGLContext::format() const
bool QOpenWFDGLContext::makeCurrent(QPlatformSurface *surface)
{
+ Q_ASSERT(surface->surface()->surfaceType() == QSurface::OpenGLSurface);
+
EGLDisplay display = mWfdDevice->eglDisplay();
EGLContext context = mWfdDevice->eglContext();
if (!eglMakeCurrent(display,EGL_NO_SURFACE,EGL_NO_SURFACE,context)) {
diff --git a/src/plugins/platforms/qnx/qqnxglcontext.cpp b/src/plugins/platforms/qnx/qqnxglcontext.cpp
index 593180019d2..0b030bd5fe0 100644
--- a/src/plugins/platforms/qnx/qqnxglcontext.cpp
+++ b/src/plugins/platforms/qnx/qqnxglcontext.cpp
@@ -205,6 +205,8 @@ bool QQnxGLContext::makeCurrent(QPlatformSurface *surface)
{
qGLContextDebug() << Q_FUNC_INFO;
+ Q_ASSERT(surface->surface()->surfaceType() == QSurface::OpenGLSurface);
+
// Set current rendering API
EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API);
if (eglResult != EGL_TRUE) {
diff --git a/src/plugins/platforms/windows/qwindowsglcontext.cpp b/src/plugins/platforms/windows/qwindowsglcontext.cpp
index 2528ad949f2..cabc5974ebf 100644
--- a/src/plugins/platforms/windows/qwindowsglcontext.cpp
+++ b/src/plugins/platforms/windows/qwindowsglcontext.cpp
@@ -1042,6 +1042,9 @@ bool QWindowsGLContext::makeCurrent(QPlatformSurface *surface)
if (QWindowsContext::verboseGL > 1)
qDebug("%s context=%p contexts=%d", __FUNCTION__, this, m_windowContexts.size());
#endif // DEBUG_GL
+
+ Q_ASSERT(surface->surface()->surfaceType() == QSurface::OpenGLSurface);
+
// Do we already have a DC entry for that window?
QWindowsWindow *window = static_cast<QWindowsWindow *>(surface);
const HWND hwnd = window->handle();
diff --git a/src/plugins/platforms/xcb/qglxintegration.cpp b/src/plugins/platforms/xcb/qglxintegration.cpp
index 0144caae3de..cac7018e47e 100644
--- a/src/plugins/platforms/xcb/qglxintegration.cpp
+++ b/src/plugins/platforms/xcb/qglxintegration.cpp
@@ -103,7 +103,7 @@ QGLXContext::~QGLXContext()
bool QGLXContext::makeCurrent(QPlatformSurface *surface)
{
- Q_ASSERT(surface);
+ Q_ASSERT(surface->surface()->surfaceType() == QSurface::OpenGLSurface);
GLXDrawable glxDrawable = static_cast<QXcbWindow *>(surface)->xcb_window();