diff options
Diffstat (limited to 'tools/qmeegographicssystemhelper')
15 files changed, 519 insertions, 115 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.cpp b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp index d348e70..b660eb3 100644 --- a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp @@ -46,6 +46,7 @@ #include <private/qgraphicssystem_runtime_p.h> #include <private/qpixmap_raster_p.h> #include "qmeegoruntime.h" +#include "qmeegoswitchevent.h" QString QMeeGoGraphicsSystemHelper::runningGraphicsSystemName() { @@ -81,8 +82,16 @@ void QMeeGoGraphicsSystemHelper::switchToMeeGo() if (QApplicationPrivate::instance()->graphics_system_name != QLatin1String("runtime")) qWarning("Can't switch to meego - switching only supported with 'runtime' graphics system."); else { + QMeeGoSwitchEvent willSwitchEvent(QLatin1String("meego"), QMeeGoSwitchEvent::WillSwitch); + foreach (QWidget *widget, QApplication::topLevelWidgets()) + QCoreApplication::sendEvent(widget, &willSwitchEvent); + QApplication *app = static_cast<QApplication *>(QCoreApplication::instance()); app->setGraphicsSystem(QLatin1String("meego")); + + QMeeGoSwitchEvent didSwitchEvent(QLatin1String("meego"), QMeeGoSwitchEvent::DidSwitch); + foreach (QWidget *widget, QApplication::topLevelWidgets()) + QCoreApplication::sendEvent(widget, &didSwitchEvent); } } @@ -94,8 +103,16 @@ void QMeeGoGraphicsSystemHelper::switchToRaster() if (QApplicationPrivate::instance()->graphics_system_name != QLatin1String("runtime")) qWarning("Can't switch to raster - switching only supported with 'runtime' graphics system."); else { + QMeeGoSwitchEvent willSwitchEvent(QLatin1String("raster"), QMeeGoSwitchEvent::WillSwitch); + foreach (QWidget *widget, QApplication::topLevelWidgets()) + QCoreApplication::sendEvent(widget, &willSwitchEvent); + QApplication *app = static_cast<QApplication *>(QCoreApplication::instance()); app->setGraphicsSystem(QLatin1String("raster")); + + QMeeGoSwitchEvent didSwitchEvent(QLatin1String("raster"), QMeeGoSwitchEvent::DidSwitch); + foreach (QWidget *widget, QApplication::topLevelWidgets()) + QCoreApplication::sendEvent(widget, &didSwitchEvent); } } diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h index 2bb75eb..d47c829 100644 --- a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h @@ -102,6 +102,9 @@ public: When running with the 'runtime' graphics system, sets the currently active system to 'meego'. The window surface and all the resources are automatically migrated to OpenGL. Will fail if the active graphics system is not 'runtime'. + Calling this function will emit QMeeGoSwitchEvent to the top level widgets. + Two events will be emitted for each switch -- one before the switch (QMeeGoSwitchEvent::WillSwitch) + and one after the switch (QMeeGoSwitchEvent::DidSwitch). */ static void switchToMeeGo(); @@ -111,6 +114,9 @@ public: system to 'raster'. The window surface and the graphics resources (including the EGL shared image resources) are automatically migrated back to the CPU. All OpenGL resources (surface, context, cache, font cache) are automaticall anihilated. + Calling this function will emit QMeeGoSwitchEvent to the top level widgets. + Two events will be emitted for each switch -- one before the switch (QMeeGoSwitchEvent::WillSwitch) + and one after the switch (QMeeGoSwitchEvent::DidSwitch). */ static void switchToRaster(); @@ -147,7 +153,7 @@ public: //! Destroys an EGL shared image. /*! Destroys an EGLSharedImage previously created with an ::imageToEGLSharedImage call. - Returns true if the image was found and the destruction was successfull. Notice that + Returns true if the image was found and the destruction was successful. Notice that this destroys the image for all processes using it. */ static bool destroyEGLSharedImage(Qt::HANDLE handle); diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro index 4d69fac..360847e 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 +HEADERS = qmeegographicssystemhelper.h qmeegooverlaywidget.h qmeegolivepixmap.h qmeegoruntime.h qmeegolivepixmap_p.h qmeegofencesync.h qmeegofencesync_p.h qmeegoswitchevent.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 qmeegoswitchevent.cpp qmeegoswitchevent.h diff --git a/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp b/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp index b9dbb2b..9700581f 100644 --- a/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp +++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp @@ -40,15 +40,13 @@ ****************************************************************************/ #include "qmeegolivepixmap.h" -#include <private/qimage_p.h> -#include <private/qpixmap_raster_p.h> #include "qmeegolivepixmap_p.h" +#include "qmeegofencesync_p.h" #include "qmeegoruntime.h" -#include <QSharedMemory> /* QMeeGoLivePixmapPrivate */ -QMeeGoLivePixmapPrivate::QMeeGoLivePixmapPrivate(Qt::HANDLE h) : handle(h) +QMeeGoLivePixmapPrivate::QMeeGoLivePixmapPrivate() { } @@ -60,7 +58,7 @@ QMeeGoLivePixmapPrivate::~QMeeGoLivePixmapPrivate() QMeeGoLivePixmap* QMeeGoLivePixmap::livePixmapWithSize(int w, int h, Format format) { - QImage::Format qtFormat; + QImage::Format qtFormat; if (format == Format_RGB16) qtFormat = QImage::Format_RGB16; else if (format == Format_ARGB32_Premultiplied) @@ -69,17 +67,17 @@ QMeeGoLivePixmap* QMeeGoLivePixmap::livePixmapWithSize(int w, int h, Format form qWarning("Unsupported live pixmap format!"); return 0; } - - Qt::HANDLE liveTextureHandle = QMeeGoRuntime::createLiveTexture(w, h, qtFormat); - if (! liveTextureHandle) { + + QPixmapData *pmd = QMeeGoRuntime::pixmapDataWithNewLiveTexture(w, h, qtFormat); + if (! pmd) { qWarning("Failed to create a live texture with given size!"); return NULL; } - return QMeeGoLivePixmap::fromHandle(liveTextureHandle); + return new QMeeGoLivePixmap(pmd); } -QMeeGoLivePixmap::QMeeGoLivePixmap(QPixmapData *p, Qt::HANDLE h) : QPixmap(p), d_ptr(new QMeeGoLivePixmapPrivate(h)) +QMeeGoLivePixmap::QMeeGoLivePixmap(QPixmapData *p) : QPixmap(p), d_ptr(new QMeeGoLivePixmapPrivate()) { Q_D(QMeeGoLivePixmap); d->q_ptr = this; @@ -87,57 +85,33 @@ QMeeGoLivePixmap::QMeeGoLivePixmap(QPixmapData *p, Qt::HANDLE h) : QPixmap(p), d QMeeGoLivePixmap* QMeeGoLivePixmap::fromHandle(Qt::HANDLE liveTextureHandle) { - Qt::HANDLE eglImage = QMeeGoRuntime::liveTextureToEGLImage(liveTextureHandle); - if (! eglImage) { - qWarning("Failed to bind the live texture as an egl image!"); - return NULL; - } - - QPixmapData *pmd = QMeeGoRuntime::pixmapDataFromEGLImage(eglImage); + QPixmapData *pmd = QMeeGoRuntime::pixmapDataFromLiveTextureHandle(liveTextureHandle); if (! pmd) { - qWarning("Failed to allocate a pixmap data from a given live texture egl image!"); + qWarning("Failed to create a live texture from given handle!"); return NULL; } - - return new QMeeGoLivePixmap(pmd, liveTextureHandle); + + return new QMeeGoLivePixmap(pmd); } Qt::HANDLE QMeeGoLivePixmap::handle() { - Q_D(QMeeGoLivePixmap); - return d->handle; + return QMeeGoRuntime::getLiveTextureHandle(this); } QMeeGoLivePixmap::~QMeeGoLivePixmap() { } -QImage* QMeeGoLivePixmap::lock() +QImage* QMeeGoLivePixmap::lock(QMeeGoFenceSync *fenceSync) { - Q_D(QMeeGoLivePixmap); - - void *data = NULL; - int pitch = 0; - - if (! QMeeGoRuntime::lockLiveTexture(d->handle)) { - qWarning("Failed to lock a live texture!"); - return new QImage(); - } - - QMeeGoRuntime::queryLiveTexture(d->handle, &data, &pitch); - if (data == NULL || pitch == 0) { - qWarning("Failed to query the live texture!"); - return new QImage(); - } - - // FIXME Bug here! FIX FIX FIX FIX FIX FIX - return new QImage((uchar *) data, width(), height(), QImage::Format_RGB16); + if (fenceSync) + return QMeeGoRuntime::lockLiveTexture(this, fenceSync->d_func()->syncObject); + else + return QMeeGoRuntime::lockLiveTexture(this, NULL); } - + void QMeeGoLivePixmap::release(QImage *img) { - Q_D(QMeeGoLivePixmap); - // FIXME Make sure we're locked! - QMeeGoRuntime::unlockLiveTexture(d->handle); - delete img; + QMeeGoRuntime::releaseLiveTexture(this, img); } diff --git a/tools/qmeegographicssystemhelper/qmeegolivepixmap.h b/tools/qmeegographicssystemhelper/qmeegolivepixmap.h index 12fe994..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; @@ -52,7 +53,7 @@ class QImage; /*! */ -class QMeeGoLivePixmap : public QPixmap +class Q_DECL_EXPORT QMeeGoLivePixmap : public QPixmap { public: enum Format { @@ -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. /*! @@ -96,7 +101,7 @@ public: virtual ~QMeeGoLivePixmap(); private: - QMeeGoLivePixmap(QPixmapData *p, Qt::HANDLE h); + QMeeGoLivePixmap(QPixmapData *p); Q_DISABLE_COPY(QMeeGoLivePixmap) Q_DECLARE_PRIVATE(QMeeGoLivePixmap) diff --git a/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h b/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h index 22347d6..78d9553 100644 --- a/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h +++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h @@ -48,11 +48,9 @@ class QMeeGoLivePixmapPrivate { public: Q_DECLARE_PUBLIC(QMeeGoLivePixmap); - QMeeGoLivePixmapPrivate(Qt::HANDLE handle); + QMeeGoLivePixmapPrivate(); virtual ~QMeeGoLivePixmapPrivate(); - - Qt::HANDLE handle; - + QMeeGoLivePixmap *q_ptr; }; diff --git a/tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp index f9f14ae..b42a7ea 100644 --- a/tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp +++ b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp @@ -42,7 +42,8 @@ #include <QDebug> #include <QEvent> #include <QMouseEvent> -#include <QCoreApplication> +#include <QApplication> +#include <QDesktopWidget> #include "qmeegooverlaywidget.h" #include "qmeegographicssystemhelper.h" #include "qmeegoruntime.h" @@ -54,10 +55,12 @@ QMeeGoOverlayWidget::QMeeGoOverlayWidget(int surfaceWidth, int surfaceHeight, QW if (! QMeeGoGraphicsSystemHelper::isRunningMeeGo()) qFatal("QMeeGoOverlayWidget can only be used when running with 'meego' graphics system!"); + const QRect desktop = QApplication::desktop()->screenGeometry(parent); + QMeeGoRuntime::setSurfaceFixedSize(surfaceWidth, surfaceHeight); - scaleW = sw / 864.0; - scaleH = sh / 480.0; + scaleW = sw / desktop.width(); + scaleH = sh / desktop.height(); installEventFilter(this); } diff --git a/tools/qmeegographicssystemhelper/qmeegooverlaywidget.h b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.h index c2c08b4..e67f59b 100644 --- a/tools/qmeegographicssystemhelper/qmeegooverlaywidget.h +++ b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.h @@ -48,7 +48,7 @@ /*! */ -class QMeeGoOverlayWidget : public QWidget +class Q_DECL_EXPORT QMeeGoOverlayWidget : public QWidget { public: //! Constructs a new scaling widget. diff --git a/tools/qmeegographicssystemhelper/qmeegoruntime.cpp b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp index 44f9f58..2d3ee3c 100644 --- a/tools/qmeegographicssystemhelper/qmeegoruntime.cpp +++ b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp @@ -44,6 +44,7 @@ #include <private/qlibrary_p.h> #include <private/qfactoryloader_p.h> #include <private/qgraphicssystemplugin_p.h> +#include <stdio.h> #define ENSURE_INITIALIZED {if (!initialized) initialize();} @@ -51,36 +52,35 @@ bool QMeeGoRuntime::initialized = false; typedef int (*QMeeGoImageToEglSharedImageFunc) (const QImage&); typedef QPixmapData* (*QMeeGoPixmapDataFromEglSharedImageFunc) (Qt::HANDLE handle, const QImage&); -typedef QPixmapData* (*QMeeGoPixmapDataFromEglImageFunc) (Qt::HANDLE handle); typedef QPixmapData* (*QMeeGoPixmapDataWithGLTextureFunc) (int w, int h); typedef bool (*QMeeGoDestroyEGLSharedImageFunc) (Qt::HANDLE handle); typedef void (*QMeeGoUpdateEglSharedImagePixmapFunc) (QPixmap*); typedef void (*QMeeGoSetSurfaceFixedSizeFunc) (int w, int h); typedef void (*QMeeGoSetSurfaceScalingFunc) (int x, int y, int w, int h); typedef void (*QMeeGoSetTranslucentFunc) (bool translucent); -typedef Qt::HANDLE (*QMeeGoLiveTextureCreateFunc) (int w, int h, QImage::Format format); -typedef bool (*QMeeGoLiveTextureLockFunc) (Qt::HANDLE h); -typedef bool (*QMeeGoLiveTextureUnlockFunc) (Qt::HANDLE h); -typedef void (*QMeeGoLiveTextureDestroyFunc) (Qt::HANDLE h); -typedef void (*QMeeGoLiveTextureQueryFunc) (Qt::HANDLE h, void **data, int *pitch); -typedef Qt::HANDLE (*QMeeGoLiveTextureToEglImageFunc) (Qt::HANDLE h); +typedef QPixmapData* (*QMeeGoPixmapDataWithNewLiveTextureFunc) (int w, int h, QImage::Format format); +typedef QPixmapData* (*QMeeGoPixmapDataFromLiveTextureHandleFunc) (Qt::HANDLE h); +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; -static QMeeGoPixmapDataFromEglImageFunc qt_meego_pixmapdata_from_egl_image = NULL; static QMeeGoPixmapDataWithGLTextureFunc qt_meego_pixmapdata_with_gl_texture = NULL; static QMeeGoDestroyEGLSharedImageFunc qt_meego_destroy_egl_shared_image = NULL; static QMeeGoUpdateEglSharedImagePixmapFunc qt_meego_update_egl_shared_image_pixmap = NULL; static QMeeGoSetSurfaceFixedSizeFunc qt_meego_set_surface_fixed_size = NULL; static QMeeGoSetSurfaceScalingFunc qt_meego_set_surface_scaling = NULL; static QMeeGoSetTranslucentFunc qt_meego_set_translucent = NULL; -static QMeeGoLiveTextureCreateFunc qt_meego_live_texture_create = NULL; +static QMeeGoPixmapDataWithNewLiveTextureFunc qt_meego_pixmapdata_with_new_live_texture = NULL; +static QMeeGoPixmapDataFromLiveTextureHandleFunc qt_meego_pixmapdata_from_live_texture_handle = NULL; static QMeeGoLiveTextureLockFunc qt_meego_live_texture_lock = NULL; -static QMeeGoLiveTextureUnlockFunc qt_meego_live_texture_unlock = NULL; -static QMeeGoLiveTextureDestroyFunc qt_meego_live_texture_destroy = NULL; -static QMeeGoLiveTextureQueryFunc qt_meego_live_texture_query = NULL; -static QMeeGoLiveTextureToEglImageFunc qt_meego_live_texture_to_egl_image = 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() { @@ -96,27 +96,30 @@ void QMeeGoRuntime::initialize() if (success) { qt_meego_image_to_egl_shared_image = (QMeeGoImageToEglSharedImageFunc) library.resolve("qt_meego_image_to_egl_shared_image"); qt_meego_pixmapdata_from_egl_shared_image = (QMeeGoPixmapDataFromEglSharedImageFunc) library.resolve("qt_meego_pixmapdata_from_egl_shared_image"); - qt_meego_pixmapdata_from_egl_image = (QMeeGoPixmapDataFromEglImageFunc) library.resolve("qt_meego_pixmapdata_from_egl_image"); qt_meego_pixmapdata_with_gl_texture = (QMeeGoPixmapDataWithGLTextureFunc) library.resolve("qt_meego_pixmapdata_with_gl_texture"); qt_meego_destroy_egl_shared_image = (QMeeGoDestroyEGLSharedImageFunc) library.resolve("qt_meego_destroy_egl_shared_image"); qt_meego_update_egl_shared_image_pixmap = (QMeeGoUpdateEglSharedImagePixmapFunc) library.resolve("qt_meego_update_egl_shared_image_pixmap"); qt_meego_set_surface_fixed_size = (QMeeGoSetSurfaceFixedSizeFunc) library.resolve("qt_meego_set_surface_fixed_size"); qt_meego_set_surface_scaling = (QMeeGoSetSurfaceScalingFunc) library.resolve("qt_meego_set_surface_scaling"); qt_meego_set_translucent = (QMeeGoSetTranslucentFunc) library.resolve("qt_meego_set_translucent"); - qt_meego_live_texture_create = (QMeeGoLiveTextureCreateFunc) library.resolve("qt_meego_live_texture_create"); + qt_meego_pixmapdata_with_new_live_texture = (QMeeGoPixmapDataWithNewLiveTextureFunc) library.resolve("qt_meego_pixmapdata_with_new_live_texture"); + qt_meego_pixmapdata_from_live_texture_handle = (QMeeGoPixmapDataFromLiveTextureHandleFunc) library.resolve("qt_meego_pixmapdata_from_live_texture_handle"); qt_meego_live_texture_lock = (QMeeGoLiveTextureLockFunc) library.resolve("qt_meego_live_texture_lock"); - qt_meego_live_texture_unlock = (QMeeGoLiveTextureUnlockFunc) library.resolve("qt_meego_live_texture_unlock"); - qt_meego_live_texture_destroy = (QMeeGoLiveTextureDestroyFunc) library.resolve("qt_meego_live_texture_destroy"); - qt_meego_live_texture_query = (QMeeGoLiveTextureQueryFunc) library.resolve("qt_meego_live_texture_query"); - qt_meego_live_texture_to_egl_image = (QMeeGoLiveTextureToEglImageFunc) library.resolve("qt_meego_live_texture_to_egl_image"); + 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_from_egl_image && + 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_live_texture_create && qt_meego_live_texture_lock && qt_meego_live_texture_unlock && - qt_meego_live_texture_destroy && qt_meego_live_texture_query && qt_meego_live_texture_to_egl_image) + 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_create_fence_sync && qt_meego_destroy_fence_sync) { qDebug("Successfully resolved MeeGo graphics system: %s %s\n", qPrintable(libraryPrivate->fileName), qPrintable(libraryPrivate->fullVersion)); + } else { + Q_ASSERT(false); } } else { Q_ASSERT(false); @@ -139,13 +142,6 @@ QPixmapData* QMeeGoRuntime::pixmapDataFromEGLSharedImage(Qt::HANDLE handle, cons return qt_meego_pixmapdata_from_egl_shared_image(handle, softImage); } -QPixmapData* QMeeGoRuntime::pixmapDataFromEGLImage(Qt::HANDLE handle) -{ - ENSURE_INITIALIZED; - Q_ASSERT(qt_meego_pixmapdata_from_egl_image); - return qt_meego_pixmapdata_from_egl_image(handle); -} - QPixmapData* QMeeGoRuntime::pixmapDataWithGLTexture(int w, int h) { ENSURE_INITIALIZED; @@ -188,45 +184,51 @@ void QMeeGoRuntime::setTranslucent(bool translucent) qt_meego_set_translucent(translucent); } -Qt::HANDLE QMeeGoRuntime::createLiveTexture(int w, int h, QImage::Format format) +QPixmapData* QMeeGoRuntime::pixmapDataWithNewLiveTexture(int w, int h, QImage::Format format) { ENSURE_INITIALIZED; - Q_ASSERT(qt_meego_live_texture_create); - return qt_meego_live_texture_create(w, h, format); + Q_ASSERT(qt_meego_pixmapdata_with_new_live_texture); + return qt_meego_pixmapdata_with_new_live_texture(w, h, format); } -bool QMeeGoRuntime::lockLiveTexture(Qt::HANDLE h) +QPixmapData* QMeeGoRuntime::pixmapDataFromLiveTextureHandle(Qt::HANDLE h) { ENSURE_INITIALIZED; - Q_ASSERT(qt_meego_live_texture_lock); - return qt_meego_live_texture_lock(h); + Q_ASSERT(qt_meego_pixmapdata_from_live_texture_handle); + return qt_meego_pixmapdata_from_live_texture_handle(h); } -bool QMeeGoRuntime::unlockLiveTexture(Qt::HANDLE h) +QImage* QMeeGoRuntime::lockLiveTexture(QPixmap *p, void* fenceSync) { ENSURE_INITIALIZED; - Q_ASSERT(qt_meego_live_texture_unlock); - return qt_meego_live_texture_unlock(h); + Q_ASSERT(qt_meego_live_texture_lock); + return qt_meego_live_texture_lock(p, fenceSync); } -void QMeeGoRuntime::destroyLiveTexture(Qt::HANDLE h) +bool QMeeGoRuntime::releaseLiveTexture(QPixmap *p, QImage *i) { ENSURE_INITIALIZED; - Q_ASSERT(qt_meego_live_texture_destroy); - qt_meego_live_texture_destroy(h); + Q_ASSERT(qt_meego_live_texture_release); + return qt_meego_live_texture_release(p, i); } -void QMeeGoRuntime::queryLiveTexture(Qt::HANDLE h, void **data, int *pitch) +Qt::HANDLE QMeeGoRuntime::getLiveTextureHandle(QPixmap *pixmap) { ENSURE_INITIALIZED; - Q_ASSERT(qt_meego_live_texture_query); - qt_meego_live_texture_query(h, data, pitch); + Q_ASSERT(qt_meego_live_texture_get_handle); + return qt_meego_live_texture_get_handle(pixmap); } -Qt::HANDLE QMeeGoRuntime::liveTextureToEGLImage(Qt::HANDLE handle) +void* QMeeGoRuntime::createFenceSync() { ENSURE_INITIALIZED; - Q_ASSERT(qt_meego_live_texture_to_egl_image); - return qt_meego_live_texture_to_egl_image(handle); + 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 048b9be..be6ff6b 100644 --- a/tools/qmeegographicssystemhelper/qmeegoruntime.h +++ b/tools/qmeegographicssystemhelper/qmeegoruntime.h @@ -49,19 +49,19 @@ public: static Qt::HANDLE imageToEGLSharedImage(const QImage &image); static QPixmapData* pixmapDataFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage); - static QPixmapData* pixmapDataFromEGLImage(Qt::HANDLE handle); static QPixmapData* pixmapDataWithGLTexture(int w, int h); static bool destroyEGLSharedImage(Qt::HANDLE handle); static void updateEGLSharedImagePixmap(QPixmap *p); static void setSurfaceFixedSize(int w, int h); static void setSurfaceScaling(int x, int y, int w, int h); static void setTranslucent(bool translucent); - static Qt::HANDLE createLiveTexture(int w, int h, QImage::Format format); - static bool lockLiveTexture(Qt::HANDLE h); - static bool unlockLiveTexture(Qt::HANDLE h); - static void destroyLiveTexture(Qt::HANDLE h); - static void queryLiveTexture(Qt::HANDLE h, void **data, int *pitch); - static Qt::HANDLE liveTextureToEGLImage(Qt::HANDLE); + static QPixmapData* pixmapDataWithNewLiveTexture(int w, int h, QImage::Format format); + static QPixmapData* pixmapDataFromLiveTextureHandle(Qt::HANDLE h); + 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; diff --git a/tools/qmeegographicssystemhelper/qmeegoswitchevent.cpp b/tools/qmeegographicssystemhelper/qmeegoswitchevent.cpp new file mode 100644 index 0000000..22ea0fe --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegoswitchevent.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** 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 "qmeegoswitchevent.h" + +static int switchEventNumber = -1; + +QMeeGoSwitchEvent::QMeeGoSwitchEvent(const QString &graphicsSystemName, QMeeGoSwitchEvent::State s) : QEvent(QMeeGoSwitchEvent::eventNumber()) +{ + name = graphicsSystemName; + switchState = s; +} + +QString QMeeGoSwitchEvent::graphicsSystemName() const +{ + return name; +} + +QMeeGoSwitchEvent::State QMeeGoSwitchEvent::state() const +{ + return switchState; +} + +QEvent::Type QMeeGoSwitchEvent::eventNumber() +{ + if (switchEventNumber < 0) + switchEventNumber = QEvent::registerEventType(); + + return (QEvent::Type) switchEventNumber; +}
\ No newline at end of file diff --git a/tools/qmeegographicssystemhelper/qmeegoswitchevent.h b/tools/qmeegographicssystemhelper/qmeegoswitchevent.h new file mode 100644 index 0000000..0ddbd3d --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegoswitchevent.h @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** 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 <QEvent> +#include <QString> + +//! A custom event representing a graphics system switch. +/*! + This event is sent two times -- before the actual switch and after the switch. + The current mode of the event can be detected by looking at the State of the + event. + + The end-user application can use the event to drop it's own allocated GL resources + when going to software mode. +*/ + +class QMeeGoSwitchEvent : public QEvent +{ +public: + + //! The state represented by this event. + enum State { + WillSwitch, + DidSwitch + }; + + //! Constructor for the event. + /*! + Creates a new event with the given name and the given state. + */ + QMeeGoSwitchEvent(const QString &graphicsSystemName, State s); + + //! Returns the name of the target graphics system. + /*! + Depending on the state, the name represents the system we're about to swtich to, + or the system we just switched to. + */ + QString graphicsSystemName() const; + + //! Returns the state represented by this event. + State state() const; + + //! Returns the event type/number for QMeeGoSwitchEvent. + /*! + The type is registered on first access. Use this to detect incoming + QMeeGoSwitchEvents. + */ + QEvent::Type eventNumber(); + +private: + QString name; + State switchState; +}; |