Add serverbufferintegration to the qpa plugin

Change-Id: I3802ec2c2b69fa56d6a64962590ebaa7314b3eea
Reviewed-by: Andy Nichols <andy.nichols@digia.com>
This commit is contained in:
Jorgen Lind 2013-11-22 14:12:58 +01:00 committed by The Qt Project
parent ba54fc0bb1
commit 11b385740b
10 changed files with 410 additions and 9 deletions

View File

@ -38,7 +38,7 @@
$QT_END_LICENSE$
</copyright>
<interface name="qt_server_buffer_extension" version="1">
<interface name="qt_server_buffer" version="1">
<description summary="buffers managed by the compositor">
Server buffer is an extension which makes it possible to share a
buffer created by the compositor to share it with arbitrary
@ -47,9 +47,6 @@
Server buffers main purpose is to help implement caches
</description>
<event name="destroy" type="destructor">
</event>
<request name="release">
</request>
</interface>

View File

@ -1,10 +1,19 @@
WAYLANDCLIENTSOURCES += \
$$PWD/../../extensions/server-buffer-extension.xml
SOURCES += \
$$PWD/qwaylandclientbufferintegration.cpp \
$$PWD/qwaylandclientbufferintegrationplugin.cpp \
$$PWD/qwaylandclientbufferintegrationfactory.cpp
$$PWD/qwaylandclientbufferintegrationfactory.cpp \
$$PWD/qwaylandserverbufferintegration.cpp \
$$PWD/qwaylandserverbufferintegrationplugin.cpp \
$$PWD/qwaylandserverbufferintegrationfactory.cpp
HEADERS += \
$$PWD/qwaylandclientbufferintegration.h \
$$PWD/qwaylandclientbufferintegrationplugin.h \
$$PWD/qwaylandclientbufferintegrationfactory.h
$$PWD/qwaylandclientbufferintegrationfactory.h \
$$PWD/qwaylandserverbufferintegration.h \
$$PWD/qwaylandserverbufferintegrationplugin.h \
$$PWD/qwaylandserverbufferintegrationfactory.h

View File

@ -0,0 +1,9 @@
#include "qwaylandserverbufferintegration.h"
QWaylandServerBufferIntegration::QWaylandServerBufferIntegration()
{
}
QWaylandServerBufferIntegration::~QWaylandServerBufferIntegration()
{
}

View File

