Rename QWaylandGLIntegration to QWaylandClientBufferIntegration

also add a factory to load QWaylandClientBufferIntegrationPlugins

Change-Id: Ia6a03627659b0452439ae664fceef21eaf0f6de0
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
This commit is contained in:
Jorgen Lind 2013-11-21 13:43:23 +01:00 committed by The Qt Project
parent 778b009d53
commit 4875f1d1bb
12 changed files with 344 additions and 33 deletions

View File

@ -95,7 +95,4 @@ HEADERS += qwaylandintegration.h \
qwaylandinputcontext.h \
qwaylanddatadevice.h \
contains(DEFINES, QT_WAYLAND_GL_SUPPORT) {
SOURCES += qwaylandglintegration.cpp
HEADERS += qwaylandglintegration.h
}
include(hardwareintegration/hardwareintegration.pri)

View File

@ -0,0 +1,10 @@
SOURCES += \
$$PWD/qwaylandclientbufferintegration.cpp \
$$PWD/qwaylandclientbufferintegrationplugin.cpp \
$$PWD/qwaylandclientbufferintegrationfactory.cpp
HEADERS += \
$$PWD/qwaylandclientbufferintegration.h \
$$PWD/qwaylandclientbufferintegrationplugin.h \
$$PWD/qwaylandclientbufferintegrationfactory.h

View File

@ -39,16 +39,16 @@
**
****************************************************************************/
#include "qwaylandglintegration.h"
#include "qwaylandclientbufferintegration.h"
QT_BEGIN_NAMESPACE
QWaylandGLIntegration::QWaylandGLIntegration()
QWaylandClientBufferIntegration::QWaylandClientBufferIntegration()
{
}
QWaylandGLIntegration::~QWaylandGLIntegration()
QWaylandClientBufferIntegration::~QWaylandClientBufferIntegration()
{
}

View File

@ -39,8 +39,8 @@
**
****************************************************************************/
#ifndef QWAYLANDGLINTEGRATION_H
#define QWAYLANDGLINTEGRATION_H
#ifndef QWAYLANDCLIENTBUFFERINTEGRATION_H
#define QWAYLANDCLIENTBUFFERINTEGRATION_H
#include <QtCore/qglobal.h>
#include <QtWaylandClient/qwaylandclientexport.h>
@ -54,11 +54,11 @@ class QWindow;
class QPlatformOpenGLContext;
class QSurfaceFormat;
class Q_WAYLAND_CLIENT_EXPORT QWaylandGLIntegration
class Q_WAYLAND_CLIENT_EXPORT QWaylandClientBufferIntegration
{
public:
QWaylandGLIntegration();
virtual ~QWaylandGLIntegration();
QWaylandClientBufferIntegration();
virtual ~QWaylandClientBufferIntegration();
virtual void initialize() = 0;
virtual bool waitingForEvents() { return false; }
@ -68,9 +68,9 @@ public:
virtual QWaylandWindow *createEglWindow(QWindow *window) = 0;
virtual QPlatformOpenGLContext *createPlatformOpenGLContext(const QSurfaceFormat &glFormat, QPlatformOpenGLContext *share) const = 0;
static QWaylandGLIntegration *createGLIntegration(QWaylandDisplay *waylandDisplay);
static QWaylandClientBufferIntegration *createGLIntegration(QWaylandDisplay *waylandDisplay);
};
QT_END_NAMESPACE
#endif // QWAYLANDGLINTEGRATION_H
#endif // QWAYLANDCLIENTBUFFERINTEGRATION_H

View File

