summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/minimalegl
diff options
context:
space:
mode:
authorGirish Ramakrishnan <girish.1.ramakrishnan@nokia.com>2012-05-27 09:27:57 -0700
committerQt by Nokia <qt-info@nokia.com>2012-05-30 08:30:42 +0200
commit0cb7dac534049ebda607a9a2cdde2f7c7d9533c2 (patch)
tree7944e3c430ee527be02c1d37180247aa6e828cf5 /src/plugins/platforms/minimalegl
parent9e424adbdddc172ed63ee22995ba4bcc56bef0ce (diff)
Add minimalegl QPA platform plugin
The EGLFS platform plugin was originally meant to be an example and thus to be kept simple. However, EGLFS is becoming more and more complex with the addition of hooks for board support, cursor integration, built-in evdev support etc. minimalegl is a new platform plugin that intends to follow the original intentions of EGLFS. The code is an adaptation of EGLFS as of f913859f8 Change-Id: I3d4cf84cde380cdcc7e0e8bfefff4df6be731b8d Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
Diffstat (limited to 'src/plugins/platforms/minimalegl')
-rw-r--r--src/plugins/platforms/minimalegl/main.cpp74
-rw-r--r--src/plugins/platforms/minimalegl/minimalegl.json3
-rw-r--r--src/plugins/platforms/minimalegl/minimalegl.pro32
-rw-r--r--src/plugins/platforms/minimalegl/qminimaleglbackingstore.cpp100
-rw-r--r--src/plugins/platforms/minimalegl/qminimaleglbackingstore.h73
-rw-r--r--src/plugins/platforms/minimalegl/qminimaleglintegration.cpp126
-rw-r--r--src/plugins/platforms/minimalegl/qminimaleglintegration.h80
-rw-r--r--src/plugins/platforms/minimalegl/qminimaleglscreen.cpp216
-rw-r--r--src/plugins/platforms/minimalegl/qminimaleglscreen.h82
-rw-r--r--src/plugins/platforms/minimalegl/qminimaleglwindow.cpp77
-rw-r--r--src/plugins/platforms/minimalegl/qminimaleglwindow.h65
11 files changed, 928 insertions, 0 deletions
diff --git a/src/plugins/platforms/minimalegl/main.cpp b/src/plugins/platforms/minimalegl/main.cpp
new file mode 100644
index 0000000000..33098f1788
--- /dev/null
+++ b/src/plugins/platforms/minimalegl/main.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qpa/qplatformintegrationplugin.h>
+#include "qminimaleglintegration.h"
+
+QT_BEGIN_NAMESPACE
+
+class QMinimalEglIntegrationPlugin : public QPlatformIntegrationPlugin
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QPlatformIntegrationFactoryInterface" FILE "minimalegl.json")
+public:
+ QStringList keys() const;
+ QPlatformIntegration *create(const QString&, const QStringList&);
+};
+
+QStringList QMinimalEglIntegrationPlugin::keys() const
+{
+ QStringList list;
+ list << "MinimalEgl";
+ return list;
+}
+
+QPlatformIntegration* QMinimalEglIntegrationPlugin::create(const QString& system, const QStringList& paramList)
+{
+ Q_UNUSED(paramList);
+ if (system.toLower() == "minimalegl")
+ return new QMinimalEglIntegration;
+
+ return 0;
+}
+
+QT_END_NAMESPACE
+
+#include "main.moc"
diff --git a/src/plugins/platforms/minimalegl/minimalegl.json b/src/plugins/platforms/minimalegl/minimalegl.json
new file mode 100644
index 0000000000..d2e32be518
--- /dev/null
+++ b/src/plugins/platforms/minimalegl/minimalegl.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "minimalegl" ]
+}
diff --git a/src/plugins/platforms/minimalegl/minimalegl.pro b/src/plugins/platforms/minimalegl/minimalegl.pro
new file mode 100644
index 0000000000..22e3729ed7
--- /dev/null
+++ b/src/plugins/platforms/minimalegl/minimalegl.pro
@@ -0,0 +1,32 @@
+TARGET = qminimalegl
+load(qt_plugin)
+
+QT += core-private gui-private platformsupport-private
+
+DESTDIR = $$QT.gui.plugins/platforms
+
+#DEFINES += QEGL_EXTRA_DEBUG
+
+#DEFINES += Q_OPENKODE
+
+#Avoid X11 header collision
+DEFINES += MESA_EGL_NO_X11_HEADERS
+
+SOURCES = main.cpp \
+ qminimaleglintegration.cpp \
+ qminimaleglwindow.cpp \
+ qminimaleglbackingstore.cpp \
+ qminimaleglscreen.cpp
+
+HEADERS = qminimaleglintegration.h \
+ qminimaleglwindow.h \
+ qminimaleglbackingstore.h \
+ qminimaleglscreen.h
+
+CONFIG += egl qpa/genericunixfontdatabase
+
+target.path += $$[QT_INSTALL_PLUGINS]/platforms
+INSTALLS += target
+
+OTHER_FILES += \
+ minimalegl.json
diff --git a/src/plugins/platforms/minimalegl/qminimaleglbackingstore.cpp b/src/plugins/platforms/minimalegl/qminimaleglbackingstore.cpp
new file mode 100644
index 0000000000..7d96381095
--- /dev/null
+++ b/src/plugins/platforms/minimalegl/qminimaleglbackingstore.cpp
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qminimaleglbackingstore.h"
+
+#include <QtGui/QOpenGLContext>
+#include <QtGui/QOpenGLPaintDevice>
+
+QT_BEGIN_NAMESPACE
+
+QMinimalEglBackingStore::QMinimalEglBackingStore(QWindow *window)
+ : QPlatformBackingStore(window)
+ , m_context(new QOpenGLContext)
+{
+ m_context->setFormat(window->requestedFormat());
+ m_context->setScreen(window->screen());
+ m_context->create();
+}
+
+QMinimalEglBackingStore::~QMinimalEglBackingStore()
+{
+ delete m_context;
+}
+
+QPaintDevice *QMinimalEglBackingStore::paintDevice()
+{
+ return m_device;
+}
+
+void QMinimalEglBackingStore::flush(QWindow *window, const QRegion &region, const QPoint &offset)
+{
+ Q_UNUSED(region);
+ Q_UNUSED(offset);
+
+#ifdef QEGL_EXTRA_DEBUG
+ qWarning("QEglBackingStore::flush %p", window);
+#endif
+
+ m_context->swapBuffers(window);
+}
+
+void QMinimalEglBackingStore::beginPaint(const QRegion &)
+{
+ // needed to prevent QOpenGLContext::makeCurrent() from failing
+ window()->setSurfaceType(QSurface::OpenGLSurface);
+
+ m_context->makeCurrent(window());
+ m_device = new QOpenGLPaintDevice(window()->size());
+}
+
+void QMinimalEglBackingStore::endPaint()
+{
+ delete m_device;
+}
+
+void QMinimalEglBackingStore::resize(const QSize &size, const QRegion &staticContents)
+{
+ Q_UNUSED(size);
+ Q_UNUSED(staticContents);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/minimalegl/qminimaleglbackingstore.h b/src/plugins/platforms/minimalegl/qminimaleglbackingstore.h
new file mode 100644
index 0000000000..40acbe539a
--- /dev/null
+++ b/src/plugins/platforms/minimalegl/qminimaleglbackingstore.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMINIMALEGLBACKINGSTORE_H
+#define QMINIMALEGLBACKINGSTORE_H
+
+#include <qpa/qplatformbackingstore.h>
+
+QT_BEGIN_NAMESPACE
+
+class QOpenGLContext;
+class QOpenGLPaintDevice;
+
+class QMinimalEglBackingStore : public QPlatformBackingStore
+{
+public:
+ QMinimalEglBackingStore(QWindow *window);
+ ~QMinimalEglBackingStore();
+
+ QPaintDevice *paintDevice();
+
+ void beginPaint(const QRegion &);
+ void endPaint();
+
+ void flush(QWindow *window, const QRegion &region, const QPoint &offset);
+ void resize(const QSize &size, const QRegion &staticContents);
+
+private:
+ QOpenGLContext *m_context;
+ QOpenGLPaintDevice *m_device;
+};
+
+QT_END_NAMESPACE
+
+#endif // QMINIMALEGLBACKINGSTORE_H
diff --git a/src/plugins/platforms/minimalegl/qminimaleglintegration.cpp b/src/plugins/platforms/minimalegl/qminimaleglintegration.cpp
new file mode 100644
index 0000000000..d4e44e58b1
--- /dev/null
+++ b/src/plugins/platforms/minimalegl/qminimaleglintegration.cpp
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qminimaleglintegration.h"
+
+#include "qminimaleglwindow.h"
+#include "qminimaleglbackingstore.h"
+
+#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
+#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
+
+#include <qpa/qplatformwindow.h>
+#include <QtGui/QSurfaceFormat>
+#include <QtGui/QOpenGLContext>
+#include <QtGui/QScreen>
+
+#include <EGL/egl.h>
+
+QT_BEGIN_NAMESPACE
+
+QMinimalEglIntegration::QMinimalEglIntegration()
+ : mFontDb(new QGenericUnixFontDatabase()), mScreen(new QMinimalEglScreen(EGL_DEFAULT_DISPLAY))
+{
+ screenAdded(mScreen);
+
+#ifdef QEGL_EXTRA_DEBUG
+ qWarning("QMinimalEglIntegration\n");
+#endif
+}
+
+QMinimalEglIntegration::~QMinimalEglIntegration()
+{
+ delete mScreen;
+}
+
+bool QMinimalEglIntegration::hasCapability(QPlatformIntegration::Capability cap) const
+{
+ switch (cap) {
+ case ThreadedPixmaps: return true;
+ case OpenGL: return true;
+ case ThreadedOpenGL: return true;
+ default: return QPlatformIntegration::hasCapability(cap);
+ }
+}
+
+QPlatformWindow *QMinimalEglIntegration::createPlatformWindow(QWindow *window) const
+{
+#ifdef QEGL_EXTRA_DEBUG
+ qWarning("QMinimalEglIntegration::createPlatformWindow %p\n",window);
+#endif
+ QPlatformWindow *w = new QMinimalEglWindow(window);
+ w->requestActivateWindow();
+ return w;
+}
+
+
+QPlatformBackingStore *QMinimalEglIntegration::createPlatformBackingStore(QWindow *window) const
+{
+#ifdef QEGL_EXTRA_DEBUG
+ qWarning("QMinimalEglIntegration::createWindowSurface %p\n", window);
+#endif
+ return new QMinimalEglBackingStore(window);
+}
+
+QPlatformOpenGLContext *QMinimalEglIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
+{
+ return static_cast<QMinimalEglScreen *>(context->screen()->handle())->platformContext();
+}
+
+QPlatformFontDatabase *QMinimalEglIntegration::fontDatabase() const
+{
+ return mFontDb;
+}
+
+QAbstractEventDispatcher *QMinimalEglIntegration::guiThreadEventDispatcher() const
+{
+ return createUnixEventDispatcher();
+}
+
+QVariant QMinimalEglIntegration::styleHint(QPlatformIntegration::StyleHint hint) const
+{
+ if (hint == QPlatformIntegration::ShowIsFullScreen)
+ return true;
+
+ return QPlatformIntegration::styleHint(hint);
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/minimalegl/qminimaleglintegration.h b/src/plugins/platforms/minimalegl/qminimaleglintegration.h
new file mode 100644
index 0000000000..7136e1b35f
--- /dev/null
+++ b/src/plugins/platforms/minimalegl/qminimaleglintegration.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMINIMALEGLINTEGRATION_H
+#define QMINIMALEGLINTEGRATION_H
+
+#include "qminimaleglscreen.h"
+
+#include <qpa/qplatformintegration.h>
+#include <qpa/qplatformscreen.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QMinimalEglIntegration : public QPlatformIntegration
+{
+public:
+ QMinimalEglIntegration();
+ ~QMinimalEglIntegration();
+
+ bool hasCapability(QPlatformIntegration::Capability cap) const;
+
+ QPlatformWindow *createPlatformWindow(QWindow *window) const;
+ QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const;
+ QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const;
+
+ QPlatformFontDatabase *fontDatabase() const;
+
+ QAbstractEventDispatcher *guiThreadEventDispatcher() const;
+
+ QVariant styleHint(QPlatformIntegration::StyleHint hint) const;
+
+private:
+ QPlatformFontDatabase *mFontDb;
+ QPlatformScreen *mScreen;
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+
+#endif // QMINIMALEGLINTEGRATION_H
diff --git a/src/plugins/platforms/minimalegl/qminimaleglscreen.cpp b/src/plugins/platforms/minimalegl/qminimaleglscreen.cpp
new file mode 100644
index 0000000000..ff1617d538
--- /dev/null
+++ b/src/plugins/platforms/minimalegl/qminimaleglscreen.cpp
@@ -0,0 +1,216 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qminimaleglscreen.h"
+#include "qminimaleglwindow.h"
+
+#include <QtPlatformSupport/private/qeglconvenience_p.h>
+#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
+
+#ifdef Q_OPENKODE
+#include <KD/kd.h>
+#include <KD/NV_initialize.h>
+#endif //Q_OPENKODE
+
+QT_BEGIN_NAMESPACE
+
+// #define QEGL_EXTRA_DEBUG
+
+class QMinimalEglContext : public QEGLPlatformContext
+{
+public:
+ QMinimalEglContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display,
+ EGLenum eglApi = EGL_OPENGL_ES_API)
+ : QEGLPlatformContext(format, share, display, eglApi)
+ {
+ }
+
+ EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface)
+ {
+ QMinimalEglWindow *window = static_cast<QMinimalEglWindow *>(surface);
+ QMinimalEglScreen *screen = static_cast<QMinimalEglScreen *>(window->screen());
+ return screen->surface();
+ }
+};
+
+QMinimalEglScreen::QMinimalEglScreen(EGLNativeDisplayType display)
+ : m_depth(32)
+ , m_format(QImage::Format_Invalid)
+ , m_platformContext(0)
+ , m_surface(0)
+{
+#ifdef QEGL_EXTRA_DEBUG
+ qWarning("QEglScreen %p\n", this);
+#endif
+
+ EGLint major, minor;
+
+ if (!eglBindAPI(EGL_OPENGL_ES_API)) {
+ qWarning("Could not bind GL_ES API\n");
+ qFatal("EGL error");
+ }
+
+ m_dpy = eglGetDisplay(display);
+ if (m_dpy == EGL_NO_DISPLAY) {
+ qWarning("Could not open egl display\n");
+ qFatal("EGL error");
+ }
+ qWarning("Opened display %p\n", m_dpy);
+
+ if (!eglInitialize(m_dpy, &major, &minor)) {
+ qWarning("Could not initialize egl display\n");
+ qFatal("EGL error");
+ }
+
+ qWarning("Initialized display %d %d\n", major, minor);
+
+ int swapInterval = 1;
+ QByteArray swapIntervalString = qgetenv("QT_QPA_EGLFS_SWAPINTERVAL");
+ if (!swapIntervalString.isEmpty()) {
+ bool ok;
+ swapInterval = swapIntervalString.toInt(&ok);
+ if (!ok)
+ swapInterval = 1;
+ }
+ eglSwapInterval(m_dpy, swapInterval);
+}
+
+QMinimalEglScreen::~QMinimalEglScreen()
+{
+ if (m_surface)
+ eglDestroySurface(m_dpy, m_surface);
+
+ eglTerminate(m_dpy);
+}
+
+void QMinimalEglScreen::createAndSetPlatformContext() const {
+ const_cast<QMinimalEglScreen *>(this)->createAndSetPlatformContext();
+}
+
+void QMinimalEglScreen::createAndSetPlatformContext()
+{
+ QSurfaceFormat platformFormat;
+
+ QByteArray depthString = qgetenv("QT_QPA_EGLFS_DEPTH");
+ if (depthString.toInt() == 16) {
+ platformFormat.setDepthBufferSize(16);
+ platformFormat.setRedBufferSize(5);
+ platformFormat.setGreenBufferSize(6);
+ platformFormat.setBlueBufferSize(5);
+ m_depth = 16;
+ m_format = QImage::Format_RGB16;
+ } else {
+ platformFormat.setDepthBufferSize(24);
+ platformFormat.setStencilBufferSize(8);
+ platformFormat.setRedBufferSize(8);
+ platformFormat.setGreenBufferSize(8);
+ platformFormat.setBlueBufferSize(8);
+ m_depth = 32;
+ m_format = QImage::Format_RGB32;
+ }
+
+ if (!qgetenv("QT_QPA_EGLFS_MULTISAMPLE").isEmpty())
+ platformFormat.setSamples(4);
+
+ EGLConfig config = q_configFromGLFormat(m_dpy, platformFormat);
+
+ EGLNativeWindowType eglWindow = 0;
+#ifdef Q_OPENKODE
+ if (kdInitializeNV() == KD_ENOTINITIALIZED) {
+ qFatal("Did not manage to initialize openkode");
+ }
+ KDWindow *window = kdCreateWindow(m_dpy,config,0);
+
+ kdRealizeWindow(window,&eglWindow);
+#endif
+
+#ifdef QEGL_EXTRA_DEBUG
+ q_printEglConfig(m_dpy, config);
+#endif
+
+ m_surface = eglCreateWindowSurface(m_dpy, config, eglWindow, NULL);
+ if (m_surface == EGL_NO_SURFACE) {
+ qWarning("Could not create the egl surface: error = 0x%x\n", eglGetError());
+ eglTerminate(m_dpy);
+ qFatal("EGL error");
+ }
+ // qWarning("Created surface %dx%d\n", w, h);
+
+ QEGLPlatformContext *platformContext = new QMinimalEglContext(platformFormat, 0, m_dpy);
+ m_platformContext = platformContext;
+
+ EGLint w,h; // screen size detection
+ eglQuerySurface(m_dpy, m_surface, EGL_WIDTH, &w);
+ eglQuerySurface(m_dpy, m_surface, EGL_HEIGHT, &h);
+
+ m_geometry = QRect(0,0,w,h);
+
+}
+
+QRect QMinimalEglScreen::geometry() const
+{
+ if (m_geometry.isNull()) {
+ createAndSetPlatformContext();
+ }
+ return m_geometry;
+}
+
+int QMinimalEglScreen::depth() const
+{
+ return m_depth;
+}
+
+QImage::Format QMinimalEglScreen::format() const
+{
+ if (m_format == QImage::Format_Invalid)
+ createAndSetPlatformContext();
+ return m_format;
+}
+QPlatformOpenGLContext *QMinimalEglScreen::platformContext() const
+{
+ if (!m_platformContext) {
+ QMinimalEglScreen *that = const_cast<QMinimalEglScreen *>(this);
+ that->createAndSetPlatformContext();
+ }
+ return m_platformContext;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/minimalegl/qminimaleglscreen.h b/src/plugins/platforms/minimalegl/qminimaleglscreen.h
new file mode 100644
index 0000000000..317aa2d7da
--- /dev/null
+++ b/src/plugins/platforms/minimalegl/qminimaleglscreen.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMINIMALEGLSCREEN_H
+#define QMINIMALEGLSCREEN_H
+
+#include <qpa/qplatformscreen.h>
+
+#include <QtCore/QTextStream>
+
+#include <EGL/egl.h>
+
+QT_BEGIN_NAMESPACE
+
+class QPlatformOpenGLContext;
+
+class QMinimalEglScreen : public QPlatformScreen
+{
+public:
+ QMinimalEglScreen(EGLNativeDisplayType display);
+ ~QMinimalEglScreen();
+
+ QRect geometry() const;
+ int depth() const;
+ QImage::Format format() const;
+
+ QPlatformOpenGLContext *platformContext() const;
+
+ EGLSurface surface() const { return m_surface; }
+
+private:
+ void createAndSetPlatformContext() const;
+ void createAndSetPlatformContext();
+
+ QRect m_geometry;
+ int m_depth;
+ QImage::Format m_format;
+ QPlatformOpenGLContext *m_platformContext;
+ EGLDisplay m_dpy;
+ EGLSurface m_surface;
+};
+
+QT_END_NAMESPACE
+#endif // QMINIMALEGLSCREEN_H
diff --git a/src/plugins/platforms/minimalegl/qminimaleglwindow.cpp b/src/plugins/platforms/minimalegl/qminimaleglwindow.cpp
new file mode 100644
index 0000000000..0279cfb413
--- /dev/null
+++ b/src/plugins/platforms/minimalegl/qminimaleglwindow.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qminimaleglwindow.h"
+
+#include <QtGui/QWindowSystemInterface>
+
+QT_BEGIN_NAMESPACE
+
+QMinimalEglWindow::QMinimalEglWindow(QWindow *w)
+ : QPlatformWindow(w)
+{
+ static int serialNo = 0;
+ m_winid = ++serialNo;
+#ifdef QEGL_EXTRA_DEBUG
+ qWarning("QEglWindow %p: %p 0x%x\n", this, w, uint(m_winid));
+#endif
+
+ QRect screenGeometry(screen()->availableGeometry());
+ if (w->geometry() != screenGeometry) {
+ QWindowSystemInterface::handleGeometryChange(w, screenGeometry);
+ }
+}
+
+void QMinimalEglWindow::setGeometry(const QRect &)
+{
+ // We only support full-screen windows
+ QRect rect(screen()->availableGeometry());
+ QWindowSystemInterface::handleGeometryChange(window(), rect);
+
+ QPlatformWindow::setGeometry(rect);
+}
+
+WId QMinimalEglWindow::winId() const
+{
+ return m_winid;
+}
+
+QT_END_NAMESPACE
diff --git a/src/plugins/platforms/minimalegl/qminimaleglwindow.h b/src/plugins/platforms/minimalegl/qminimaleglwindow.h
new file mode 100644
index 0000000000..766a9604ac
--- /dev/null
+++ b/src/plugins/platforms/minimalegl/qminimaleglwindow.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMINIMALEGLWINDOW_H
+#define QMINIMALEGLWINDOW_H
+
+#include "qminimaleglintegration.h"
+#include "qminimaleglscreen.h"
+
+#include <qpa/qplatformwindow.h>
+#include <QtWidgets/QWidget>
+
+QT_BEGIN_NAMESPACE
+
+class QMinimalEglWindow : public QPlatformWindow
+{
+public:
+ QMinimalEglWindow(QWindow *w);
+
+ void setGeometry(const QRect &);
+ WId winId() const;
+
+private:
+ WId m_winid;
+};
+QT_END_NAMESPACE
+#endif // QMINIMALEGLWINDOW_H