Add platform native interface to offscreen plugin
Adds trival support for querying "display" and "glxconfig" in case offscreen plugin is compiled with xlib support. This is required so this plugin could work with webengine. Taks-number: QTBUG-63346 Change-Id: Ie0f29385cb44429ddf383ad459e0c9f3263ccffe Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
parent
7472415f3f
commit
3fe9f245e8
@ -41,6 +41,7 @@
|
||||
#define QOFFSCREENINTEGRATION_H
|
||||
|
||||
#include <qpa/qplatformintegration.h>
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
|
||||
#include <qscopedpointer.h>
|
||||
|
||||
|
@ -52,6 +52,30 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QOffscreenX11Info
|
||||
{
|
||||
public:
|
||||
QOffscreenX11Info(QOffscreenX11Connection *connection)
|
||||
: m_connection(connection)
|
||||
{
|
||||
}
|
||||
|
||||
Display *display() const {
|
||||
return (Display *)m_connection->display();
|
||||
}
|
||||
|
||||
Window root() const {
|
||||
return DefaultRootWindow(display());
|
||||
}
|
||||
|
||||
int screenNumber() const {
|
||||
return m_connection->screenNumber();
|
||||
}
|
||||
|
||||
private:
|
||||
QOffscreenX11Connection *m_connection;
|
||||
};
|
||||
|
||||
QOffscreenIntegration *QOffscreenIntegration::createOffscreenIntegration()
|
||||
{
|
||||
return new QOffscreenX11Integration;
|
||||
@ -77,6 +101,35 @@ QPlatformOpenGLContext *QOffscreenX11Integration::createPlatformOpenGLContext(QO
|
||||
return new QOffscreenX11GLXContext(m_connection->x11Info(), context);
|
||||
}
|
||||
|
||||
QPlatformNativeInterface *QOffscreenX11Integration::nativeInterface() const
|
||||
{
|
||||
return const_cast<QOffscreenX11Integration *>(this);
|
||||
}
|
||||
|
||||
void *QOffscreenX11Integration::nativeResourceForScreen(const QByteArray &resource, QScreen *screen)
|
||||
{
|
||||
Q_UNUSED(screen)
|
||||
if (resource.toLower() == QByteArrayLiteral("display") ) {
|
||||
if (!m_connection)
|
||||
m_connection.reset(new QOffscreenX11Connection);
|
||||
return m_connection->display();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_OPENGL
|
||||
void *QOffscreenX11Integration::nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) {
|
||||
if (resource.toLower() == QByteArrayLiteral("glxconfig") ) {
|
||||
if (!m_connection)
|
||||
m_connection.reset(new QOffscreenX11Connection);
|
||||
QOffscreenX11Info *x11 = m_connection->x11Info();
|
||||
GLXFBConfig config = qglx_findConfig(x11->display(), x11->screenNumber(), context->format());
|
||||
return config;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
QOffscreenX11Connection::QOffscreenX11Connection()
|
||||
{
|
||||
XInitThreads();
|
||||
@ -93,30 +146,6 @@ QOffscreenX11Connection::~QOffscreenX11Connection()
|
||||
XCloseDisplay((Display *)m_display);
|
||||
}
|
||||
|
||||
class QOffscreenX11Info
|
||||
{
|
||||
public:
|
||||
QOffscreenX11Info(QOffscreenX11Connection *connection)
|
||||
: m_connection(connection)
|
||||
{
|
||||
}
|
||||
|
||||
Display *display() const {
|
||||
return (Display *)m_connection->display();
|
||||
}
|
||||
|
||||
Window root() const {
|
||||
return DefaultRootWindow(display());
|
||||
}
|
||||
|
||||
int screenNumber() const {
|
||||
return m_connection->screenNumber();
|
||||
}
|
||||
|
||||
private:
|
||||
QOffscreenX11Connection *m_connection;
|
||||
};
|
||||
|
||||
QOffscreenX11Info *QOffscreenX11Connection::x11Info()
|
||||
{
|
||||
if (!m_x11Info)
|
||||
|
@ -52,12 +52,19 @@ QT_BEGIN_NAMESPACE
|
||||
class QOffscreenX11Connection;
|
||||
class QOffscreenX11Info;
|
||||
|
||||
class QOffscreenX11Integration : public QOffscreenIntegration
|
||||
class QOffscreenX11Integration : public QOffscreenIntegration, public QPlatformNativeInterface
|
||||
{
|
||||
public:
|
||||
bool hasCapability(QPlatformIntegration::Capability cap) const override;
|
||||
|
||||
QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const override;
|
||||
QPlatformNativeInterface *nativeInterface()const override;
|
||||
|
||||
// QPlatformNativeInterface
|
||||
void *nativeResourceForScreen(const QByteArray &resource, QScreen *screen) override;
|
||||
#ifndef QT_NO_OPENGL
|
||||
void *nativeResourceForContext(const QByteArray &resource, QOpenGLContext *context) override;
|
||||
#endif
|
||||
|
||||
private:
|
||||
mutable QScopedPointer<QOffscreenX11Connection> m_connection;
|
||||
|
Loading…
Reference in New Issue
Block a user