@ -0,0 +1,96 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtGui module 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 "qwaylandclientbufferintegrationfactory.h"
#include "qwaylandclientbufferintegrationplugin.h"
#include "qwaylandclientbufferintegration.h"
#include <QtCore/private/qfactoryloader_p.h>
#include <QtCore/QCoreApplication>
#include <QtCore/QDir>
QT_BEGIN_NAMESPACE
#ifndef QT_NO_LIBRARY
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
(QWaylandClientBufferIntegrationFactoryInterface_iid, QLatin1String("/wayland-graphics-integration/client"), Qt::CaseInsensitive))
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader,
(QWaylandClientBufferIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
#endif
QStringList QWaylandClientBufferIntegrationFactory::keys(const QString &pluginPath)
{
#ifndef QT_NO_LIBRARY
QStringList list;
if (!pluginPath.isEmpty()) {
QCoreApplication::addLibraryPath(pluginPath);
list = directLoader()->keyMap().values();
if (!list.isEmpty()) {
const QString postFix = QStringLiteral(" (from ")
+ QDir::toNativeSeparators(pluginPath)
+ QLatin1Char(')');
const QStringList::iterator end = list.end();
for (QStringList::iterator it = list.begin(); it != end; ++it)
(*it).append(postFix);
}
}
list.append(loader()->keyMap().values());
return list;
#else
return QStringList();
#endif
}
QWaylandClientBufferIntegration *QWaylandClientBufferIntegrationFactory::create(const QString &name, const QStringList &args, const QString &pluginPath)
{
#ifndef QT_NO_LIBRARY
// Try loading the plugin from platformPluginPath first:
if (!pluginPath.isEmpty()) {
QCoreApplication::addLibraryPath(pluginPath);
if (QWaylandClientBufferIntegration *ret = qLoadPlugin1<QWaylandClientBufferIntegration, QWaylandClientBufferIntegrationPlugin>(directLoader(), name, args))
return ret;
}
if (QWaylandClientBufferIntegration *ret = qLoadPlugin1<QWaylandClientBufferIntegration, QWaylandClientBufferIntegrationPlugin>(loader(), name, args))
return ret;
#endif
return 0;
}
QT_END_NAMESPACE

View File

@ -0,0 +1,61 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtGui module 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 QWAYLANDCLIENTBUFFERINTEGRATIONFACTORY_H
#define QWAYLANDCLIENTBUFFERINTEGRATIONFACTORY_H
#include <QtWaylandClient/qwaylandclientexport.h>
#include <QtCore/QStringList>
QT_BEGIN_NAMESPACE
class QWaylandClientBufferIntegration;
class Q_WAYLAND_CLIENT_EXPORT QWaylandClientBufferIntegrationFactory
{
public:
static QStringList keys(const QString &pluginPath = QString());
static QWaylandClientBufferIntegration *create(const QString &name, const QStringList &args, const QString &pluginPath = QString());
};
QT_END_NAMESPACE
#endif // QWAYLANDCLIENTBUFFERINTEGRATIONFACTORY_H

View File

@ -0,0 +1,55 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtGui module 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 "qwaylandclientbufferintegrationplugin.h"
QT_BEGIN_NAMESPACE
QWaylandClientBufferIntegrationPlugin::QWaylandClientBufferIntegrationPlugin(QObject *parent) :
QObject(parent)
{
}
QWaylandClientBufferIntegrationPlugin::~QWaylandClientBufferIntegrationPlugin()
{
}
QT_END_NAMESPACE

View File

@ -0,0 +1,69 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtGui module 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 QWAYLANDCLIENTBUFFERINTEGRATIONPLUGIN_H
#define QWAYLANDCLIENTBUFFERINTEGRATIONPLUGIN_H
#include <QtWaylandClient/qwaylandclientexport.h>
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
#include <QtCore/QObject>
QT_BEGIN_NAMESPACE
class QWaylandClientBufferIntegration;
#define QWaylandClientBufferIntegrationFactoryInterface_iid "org.qt-project.Qt.WaylandClient.QWaylandClientBufferIntegrationFactoryInterface.5.1"
class Q_WAYLAND_CLIENT_EXPORT QWaylandClientBufferIntegrationPlugin : public QObject
{
Q_OBJECT
public:
explicit QWaylandClientBufferIntegrationPlugin(QObject *parent = 0);
~QWaylandClientBufferIntegrationPlugin();
virtual QWaylandClientBufferIntegration *create(const QString &key, const QStringList &paramList) = 0;
};
QT_END_NAMESPACE
#endif // QWAYLANDCLIENTBUFFERINTEGRATIONPLUGIN_H

View File

@ -50,7 +50,7 @@
#include "qwaylandclipboard.h"
#include "qwaylanddatadevicemanager.h"
#include "qwaylandglintegration.h"
#include "qwaylandclientbufferintegration.h"
#include "qwaylandwindowmanagerintegration.h"
@ -78,9 +78,9 @@ struct wl_surface *QWaylandDisplay::createSurface(void *handle)
return surface;
}
QWaylandGLIntegration * QWaylandDisplay::glIntegration() const
QWaylandClientBufferIntegration * QWaylandDisplay::clientBufferIntegration() const
{
return mWaylandIntegration->glIntegration();
return mWaylandIntegration->clientBufferIntegration();
}
QWaylandWindowManagerIntegration *QWaylandDisplay::windowManagerIntegration() const

View File

@ -62,7 +62,7 @@ class QSocketNotifier;
class QWaylandBuffer;
class QPlatformScreen;
class QWaylandScreen;
class QWaylandGLIntegration;
class QWaylandClientBufferIntegration;
class QWaylandWindowManagerIntegration;
class QWaylandDataDeviceManager;
class QWaylandTouchExtension;
@ -98,7 +98,7 @@ public:
struct wl_surface *createSurface(void *handle);
QWaylandGLIntegration *glIntegration() const;
QWaylandClientBufferIntegration *clientBufferIntegration() const;
QWaylandWindowManagerIntegration *windowManagerIntegration() const;

View File

