EGLFS: Enablers for Android plugin
These are some changes that are needed to make the Android plugin as a subclass of the EGLFS plugin. Change-Id: I7c77931f311d8a07f9292715d2abc256c5d552d8 Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
This commit is contained in:
parent
f4d7b4d10f
commit
dedec0b305
44
src/plugins/platforms/eglfs/eglfs.pri
Normal file
44
src/plugins/platforms/eglfs/eglfs.pri
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
QT += core-private gui-private platformsupport-private
|
||||||
|
|
||||||
|
#DEFINES += QEGL_EXTRA_DEBUG
|
||||||
|
|
||||||
|
#Avoid X11 header collision
|
||||||
|
DEFINES += MESA_EGL_NO_X11_HEADERS
|
||||||
|
|
||||||
|
#To test the hooks on x11 (xlib), comment the above define too
|
||||||
|
#EGLFS_PLATFORM_HOOKS_SOURCES += qeglfshooks_x11.cpp
|
||||||
|
#LIBS += -lX11
|
||||||
|
|
||||||
|
SOURCES += $$PWD/qeglfsintegration.cpp \
|
||||||
|
$$PWD/qeglfswindow.cpp \
|
||||||
|
$$PWD/qeglfsbackingstore.cpp \
|
||||||
|
$$PWD/qeglfsscreen.cpp \
|
||||||
|
$$PWD/qeglfshooks_stub.cpp \
|
||||||
|
$$PWD/qeglfscursor.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
|
||||||
|
|
||||||
|
QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF
|
||||||
|
|
||||||
|
INCLUDEPATH += $$PWD
|
||||||
|
|
||||||
|
!isEmpty(EGLFS_PLATFORM_HOOKS_SOURCES) {
|
||||||
|
HEADERS += $$EGLFS_PLATFORM_HOOKS_HEADERS
|
||||||
|
SOURCES += $$EGLFS_PLATFORM_HOOKS_SOURCES
|
||||||
|
LIBS += $$EGLFS_PLATFORM_HOOKS_LIBS
|
||||||
|
DEFINES += EGLFS_PLATFORM_HOOKS
|
||||||
|
}
|
||||||
|
|
||||||
|
CONFIG += egl qpa/genericunixfontdatabase
|
||||||
|
|
||||||
|
RESOURCES += $$PWD/cursor.qrc
|
||||||
|
|
||||||
|
OTHER_FILES += \
|
||||||
|
$$PWD/eglfs.json
|
@ -4,48 +4,6 @@ PLUGIN_TYPE = platforms
|
|||||||
PLUGIN_CLASS_NAME = QEglFSIntegrationPlugin
|
PLUGIN_CLASS_NAME = QEglFSIntegrationPlugin
|
||||||
load(qt_plugin)
|
load(qt_plugin)
|
||||||
|
|
||||||
QT += core-private gui-private platformsupport-private
|
SOURCES += $$PWD/main.cpp
|
||||||
|
|
||||||
#DEFINES += QEGL_EXTRA_DEBUG
|
include(eglfs.pri)
|
||||||
|
|
||||||
#Avoid X11 header collision
|
|
||||||
DEFINES += MESA_EGL_NO_X11_HEADERS
|
|
||||||
|
|
||||||
#To test the hooks on x11 (xlib), comment the above define too
|
|
||||||
#EGLFS_PLATFORM_HOOKS_SOURCES += qeglfshooks_x11.cpp
|
|
||||||
#LIBS += -lX11
|
|
||||||
|
|
||||||
SOURCES = main.cpp \
|
|
||||||
qeglfsintegration.cpp \
|
|
||||||
qeglfswindow.cpp \
|
|
||||||
qeglfsbackingstore.cpp \
|
|
||||||
qeglfsscreen.cpp \
|
|
||||||
qeglfshooks_stub.cpp \
|
|
||||||
qeglfscursor.cpp \
|
|
||||||
qeglfscontext.cpp
|
|
||||||
|
|
||||||
HEADERS = qeglfsintegration.h \
|
|
||||||
qeglfswindow.h \
|
|
||||||
qeglfsbackingstore.h \
|
|
||||||
qeglfsscreen.h \
|
|
||||||
qeglfscursor.h \
|
|
||||||
qeglfshooks.h \
|
|
||||||
qeglfscontext.h
|
|
||||||
|
|
||||||
QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF
|
|
||||||
|
|
||||||
INCLUDEPATH += $$PWD
|
|
||||||
|
|
||||||
!isEmpty(EGLFS_PLATFORM_HOOKS_SOURCES) {
|
|
||||||
HEADERS += $$EGLFS_PLATFORM_HOOKS_HEADERS
|
|
||||||
SOURCES += $$EGLFS_PLATFORM_HOOKS_SOURCES
|
|
||||||
LIBS += $$EGLFS_PLATFORM_HOOKS_LIBS
|
|
||||||
DEFINES += EGLFS_PLATFORM_HOOKS
|
|
||||||
}
|
|
||||||
|
|
||||||
CONFIG += egl qpa/genericunixfontdatabase
|
|
||||||
|
|
||||||
RESOURCES += cursor.qrc
|
|
||||||
|
|
||||||
OTHER_FILES += \
|
|
||||||
eglfs.json
|
|
||||||
|
@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
QEglFSContext::QEglFSContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share,
|
QEglFSContext::QEglFSContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share,
|
||||||
EGLDisplay display, EGLenum eglApi)
|
EGLDisplay display, EGLenum eglApi)
|
||||||
: QEGLPlatformContext(format, share, display, QEglFSIntegration::chooseConfig(display, format), eglApi)
|
: QEGLPlatformContext(QEglFSHooks::hooks()->surfaceFormatFor(format), share, display, QEglFSIntegration::chooseConfig(display, QEglFSHooks::hooks()->surfaceFormatFor(format)), eglApi)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,12 +246,14 @@ QEglFSCursor *QEglFSHooks::createCursor(QEglFSScreen *screen) const
|
|||||||
|
|
||||||
void QEglFSHooks::waitForVSync() const
|
void QEglFSHooks::waitForVSync() const
|
||||||
{
|
{
|
||||||
|
#if defined(FBIO_WAITFORVSYNC)
|
||||||
static const bool forceSync = qgetenv("QT_QPA_EGLFS_FORCEVSYNC").toInt();
|
static const bool forceSync = qgetenv("QT_QPA_EGLFS_FORCEVSYNC").toInt();
|
||||||
if (forceSync && framebuffer != -1) {
|
if (forceSync && framebuffer != -1) {
|
||||||
int arg = 0;
|
int arg = 0;
|
||||||
if (ioctl(framebuffer, FBIO_WAITFORVSYNC, &arg) == -1)
|
if (ioctl(framebuffer, FBIO_WAITFORVSYNC, &arg) == -1)
|
||||||
qWarning("Could not wait for vsync.");
|
qWarning("Could not wait for vsync.");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef EGLFS_PLATFORM_HOOKS
|
#ifndef EGLFS_PLATFORM_HOOKS
|
||||||
|
@ -74,8 +74,11 @@ public:
|
|||||||
void *nativeResourceForIntegration(const QByteArray &resource);
|
void *nativeResourceForIntegration(const QByteArray &resource);
|
||||||
void *nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context);
|
void *nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context);
|
||||||
|
|
||||||
|
QPlatformScreen *screen() const { return mScreen; }
|
||||||
static EGLConfig chooseConfig(EGLDisplay display, const QSurfaceFormat &format);
|
static EGLConfig chooseConfig(EGLDisplay display, const QSurfaceFormat &format);
|
||||||
|
|
||||||
|
EGLDisplay display() const { return mDisplay; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EGLDisplay mDisplay;
|
EGLDisplay mDisplay;
|
||||||
QAbstractEventDispatcher *mEventDispatcher;
|
QAbstractEventDispatcher *mEventDispatcher;
|
||||||
|
@ -84,11 +84,28 @@ void QEglFSWindow::create()
|
|||||||
|
|
||||||
EGLDisplay display = (static_cast<QEglFSScreen *>(window()->screen()->handle()))->display();
|
EGLDisplay display = (static_cast<QEglFSScreen *>(window()->screen()->handle()))->display();
|
||||||
QSurfaceFormat platformFormat = QEglFSHooks::hooks()->surfaceFormatFor(window()->requestedFormat());
|
QSurfaceFormat platformFormat = QEglFSHooks::hooks()->surfaceFormatFor(window()->requestedFormat());
|
||||||
EGLConfig config = QEglFSIntegration::chooseConfig(display, platformFormat);
|
m_config = QEglFSIntegration::chooseConfig(display, platformFormat);
|
||||||
|
m_format = q_glFormatFromConfig(display, m_config);
|
||||||
|
resetSurface();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QEglFSWindow::invalidateSurface()
|
||||||
|
{
|
||||||
|
// Native surface has been deleted behind our backs
|
||||||
|
m_window = 0;
|
||||||
|
if (m_surface != 0) {
|
||||||
|
EGLDisplay display = (static_cast<QEglFSScreen *>(window()->screen()->handle()))->display();
|
||||||
|
eglDestroySurface(display, m_surface);
|
||||||
|
m_surface = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void QEglFSWindow::resetSurface()
|
||||||
|
{
|
||||||
|
EGLDisplay display = static_cast<QEglFSScreen *>(screen())->display();
|
||||||
|
|
||||||
m_format = q_glFormatFromConfig(display, config);
|
|
||||||
m_window = QEglFSHooks::hooks()->createNativeWindow(QEglFSHooks::hooks()->screenSize(), m_format);
|
m_window = QEglFSHooks::hooks()->createNativeWindow(QEglFSHooks::hooks()->screenSize(), m_format);
|
||||||
m_surface = eglCreateWindowSurface(display, config, m_window, NULL);
|
m_surface = eglCreateWindowSurface(display, m_config, m_window, NULL);
|
||||||
if (m_surface == EGL_NO_SURFACE) {
|
if (m_surface == EGL_NO_SURFACE) {
|
||||||
EGLint error = eglGetError();
|
EGLint error = eglGetError();
|
||||||
eglTerminate(display);
|
eglTerminate(display);
|
||||||
@ -99,7 +116,7 @@ void QEglFSWindow::create()
|
|||||||
void QEglFSWindow::destroy()
|
void QEglFSWindow::destroy()
|
||||||
{
|
{
|
||||||
if (m_surface) {
|
if (m_surface) {
|
||||||
EGLDisplay display = (static_cast<QEglFSScreen *>(window()->screen()->handle()))->display();
|
EGLDisplay display = static_cast<QEglFSScreen *>(screen())->display();
|
||||||
eglDestroySurface(display, m_surface);
|
eglDestroySurface(display, m_surface);
|
||||||
m_surface = 0;
|
m_surface = 0;
|
||||||
}
|
}
|
||||||
@ -114,9 +131,8 @@ void QEglFSWindow::setGeometry(const QRect &)
|
|||||||
{
|
{
|
||||||
// We only support full-screen windows
|
// We only support full-screen windows
|
||||||
QRect rect(screen()->availableGeometry());
|
QRect rect(screen()->availableGeometry());
|
||||||
QWindowSystemInterface::handleGeometryChange(window(), rect);
|
|
||||||
|
|
||||||
QPlatformWindow::setGeometry(rect);
|
QPlatformWindow::setGeometry(rect);
|
||||||
|
QWindowSystemInterface::handleGeometryChange(window(), rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QEglFSWindow::setWindowState(Qt::WindowState)
|
void QEglFSWindow::setWindowState(Qt::WindowState)
|
||||||
|
@ -65,10 +65,14 @@ public:
|
|||||||
void create();
|
void create();
|
||||||
void destroy();
|
void destroy();
|
||||||
|
|
||||||
|
virtual void invalidateSurface();
|
||||||
|
virtual void resetSurface();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
WId m_winid;
|
WId m_winid;
|
||||||
EGLSurface m_surface;
|
EGLSurface m_surface;
|
||||||
EGLNativeWindowType m_window;
|
EGLNativeWindowType m_window;
|
||||||
|
EGLConfig m_config;
|
||||||
QSurfaceFormat m_format;
|
QSurfaceFormat m_format;
|
||||||
};
|
};
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
Loading…
Reference in New Issue
Block a user