@ -0,0 +1,73 @@
/****************************************************************************
**
** Copyright (C) 2012 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 QWAYLANDSERVERBUFFERINTEGRATION_H
#define QWAYLANDSERVERBUFFERINTEGRATION_H
#include <QtGui/qopengl.h>
#include <QtWaylandClient/private/qwayland-server-buffer-extension.h>
#include <QtWaylandClient/qwaylandclientexport.h>
QT_BEGIN_NAMESPACE
class QWaylandDisplay;
class Q_WAYLAND_CLIENT_EXPORT QWaylandServerBufferIntegration
{
public:
QWaylandServerBufferIntegration();
virtual ~QWaylandServerBufferIntegration();
virtual void initialize(QWaylandDisplay *display) = 0;
//creates new texture for buffer
virtual GLuint createTextureFor(struct qt_server_buffer *buffer) = 0;
//does not clean up textures. Just lets server know that it does
//not intend to use the buffer anymore. Textures should have been
//deleted prior to calling this function
virtual void release(struct qt_server_buffer *buffer) = 0;
};
QT_END_NAMESPACE
#endif

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 "qwaylandserverbufferintegrationfactory.h"
#include "qwaylandserverbufferintegrationplugin.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,
(QWaylandServerBufferIntegrationFactoryInterface_iid, QLatin1String("/wayland-graphics-integration/client"), Qt::CaseInsensitive))
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader,
(QWaylandServerBufferIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
#endif
QStringList QWaylandServerBufferIntegrationFactory::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
}
QWaylandServerBufferIntegration *QWaylandServerBufferIntegrationFactory::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 (QWaylandServerBufferIntegration *ret = qLoadPlugin1<QWaylandServerBufferIntegration, QWaylandServerBufferIntegrationPlugin>(directLoader(), name, args))
return ret;
}
if (QWaylandServerBufferIntegration *ret = qLoadPlugin1<QWaylandServerBufferIntegration, QWaylandServerBufferIntegrationPlugin>(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 QWAYLANDSERVERBUFFERINTEGRATIONFACTORY_H
#define QWAYLANDSERVERBUFFERINTEGRATIONFACTORY_H
#include <QtWaylandClient/qwaylandclientexport.h>
#include <QtCore/QStringList>
QT_BEGIN_NAMESPACE
class QWaylandServerBufferIntegration;
class Q_WAYLAND_CLIENT_EXPORT QWaylandServerBufferIntegrationFactory
{
public:
static QStringList keys(const QString &pluginPath = QString());
static QWaylandServerBufferIntegration *create(const QString &name, const QStringList &args, const QString &pluginPath = QString());
};
QT_END_NAMESPACE
#endif // QWAYLANDSERVERBUFFERINTEGRATIONFACTORY_H

View File

@ -0,0 +1,54 @@
/****************************************************************************
**
** 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 "qwaylandserverbufferintegrationplugin.h"
QT_BEGIN_NAMESPACE
QWaylandServerBufferIntegrationPlugin::QWaylandServerBufferIntegrationPlugin(QObject *parent)
: QObject(parent)
{
}
QWaylandServerBufferIntegrationPlugin::~QWaylandServerBufferIntegrationPlugin()
{
}
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 QWAYLANDSERVERBUFFERINTEGRATIONPLUGIN_H
#define QWAYLANDSERVERBUFFERINTEGRATIONPLUGIN_H
#include <QtWaylandClient/qwaylandclientexport.h>
#include <QtCore/qplugin.h>
#include <QtCore/qfactoryinterface.h>
#include <QtCore/QObject>
QT_BEGIN_NAMESPACE
class QWaylandServerBufferIntegration;
#define QWaylandServerBufferIntegrationFactoryInterface_iid "org.qt-project.Qt.WaylandClient.QWaylandServerBufferIntegrationFactoryInterface.5.1"
class Q_WAYLAND_CLIENT_EXPORT QWaylandServerBufferIntegrationPlugin : public QObject
{
Q_OBJECT
public:
explicit QWaylandServerBufferIntegrationPlugin(QObject *parent = 0);
~QWaylandServerBufferIntegrationPlugin();
virtual QWaylandServerBufferIntegration *create(const QString &key, const QStringList &paramList) = 0;
};
QT_END_NAMESPACE
#endif // QWAYLANDSERVERBUFFERINTEGRATIONPLUGIN_H

View File

@ -68,6 +68,8 @@
#include "qwaylandclientbufferintegration.h"
#include "qwaylandclientbufferintegrationfactory.h"
#include "qwaylandserverbufferintegration.h"
#include "qwaylandserverbufferintegrationfactory.h"
QT_BEGIN_NAMESPACE
@ -110,6 +112,7 @@ QWaylandIntegration::QWaylandIntegration()
, mAccessibility(0)
#endif
, mClientBufferIntegrationInitialized(false)
, mServerBufferIntegrationInitialized(false)
{
mDisplay = new QWaylandDisplay(this);
mClipboard = new QWaylandClipboard(mDisplay);
@ -240,12 +243,20 @@ QPlatformTheme *QWaylandIntegration::createPlatformTheme(const QString &name) co
QWaylandClientBufferIntegration *QWaylandIntegration::clientBufferIntegration() const
{
if (!mClientBufferIntegrationInitialized)
const_cast<QWaylandIntegration *>(this)->initializeBufferIntegration();
const_cast<QWaylandIntegration *>(this)->initializeClientBufferIntegration();
return mClientBufferIntegration;
}
void QWaylandIntegration::initializeBufferIntegration()
QWaylandServerBufferIntegration *QWaylandIntegration::serverBufferIntegration() const
{
if (!mServerBufferIntegrationInitialized)
const_cast<QWaylandIntegration *>(this)->initializeServerBufferIntegration();
return mServerBufferIntegration;
}
void QWaylandIntegration::initializeClientBufferIntegration()
{
mClientBufferIntegrationInitialized = true;
@ -262,4 +273,21 @@ void QWaylandIntegration::initializeBufferIntegration()
mClientBufferIntegration->initialize(mDisplay);
}
void QWaylandIntegration::initializeServerBufferIntegration()
{
mServerBufferIntegrationInitialized = true;
QByteArray serverBufferIntegrationName = qgetenv("QT_WAYLAND_SERVER_BUFFER_INTEGRATION");
if (serverBufferIntegrationName.isEmpty())
serverBufferIntegrationName = QByteArrayLiteral("wayland-egl");
QStringList keys = QWaylandServerBufferIntegrationFactory::keys();
QString targetKey = QString::fromLocal8Bit(serverBufferIntegrationName);
if (keys.contains(targetKey)) {
mServerBufferIntegration = QWaylandServerBufferIntegrationFactory::create(targetKey, QStringList());
}
if (mServerBufferIntegration)
mServerBufferIntegration->initialize(mDisplay);
}
QT_END_NAMESPACE

View File

@ -50,6 +50,7 @@ QT_BEGIN_NAMESPACE
class QWaylandBuffer;
class QWaylandDisplay;
class QWaylandClientBufferIntegration;
class QWaylandServerBufferIntegration;
class Q_WAYLAND_CLIENT_EXPORT QWaylandIntegration : public QPlatformIntegration
{
@ -88,10 +89,13 @@ public:
QPlatformTheme *createPlatformTheme(const QString &name) const;
virtual QWaylandClientBufferIntegration *clientBufferIntegration() const;
virtual QWaylandServerBufferIntegration *serverBufferIntegration() const;
protected:
QWaylandClientBufferIntegration *mClientBufferIntegration;
QWaylandServerBufferIntegration *mServerBufferIntegration;
private:
void initializeBufferIntegration();
void initializeClientBufferIntegration();
void initializeServerBufferIntegration();
QPlatformFontDatabase *mFontDb;
QPlatformClipboard *mClipboard;
QPlatformDrag *mDrag;
@ -100,6 +104,7 @@ private:
QScopedPointer<QPlatformInputContext> mInputContext;
QPlatformAccessibility *mAccessibility;
bool mClientBufferIntegrationInitialized;
bool mServerBufferIntegrationInitialized;
};
QT_END_NAMESPACE