summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMichael Dominic K <mdk@codethink.co.uk>2010-11-11 07:25:10 (GMT)
committerSamuel Rødal <samuel.rodal@nokia.com>2010-11-11 07:25:10 (GMT)
commit4e7eb76cb231fc5a8b0deb67a87c45f6760e44bb (patch)
treea36105d057ae7e53b9ba94a89002e716197209e3 /tools
parent8d6c8e95f47e6be3f8db85adc2412d55a6915ac4 (diff)
downloadQt-4e7eb76cb231fc5a8b0deb67a87c45f6760e44bb.zip
Qt-4e7eb76cb231fc5a8b0deb67a87c45f6760e44bb.tar.gz
Qt-4e7eb76cb231fc5a8b0deb67a87c45f6760e44bb.tar.bz2
Helper-side support for QMeeGoFenceSync.
Merge-request: 2502 Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/qmeegographicssystemhelper/qmeegofencesync.cpp79
-rw-r--r--tools/qmeegographicssystemhelper/qmeegofencesync.h101
-rw-r--r--tools/qmeegographicssystemhelper/qmeegofencesync_p.h60
-rw-r--r--tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro4
-rw-r--r--tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp9
-rw-r--r--tools/qmeegographicssystemhelper/qmeegolivepixmap.h7
-rw-r--r--tools/qmeegographicssystemhelper/qmeegoruntime.cpp29
-rw-r--r--tools/qmeegographicssystemhelper/qmeegoruntime.h4
8 files changed, 282 insertions, 11 deletions
diff --git a/tools/qmeegographicssystemhelper/qmeegofencesync.cpp b/tools/qmeegographicssystemhelper/qmeegofencesync.cpp
new file mode 100644
index 0000000..499e102
--- /dev/null
+++ b/tools/qmeegographicssystemhelper/qmeegofencesync.cpp
@@ -0,0 +1,79 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmeegofencesync.h"
+#include "qmeegofencesync_p.h"
+#include "qmeegoruntime.h"
+
+/* QMeeGoFenceSyncPrivate */
+
+QMeeGoFenceSyncPrivate::QMeeGoFenceSyncPrivate() : syncObject(NULL)
+{
+}
+
+QMeeGoFenceSyncPrivate::~QMeeGoFenceSyncPrivate()
+{
+ if (syncObject) {
+ QMeeGoRuntime::destroyFenceSync(syncObject);
+ syncObject = NULL;
+ }
+}
+
+/* QMeeGoFenceSync */
+
+QMeeGoFenceSync::QMeeGoFenceSync(QWidget *parent) : QObject(parent), d_ptr(new QMeeGoFenceSyncPrivate())
+{
+ Q_D(QMeeGoFenceSync);
+ d->q_ptr = this;
+}
+
+QMeeGoFenceSync::~QMeeGoFenceSync()
+{
+}
+
+void QMeeGoFenceSync::setSyncPoint()
+{
+ Q_D(QMeeGoFenceSync);
+ if (d->syncObject)
+ QMeeGoRuntime::destroyFenceSync(d->syncObject);
+
+ d->syncObject = QMeeGoRuntime::createFenceSync();
+}
diff --git a/tools/qmeegographicssystemhelper/qmeegofencesync.h b/tools/qmeegographicssystemhelper/qmeegofencesync.h
new file mode 100644
index 0000000..2d3f5c5
--- /dev/null
+++ b/tools/qmeegographicssystemhelper/qmeegofencesync.h
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMEEGOFENCESYNC_H
+#define QMEEGOFENCESYNC_H
+
+#include <QWidget>
+
+class QMeeGoFenceSyncPrivate;
+
+//! A synchronization helper for GL pipeline.
+/*!
+ Fence syncs provide a mechanism for synchronizing access to certain GL primitives
+ and make it possible for the application developer to be sure that a certain point
+ in the GL processing pipeline has been already executed before continuing operation.
+
+ Currently fence syncs are only useful in conjunction with QMeeGoLivePixmaps.
+ \code
+ ...
+ // In your paint/expose event:
+ QImage *image = livePixmap->lock(&someGlobalFenceSync);
+ // Modify the image...
+ livePixmap->release(image);
+
+ painter->drawPixmap(0, 0, *livePixmap);
+ someGlobalFenceSync.setSyncPoint();
+ ...
+ \endcode
+
+ Assuming the paint/expose events come repeatedly, the lock operation
+ will block till the previous event completed painting the livePixmap.
+*/
+
+class Q_DECL_EXPORT QMeeGoFenceSync : public QObject
+{
+public:
+ //! Constructs a new fence sync.
+ /*!
+ The fence sync is created without a sync point. You need to set the sync point manually.
+ */
+ QMeeGoFenceSync(QWidget *parent = 0);
+
+ //! Destructor for the fence sync.
+ virtual ~QMeeGoFenceSync();
+
+ //! Sets the fence sync.
+ /*!
+ The fence sync synchronization point should be set after all drawing has been scheduled.
+ Setting a synchronization point always overrides the previous point -- whetver is was
+ used (waited upon) or not.
+ */
+ void setSyncPoint();
+
+private:
+ Q_DISABLE_COPY(QMeeGoFenceSync)
+ Q_DECLARE_PRIVATE(QMeeGoFenceSync)
+
+protected:
+ QScopedPointer<QMeeGoFenceSyncPrivate> d_ptr; //! Private bits.
+ friend class QMeeGoLivePixmap;
+};
+
+#endif
diff --git a/tools/qmeegographicssystemhelper/qmeegofencesync_p.h b/tools/qmeegographicssystemhelper/qmeegofencesync_p.h
new file mode 100644
index 0000000..8a5d26e
--- /dev/null
+++ b/tools/qmeegographicssystemhelper/qmeegofencesync_p.h
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the plugins of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmeegofencesync.h"
+
+#ifndef QMEEGOFENCESYNC_P_H
+#define QMEEGOFENCESYNC_P_H
+
+class QMeeGoFenceSyncPrivate
+{
+public:
+ Q_DECLARE_PUBLIC(QMeeGoFenceSync);
+ QMeeGoFenceSyncPrivate();
+
+ virtual ~QMeeGoFenceSyncPrivate();
+
+ void* syncObject;
+
+ QMeeGoFenceSync *q_ptr;
+};
+
+#endif
diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro
index 7412fc3..161a31b 100644
--- a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro
+++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro
@@ -6,5 +6,5 @@ include(../../src/qbase.pri)
QT += gui
INCLUDEPATH += '../../src/plugins/graphicssystems/meego'
-HEADERS = qmeegographicssystemhelper.h qmeegooverlaywidget.h qmeegolivepixmap.h qmeegoruntime.h qmeegolivepixmap_p.h
-SOURCES = qmeegographicssystemhelper.cpp qmeegooverlaywidget.cpp qmeegoruntime.cpp qmeegolivepixmap.cpp qmeegographicssystemhelper.h qmeegooverlaywidget.h qmeegolivepixmap.h qmeegoruntime.h qmeegolivepixmap_p.h
+HEADERS = qmeegographicssystemhelper.h qmeegooverlaywidget.h qmeegolivepixmap.h qmeegoruntime.h qmeegolivepixmap_p.h qmeegofencesync.h qmeegofencesync_p.h
+SOURCES = qmeegographicssystemhelper.cpp qmeegooverlaywidget.cpp qmeegoruntime.cpp qmeegolivepixmap.cpp qmeegographicssystemhelper.h qmeegooverlaywidget.h qmeegolivepixmap.h qmeegoruntime.h qmeegolivepixmap_p.h qmeegofencesync.h qmeegofencesync_p.h qmeegofencesync.cpp
diff --git a/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp b/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp
index d43efe2..9700581f 100644
--- a/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp
+++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp
@@ -41,6 +41,7 @@
#include "qmeegolivepixmap.h"
#include "qmeegolivepixmap_p.h"
+#include "qmeegofencesync_p.h"
#include "qmeegoruntime.h"
/* QMeeGoLivePixmapPrivate */
@@ -102,10 +103,12 @@ QMeeGoLivePixmap::~QMeeGoLivePixmap()
{
}
-QImage* QMeeGoLivePixmap::lock()
+QImage* QMeeGoLivePixmap::lock(QMeeGoFenceSync *fenceSync)
{
- return QMeeGoRuntime::lockLiveTexture(this);
-
+ if (fenceSync)
+ return QMeeGoRuntime::lockLiveTexture(this, fenceSync->d_func()->syncObject);
+ else
+ return QMeeGoRuntime::lockLiveTexture(this, NULL);
}
void QMeeGoLivePixmap::release(QImage *img)
diff --git a/tools/qmeegographicssystemhelper/qmeegolivepixmap.h b/tools/qmeegographicssystemhelper/qmeegolivepixmap.h
index 7be2c4b..51b5976 100644
--- a/tools/qmeegographicssystemhelper/qmeegolivepixmap.h
+++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap.h
@@ -43,6 +43,7 @@
#define QMEEGOLIVEPIXMAP_H
#include <QPixmap>
+#include "qmeegofencesync.h"
class QMeeGoLivePixmapPrivate;
class QSharedMemory;
@@ -82,8 +83,12 @@ public:
//! Locks the access to the pixmap.
/*!
The returned image can be used for direct access.
+ You can optionally specify a fence sync to wait upon before unlocking. When
+ you specify a fence sync, you can be sure that this function will return only
+ when the previsouly set QMeeGoFenceSync synchronization point has been executed/passed
+ by the GL processing pipeline.
*/
- QImage* lock();
+ QImage* lock(QMeeGoFenceSync *fenceSync = NULL);
//! Unlocks the access to the pixmap.
/*!
diff --git a/tools/qmeegographicssystemhelper/qmeegoruntime.cpp b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp
index ac627e5..2d3ee3c 100644
--- a/tools/qmeegographicssystemhelper/qmeegoruntime.cpp
+++ b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp
@@ -60,9 +60,11 @@ typedef void (*QMeeGoSetSurfaceScalingFunc) (int x, int y, int w, int h);
typedef void (*QMeeGoSetTranslucentFunc) (bool translucent);
typedef QPixmapData* (*QMeeGoPixmapDataWithNewLiveTextureFunc) (int w, int h, QImage::Format format);
typedef QPixmapData* (*QMeeGoPixmapDataFromLiveTextureHandleFunc) (Qt::HANDLE h);
-typedef QImage* (*QMeeGoLiveTextureLockFunc) (QPixmap*);
+typedef QImage* (*QMeeGoLiveTextureLockFunc) (QPixmap*, void* fenceSync);
typedef bool (*QMeeGoLiveTextureReleaseFunc) (QPixmap*, QImage *i);
typedef Qt::HANDLE (*QMeeGoLiveTextureGetHandleFunc) (QPixmap*);
+typedef void* (*QMeeGoCreateFenceSyncFunc) (void);
+typedef void (*QMeeGoDestroyFenceSyncFunc) (void *fs);
static QMeeGoImageToEglSharedImageFunc qt_meego_image_to_egl_shared_image = NULL;
static QMeeGoPixmapDataFromEglSharedImageFunc qt_meego_pixmapdata_from_egl_shared_image = NULL;
@@ -77,6 +79,8 @@ static QMeeGoPixmapDataFromLiveTextureHandleFunc qt_meego_pixmapdata_from_live_t
static QMeeGoLiveTextureLockFunc qt_meego_live_texture_lock = NULL;
static QMeeGoLiveTextureReleaseFunc qt_meego_live_texture_release = NULL;
static QMeeGoLiveTextureGetHandleFunc qt_meego_live_texture_get_handle = NULL;
+static QMeeGoCreateFenceSyncFunc qt_meego_create_fence_sync = NULL;
+static QMeeGoDestroyFenceSyncFunc qt_meego_destroy_fence_sync = NULL;
void QMeeGoRuntime::initialize()
{
@@ -103,12 +107,15 @@ void QMeeGoRuntime::initialize()
qt_meego_live_texture_lock = (QMeeGoLiveTextureLockFunc) library.resolve("qt_meego_live_texture_lock");
qt_meego_live_texture_release = (QMeeGoLiveTextureReleaseFunc) library.resolve("qt_meego_live_texture_release");
qt_meego_live_texture_get_handle = (QMeeGoLiveTextureGetHandleFunc) library.resolve("qt_meego_live_texture_get_handle");
+ qt_meego_create_fence_sync = (QMeeGoCreateFenceSyncFunc) library.resolve("qt_meego_create_fence_sync");
+ qt_meego_destroy_fence_sync = (QMeeGoDestroyFenceSyncFunc) library.resolve("qt_meego_destroy_fence_sync");
if (qt_meego_image_to_egl_shared_image && qt_meego_pixmapdata_from_egl_shared_image &&
qt_meego_pixmapdata_with_gl_texture && qt_meego_destroy_egl_shared_image && qt_meego_update_egl_shared_image_pixmap &&
qt_meego_set_surface_fixed_size && qt_meego_set_surface_scaling && qt_meego_set_translucent &&
qt_meego_pixmapdata_with_new_live_texture && qt_meego_pixmapdata_from_live_texture_handle &&
- qt_meego_live_texture_lock && qt_meego_live_texture_release && qt_meego_live_texture_get_handle)
+ qt_meego_live_texture_lock && qt_meego_live_texture_release && qt_meego_live_texture_get_handle &&
+ qt_meego_create_fence_sync && qt_meego_destroy_fence_sync)
{
qDebug("Successfully resolved MeeGo graphics system: %s %s\n", qPrintable(libraryPrivate->fileName), qPrintable(libraryPrivate->fullVersion));
} else {
@@ -191,11 +198,11 @@ QPixmapData* QMeeGoRuntime::pixmapDataFromLiveTextureHandle(Qt::HANDLE h)
return qt_meego_pixmapdata_from_live_texture_handle(h);
}
-QImage* QMeeGoRuntime::lockLiveTexture(QPixmap *p)
+QImage* QMeeGoRuntime::lockLiveTexture(QPixmap *p, void* fenceSync)
{
ENSURE_INITIALIZED;
Q_ASSERT(qt_meego_live_texture_lock);
- return qt_meego_live_texture_lock(p);
+ return qt_meego_live_texture_lock(p, fenceSync);
}
bool QMeeGoRuntime::releaseLiveTexture(QPixmap *p, QImage *i)
@@ -211,3 +218,17 @@ Qt::HANDLE QMeeGoRuntime::getLiveTextureHandle(QPixmap *pixmap)
Q_ASSERT(qt_meego_live_texture_get_handle);
return qt_meego_live_texture_get_handle(pixmap);
}
+
+void* QMeeGoRuntime::createFenceSync()
+{
+ ENSURE_INITIALIZED;
+ Q_ASSERT(qt_meego_create_fence_sync);
+ return qt_meego_create_fence_sync();
+}
+
+void QMeeGoRuntime::destroyFenceSync(void *fs)
+{
+ ENSURE_INITIALIZED;
+ Q_ASSERT(qt_meego_destroy_fence_sync);
+ qt_meego_destroy_fence_sync(fs);
+}
diff --git a/tools/qmeegographicssystemhelper/qmeegoruntime.h b/tools/qmeegographicssystemhelper/qmeegoruntime.h
index 6b34836..be6ff6b 100644
--- a/tools/qmeegographicssystemhelper/qmeegoruntime.h
+++ b/tools/qmeegographicssystemhelper/qmeegoruntime.h
@@ -57,9 +57,11 @@ public:
static void setTranslucent(bool translucent);
static QPixmapData* pixmapDataWithNewLiveTexture(int w, int h, QImage::Format format);
static QPixmapData* pixmapDataFromLiveTextureHandle(Qt::HANDLE h);
- static QImage* lockLiveTexture(QPixmap *pixmap);
+ static QImage* lockLiveTexture(QPixmap *pixmap, void *fenceSync);
static bool releaseLiveTexture(QPixmap *pixmap, QImage *image);
static Qt::HANDLE getLiveTextureHandle(QPixmap *pixmap);
+ static void* createFenceSync();
+ static void destroyFenceSync(void *fs);
private:
static bool initialized;