@ -65,9 +65,8 @@
#include <qpa/qplatformaccessibility.h>
#include <qpa/qplatforminputcontext.h>
#ifdef QT_WAYLAND_GL_SUPPORT
#include "qwaylandglintegration.h"
#endif
#include "qwaylandclientbufferintegration.h"
#include "qwaylandclientbufferintegrationfactory.h"
QT_BEGIN_NAMESPACE
@ -102,13 +101,15 @@ public:
};
QWaylandIntegration::QWaylandIntegration()
: mFontDb(new QGenericUnixFontDatabase())
: mClientBufferIntegration(0)
, mFontDb(new QGenericUnixFontDatabase())
, mNativeInterface(new QWaylandNativeInterface(this))
#ifndef QT_NO_ACCESSIBILITY
, mAccessibility(new QPlatformAccessibility())
#else
, mAccessibility(0)
#endif
, mClientBufferIntegrationInitialized(false)
{
mDisplay = new QWaylandDisplay(this);
mClipboard = new QWaylandClipboard(mDisplay);
@ -141,9 +142,9 @@ bool QWaylandIntegration::hasCapability(QPlatformIntegration::Capability cap) co
switch (cap) {
case ThreadedPixmaps: return true;
case OpenGL:
return mDisplay->glIntegration();
return mDisplay->clientBufferIntegration();
case ThreadedOpenGL:
return mDisplay->glIntegration() && mDisplay->glIntegration()->supportsThreadedOpenGL();
return mDisplay->clientBufferIntegration() && mDisplay->clientBufferIntegration()->supportsThreadedOpenGL();
case BufferQueueingOpenGL:
return true;
case MultipleWindows:
@ -155,15 +156,15 @@ bool QWaylandIntegration::hasCapability(QPlatformIntegration::Capability cap) co
QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWindow *window) const
{
if (window->surfaceType() == QWindow::OpenGLSurface && mDisplay->glIntegration())
return mDisplay->glIntegration()->createEglWindow(window);
if (window->surfaceType() == QWindow::OpenGLSurface && mDisplay->clientBufferIntegration())
return mDisplay->clientBufferIntegration()->createEglWindow(window);
return new QWaylandShmWindow(window);
}
QPlatformOpenGLContext *QWaylandIntegration::createPlatformOpenGLContext(QOpenGLContext *context) const
{
if (mDisplay->glIntegration())
return mDisplay->glIntegration()->createPlatformOpenGLContext(context->format(), context->shareHandle());
if (mDisplay->clientBufferIntegration())
return mDisplay->clientBufferIntegration()->createPlatformOpenGLContext(context->format(), context->shareHandle());
return 0;
}
@ -236,9 +237,27 @@ QPlatformTheme *QWaylandIntegration::createPlatformTheme(const QString &name) co
return GenericWaylandTheme::createUnixTheme(name);
}
QWaylandGLIntegration *QWaylandIntegration::glIntegration() const
QWaylandClientBufferIntegration *QWaylandIntegration::clientBufferIntegration() const
{
return 0;
if (!mClientBufferIntegrationInitialized)
const_cast<QWaylandIntegration *>(this)->initializeBufferIntegration();
return mClientBufferIntegration;
}
void QWaylandIntegration::initializeBufferIntegration()
{
mClientBufferIntegrationInitialized = true;
QByteArray clientBufferIntegrationName = qgetenv("QT_WAYLAND_CLIENT_BUFFER_INTEGRATION");
if (clientBufferIntegrationName.isEmpty())
clientBufferIntegrationName = QByteArrayLiteral("wayland-egl");
QStringList keys = QWaylandClientBufferIntegrationFactory::keys();
QString targetKey = QString::fromLocal8Bit(clientBufferIntegrationName);
if (keys.contains(targetKey)) {
mClientBufferIntegration = QWaylandClientBufferIntegrationFactory::create(targetKey, QStringList());
}
}
QT_END_NAMESPACE

View File

@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE
class QWaylandBuffer;
class QWaylandDisplay;
class QWaylandGLIntegration;
class QWaylandClientBufferIntegration;
class Q_WAYLAND_CLIENT_EXPORT QWaylandIntegration : public QPlatformIntegration
{
@ -87,8 +87,11 @@ public:
QPlatformTheme *createPlatformTheme(const QString &name) const;
virtual QWaylandGLIntegration *glIntegration() const;
virtual QWaylandClientBufferIntegration *clientBufferIntegration() const;
protected:
QWaylandClientBufferIntegration *mClientBufferIntegration;
private:
void initializeBufferIntegration();
QPlatformFontDatabase *mFontDb;
QPlatformClipboard *mClipboard;
QPlatformDrag *mDrag;
@ -96,6 +99,7 @@ private:
QPlatformNativeInterface *mNativeInterface;
QScopedPointer<QPlatformInputContext> mInputContext;
QPlatformAccessibility *mAccessibility;
bool mClientBufferIntegrationInitialized;
};
QT_END_NAMESPACE