summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/eglfs
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/eglfs')
-rw-r--r--src/plugins/platforms/eglfs/eglfs.pri10
-rw-r--r--src/plugins/platforms/eglfs/qeglfsbackingstore.cpp157
-rw-r--r--src/plugins/platforms/eglfs/qeglfsbackingstore.h81
-rw-r--r--src/plugins/platforms/eglfs/qeglfscompositor.cpp203
-rw-r--r--src/plugins/platforms/eglfs/qeglfscompositor.h85
-rw-r--r--src/plugins/platforms/eglfs/qeglfscontext.cpp15
-rw-r--r--src/plugins/platforms/eglfs/qeglfscontext.h6
-rw-r--r--src/plugins/platforms/eglfs/qeglfscursor.cpp356
-rw-r--r--src/plugins/platforms/eglfs/qeglfscursor.h125
-rw-r--r--src/plugins/platforms/eglfs/qeglfshooks.h4
-rw-r--r--src/plugins/platforms/eglfs/qeglfshooks_stub.cpp129
-rw-r--r--src/plugins/platforms/eglfs/qeglfsintegration.cpp189
-rw-r--r--src/plugins/platforms/eglfs/qeglfsintegration.h47
-rw-r--r--src/plugins/platforms/eglfs/qeglfsscreen.cpp68
-rw-r--r--src/plugins/platforms/eglfs/qeglfsscreen.h40
-rw-r--r--src/plugins/platforms/eglfs/qeglfswindow.cpp56
-rw-r--r--src/plugins/platforms/eglfs/qeglfswindow.h41
17 files changed, 91 insertions, 1521 deletions
diff --git a/src/plugins/platforms/eglfs/eglfs.pri b/src/plugins/platforms/eglfs/eglfs.pri
index 390061c168..7afa9c9e11 100644
--- a/src/plugins/platforms/eglfs/eglfs.pri
+++ b/src/plugins/platforms/eglfs/eglfs.pri
@@ -12,21 +12,15 @@ DEFINES += MESA_EGL_NO_X11_HEADERS
SOURCES += $$PWD/qeglfsintegration.cpp \
$$PWD/qeglfswindow.cpp \
- $$PWD/qeglfsbackingstore.cpp \
$$PWD/qeglfsscreen.cpp \
$$PWD/qeglfshooks_stub.cpp \
- $$PWD/qeglfscursor.cpp \
- $$PWD/qeglfscontext.cpp \
- $$PWD/qeglfscompositor.cpp
+ $$PWD/qeglfscontext.cpp
HEADERS += $$PWD/qeglfsintegration.h \
$$PWD/qeglfswindow.h \
- $$PWD/qeglfsbackingstore.h \
$$PWD/qeglfsscreen.h \
- $$PWD/qeglfscursor.h \
$$PWD/qeglfshooks.h \
- $$PWD/qeglfscontext.h \
- $$PWD/qeglfscompositor.h
+ $$PWD/qeglfscontext.h
QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF
diff --git a/src/plugins/platforms/eglfs/qeglfsbackingstore.cpp b/src/plugins/platforms/eglfs/qeglfsbackingstore.cpp
deleted file mode 100644
index 03531916cf..0000000000
--- a/src/plugins/platforms/eglfs/qeglfsbackingstore.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, 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, Digia gives you certain additional
-** rights. These rights are described in the Digia 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.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qeglfsbackingstore.h"
-#include "qeglfscompositor.h"
-#include "qeglfscursor.h"
-#include "qeglfswindow.h"
-#include "qeglfscontext.h"
-
-#include <QtGui/QOpenGLPaintDevice>
-#include <QtGui/QOpenGLShaderProgram>
-
-QT_BEGIN_NAMESPACE
-
-QEglFSBackingStore::QEglFSBackingStore(QWindow *window)
- : QPlatformBackingStore(window),
- m_window(static_cast<QEglFSWindow *>(window->handle())),
- m_texture(0)
-{
- m_window->setBackingStore(this);
-}
-
-QPaintDevice *QEglFSBackingStore::paintDevice()
-{
- return &m_image;
-}
-
-void QEglFSBackingStore::updateTexture()
-{
- glBindTexture(GL_TEXTURE_2D, m_texture);
-
- if (!m_dirty.isNull()) {
- QRegion fixed;
- QRect imageRect = m_image.rect();
- m_dirty |= imageRect;
-
- foreach (const QRect &rect, m_dirty.rects()) {
- // intersect with image rect to be sure
- QRect r = imageRect & rect;
-
- // if the rect is wide enough it's cheaper to just
- // extend it instead of doing an image copy
- if (r.width() >= imageRect.width() / 2) {
- r.setX(0);
- r.setWidth(imageRect.width());
- }
-
- fixed |= r;
- }
-
- foreach (const QRect &rect, fixed.rects()) {
- // if the sub-rect is full-width we can pass the image data directly to
- // OpenGL instead of copying, since there's no gap between scanlines
- if (rect.width() == imageRect.width()) {
- glTexSubImage2D(GL_TEXTURE_2D, 0, 0, rect.y(), rect.width(), rect.height(), GL_RGBA, GL_UNSIGNED_BYTE,
- m_image.constScanLine(rect.y()));
- } else {
- glTexSubImage2D(GL_TEXTURE_2D, 0, rect.x(), rect.y(), rect.width(), rect.height(), GL_RGBA, GL_UNSIGNED_BYTE,
- m_image.copy(rect).constBits());
- }
- }
-
- m_dirty = QRegion();
- }
-}
-
-void QEglFSBackingStore::flush(QWindow *window, const QRegion &region, const QPoint &offset)
-{
- Q_UNUSED(window);
- Q_UNUSED(region);
- Q_UNUSED(offset);
-
-#ifdef QEGL_EXTRA_DEBUG
- qWarning("QEglBackingStore::flush %p", window);
-#endif
-
- QEglFSWindow *rootWin = m_window->screen()->rootWindow();
- if (!rootWin || !rootWin->isRaster())
- return;
-
- m_window->create();
- rootWin->screen()->rootContext()->makeCurrent(rootWin->window());
- updateTexture();
- QEglFSCompositor::instance()->schedule(rootWin->screen());
-}
-
-void QEglFSBackingStore::beginPaint(const QRegion &rgn)
-{
- m_dirty |= rgn;
-}
-
-void QEglFSBackingStore::resize(const QSize &size, const QRegion &staticContents)
-{
- Q_UNUSED(staticContents);
-
- QEglFSWindow *rootWin = m_window->screen()->rootWindow();
- if (!rootWin || !rootWin->isRaster())
- return;
-
- m_image = QImage(size, QImage::Format_RGB32);
- m_window->create();
-
- rootWin->screen()->rootContext()->makeCurrent(rootWin->window());
- initializeOpenGLFunctions();
-
- if (m_texture)
- glDeleteTextures(1, &m_texture);
-
- glGenTextures(1, &m_texture);
- glBindTexture(GL_TEXTURE_2D, m_texture);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size.width(), size.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsbackingstore.h b/src/plugins/platforms/eglfs/qeglfsbackingstore.h
deleted file mode 100644
index 9af856e8e7..0000000000
--- a/src/plugins/platforms/eglfs/qeglfsbackingstore.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, 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, Digia gives you certain additional
-** rights. These rights are described in the Digia 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.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QEGLFSBACKINGSTORE_H
-#define QEGLFSBACKINGSTORE_H
-
-#include <qpa/qplatformbackingstore.h>
-#include <QtGui/QOpenGLFunctions>
-
-#include <QImage>
-#include <QRegion>
-
-QT_BEGIN_NAMESPACE
-
-class QOpenGLPaintDevice;
-class QEglFSWindow;
-
-class QEglFSBackingStore : public QPlatformBackingStore, public QOpenGLFunctions
-{
-public:
- QEglFSBackingStore(QWindow *window);
-
- QPaintDevice *paintDevice();
-
- void beginPaint(const QRegion &);
-
- void flush(QWindow *window, const QRegion &region, const QPoint &offset);
- void resize(const QSize &size, const QRegion &staticContents);
-
- uint texture() const { return m_texture; }
-
-private:
- void updateTexture();
-
- QEglFSWindow *m_window;
- QImage m_image;
- uint m_texture;
- QRegion m_dirty;
-};
-
-QT_END_NAMESPACE
-
-#endif // QEGLFSBACKINGSTORE_H
diff --git a/src/plugins/platforms/eglfs/qeglfscompositor.cpp b/src/plugins/platforms/eglfs/qeglfscompositor.cpp
deleted file mode 100644
index 845bb5b3b5..0000000000
--- a/src/plugins/platforms/eglfs/qeglfscompositor.cpp
+++ /dev/null
@@ -1,203 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, 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, Digia gives you certain additional
-** rights. These rights are described in the Digia 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.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qeglfscompositor.h"
-#include "qeglfswindow.h"
-#include "qeglfscontext.h"
-
-#include <QtGui/QOpenGLContext>
-#include <QtGui/QOpenGLShaderProgram>
-#include <QtGui/QOpenGLFramebufferObject>
-
-QT_BEGIN_NAMESPACE
-
-static QEglFSCompositor *compositor = 0;
-
-QEglFSCompositor::QEglFSCompositor()
- : m_screen(0),
- m_program(0),
- m_initialized(false)
-{
- Q_ASSERT(!compositor);
- m_updateTimer.setSingleShot(true);
- m_updateTimer.setInterval(0);
- connect(&m_updateTimer, SIGNAL(timeout()), SLOT(renderAll()));
-}
-
-QEglFSCompositor::~QEglFSCompositor()
-{
- Q_ASSERT(compositor == this);
- delete m_program;
- compositor = 0;
-}
-
-void QEglFSCompositor::schedule(QEglFSScreen *screen)
-{
- m_screen = screen;
- if (!m_updateTimer.isActive())
- m_updateTimer.start();
-}
-
-void QEglFSCompositor::renderAll()
-{
- QEglFSWindow *rootWin = m_screen->rootWindow();
- if (!rootWin)
- return;
-
- Q_ASSERT(rootWin->hasNativeWindow());
- QOpenGLContext *context = m_screen->rootContext();
- Q_ASSERT(context);
-
- context->makeCurrent(rootWin->window());
- if (!m_initialized) {
- initializeOpenGLFunctions();
- m_initialized = true;
- }
- ensureProgram();
- m_program->bind();
-
- QList<QEglFSWindow *> windows = m_screen->windows();
- for (int i = 0; i < windows.size(); ++i) {
- QEglFSWindow *window = windows.at(i);
- uint texture = window->texture();
- if (texture)
- render(window, texture, window->isRaster());
- }
-
- m_program->release();
- context->swapBuffers(rootWin->window());
-}
-
-void QEglFSCompositor::ensureProgram()
-{
- if (!m_program) {
- static const char *textureVertexProgram =
- "attribute highp vec2 vertexCoordEntry;\n"
- "attribute highp vec2 textureCoordEntry;\n"
- "varying highp vec2 textureCoord;\n"
- "void main() {\n"
- " textureCoord = textureCoordEntry;\n"
- " gl_Position = vec4(vertexCoordEntry, 0.0, 1.0);\n"
- "}\n";
-
- static const char *textureFragmentProgram =
- "uniform sampler2D texture;\n"
- "varying highp vec2 textureCoord;\n"
- "uniform bool isRaster;\n"
- "void main() {\n"
- " lowp vec4 c = texture2D(texture, textureCoord);\n"
- " gl_FragColor = isRaster ? c.bgra : c.rgba;\n"
- "}\n";
-
- m_program = new QOpenGLShaderProgram;
-
- m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, textureVertexProgram);
- m_program->addShaderFromSourceCode(QOpenGLShader::Fragment, textureFragmentProgram);
- m_program->link();
-
- m_vertexCoordEntry = m_program->attributeLocation("vertexCoordEntry");
- m_textureCoordEntry = m_program->attributeLocation("textureCoordEntry");
- m_isRasterEntry = m_program->uniformLocation("isRaster");
- }
-}
-
-void QEglFSCompositor::render(QEglFSWindow *window, uint texture, bool raster)
-{
- const GLfloat textureCoordinates[] = {
- 0, 0,
- 1, 0,
- 1, 1,
- 0, 1
- };
-
- QRectF sr = window->screen()->geometry();
- QRect r = window->window()->geometry();
- QPoint tl = r.topLeft();
- QPoint br = r.bottomRight();
-
- GLfloat x1 = (tl.x() / sr.width()) * 2 - 1;
- GLfloat x2 = (br.x() / sr.width()) * 2 - 1;
- GLfloat y1 = ((sr.height() - tl.y()) / sr.height()) * 2 - 1;
- GLfloat y2 = ((sr.height() - br.y()) / sr.height()) * 2 - 1;
-
- if (!raster)
- qSwap(y1, y2);
-
- const GLfloat vertexCoordinates[] = {
- x1, y1,
- x2, y1,
- x2, y2,
- x1, y2
- };
-
- glViewport(0, 0, sr.width(), sr.height());
-
- glEnableVertexAttribArray(m_vertexCoordEntry);
- glEnableVertexAttribArray(m_textureCoordEntry);
-
- glVertexAttribPointer(m_vertexCoordEntry, 2, GL_FLOAT, GL_FALSE, 0, vertexCoordinates);
- glVertexAttribPointer(m_textureCoordEntry, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinates);
-
- glBindTexture(GL_TEXTURE_2D, texture);
-
- m_program->setUniformValue(m_isRasterEntry, raster);
-
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
-
- glBindTexture(GL_TEXTURE_2D, 0);
- glDisableVertexAttribArray(m_vertexCoordEntry);
- glDisableVertexAttribArray(m_textureCoordEntry);
-}
-
-QEglFSCompositor *QEglFSCompositor::instance()
-{
- if (!compositor)
- compositor = new QEglFSCompositor;
- return compositor;
-}
-
-void QEglFSCompositor::destroy()
-{
- delete compositor;
- compositor = 0;
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfscompositor.h b/src/plugins/platforms/eglfs/qeglfscompositor.h
deleted file mode 100644
index 0d5daafa2c..0000000000
--- a/src/plugins/platforms/eglfs/qeglfscompositor.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, 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, Digia gives you certain additional
-** rights. These rights are described in the Digia 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.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QEGLFSCOMPOSITOR_H
-#define QEGLFSCOMPOSITOR_H
-
-#include <QtCore/QTimer>
-#include <QtGui/QOpenGLFunctions>
-
-QT_BEGIN_NAMESPACE
-
-class QEglFSScreen;
-class QEglFSWindow;
-class QOpenGLShaderProgram;
-
-class QEglFSCompositor : public QObject, public QOpenGLFunctions
-{
- Q_OBJECT
-
-public:
- void schedule(QEglFSScreen *screen);
-
- static QEglFSCompositor *instance();
- static void destroy();
-
-private slots:
- void renderAll();
-
-private:
- QEglFSCompositor();
- ~QEglFSCompositor();
-
- void render(QEglFSWindow *window, uint texture, bool raster);
- void ensureProgram();
-
- QEglFSScreen *m_screen;
- QTimer m_updateTimer;
- QOpenGLShaderProgram *m_program;
- int m_vertexCoordEntry;
- int m_textureCoordEntry;
- int m_isRasterEntry;
- bool m_initialized;
-};
-
-QT_END_NAMESPACE
-
-#endif // QEGLFSCOMPOSITOR_H
diff --git a/src/plugins/platforms/eglfs/qeglfscontext.cpp b/src/plugins/platforms/eglfs/qeglfscontext.cpp
index dd3f272d8b..86ceb0721b 100644
--- a/src/plugins/platforms/eglfs/qeglfscontext.cpp
+++ b/src/plugins/platforms/eglfs/qeglfscontext.cpp
@@ -41,11 +41,12 @@
#include "qeglfscontext.h"
#include "qeglfswindow.h"
-#include "qeglfscursor.h"
#include "qeglfshooks.h"
#include "qeglfsintegration.h"
+#include <QtPlatformSupport/private/qeglconvenience_p.h>
#include <QtPlatformSupport/private/qeglpbuffer_p.h>
+#include <QtPlatformSupport/private/qeglplatformcursor_p.h>
#include <QtGui/QSurface>
#include <QtDebug>
@@ -58,11 +59,6 @@ QEglFSContext::QEglFSContext(const QSurfaceFormat &format, QPlatformOpenGLContex
{
}
-bool QEglFSContext::makeCurrent(QPlatformSurface *surface)
-{
- return QEGLPlatformContext::makeCurrent(surface);
-}
-
EGLSurface QEglFSContext::eglSurfaceForPlatformSurface(QPlatformSurface *surface)
{
if (surface->surface()->surfaceClass() == QSurface::Window)
@@ -73,10 +69,10 @@ EGLSurface QEglFSContext::eglSurfaceForPlatformSurface(QPlatformSurface *surface
void QEglFSContext::swapBuffers(QPlatformSurface *surface)
{
+ // draw the cursor
if (surface->surface()->surfaceClass() == QSurface::Window) {
- QEglFSWindow *window = static_cast<QEglFSWindow *>(surface);
- // draw the cursor
- if (QEglFSCursor *cursor = static_cast<QEglFSCursor *>(window->screen()->cursor()))
+ QPlatformWindow *window = static_cast<QPlatformWindow *>(surface);
+ if (QEGLPlatformCursor *cursor = static_cast<QEGLPlatformCursor *>(window->screen()->cursor()))
cursor->paintOnScreen();
}
@@ -85,4 +81,3 @@ void QEglFSContext::swapBuffers(QPlatformSurface *surface)
}
QT_END_NAMESPACE
-
diff --git a/src/plugins/platforms/eglfs/qeglfscontext.h b/src/plugins/platforms/eglfs/qeglfscontext.h
index 6caa49ab4f..22a7c67e46 100644
--- a/src/plugins/platforms/eglfs/qeglfscontext.h
+++ b/src/plugins/platforms/eglfs/qeglfscontext.h
@@ -42,7 +42,6 @@
#ifndef QEGLFSCONTEXT_H
#define QEGLFSCONTEXT_H
-#include <QtPlatformSupport/private/qeglconvenience_p.h>
#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
QT_BEGIN_NAMESPACE
@@ -52,9 +51,8 @@ class QEglFSContext : public QEGLPlatformContext
public:
QEglFSContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display,
EGLenum eglApi = EGL_OPENGL_ES_API);
- bool makeCurrent(QPlatformSurface *surface);
- EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface);
- void swapBuffers(QPlatformSurface *surface);
+ EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) Q_DECL_OVERRIDE;
+ void swapBuffers(QPlatformSurface *surface) Q_DECL_OVERRIDE;
};
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfscursor.cpp b/src/plugins/platforms/eglfs/qeglfscursor.cpp
deleted file mode 100644
index 0066426769..0000000000
--- a/src/plugins/platforms/eglfs/qeglfscursor.cpp
+++ /dev/null
@@ -1,356 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, 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, Digia gives you certain additional
-** rights. These rights are described in the Digia 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.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qeglfscursor.h"
-#include <qpa/qwindowsysteminterface.h>
-#include <QtGui/QOpenGLContext>
-#include <QtCore/QJsonDocument>
-#include <QtCore/QJsonArray>
-#include <QtCore/QJsonObject>
-#include <QtDebug>
-
-QT_BEGIN_NAMESPACE
-
-QEglFSCursor::QEglFSCursor(QEglFSScreen *screen)
- : m_screen(screen), m_program(0), m_vertexCoordEntry(0), m_textureCoordEntry(0), m_textureEntry(0)
-{
- initCursorAtlas();
-
- // initialize the cursor
-#ifndef QT_NO_CURSOR
- QCursor cursor(Qt::ArrowCursor);
- setCurrentCursor(&cursor);
-#endif
-}
-
-QEglFSCursor::~QEglFSCursor()
-{
- resetResources();
-}
-
-void QEglFSCursor::resetResources()
-{
- if (QOpenGLContext::currentContext()) {
- glDeleteProgram(m_program);
- glDeleteTextures(1, &m_cursor.customCursorTexture);
- glDeleteTextures(1, &m_cursorAtlas.texture);
- }
- m_program = 0;
- m_cursor.customCursorTexture = 0;
- m_cursor.customCursorPending = !m_cursor.customCursorImage.isNull();
- m_cursorAtlas.texture = 0;
-}
-
-GLuint QEglFSCursor::createShader(GLenum shaderType, const char *program)
-{
- GLuint shader = glCreateShader(shaderType);
- glShaderSource(shader, 1 /* count */, &program, NULL /* lengths */);
- glCompileShader(shader);
- GLint status;
- glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
- if (status == GL_TRUE)
- return shader;
-
- GLint length;
- glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length);
- char *infoLog = new char[length];
- glGetShaderInfoLog(shader, length, NULL, infoLog);
- qDebug("%s shader compilation error: %s", shaderType == GL_VERTEX_SHADER ? "vertex" : "fragment", infoLog);
- delete [] infoLog;
- return 0;
-}
-
-GLuint QEglFSCursor::createProgram(GLuint vshader, GLuint fshader)
-{
- GLuint program = glCreateProgram();
- glAttachShader(program, vshader);
- glAttachShader(program, fshader);
- glLinkProgram(program);
- GLint status;
- glGetProgramiv(program, GL_LINK_STATUS, &status);
- if (status == GL_TRUE)
- return program;
-
- GLint length;
- glGetProgramiv(program, GL_INFO_LOG_LENGTH, &length);
- char *infoLog = new char[length];
- glGetProgramInfoLog(program, length, NULL, infoLog);
- qDebug("program link error: %s", infoLog);
- delete [] infoLog;
- return 0;
-}
-
-void QEglFSCursor::createShaderPrograms()
-{
- static const char *textureVertexProgram =
- "attribute highp vec2 vertexCoordEntry;\n"
- "attribute highp vec2 textureCoordEntry;\n"
- "varying highp vec2 textureCoord;\n"
- "void main() {\n"
- " textureCoord = textureCoordEntry;\n"
- " gl_Position = vec4(vertexCoordEntry, 1.0, 1.0);\n"
- "}\n";
-
- static const char *textureFragmentProgram =
- "uniform sampler2D texture;\n"
- "varying highp vec2 textureCoord;\n"
- "void main() {\n"
- " gl_FragColor = texture2D(texture, textureCoord).bgra;\n"
- "}\n";
-
- GLuint vertexShader = createShader(GL_VERTEX_SHADER, textureVertexProgram);
- GLuint fragmentShader = createShader(GL_FRAGMENT_SHADER, textureFragmentProgram);
- m_program = createProgram(vertexShader, fragmentShader);
- glDeleteShader(vertexShader);
- glDeleteShader(fragmentShader);
-
- m_vertexCoordEntry = glGetAttribLocation(m_program, "vertexCoordEntry");
- m_textureCoordEntry = glGetAttribLocation(m_program, "textureCoordEntry");
- m_textureEntry = glGetUniformLocation(m_program, "texture");
-}
-
-void QEglFSCursor::createCursorTexture(uint *texture, const QImage &image)
-{
- if (!*texture)
- glGenTextures(1, texture);
- glBindTexture(GL_TEXTURE_2D, *texture);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-
- glTexImage2D(GL_TEXTURE_2D, 0 /* level */, GL_RGBA, image.width(), image.height(), 0 /* border */,
- GL_RGBA, GL_UNSIGNED_BYTE, image.constBits());
-}
-
-void QEglFSCursor::initCursorAtlas()
-{
- static QByteArray json = qgetenv("QT_QPA_EGLFS_CURSOR");
- if (json.isEmpty())
- json = ":/cursor.json";
-
- QFile file(json);
- file.open(QFile::ReadOnly);
- QJsonDocument doc = QJsonDocument::fromJson(file.readAll());
- QJsonObject object = doc.object();
-
- QString atlas = object.value("image").toString();
- Q_ASSERT(!atlas.isEmpty());
-
- const int cursorsPerRow = object.value("cursorsPerRow").toDouble();
- Q_ASSERT(cursorsPerRow);
- m_cursorAtlas.cursorsPerRow = cursorsPerRow;
-
- const QJsonArray hotSpots = object.value("hotSpots").toArray();
- Q_ASSERT(hotSpots.count() == Qt::LastCursor);
- for (int i = 0; i < hotSpots.count(); i++) {
- QPoint hotSpot(hotSpots[i].toArray()[0].toDouble(), hotSpots[i].toArray()[1].toDouble());
- m_cursorAtlas.hotSpots << hotSpot;
- }
-
- QImage image = QImage(atlas).convertToFormat(QImage::Format_ARGB32_Premultiplied);
- m_cursorAtlas.cursorWidth = image.width() / m_cursorAtlas.cursorsPerRow;
- m_cursorAtlas.cursorHeight = image.height() / ((Qt::LastCursor + cursorsPerRow - 1) / cursorsPerRow);
- m_cursorAtlas.width = image.width();
- m_cursorAtlas.height = image.height();
- m_cursorAtlas.image = image;
-}
-
-#ifndef QT_NO_CURSOR
-void QEglFSCursor::changeCursor(QCursor *cursor, QWindow *window)
-{
- Q_UNUSED(window);
- const QRect oldCursorRect = cursorRect();
- if (setCurrentCursor(cursor))
- update(oldCursorRect | cursorRect());
-}
-
-bool QEglFSCursor::setCurrentCursor(QCursor *cursor)
-{
- const Qt::CursorShape newShape = cursor ? cursor->shape() : Qt::ArrowCursor;
- if (m_cursor.shape == newShape && newShape != Qt::BitmapCursor)
- return false;
-
- if (m_cursor.shape == Qt::BitmapCursor) {
- m_cursor.customCursorImage = QImage();
- m_cursor.customCursorPending = false;
- }
- m_cursor.shape = newShape;
- if (newShape != Qt::BitmapCursor) { // standard cursor
- const float ws = (float)m_cursorAtlas.cursorWidth / m_cursorAtlas.width,
- hs = (float)m_cursorAtlas.cursorHeight / m_cursorAtlas.height;
- m_cursor.textureRect = QRectF(ws * (m_cursor.shape % m_cursorAtlas.cursorsPerRow),
- hs * (m_cursor.shape / m_cursorAtlas.cursorsPerRow),
- ws, hs);
- m_cursor.hotSpot = m_cursorAtlas.hotSpots[m_cursor.shape];
- m_cursor.texture = m_cursorAtlas.texture;
- m_cursor.size = QSize(m_cursorAtlas.cursorWidth, m_cursorAtlas.cursorHeight);
- } else {
- QImage image = cursor->pixmap().toImage();
- m_cursor.textureRect = QRectF(0, 0, 1, 1);
- m_cursor.hotSpot = cursor->hotSpot();
- m_cursor.texture = 0; // will get updated in the next render()
- m_cursor.size = image.size();
- m_cursor.customCursorImage = image;
- m_cursor.customCursorPending = true;
- }
-
- return true;
-}
-#endif
-
-void QEglFSCursor::update(const QRegion &rgn)
-{
- QWindowSystemInterface::handleExposeEvent(m_screen->topLevelAt(m_cursor.pos), rgn);
- QWindowSystemInterface::flushWindowSystemEvents();
-}
-
-QRect QEglFSCursor::cursorRect() const
-{
- return QRect(m_cursor.pos - m_cursor.hotSpot, m_cursor.size);
-}
-
-QPoint QEglFSCursor::pos() const
-{
- return m_cursor.pos;
-}
-
-void QEglFSCursor::setPos(const QPoint &pos)
-{
- const QRect oldCursorRect = cursorRect();
- m_cursor.pos = pos;
- update(oldCursorRect | cursorRect());
-}
-
-void QEglFSCursor::pointerEvent(const QMouseEvent &event)
-{
- if (event.type() != QEvent::MouseMove)
- return;
- const QRect oldCursorRect = cursorRect();
- m_cursor.pos = event.screenPos().toPoint();
- update(oldCursorRect | cursorRect());
-}
-
-void QEglFSCursor::paintOnScreen()
-{
- const QRectF cr = cursorRect();
- const QRect screenRect(m_screen->geometry());
- const GLfloat x1 = 2 * (cr.left() / screenRect.width()) - 1;
- const GLfloat x2 = 2 * (cr.right() / screenRect.width()) - 1;
- const GLfloat y1 = 1 - (cr.top() / screenRect.height()) * 2;
- const GLfloat y2 = 1 - (cr.bottom() / screenRect.height()) * 2;
- QRectF r(QPointF(x1, y1), QPointF(x2, y2));
-
- draw(r);
-}
-
-void QEglFSCursor::draw(const QRectF &r)
-{
- if (!m_program) {
- // one time initialization
- initializeOpenGLFunctions();
- createShaderPrograms();
-
- if (!m_cursorAtlas.texture) {
- createCursorTexture(&m_cursorAtlas.texture, m_cursorAtlas.image);
-
- if (m_cursor.shape != Qt::BitmapCursor)
- m_cursor.texture = m_cursorAtlas.texture;
- }
- }
-
- if (m_cursor.shape == Qt::BitmapCursor && m_cursor.customCursorPending) {
- // upload the custom cursor
- createCursorTexture(&m_cursor.customCursorTexture, m_cursor.customCursorImage);
- m_cursor.texture = m_cursor.customCursorTexture;
- m_cursor.customCursorPending = false;
- }
-
- Q_ASSERT(m_cursor.texture);
-
- glUseProgram(m_program);
-
- const GLfloat x1 = r.left();
- const GLfloat x2 = r.right();
- const GLfloat y1 = r.top();
- const GLfloat y2 = r.bottom();
- const GLfloat cursorCoordinates[] = {
- x1, y2,
- x2, y2,
- x1, y1,
- x2, y1
- };
-
- const GLfloat s1 = m_cursor.textureRect.left();
- const GLfloat s2 = m_cursor.textureRect.right();
- const GLfloat t1 = m_cursor.textureRect.top();
- const GLfloat t2 = m_cursor.textureRect.bottom();
- const GLfloat textureCoordinates[] = {
- s1, t2,
- s2, t2,
- s1, t1,
- s2, t1
- };
-
- glBindTexture(GL_TEXTURE_2D, m_cursor.texture);
-
- glEnableVertexAttribArray(m_vertexCoordEntry);
- glEnableVertexAttribArray(m_textureCoordEntry);
-
- glVertexAttribPointer(m_vertexCoordEntry, 2, GL_FLOAT, GL_FALSE, 0, cursorCoordinates);
- glVertexAttribPointer(m_textureCoordEntry, 2, GL_FLOAT, GL_FALSE, 0, textureCoordinates);
-
- glUniform1i(m_textureEntry, 0);
-
- glEnable(GL_BLEND);
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
- glDisable(GL_DEPTH_TEST); // disable depth testing to make sure cursor is always on top
- glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
- glDisable(GL_BLEND);
-
- glBindTexture(GL_TEXTURE_2D, 0);
- glDisableVertexAttribArray(m_vertexCoordEntry);
- glDisableVertexAttribArray(m_textureCoordEntry);
-
- glUseProgram(0);
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfscursor.h b/src/plugins/platforms/eglfs/qeglfscursor.h
deleted file mode 100644
index 71ff73b8f3..0000000000
--- a/src/plugins/platforms/eglfs/qeglfscursor.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, 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, Digia gives you certain additional
-** rights. These rights are described in the Digia 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.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QEGLFSCURSOR_H
-#define QEGLFSCURSOR_H
-
-#include <qpa/qplatformcursor.h>
-#include <QtGui/QOpenGLFunctions>
-#include "qeglfsscreen.h"
-
-QT_BEGIN_NAMESPACE
-
-class QOpenGLShaderProgram;
-class QEglFSScreen;
-
-class QEglFSCursor : public QPlatformCursor, public QOpenGLFunctions
-{
-public:
- QEglFSCursor(QEglFSScreen *screen);
- ~QEglFSCursor();
-
-#ifndef QT_NO_CURSOR
- void changeCursor(QCursor *cursor, QWindow *widget) Q_DECL_OVERRIDE;
-#endif
- void pointerEvent(const QMouseEvent &event) Q_DECL_OVERRIDE;
-
- QPoint pos() const Q_DECL_OVERRIDE;
- void setPos(const QPoint &pos) Q_DECL_OVERRIDE;
-
- QRect cursorRect() const;
-
- virtual void paintOnScreen();
-
- void resetResources();
-
-protected:
-#ifndef QT_NO_CURSOR
- bool setCurrentCursor(QCursor *cursor);
-#endif
- void draw(const QRectF &rect);
- void update(const QRegion &region);
-
- GLuint createShader(GLenum shaderType, const char *program);
- GLuint createProgram(GLuint vshader, GLuint fshader);
-
- QEglFSScreen *m_screen;
-
- // current cursor information
- struct Cursor {
- Cursor() : texture(0), shape(Qt::BlankCursor), customCursorTexture(0), customCursorPending(false) { }
- uint texture; // a texture from 'image' or the atlas
- Qt::CursorShape shape;
- QRectF textureRect; // normalized rect inside texture
- QSize size; // size of the cursor
- QPoint hotSpot;
- QImage customCursorImage;
- QPoint pos; // current cursor position
- uint customCursorTexture;
- bool customCursorPending;
- } m_cursor;
-
-private:
- void createShaderPrograms();
- static void createCursorTexture(uint *texture, const QImage &image);
- void initCursorAtlas();
-
- // cursor atlas information
- struct CursorAtlas {
- CursorAtlas() : cursorsPerRow(0), texture(0), cursorWidth(0), cursorHeight(0) { }
- int cursorsPerRow;
- uint texture;
- int width, height; // width and height of the the atlas
- int cursorWidth, cursorHeight; // width and height of cursors inside the atlas
- QList<QPoint> hotSpots;
- QImage image; // valid until it's uploaded
- } m_cursorAtlas;
-
- GLuint m_program;
- int m_vertexCoordEntry;
- int m_textureCoordEntry;
- int m_textureEntry;
-};
-
-QT_END_NAMESPACE
-
-#endif // QEGLFSCURSOR_H
-
diff --git a/src/plugins/platforms/eglfs/qeglfshooks.h b/src/plugins/platforms/eglfs/qeglfshooks.h
index 1cd1380994..dfafec73af 100644
--- a/src/plugins/platforms/eglfs/qeglfshooks.h
+++ b/src/plugins/platforms/eglfs/qeglfshooks.h
@@ -50,7 +50,7 @@
QT_BEGIN_NAMESPACE
-class QEglFSCursor;
+class QEGLPlatformCursor;
class QEglFSScreen;
class QEglFSHooks
@@ -73,7 +73,7 @@ public:
const QSurfaceFormat &format);
virtual void destroyNativeWindow(EGLNativeWindowType window);
virtual bool hasCapability(QPlatformIntegration::Capability cap) const;
- virtual QEglFSCursor *createCursor(QEglFSScreen *screen) const;
+ virtual QEGLPlatformCursor *createCursor(QPlatformScreen *screen) const;
virtual bool filterConfig(EGLDisplay display, EGLConfig config) const;
virtual void waitForVSync() const;
diff --git a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp
index 4dc0783d43..f5467fd6a4 100644
--- a/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp
+++ b/src/plugins/platforms/eglfs/qeglfshooks_stub.cpp
@@ -40,14 +40,14 @@
****************************************************************************/
#include "qeglfshooks.h"
-#include "qeglfscursor.h"
+#include <QtPlatformSupport/private/qeglplatformcursor_p.h>
+#include <QtPlatformSupport/private/qeglconvenience_p.h>
#include <fcntl.h>
#include <unistd.h>
#include <linux/fb.h>
#include <sys/ioctl.h>
-#include <private/qmath_p.h>
#include <private/qcore_unix_p.h>
QT_BEGIN_NAMESPACE
@@ -82,105 +82,12 @@ EGLNativeDisplayType QEglFSHooks::platformDisplay() const
QSizeF QEglFSHooks::physicalScreenSize() const
{
- static QSizeF size;
- if (size.isEmpty()) {
-
- // Note: in millimeters
- int width = qgetenv("QT_QPA_EGLFS_PHYSICAL_WIDTH").toInt();
- int height = qgetenv("QT_QPA_EGLFS_PHYSICAL_HEIGHT").toInt();
-
- if (width && height) {
- // no need to read fb0
- size.setWidth(width);
- size.setHeight(height);
- return size;
- }
-
- struct fb_var_screeninfo vinfo;
- int w = -1;
- int h = -1;
- QSize screenResolution;
-
- if (framebuffer != -1) {
- if (ioctl(framebuffer, FBIOGET_VSCREENINFO, &vinfo) == -1) {
- qWarning("EGLFS: Could not query variable screen info.");
- } else {
- w = vinfo.width;
- h = vinfo.height;
- screenResolution = QSize(vinfo.xres, vinfo.yres);
- }
- } else {
- screenResolution = screenSize();
- }
-
- const int defaultPhysicalDpi = 100;
- size.setWidth(w <= 0 ? screenResolution.width() * Q_MM_PER_INCH / defaultPhysicalDpi : qreal(w));
- size.setHeight(h <= 0 ? screenResolution.height() * Q_MM_PER_INCH / defaultPhysicalDpi : qreal(h));
-
- if (w <= 0 || h <= 0) {
- qWarning("EGLFS: Unable to query physical screen size, defaulting to %d dpi.\n"
- "EGLFS: To override, set QT_QPA_EGLFS_PHYSICAL_WIDTH "
- "and QT_QPA_EGLFS_PHYSICAL_HEIGHT (in millimeters).",
- defaultPhysicalDpi);
- }
-
- // override fb0 from environment var setting
- if (width)
- size.setWidth(width);
- if (height)
- size.setWidth(height);
- }
- return size;
+ return q_physicalScreenSizeFromFb(framebuffer);
}
QSize QEglFSHooks::screenSize() const
{
- static QSize size;
-
- if (size.isEmpty()) {
- int width = qgetenv("QT_QPA_EGLFS_WIDTH").toInt();
- int height = qgetenv("QT_QPA_EGLFS_HEIGHT").toInt();
-
- if (width && height) {
- // no need to read fb0
- size.setWidth(width);
- size.setHeight(height);
- return size;
- }
-
- struct fb_var_screeninfo vinfo;
-
- int xres = -1;
- int yres = -1;
-
- if (framebuffer != -1) {
- if (ioctl(framebuffer, FBIOGET_VSCREENINFO, &vinfo) == -1) {
- qWarning("EGLFS: Could not query variable screen info.");
- } else {
- xres = vinfo.xres;
- yres = vinfo.yres;
- }
- }
-
- const int defaultWidth = 800;
- const int defaultHeight = 600;
- size.setWidth(xres <= 0 ? defaultWidth : xres);
- size.setHeight(yres <= 0 ? defaultHeight : yres);
-
- if (xres <= 0 || yres <= 0) {
- qWarning("EGLFS: Unable to query screen resolution, defaulting to %dx%d.\n"
- "EGLFS: To override, set QT_QPA_EGLFS_WIDTH and QT_QPA_EGLFS_HEIGHT.",
- defaultWidth, defaultHeight);
- }
-
- // override fb0 from environment var setting
- if (width)
- size.setWidth(width);
- if (height)
- size.setHeight(height);
- }
-
- return size;
+ return q_screenSizeFromFb(framebuffer);
}
QDpi QEglFSHooks::logicalDpi() const
@@ -204,29 +111,7 @@ Qt::ScreenOrientation QEglFSHooks::orientation() const
int QEglFSHooks::screenDepth() const
{
- static int depth = qgetenv("QT_QPA_EGLFS_DEPTH").toInt();
-
- if (depth == 0) {
- struct fb_var_screeninfo vinfo;
-
- if (framebuffer != -1) {
- if (ioctl(framebuffer, FBIOGET_VSCREENINFO, &vinfo) == -1)
- qWarning("EGLFS: Could not query variable screen info.");
- else
- depth = vinfo.bits_per_pixel;
- }
-
- const int defaultDepth = 32;
-
- if (depth <= 0) {
- depth = defaultDepth;
-
- qWarning("EGLFS: Unable to query screen depth, defaulting to %d.\n"
- "EGLFS: To override, set QT_QPA_EGLFS_DEPTH.", defaultDepth);
- }
- }
-
- return depth;
+ return q_screenDepthFromFb(framebuffer);
}
QImage::Format QEglFSHooks::screenFormat() const
@@ -265,9 +150,9 @@ bool QEglFSHooks::hasCapability(QPlatformIntegration::Capability cap) const
return false;
}
-QEglFSCursor *QEglFSHooks::createCursor(QEglFSScreen *screen) const
+QEGLPlatformCursor *QEglFSHooks::createCursor(QPlatformScreen *screen) const
{
- return new QEglFSCursor(screen);
+ return new QEGLPlatformCursor(screen);
}
void QEglFSHooks::waitForVSync() const
diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.cpp b/src/plugins/platforms/eglfs/qeglfsintegration.cpp
index d6832493f1..dfe240a888 100644
--- a/src/plugins/platforms/eglfs/qeglfsintegration.cpp
+++ b/src/plugins/platforms/eglfs/qeglfsintegration.cpp
@@ -42,15 +42,10 @@
#include "qeglfsintegration.h"
#include "qeglfswindow.h"
-#include "qeglfsbackingstore.h"
-#include "qeglfscompositor.h"
#include "qeglfshooks.h"
#include <QtGui/private/qguiapplication_p.h>
-#include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h>
-#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h>
-#include <QtPlatformSupport/private/qgenericunixservices_p.h>
#include <QtPlatformSupport/private/qeglconvenience_p.h>
#include <QtPlatformSupport/private/qeglplatformcontext_p.h>
#include <QtPlatformSupport/private/qeglpbuffer_p.h>
@@ -68,8 +63,6 @@
#include <QtGui/QOffscreenSurface>
#include <qpa/qplatformcursor.h>
-#include <qpa/qplatforminputcontextfactory_p.h>
-
#include "qeglfscontext.h"
#include <EGL/egl.h>
@@ -82,10 +75,6 @@ static void initResources()
QT_BEGIN_NAMESPACE
QEglFSIntegration::QEglFSIntegration()
- : mFontDb(new QGenericUnixFontDatabase)
- , mServices(new QGenericUnixServices)
- , mScreen(0)
- , mInputContext(0)
{
mDisableInputHandlers = qgetenv("QT_QPA_EGLFS_DISABLE_INPUT").toInt();
@@ -94,9 +83,6 @@ QEglFSIntegration::QEglFSIntegration()
QEglFSIntegration::~QEglFSIntegration()
{
- QEglFSCompositor::destroy();
- delete mScreen;
- eglTerminate(mDisplay);
QEglFSHooks::hooks()->platformDestroy();
}
@@ -106,33 +92,12 @@ bool QEglFSIntegration::hasCapability(QPlatformIntegration::Capability cap) cons
if (QEglFSHooks::hooks() && QEglFSHooks::hooks()->hasCapability(cap))
return true;
- switch (cap) {
- case ThreadedPixmaps: return true;
- case OpenGL: return true;
- case ThreadedOpenGL: return true;
- case WindowManagement: return false;
- default: return QPlatformIntegration::hasCapability(cap);
- }
-}
-
-QPlatformWindow *QEglFSIntegration::createPlatformWindow(QWindow *window) const
-{
- QWindowSystemInterface::flushWindowSystemEvents();
- QEglFSWindow *w = new QEglFSWindow(window);
- w->create();
- if (window->type() != Qt::ToolTip)
- w->requestActivateWindow();
- return w;
-}
-
-QPlatformBackingStore *QEglFSIntegration::createPlatformBackingStore(QWindow *window) const
-{
- return new QEglFSBackingStore(window);
+ return QEGLPlatformIntegration::hasCapability(cap);
}
QPlatformOpenGLContext *QEglFSIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
{
- return new QEglFSContext(QEglFSHooks::hooks()->surfaceFormatFor(context->format()), context->shareHandle(), mDisplay);
+ return new QEglFSContext(QEglFSHooks::hooks()->surfaceFormatFor(context->format()), context->shareHandle(), display());
}
QPlatformOffscreenSurface *QEglFSIntegration::createPlatformOffscreenSurface(QOffscreenSurface *surface) const
@@ -141,164 +106,40 @@ QPlatformOffscreenSurface *QEglFSIntegration::createPlatformOffscreenSurface(QOf
return new QEGLPbuffer(screen->display(), QEglFSHooks::hooks()->surfaceFormatFor(surface->requestedFormat()), surface);
}
-QPlatformFontDatabase *QEglFSIntegration::fontDatabase() const
-{
- return mFontDb.data();
-}
-
-QAbstractEventDispatcher *QEglFSIntegration::createEventDispatcher() const
-{
- return createUnixEventDispatcher();
-}
-
void QEglFSIntegration::initialize()
{
QEglFSHooks::hooks()->platformInit();
- EGLint major, minor;
-
- if (!eglBindAPI(EGL_OPENGL_ES_API)) {
- qWarning("Could not bind GL_ES API\n");
- qFatal("EGL error");
- }
-
- mDisplay = eglGetDisplay(QEglFSHooks::hooks() ? QEglFSHooks::hooks()->platformDisplay() : EGL_DEFAULT_DISPLAY);
- if (mDisplay == EGL_NO_DISPLAY) {
- qWarning("Could not open egl display\n");
- qFatal("EGL error");
- }
-
- if (!eglInitialize(mDisplay, &major, &minor)) {
- qWarning("Could not initialize egl display\n");
- qFatal("EGL error");
- }
-
- mScreen = createScreen();
- screenAdded(mScreen);
-
- mInputContext = QPlatformInputContextFactory::create();
+ QEGLPlatformIntegration::initialize();
if (!mDisableInputHandlers)
createInputHandlers();
}
-QEglFSScreen *QEglFSIntegration::createScreen() const
+EGLNativeDisplayType QEglFSIntegration::nativeDisplay() const
{
- return new QEglFSScreen(mDisplay);
+ return QEglFSHooks::hooks()->platformDisplay();
}
-QVariant QEglFSIntegration::styleHint(QPlatformIntegration::StyleHint hint) const
+QEGLPlatformScreen *QEglFSIntegration::createScreen() const
{
- switch (hint)
- {
- case QPlatformIntegration::ShowIsFullScreen:
- return mScreen->rootWindow() == 0;
- default:
- return QPlatformIntegration::styleHint(hint);
- }
-}
-
-QPlatformServices *QEglFSIntegration::services() const
-{
- return mServices.data();
+ return new QEglFSScreen(display());
}
-QPlatformNativeInterface *QEglFSIntegration::nativeInterface() const
+QEGLPlatformWindow *QEglFSIntegration::createWindow(QWindow *window) const
{
- return const_cast<QEglFSIntegration *>(this);
+ return new QEglFSWindow(window);
}
-enum ResourceType {
- EglDisplay,
- EglWindow,
- EglContext
-};
-
-static int resourceType(const QByteArray &key)
-{
- static const QByteArray names[] = { // match ResourceType
- QByteArrayLiteral("egldisplay"),
- QByteArrayLiteral("eglwindow"),
- QByteArrayLiteral("eglcontext")
- };
- const QByteArray *end = names + sizeof(names) / sizeof(names[0]);
- const QByteArray *result = std::find(names, end, key);
- if (result == end)
- result = std::find(names, end, key.toLower());
- return int(result - names);
-}
-
-void *QEglFSIntegration::nativeResourceForIntegration(const QByteArray &resource)
-{
- void *result = 0;
-
- switch (resourceType(resource)) {
- case EglDisplay:
- result = mScreen->display();
- break;
- default:
- break;
- }
-
- return result;
-}
-
-void *QEglFSIntegration::nativeResourceForWindow(const QByteArray &resource, QWindow *window)
-{
- void *result = 0;
-
- switch (resourceType(resource)) {
- case EglDisplay:
- if (window && window->handle())
- result = static_cast<QEglFSScreen *>(window->handle()->screen())->display();
- else
- result = mScreen->display();
- break;
- case EglWindow:
- if (window && window->handle())
- result = reinterpret_cast<void*>(static_cast<QEglFSWindow *>(window->handle())->eglWindow());
- break;
- default:
- break;
- }
-
- return result;
-}
-
-void *QEglFSIntegration::nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context)
+QVariant QEglFSIntegration::styleHint(QPlatformIntegration::StyleHint hint) const
{
- void *result = 0;
-
- switch (resourceType(resource)) {
- case EglContext:
- if (context->handle())
- result = static_cast<QEGLPlatformContext *>(context->handle())->eglContext();
- break;
+ switch (hint)
+ {
+ case QPlatformIntegration::ShowIsFullScreen:
+ return screen()->compositingWindow() == 0;
default:
- break;
+ return QPlatformIntegration::styleHint(hint);
}
-
- return result;
-}
-
-static void *eglContextForContext(QOpenGLContext *context)
-{
- Q_ASSERT(context);
-
- QEGLPlatformContext *handle = static_cast<QEGLPlatformContext *>(context->handle());
- if (!handle)
- return 0;
-
- return handle->eglContext();
-}
-
-QPlatformNativeInterface::NativeResourceForContextFunction QEglFSIntegration::nativeResourceFunctionForContext(const QByteArray &resource)
-{
- QByteArray lowerCaseResource = resource.toLower();
- if (lowerCaseResource == "get_egl_context")
- return NativeResourceForContextFunction(eglContextForContext);
-
- return 0;
}
EGLConfig QEglFSIntegration::chooseConfig(EGLDisplay display, const QSurfaceFormat &format)
diff --git a/src/plugins/platforms/eglfs/qeglfsintegration.h b/src/plugins/platforms/eglfs/qeglfsintegration.h
index 12c8158bd1..581b523c76 100644
--- a/src/plugins/platforms/eglfs/qeglfsintegration.h
+++ b/src/plugins/platforms/eglfs/qeglfsintegration.h
@@ -42,61 +42,36 @@
#ifndef QEGLFSINTEGRATION_H
#define QEGLFSINTEGRATION_H
-#include "qeglfsscreen.h"
-
-#include <qpa/qplatformintegration.h>
-#include <qpa/qplatformnativeinterface.h>
+#include <QtPlatformSupport/private/qeglplatformintegration_p.h>
#include <qpa/qplatformscreen.h>
+#include <EGL/egl.h>
QT_BEGIN_NAMESPACE
-class QEglFSIntegration : public QPlatformIntegration, public QPlatformNativeInterface
+class QEglFSIntegration : public QEGLPlatformIntegration
{
public:
QEglFSIntegration();
~QEglFSIntegration();
- bool hasCapability(QPlatformIntegration::Capability cap) const;
-
- QPlatformWindow *createPlatformWindow(QWindow *window) const;
- QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const;
- QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const;
- QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const;
- QPlatformNativeInterface *nativeInterface() const;
-
- QPlatformFontDatabase *fontDatabase() const;
- QPlatformServices *services() const;
-
- QAbstractEventDispatcher *createEventDispatcher() const;
- void initialize();
+ QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const Q_DECL_OVERRIDE;
+ QPlatformOffscreenSurface *createPlatformOffscreenSurface(QOffscreenSurface *surface) const Q_DECL_OVERRIDE;
- QVariant styleHint(QPlatformIntegration::StyleHint hint) const;
+ void initialize() Q_DECL_OVERRIDE;
- // QPlatformNativeInterface
- void *nativeResourceForIntegration(const QByteArray &resource);
- void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) Q_DECL_OVERRIDE;
- void *nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context);
+ bool hasCapability(QPlatformIntegration::Capability cap) const Q_DECL_OVERRIDE;
+ QVariant styleHint(QPlatformIntegration::StyleHint hint) const Q_DECL_OVERRIDE;
- NativeResourceForContextFunction nativeResourceFunctionForContext(const QByteArray &resource) Q_DECL_OVERRIDE;
-
- QPlatformScreen *screen() const { return mScreen; }
static EGLConfig chooseConfig(EGLDisplay display, const QSurfaceFormat &format);
- EGLDisplay display() const { return mDisplay; }
-
- QPlatformInputContext *inputContext() const { return mInputContext; }
-
protected:
- virtual QEglFSScreen *createScreen() const;
+ QEGLPlatformScreen *createScreen() const Q_DECL_OVERRIDE;
+ QEGLPlatformWindow *createWindow(QWindow *window) const Q_DECL_OVERRIDE;
+ EGLNativeDisplayType nativeDisplay() const Q_DECL_OVERRIDE;
private:
void createInputHandlers();
- EGLDisplay mDisplay;
- QScopedPointer<QPlatformFontDatabase> mFontDb;
- QScopedPointer<QPlatformServices> mServices;
- QEglFSScreen *mScreen;
- QPlatformInputContext *mInputContext;
bool mDisableInputHandlers;
};
diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.cpp b/src/plugins/platforms/eglfs/qeglfsscreen.cpp
index 758b461b3f..11c1160ce9 100644
--- a/src/plugins/platforms/eglfs/qeglfsscreen.cpp
+++ b/src/plugins/platforms/eglfs/qeglfsscreen.cpp
@@ -39,39 +39,25 @@
**
****************************************************************************/
-#include "qeglfscursor.h"
#include "qeglfsscreen.h"
#include "qeglfswindow.h"
#include "qeglfshooks.h"
-
-#if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK))
-#include <QtPlatformSupport/private/qdevicediscovery_p.h>
-#endif
+#include <QtPlatformSupport/private/qeglplatformcursor_p.h>
QT_BEGIN_NAMESPACE
QEglFSScreen::QEglFSScreen(EGLDisplay dpy)
- : m_dpy(dpy),
+ : QEGLPlatformScreen(dpy),
m_surface(EGL_NO_SURFACE),
m_cursor(0),
+ m_rootWindow(0),
m_rootContext(0)
{
#ifdef QEGL_EXTRA_DEBUG
qWarning("QEglScreen %p\n", this);
#endif
- QByteArray hideCursorVal = qgetenv("QT_QPA_EGLFS_HIDECURSOR");
- bool hideCursor = false;
- if (hideCursorVal.isEmpty()) {
-#if !defined(QT_NO_EVDEV) && (!defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK))
- QScopedPointer<QDeviceDiscovery> dis(QDeviceDiscovery::create(QDeviceDiscovery::Device_Mouse));
- hideCursor = dis->scanConnectedDevices().isEmpty();
-#endif
- } else {
- hideCursor = hideCursorVal.toInt() != 0;
- }
- if (!hideCursor)
- m_cursor = QEglFSHooks::hooks()->createCursor(this);
+ m_cursor = QEglFSHooks::hooks()->createCursor(this);
}
QEglFSScreen::~QEglFSScreen()
@@ -124,50 +110,4 @@ void QEglFSScreen::setPrimarySurface(EGLSurface surface)
m_surface = surface;
}
-void QEglFSScreen::addWindow(QEglFSWindow *window)
-{
- if (!m_windows.contains(window)) {
- m_windows.append(window);
- topWindowChanged(window);
- }
-}
-
-void QEglFSScreen::removeWindow(QEglFSWindow *window)
-{
- m_windows.removeOne(window);
- if (!m_windows.isEmpty())
- topWindowChanged(m_windows.last());
-}
-
-void QEglFSScreen::moveToTop(QEglFSWindow *window)
-{
- m_windows.removeOne(window);
- m_windows.append(window);
- topWindowChanged(window);
-}
-
-void QEglFSScreen::changeWindowIndex(QEglFSWindow *window, int newIdx)
-{
- int idx = m_windows.indexOf(window);
- if (idx != -1 && idx != newIdx) {
- m_windows.move(idx, newIdx);
- if (newIdx == m_windows.size() - 1)
- topWindowChanged(m_windows.last());
- }
-}
-
-QEglFSWindow *QEglFSScreen::rootWindow()
-{
- Q_FOREACH (QEglFSWindow *window, m_windows) {
- if (window->hasNativeWindow())
- return window;
- }
- return 0;
-}
-
-void QEglFSScreen::topWindowChanged(QPlatformWindow *window)
-{
- Q_UNUSED(window);
-}
-
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfsscreen.h b/src/plugins/platforms/eglfs/qeglfsscreen.h
index 11d66b7e0f..13f7cfddd8 100644
--- a/src/plugins/platforms/eglfs/qeglfsscreen.h
+++ b/src/plugins/platforms/eglfs/qeglfsscreen.h
@@ -42,7 +42,7 @@
#ifndef QEGLFSSCREEN_H
#define QEGLFSSCREEN_H
-#include <qpa/qplatformscreen.h>
+#include <QtPlatformSupport/private/qeglplatformscreen_p.h>
#include <QtCore/QTextStream>
@@ -50,52 +50,48 @@
QT_BEGIN_NAMESPACE
-class QEglFSCursor;
+class QEGLPlatformCursor;
class QEglFSWindow;
class QOpenGLContext;
-class QEglFSScreen : public QPlatformScreen
+class QEglFSScreen : public QEGLPlatformScreen
{
public:
QEglFSScreen(EGLDisplay display);
~QEglFSScreen();
- QRect geometry() const;
- int depth() const;
- QImage::Format format() const;
+ QRect geometry() const Q_DECL_OVERRIDE;
+ int depth() const Q_DECL_OVERRIDE;
+ QImage::Format format() const Q_DECL_OVERRIDE;
- QSizeF physicalSize() const;
- QDpi logicalDpi() const;
- Qt::ScreenOrientation nativeOrientation() const;
- Qt::ScreenOrientation orientation() const;
+ QSizeF physicalSize() const Q_DECL_OVERRIDE;
+ QDpi logicalDpi() const Q_DECL_OVERRIDE;
+ Qt::ScreenOrientation nativeOrientation() const Q_DECL_OVERRIDE;
+ Qt::ScreenOrientation orientation() const Q_DECL_OVERRIDE;
- QPlatformCursor *cursor() const;
+ QPlatformCursor *cursor() const Q_DECL_OVERRIDE;
- EGLDisplay display() const { return m_dpy; }
EGLSurface primarySurface() const { return m_surface; }
- QList<QEglFSWindow *> windows() const { return m_windows; }
- void addWindow(QEglFSWindow *window);
- void removeWindow(QEglFSWindow *window);
- void moveToTop(QEglFSWindow *window);
- void changeWindowIndex(QEglFSWindow *window, int newIdx);
- QEglFSWindow *rootWindow();
- QOpenGLContext *rootContext() { return m_rootContext; }
+ QEGLPlatformWindow *compositingWindow() Q_DECL_OVERRIDE { return m_rootWindow; }
+ QOpenGLContext *compositingContext() Q_DECL_OVERRIDE { return m_rootContext; }
+
+ void setRootWindow(QEGLPlatformWindow *window) { m_rootWindow = window; }
void setRootContext(QOpenGLContext *context) { m_rootContext = context; }
protected:
void setPrimarySurface(EGLSurface surface);
- virtual void topWindowChanged(QPlatformWindow *window);
private:
friend class QEglFSWindow;
EGLDisplay m_dpy;
EGLSurface m_surface;
- QEglFSCursor *m_cursor;
- QList<QEglFSWindow *> m_windows;
+ QEGLPlatformCursor *m_cursor;
+ QEGLPlatformWindow *m_rootWindow;
QOpenGLContext *m_rootContext;
};
QT_END_NAMESPACE
+
#endif // QEGLFSSCREEN_H
diff --git a/src/plugins/platforms/eglfs/qeglfswindow.cpp b/src/plugins/platforms/eglfs/qeglfswindow.cpp
index cc0e64a83b..279e7bbc91 100644
--- a/src/plugins/platforms/eglfs/qeglfswindow.cpp
+++ b/src/plugins/platforms/eglfs/qeglfswindow.cpp
@@ -41,13 +41,11 @@
#include "qeglfswindow.h"
#include "qeglfshooks.h"
-#include "qeglfscursor.h"
-#include "qeglfsbackingstore.h"
#include <qpa/qwindowsysteminterface.h>
#include <qpa/qplatformintegration.h>
#include <private/qguiapplication_p.h>
#include <QtGui/QOpenGLContext>
-
+#include <QtPlatformSupport/private/qeglplatformcursor_p.h>
#include <QtPlatformSupport/private/qeglconvenience_p.h>
#include <QtDebug>
@@ -55,11 +53,9 @@
QT_BEGIN_NAMESPACE
QEglFSWindow::QEglFSWindow(QWindow *w)
- : QPlatformWindow(w)
+ : QEGLPlatformWindow(w)
, m_surface(0)
, m_window(0)
- , m_wid(0)
- , m_backingStore(0)
, m_flags(0)
{
#ifdef QEGL_EXTRA_DEBUG
@@ -72,41 +68,24 @@ QEglFSWindow::~QEglFSWindow()
destroy();
}
-static WId newWId()
-{
- static WId id = 0;
-
- if (id == std::numeric_limits<WId>::max())
- qWarning("EGLFS: Out of window IDs");
-
- return ++id;
-}
-
void QEglFSWindow::create()
{
if (m_flags.testFlag(Created))
return;
+ QEGLPlatformWindow::create();
+
m_flags = Created;
- m_wid = newWId();
- if (window()->type() == Qt::Desktop) {
- QRect rect(QPoint(), QEglFSHooks::hooks()->screenSize());
- QPlatformWindow::setGeometry(rect);
- QWindowSystemInterface::handleGeometryChange(window(), rect);
+ if (window()->type() == Qt::Desktop)
return;
- }
-
- // Save the original surface type before changing to OpenGLSurface.
- if (window()->surfaceType() == QSurface::RasterSurface)
- m_flags |= IsRaster;
// Stop if there is already a window backed by a native window and surface. Additional
// raster windows will not have their own native window, surface and context. Instead,
// they will be composited onto the root window's surface.
QEglFSScreen *screen = this->screen();
if (screen->primarySurface() != EGL_NO_SURFACE) {
- if (m_flags.testFlag(IsRaster) && screen->rootWindow()->m_flags.testFlag(IsRaster))
+ if (isRaster() && screen->compositingWindow())
return;
#if !defined(Q_OS_ANDROID) || defined(Q_OS_ANDROID_NO_SDK)
@@ -118,7 +97,6 @@ void QEglFSWindow::create()
return;
}
- window()->setSurfaceType(QSurface::OpenGLSurface);
m_flags |= HasNativeWindow;
setGeometry(QRect()); // will become fullscreen
QWindowSystemInterface::handleExposeEvent(window(), geometry());
@@ -132,12 +110,13 @@ void QEglFSWindow::create()
screen->setPrimarySurface(m_surface);
- if (m_flags.testFlag(IsRaster)) {
+ if (isRaster()) {
QOpenGLContext *context = new QOpenGLContext(QGuiApplication::instance());
context->setFormat(window()->requestedFormat());
context->setScreen(window()->screen());
context->create();
screen->setRootContext(context);
+ screen->setRootWindow(this);
}
}
@@ -145,7 +124,7 @@ void QEglFSWindow::destroy()
{
QEglFSScreen *screen = this->screen();
if (m_flags.testFlag(HasNativeWindow)) {
- QEglFSCursor *cursor = static_cast<QEglFSCursor *>(screen->cursor());
+ QEGLPlatformCursor *cursor = static_cast<QEGLPlatformCursor *>(screen->cursor());
if (cursor)
cursor->resetResources();
@@ -188,7 +167,7 @@ void QEglFSWindow::resetSurface()
void QEglFSWindow::setVisible(bool visible)
{
- QList<QEglFSWindow *> windows = screen()->windows();
+ QList<QEGLPlatformWindow *> windows = screen()->windows();
if (window()->type() != Qt::Desktop) {
if (visible) {
@@ -234,11 +213,6 @@ QRect QEglFSWindow::geometry() const
return QPlatformWindow::geometry();
}
-WId QEglFSWindow::winId() const
-{
- return m_wid;
-}
-
void QEglFSWindow::requestActivateWindow()
{
if (window()->type() != Qt::Desktop)
@@ -258,7 +232,7 @@ void QEglFSWindow::raise()
void QEglFSWindow::lower()
{
- QList<QEglFSWindow *> windows = screen()->windows();
+ QList<QEGLPlatformWindow *> windows = screen()->windows();
if (window()->type() != Qt::Desktop && windows.count() > 1) {
int idx = windows.indexOf(this);
if (idx > 0) {
@@ -288,12 +262,4 @@ QEglFSScreen *QEglFSWindow::screen() const
return static_cast<QEglFSScreen *>(QPlatformWindow::screen());
}
-uint QEglFSWindow::texture() const
-{
- if (m_backingStore)
- return m_backingStore->texture();
-
- return 0;
-}
-
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglfs/qeglfswindow.h b/src/plugins/platforms/eglfs/qeglfswindow.h
index ee3c194a7c..f93a9d54bc 100644
--- a/src/plugins/platforms/eglfs/qeglfswindow.h
+++ b/src/plugins/platforms/eglfs/qeglfswindow.h
@@ -45,42 +45,32 @@
#include "qeglfsintegration.h"
#include "qeglfsscreen.h"
-#include <qpa/qplatformwindow.h>
+#include <QtPlatformSupport/private/qeglplatformwindow_p.h>
QT_BEGIN_NAMESPACE
-class QEglFSBackingStore;
-
-class QEglFSWindow : public QPlatformWindow
+class QEglFSWindow : public QEGLPlatformWindow
{
public:
QEglFSWindow(QWindow *w);
~QEglFSWindow();
- void setGeometry(const QRect &);
- QRect geometry() const;
- WId winId() const;
- void setVisible(bool visible);
- void requestActivateWindow();
- void raise();
- void lower();
+ void create() Q_DECL_OVERRIDE;
+ void destroy();
+
+ void setGeometry(const QRect &) Q_DECL_OVERRIDE;
+ QRect geometry() const Q_DECL_OVERRIDE;
+ void setVisible(bool visible) Q_DECL_OVERRIDE;
+ void requestActivateWindow() Q_DECL_OVERRIDE;
+ void raise() Q_DECL_OVERRIDE;
+ void lower() Q_DECL_OVERRIDE;
+ QSurfaceFormat format() const Q_DECL_OVERRIDE;
+ EGLNativeWindowType eglWindow() const Q_DECL_OVERRIDE;
EGLSurface surface() const;
- QSurfaceFormat format() const;
- EGLNativeWindowType eglWindow() const;
-
QEglFSScreen *screen() const;
- void create();
- void destroy();
-
bool hasNativeWindow() const { return m_flags.testFlag(HasNativeWindow); }
- bool isRaster() const { return m_flags.testFlag(IsRaster); }
-
- QEglFSBackingStore *backingStore() { return m_backingStore; }
- void setBackingStore(QEglFSBackingStore *backingStore) { m_backingStore = backingStore; }
-
- uint texture() const;
virtual void invalidateSurface();
virtual void resetSurface();
@@ -92,13 +82,10 @@ protected:
private:
EGLConfig m_config;
QSurfaceFormat m_format;
- WId m_wid;
- QEglFSBackingStore *m_backingStore;
enum Flag {
Created = 0x01,
- IsRaster = 0x02,
- HasNativeWindow = 0x04
+ HasNativeWindow = 0x02
};
Q_DECLARE_FLAGS(Flags, Flag);
Flags m_flags;