diff options
author | Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com> | 2012-06-06 13:57:09 -0700 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-12 04:29:49 +0200 |
commit | e9df01d3db83ec4ba64c99c92495e6dd0e201420 (patch) | |
tree | 11ed60d01ae457b676d9be854762c58b9b178da3 /src/plugins/platforms/eglfs/qeglfswindow.cpp | |
parent | 040f30decd24c32f71f14eeaed5fdcd58b2dce3d (diff) |
eglfs refactor: move window creation into qeglfswindow
This potentially allows the creation of multiple QWindows. The platform
context is now in a seperate file and the integration provides a new
instance of the context allowing creation of multiple contexts.
Change-Id: If2b6fa29b573d87c0a4cd0a8eff1f044bd1ff9b8
Reviewed-by: Girish Ramakrishnan <girish.1.ramakrishnan@nokia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src/plugins/platforms/eglfs/qeglfswindow.cpp')
-rw-r--r-- | src/plugins/platforms/eglfs/qeglfswindow.cpp | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/src/plugins/platforms/eglfs/qeglfswindow.cpp b/src/plugins/platforms/eglfs/qeglfswindow.cpp index 379150cfa6..5e6d09a637 100644 --- a/src/plugins/platforms/eglfs/qeglfswindow.cpp +++ b/src/plugins/platforms/eglfs/qeglfswindow.cpp @@ -40,13 +40,19 @@ ****************************************************************************/ #include "qeglfswindow.h" - +#include "qeglfshooks.h" #include <QtGui/QWindowSystemInterface> +#include <QtPlatformSupport/private/qeglconvenience_p.h> + +#include <QtDebug> + QT_BEGIN_NAMESPACE QEglFSWindow::QEglFSWindow(QWindow *w) : QPlatformWindow(w) + , m_surface(0) + , m_window(0) { static int serialNo = 0; m_winid = ++serialNo; @@ -57,6 +63,43 @@ QEglFSWindow::QEglFSWindow(QWindow *w) setWindowState(Qt::WindowFullScreen); } +QEglFSWindow::~QEglFSWindow() +{ + destroy(); +} + +void QEglFSWindow::create() +{ + if (m_window) { + return; + } + + EGLDisplay display = (static_cast<QEglFSScreen *>(window()->screen()->handle()))->display(); + QSurfaceFormat platformFormat = hooks->defaultSurfaceFormat(); + EGLConfig config = q_configFromGLFormat(display, platformFormat); + m_window = hooks->createNativeWindow(hooks->screenSize()); + m_surface = eglCreateWindowSurface(display, config, m_window, NULL); + if (m_surface == EGL_NO_SURFACE) { + qWarning("Could not create the egl surface: error = 0x%x\n", eglGetError()); + eglTerminate(display); + qFatal("EGL error"); + } +} + +void QEglFSWindow::destroy() +{ + if (m_surface) { + EGLDisplay display = (static_cast<QEglFSScreen *>(window()->screen()->handle()))->display(); + eglDestroySurface(display, m_surface); + m_surface = 0; + } + + if (m_window) { + hooks->destroyNativeWindow(m_window); + m_window = 0; + } +} + void QEglFSWindow::setGeometry(const QRect &) { // We only support full-screen windows @@ -77,4 +120,9 @@ WId QEglFSWindow::winId() const return m_winid; } +QSurfaceFormat QEglFSWindow::format() const +{ + return hooks->defaultSurfaceFormat(); +} + QT_END_NAMESPACE |