eglfs: Add support for systems without pbuffer support
Use a small native window and window surface in case the hooks indicate that pbuffer support is not available. Change-Id: I6515309041f0e1e2f5321d59941f35d6ee16dca7 Reviewed-by: Louai Al-Khanji <louai.al-khanji@digia.com> Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
This commit is contained in:
parent
881ceeff42
commit
1f040d401d
@ -606,6 +606,7 @@ bool QOpenGLContext::create()
|
|||||||
d->platformGLContext = QGuiApplicationPrivate::platformIntegration()->createPlatformOpenGLContext(this);
|
d->platformGLContext = QGuiApplicationPrivate::platformIntegration()->createPlatformOpenGLContext(this);
|
||||||
if (!d->platformGLContext)
|
if (!d->platformGLContext)
|
||||||
return false;
|
return false;
|
||||||
|
d->platformGLContext->initialize();
|
||||||
d->platformGLContext->setContext(this);
|
d->platformGLContext->setContext(this);
|
||||||
if (!d->platformGLContext->isSharing())
|
if (!d->platformGLContext->isSharing())
|
||||||
d->shareContext = 0;
|
d->shareContext = 0;
|
||||||
|
@ -88,6 +88,16 @@ QPlatformOpenGLContext::~QPlatformOpenGLContext()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Called after a new instance is constructed. The default implementation does nothing.
|
||||||
|
|
||||||
|
Subclasses can use this function to perform additional initialization that relies on
|
||||||
|
virtual functions.
|
||||||
|
*/
|
||||||
|
void QPlatformOpenGLContext::initialize()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Reimplement in subclass if your platform uses framebuffer objects for surfaces.
|
Reimplement in subclass if your platform uses framebuffer objects for surfaces.
|
||||||
|
|
||||||
|
@ -63,6 +63,8 @@ public:
|
|||||||
QPlatformOpenGLContext();
|
QPlatformOpenGLContext();
|
||||||
virtual ~QPlatformOpenGLContext();
|
virtual ~QPlatformOpenGLContext();
|
||||||
|
|
||||||
|
virtual void initialize();
|
||||||
|
|
||||||
virtual QSurfaceFormat format() const = 0;
|
virtual QSurfaceFormat format() const = 0;
|
||||||
|
|
||||||
virtual void swapBuffers(QPlatformSurface *surface) = 0;
|
virtual void swapBuffers(QPlatformSurface *surface) = 0;
|
||||||
|
@ -187,7 +187,7 @@ void QEGLPlatformContext::init(const QSurfaceFormat &format, QPlatformOpenGLCont
|
|||||||
q_printEglConfig(m_eglDisplay, m_eglConfig);
|
q_printEglConfig(m_eglDisplay, m_eglConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateFormatFromGL();
|
// Cannot just call updateFormatFromGL() since it relies on virtuals. Defer it to initialize().
|
||||||
}
|
}
|
||||||
|
|
||||||
void QEGLPlatformContext::adopt(const QVariant &nativeHandle, QPlatformOpenGLContext *share)
|
void QEGLPlatformContext::adopt(const QVariant &nativeHandle, QPlatformOpenGLContext *share)
|
||||||
@ -238,6 +238,34 @@ void QEGLPlatformContext::adopt(const QVariant &nativeHandle, QPlatformOpenGLCon
|
|||||||
updateFormatFromGL();
|
updateFormatFromGL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QEGLPlatformContext::initialize()
|
||||||
|
{
|
||||||
|
updateFormatFromGL();
|
||||||
|
}
|
||||||
|
|
||||||
|
EGLSurface QEGLPlatformContext::createTemporaryOffscreenSurface()
|
||||||
|
{
|
||||||
|
// Make the context current to ensure the GL version query works. This needs a surface too.
|
||||||
|
const EGLint pbufferAttributes[] = {
|
||||||
|
EGL_WIDTH, 1,
|
||||||
|
EGL_HEIGHT, 1,
|
||||||
|
EGL_LARGEST_PBUFFER, EGL_FALSE,
|
||||||
|
EGL_NONE
|
||||||
|
};
|
||||||
|
|
||||||
|
// Cannot just pass m_eglConfig because it may not be suitable for pbuffers. Instead,
|
||||||
|
// do what QEGLPbuffer would do: request a config with the same attributes but with
|
||||||
|
// PBUFFER_BIT set.
|
||||||
|
EGLConfig config = q_configFromGLFormat(m_eglDisplay, m_format, false, EGL_PBUFFER_BIT);
|
||||||
|
|
||||||
|
return eglCreatePbufferSurface(m_eglDisplay, config, pbufferAttributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QEGLPlatformContext::destroyTemporaryOffscreenSurface(EGLSurface surface)
|
||||||
|
{
|
||||||
|
eglDestroySurface(m_eglDisplay, surface);
|
||||||
|
}
|
||||||
|
|
||||||
void QEGLPlatformContext::updateFormatFromGL()
|
void QEGLPlatformContext::updateFormatFromGL()
|
||||||
{
|
{
|
||||||
#ifndef QT_NO_OPENGL
|
#ifndef QT_NO_OPENGL
|
||||||
@ -250,22 +278,8 @@ void QEGLPlatformContext::updateFormatFromGL()
|
|||||||
EGLSurface prevSurfaceDraw = eglGetCurrentSurface(EGL_DRAW);
|
EGLSurface prevSurfaceDraw = eglGetCurrentSurface(EGL_DRAW);
|
||||||
EGLSurface prevSurfaceRead = eglGetCurrentSurface(EGL_READ);
|
EGLSurface prevSurfaceRead = eglGetCurrentSurface(EGL_READ);
|
||||||
|
|
||||||
// Make the context current to ensure the GL version query works. This needs a surface too.
|
EGLSurface tempSurface = createTemporaryOffscreenSurface();
|
||||||
const EGLint pbufferAttributes[] = {
|
if (eglMakeCurrent(m_eglDisplay, tempSurface, tempSurface, m_eglContext)) {
|
||||||
EGL_WIDTH, 1,
|
|
||||||
EGL_HEIGHT, 1,
|
|
||||||
EGL_LARGEST_PBUFFER, EGL_FALSE,
|
|
||||||
EGL_NONE
|
|
||||||
};
|
|
||||||
// Cannot just pass m_eglConfig because it may not be suitable for pbuffers. Instead,
|
|
||||||
// do what QEGLPbuffer would do: request a config with the same attributes but with
|
|
||||||
// PBUFFER_BIT set.
|
|
||||||
EGLConfig config = q_configFromGLFormat(m_eglDisplay, m_format, false, EGL_PBUFFER_BIT);
|
|
||||||
EGLSurface pbuffer = eglCreatePbufferSurface(m_eglDisplay, config, pbufferAttributes);
|
|
||||||
if (pbuffer == EGL_NO_SURFACE)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (eglMakeCurrent(m_eglDisplay, pbuffer, pbuffer, m_eglContext)) {
|
|
||||||
if (m_format.renderableType() == QSurfaceFormat::OpenGL
|
if (m_format.renderableType() == QSurfaceFormat::OpenGL
|
||||||
|| m_format.renderableType() == QSurfaceFormat::OpenGLES) {
|
|| m_format.renderableType() == QSurfaceFormat::OpenGLES) {
|
||||||
const GLubyte *s = glGetString(GL_VERSION);
|
const GLubyte *s = glGetString(GL_VERSION);
|
||||||
@ -303,7 +317,7 @@ void QEGLPlatformContext::updateFormatFromGL()
|
|||||||
}
|
}
|
||||||
eglMakeCurrent(prevDisplay, prevSurfaceDraw, prevSurfaceRead, prevContext);
|
eglMakeCurrent(prevDisplay, prevSurfaceDraw, prevSurfaceRead, prevContext);
|
||||||
}
|
}
|
||||||
eglDestroySurface(m_eglDisplay, pbuffer);
|
destroyTemporaryOffscreenSurface(tempSurface);
|
||||||
#endif // QT_NO_OPENGL
|
#endif // QT_NO_OPENGL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,6 +59,7 @@ public:
|
|||||||
EGLConfig *config = 0, const QVariant &nativeHandle = QVariant());
|
EGLConfig *config = 0, const QVariant &nativeHandle = QVariant());
|
||||||
~QEGLPlatformContext();
|
~QEGLPlatformContext();
|
||||||
|
|
||||||
|
void initialize();
|
||||||
bool makeCurrent(QPlatformSurface *surface);
|
bool makeCurrent(QPlatformSurface *surface);
|
||||||
void doneCurrent();
|
void doneCurrent();
|
||||||
void swapBuffers(QPlatformSurface *surface);
|
void swapBuffers(QPlatformSurface *surface);
|
||||||
@ -74,6 +75,8 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) = 0;
|
virtual EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) = 0;
|
||||||
|
virtual EGLSurface createTemporaryOffscreenSurface();
|
||||||
|
virtual void destroyTemporaryOffscreenSurface(EGLSurface surface);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init(const QSurfaceFormat &format, QPlatformOpenGLContext *share);
|
void init(const QSurfaceFormat &format, QPlatformOpenGLContext *share);
|
||||||
|
@ -17,13 +17,15 @@ SOURCES += $$PWD/qeglfsintegration.cpp \
|
|||||||
$$PWD/qeglfswindow.cpp \
|
$$PWD/qeglfswindow.cpp \
|
||||||
$$PWD/qeglfsscreen.cpp \
|
$$PWD/qeglfsscreen.cpp \
|
||||||
$$PWD/qeglfshooks_stub.cpp \
|
$$PWD/qeglfshooks_stub.cpp \
|
||||||
$$PWD/qeglfscontext.cpp
|
$$PWD/qeglfscontext.cpp \
|
||||||
|
$$PWD/qeglfsoffscreenwindow.cpp
|
||||||
|
|
||||||
HEADERS += $$PWD/qeglfsintegration.h \
|
HEADERS += $$PWD/qeglfsintegration.h \
|
||||||
$$PWD/qeglfswindow.h \
|
$$PWD/qeglfswindow.h \
|
||||||
$$PWD/qeglfsscreen.h \
|
$$PWD/qeglfsscreen.h \
|
||||||
$$PWD/qeglfshooks.h \
|
$$PWD/qeglfshooks.h \
|
||||||
$$PWD/qeglfscontext.h
|
$$PWD/qeglfscontext.h \
|
||||||
|
$$PWD/qeglfsoffscreenwindow.h
|
||||||
|
|
||||||
QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF
|
QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF
|
||||||
|
|
||||||
|
@ -45,7 +45,8 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
QEglFSContext::QEglFSContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display,
|
QEglFSContext::QEglFSContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display,
|
||||||
EGLConfig *config, const QVariant &nativeHandle)
|
EGLConfig *config, const QVariant &nativeHandle)
|
||||||
: QEGLPlatformContext(format, share, display, config, nativeHandle)
|
: QEGLPlatformContext(format, share, display, config, nativeHandle),
|
||||||
|
m_tempWindow(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,6 +58,33 @@ EGLSurface QEglFSContext::eglSurfaceForPlatformSurface(QPlatformSurface *surface
|
|||||||
return static_cast<QEGLPbuffer *>(surface)->pbuffer();
|
return static_cast<QEGLPbuffer *>(surface)->pbuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EGLSurface QEglFSContext::createTemporaryOffscreenSurface()
|
||||||
|
{
|
||||||
|
if (QEglFSHooks::hooks()->supportsPBuffers())
|
||||||
|
return QEGLPlatformContext::createTemporaryOffscreenSurface();
|
||||||
|
|
||||||
|
if (!m_tempWindow) {
|
||||||
|
m_tempWindow = QEglFSHooks::hooks()->createNativeOffscreenWindow(format());
|
||||||
|
if (!m_tempWindow) {
|
||||||
|
qWarning("QEglFSContext: Failed to create temporary native window");
|
||||||
|
return EGL_NO_SURFACE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EGLConfig config = q_configFromGLFormat(eglDisplay(), format());
|
||||||
|
return eglCreateWindowSurface(eglDisplay(), config, m_tempWindow, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QEglFSContext::destroyTemporaryOffscreenSurface(EGLSurface surface)
|
||||||
|
{
|
||||||
|
if (QEglFSHooks::hooks()->supportsPBuffers()) {
|
||||||
|
QEGLPlatformContext::destroyTemporaryOffscreenSurface(surface);
|
||||||
|
} else {
|
||||||
|
eglDestroySurface(eglDisplay(), surface);
|
||||||
|
QEglFSHooks::hooks()->destroyNativeWindow(m_tempWindow);
|
||||||
|
m_tempWindow = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void QEglFSContext::swapBuffers(QPlatformSurface *surface)
|
void QEglFSContext::swapBuffers(QPlatformSurface *surface)
|
||||||
{
|
{
|
||||||
// draw the cursor
|
// draw the cursor
|
||||||
|
@ -45,7 +45,12 @@ public:
|
|||||||
QEglFSContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display,
|
QEglFSContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share, EGLDisplay display,
|
||||||
EGLConfig *config, const QVariant &nativeHandle);
|
EGLConfig *config, const QVariant &nativeHandle);
|
||||||
EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) Q_DECL_OVERRIDE;
|
EGLSurface eglSurfaceForPlatformSurface(QPlatformSurface *surface) Q_DECL_OVERRIDE;
|
||||||
|
EGLSurface createTemporaryOffscreenSurface() Q_DECL_OVERRIDE;
|
||||||
|
void destroyTemporaryOffscreenSurface(EGLSurface surface) Q_DECL_OVERRIDE;
|
||||||
void swapBuffers(QPlatformSurface *surface) Q_DECL_OVERRIDE;
|
void swapBuffers(QPlatformSurface *surface) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
EGLNativeWindowType m_tempWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -62,6 +62,7 @@ public:
|
|||||||
virtual EGLNativeWindowType createNativeWindow(QPlatformWindow *platformWindow,
|
virtual EGLNativeWindowType createNativeWindow(QPlatformWindow *platformWindow,
|
||||||
const QSize &size,
|
const QSize &size,
|
||||||
const QSurfaceFormat &format);
|
const QSurfaceFormat &format);
|
||||||
|
virtual EGLNativeWindowType createNativeOffscreenWindow(const QSurfaceFormat &format);
|
||||||
virtual void destroyNativeWindow(EGLNativeWindowType window);
|
virtual void destroyNativeWindow(EGLNativeWindowType window);
|
||||||
virtual bool hasCapability(QPlatformIntegration::Capability cap) const;
|
virtual bool hasCapability(QPlatformIntegration::Capability cap) const;
|
||||||
virtual QPlatformCursor *createCursor(QPlatformScreen *screen) const;
|
virtual QPlatformCursor *createCursor(QPlatformScreen *screen) const;
|
||||||
@ -72,6 +73,8 @@ public:
|
|||||||
virtual QByteArray fbDeviceName() const;
|
virtual QByteArray fbDeviceName() const;
|
||||||
virtual int framebufferIndex() const;
|
virtual int framebufferIndex() const;
|
||||||
|
|
||||||
|
virtual bool supportsPBuffers() const;
|
||||||
|
|
||||||
static QEglFSHooks *hooks()
|
static QEglFSHooks *hooks()
|
||||||
{
|
{
|
||||||
#ifdef EGLFS_PLATFORM_HOOKS
|
#ifdef EGLFS_PLATFORM_HOOKS
|
||||||
|
@ -108,10 +108,12 @@ public:
|
|||||||
EGLNativeWindowType createNativeWindow(QPlatformWindow *platformWindow,
|
EGLNativeWindowType createNativeWindow(QPlatformWindow *platformWindow,
|
||||||
const QSize &size,
|
const QSize &size,
|
||||||
const QSurfaceFormat &format) Q_DECL_OVERRIDE;
|
const QSurfaceFormat &format) Q_DECL_OVERRIDE;
|
||||||
|
EGLNativeWindowType createNativeOffscreenWindow(const QSurfaceFormat &format) Q_DECL_OVERRIDE;
|
||||||
void destroyNativeWindow(EGLNativeWindowType window) Q_DECL_OVERRIDE;
|
void destroyNativeWindow(EGLNativeWindowType window) Q_DECL_OVERRIDE;
|
||||||
bool hasCapability(QPlatformIntegration::Capability cap) const Q_DECL_OVERRIDE;
|
bool hasCapability(QPlatformIntegration::Capability cap) const Q_DECL_OVERRIDE;
|
||||||
QPlatformCursor *createCursor(QPlatformScreen *screen) const Q_DECL_OVERRIDE;
|
QPlatformCursor *createCursor(QPlatformScreen *screen) const Q_DECL_OVERRIDE;
|
||||||
void presentBuffer() Q_DECL_OVERRIDE;
|
void presentBuffer() Q_DECL_OVERRIDE;
|
||||||
|
bool supportsPBuffers() const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool setup_kms();
|
bool setup_kms();
|
||||||
@ -259,6 +261,18 @@ EGLNativeWindowType QEglKmsHooks::createNativeWindow(QPlatformWindow *platformWi
|
|||||||
return reinterpret_cast<EGLNativeWindowType>(m_gbm_surface);
|
return reinterpret_cast<EGLNativeWindowType>(m_gbm_surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EGLNativeWindowType QEglKmsHooks::createNativeOffscreenWindow(const QSurfaceFormat &format)
|
||||||
|
{
|
||||||
|
Q_UNUSED(format);
|
||||||
|
|
||||||
|
gbm_surface *surface = gbm_surface_create(m_gbm_device,
|
||||||
|
1, 1,
|
||||||
|
GBM_FORMAT_XRGB8888,
|
||||||
|
GBM_BO_USE_RENDERING);
|
||||||
|
|
||||||
|
return reinterpret_cast<EGLNativeWindowType>(surface);
|
||||||
|
}
|
||||||
|
|
||||||
void QEglKmsHooks::destroyNativeWindow(EGLNativeWindowType window)
|
void QEglKmsHooks::destroyNativeWindow(EGLNativeWindowType window)
|
||||||
{
|
{
|
||||||
gbm_surface *surface = reinterpret_cast<gbm_surface *>(window);
|
gbm_surface *surface = reinterpret_cast<gbm_surface *>(window);
|
||||||
@ -413,6 +427,11 @@ void QEglKmsHooks::presentBuffer()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QEglKmsHooks::supportsPBuffers() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool QEglKmsHooks::setup_kms()
|
bool QEglKmsHooks::setup_kms()
|
||||||
{
|
{
|
||||||
drmModeRes *resources;
|
drmModeRes *resources;
|
||||||
|
@ -162,6 +162,12 @@ EGLNativeWindowType QEglFSHooks::createNativeWindow(QPlatformWindow *platformWin
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EGLNativeWindowType QEglFSHooks::createNativeOffscreenWindow(const QSurfaceFormat &format)
|
||||||
|
{
|
||||||
|
Q_UNUSED(format);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void QEglFSHooks::destroyNativeWindow(EGLNativeWindowType window)
|
void QEglFSHooks::destroyNativeWindow(EGLNativeWindowType window)
|
||||||
{
|
{
|
||||||
Q_UNUSED(window);
|
Q_UNUSED(window);
|
||||||
@ -194,6 +200,11 @@ void QEglFSHooks::presentBuffer()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QEglFSHooks::supportsPBuffers() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef EGLFS_PLATFORM_HOOKS
|
#ifndef EGLFS_PLATFORM_HOOKS
|
||||||
QEglFSHooks stubHooks;
|
QEglFSHooks stubHooks;
|
||||||
#endif
|
#endif
|
||||||
|
@ -36,6 +36,7 @@
|
|||||||
#include "qeglfswindow.h"
|
#include "qeglfswindow.h"
|
||||||
#include "qeglfshooks.h"
|
#include "qeglfshooks.h"
|
||||||
#include "qeglfscontext.h"
|
#include "qeglfscontext.h"
|
||||||
|
#include "qeglfsoffscreenwindow.h"
|
||||||
|
|
||||||
#include <QtGui/private/qguiapplication_p.h>
|
#include <QtGui/private/qguiapplication_p.h>
|
||||||
|
|
||||||
@ -116,9 +117,9 @@ QEGLPlatformContext *QEglFSIntegration::createContext(const QSurfaceFormat &form
|
|||||||
QSurfaceFormat adjustedFormat = QEglFSHooks::hooks()->surfaceFormatFor(format);
|
QSurfaceFormat adjustedFormat = QEglFSHooks::hooks()->surfaceFormatFor(format);
|
||||||
if (!nativeHandle || nativeHandle->isNull()) {
|
if (!nativeHandle || nativeHandle->isNull()) {
|
||||||
EGLConfig config = QEglFSIntegration::chooseConfig(display, adjustedFormat);
|
EGLConfig config = QEglFSIntegration::chooseConfig(display, adjustedFormat);
|
||||||
ctx = new QEglFSContext(adjustedFormat, shareContext, display, &config, QVariant());
|
ctx = new QEglFSContext(adjustedFormat, shareContext, display, &config, QVariant());
|
||||||
} else {
|
} else {
|
||||||
ctx = new QEglFSContext(adjustedFormat, shareContext, display, 0, *nativeHandle);
|
ctx = new QEglFSContext(adjustedFormat, shareContext, display, 0, *nativeHandle);
|
||||||
}
|
}
|
||||||
*nativeHandle = QVariant::fromValue<QEGLNativeContext>(QEGLNativeContext(ctx->eglContext(), display));
|
*nativeHandle = QVariant::fromValue<QEGLNativeContext>(QEGLNativeContext(ctx->eglContext(), display));
|
||||||
return ctx;
|
return ctx;
|
||||||
@ -128,7 +129,13 @@ QPlatformOffscreenSurface *QEglFSIntegration::createOffscreenSurface(EGLDisplay
|
|||||||
const QSurfaceFormat &format,
|
const QSurfaceFormat &format,
|
||||||
QOffscreenSurface *surface) const
|
QOffscreenSurface *surface) const
|
||||||
{
|
{
|
||||||
return new QEGLPbuffer(display, QEglFSHooks::hooks()->surfaceFormatFor(format), surface);
|
QSurfaceFormat fmt = QEglFSHooks::hooks()->surfaceFormatFor(format);
|
||||||
|
if (QEglFSHooks::hooks()->supportsPBuffers())
|
||||||
|
return new QEGLPbuffer(display, fmt, surface);
|
||||||
|
else
|
||||||
|
return new QEglFSOffscreenWindow(display, fmt, surface);
|
||||||
|
|
||||||
|
// Never return null. Multiple QWindows are not supported by this plugin.
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant QEglFSIntegration::styleHint(QPlatformIntegration::StyleHint hint) const
|
QVariant QEglFSIntegration::styleHint(QPlatformIntegration::StyleHint hint) const
|
||||||
|
85
src/plugins/platforms/eglfs/qeglfsoffscreenwindow.cpp
Normal file
85
src/plugins/platforms/eglfs/qeglfsoffscreenwindow.cpp
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2014 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 "qeglfsoffscreenwindow.h"
|
||||||
|
#include "qeglfshooks.h"
|
||||||
|
#include <QtGui/QOffscreenSurface>
|
||||||
|
#include <QtPlatformSupport/private/qeglconvenience_p.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
/*
|
||||||
|
In some cases pbuffers are not available. Triggering QtGui's built-in
|
||||||
|
fallback for a hidden QWindow is not suitable for eglfs since this would be
|
||||||
|
treated as an attempt to create multiple top-level, native windows.
|
||||||
|
|
||||||
|
Therefore this class is provided as an alternative to QEGLPbuffer.
|
||||||
|
|
||||||
|
This class requires the hooks to implement createNativeOffscreenWindow().
|
||||||
|
*/
|
||||||
|
|
||||||
|
QEglFSOffscreenWindow::QEglFSOffscreenWindow(EGLDisplay display, const QSurfaceFormat &format, QOffscreenSurface *offscreenSurface)
|
||||||
|
: QPlatformOffscreenSurface(offscreenSurface)
|
||||||
|
, m_format(format)
|
||||||
|
, m_display(display)
|
||||||
|
, m_surface(EGL_NO_SURFACE)
|
||||||
|
, m_window(0)
|
||||||
|
{
|
||||||
|
m_window = QEglFSHooks::hooks()->createNativeOffscreenWindow(format);
|
||||||
|
if (!m_window) {
|
||||||
|
qWarning("QEglFSOffscreenWindow: Failed to create native window");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
EGLConfig config = q_configFromGLFormat(m_display, m_format);
|
||||||
|
m_surface = eglCreateWindowSurface(m_display, config, m_window, 0);
|
||||||
|
if (m_surface != EGL_NO_SURFACE)
|
||||||
|
m_format = q_glFormatFromConfig(m_display, config);
|
||||||
|
}
|
||||||
|
|
||||||
|
QEglFSOffscreenWindow::~QEglFSOffscreenWindow()
|
||||||
|
{
|
||||||
|
if (m_surface != EGL_NO_SURFACE)
|
||||||
|
eglDestroySurface(m_display, m_surface);
|
||||||
|
if (m_window)
|
||||||
|
QEglFSHooks::hooks()->destroyNativeWindow(m_window);
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
68
src/plugins/platforms/eglfs/qeglfsoffscreenwindow.h
Normal file
68
src/plugins/platforms/eglfs/qeglfsoffscreenwindow.h
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2014 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 QEGLFSOFFSCREENWINDOW_H
|
||||||
|
#define QEGLFSOFFSCREENWINDOW_H
|
||||||
|
|
||||||
|
#include <EGL/egl.h>
|
||||||
|
#include <qpa/qplatformoffscreensurface.h>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
class QEglFSOffscreenWindow : public QPlatformOffscreenSurface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
QEglFSOffscreenWindow(EGLDisplay display, const QSurfaceFormat &format, QOffscreenSurface *offscreenSurface);
|
||||||
|
~QEglFSOffscreenWindow();
|
||||||
|
|
||||||
|
QSurfaceFormat format() const Q_DECL_OVERRIDE { return m_format; }
|
||||||
|
bool isValid() const Q_DECL_OVERRIDE { return m_surface != EGL_NO_SURFACE; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
QSurfaceFormat m_format;
|
||||||
|
EGLDisplay m_display;
|
||||||
|
EGLSurface m_surface;
|
||||||
|
EGLNativeWindowType m_window;
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
#endif // QEGLFSOFFSCREENWINDOW_H
|
@ -164,7 +164,7 @@ EGLenum QQnxGLContext::checkEGLError(const char *msg)
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QQnxGLContext::initialize()
|
void QQnxGLContext::initializeContext()
|
||||||
{
|
{
|
||||||
qGLContextDebug() << Q_FUNC_INFO;
|
qGLContextDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ void QQnxGLContext::initialize()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QQnxGLContext::shutdown()
|
void QQnxGLContext::shutdownContext()
|
||||||
{
|
{
|
||||||
qGLContextDebug() << Q_FUNC_INFO;
|
qGLContextDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
|
@ -53,8 +53,8 @@ public:
|
|||||||
|
|
||||||
static EGLenum checkEGLError(const char *msg);
|
static EGLenum checkEGLError(const char *msg);
|
||||||
|
|
||||||
static void initialize();
|
static void initializeContext();
|
||||||
static void shutdown();
|
static void shutdownContext();
|
||||||
|
|
||||||
void requestSurfaceChange();
|
void requestSurfaceChange();
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@ QQnxIntegration::QQnxIntegration(const QStringList ¶mList)
|
|||||||
|
|
||||||
#if !defined(QT_NO_OPENGL)
|
#if !defined(QT_NO_OPENGL)
|
||||||
// Initialize global OpenGL resources
|
// Initialize global OpenGL resources
|
||||||
QQnxGLContext::initialize();
|
QQnxGLContext::initializeContext();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Create/start event thread
|
// Create/start event thread
|
||||||
@ -306,7 +306,7 @@ QQnxIntegration::~QQnxIntegration()
|
|||||||
|
|
||||||
#if !defined(QT_NO_OPENGL)
|
#if !defined(QT_NO_OPENGL)
|
||||||
// Cleanup global OpenGL resources
|
// Cleanup global OpenGL resources
|
||||||
QQnxGLContext::shutdown();
|
QQnxGLContext::shutdownContext();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(QQNX_PPS)
|
#if defined(QQNX_PPS)
|
||||||
|
Loading…
Reference in New Issue
Block a user