diff options
author | Michael Dominic K <mdk@codethink.co.uk> | 2010-10-07 16:51:50 (GMT) |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2010-10-07 17:01:56 (GMT) |
commit | df61814c228e6f2badf378e25b69daf9941c646b (patch) | |
tree | 3382a9f0ca78e0fc68a6317a969962e5a36fa6e2 /tools | |
parent | e7db6cd0bddb7203c5460e97e2b8164bbaf420b8 (diff) | |
download | Qt-df61814c228e6f2badf378e25b69daf9941c646b.zip Qt-df61814c228e6f2badf378e25b69daf9941c646b.tar.gz Qt-df61814c228e6f2badf378e25b69daf9941c646b.tar.bz2 |
Live texture updates to meegographicssystem helper.
Merge-request: 848
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'tools')
11 files changed, 197 insertions, 406 deletions
diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp index 0670ac4..d348e70 100644 --- a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp @@ -68,6 +68,11 @@ bool QMeeGoGraphicsSystemHelper::isRunningMeeGo() return (runningGraphicsSystemName() == QLatin1String("meego")); } +bool QMeeGoGraphicsSystemHelper::isRunningRuntime() +{ + return (QApplicationPrivate::instance()->graphics_system_name == QLatin1String("runtime")); +} + void QMeeGoGraphicsSystemHelper::switchToMeeGo() { if (isRunningMeeGo()) @@ -105,13 +110,13 @@ QPixmap QMeeGoGraphicsSystemHelper::pixmapFromEGLSharedImage(Qt::HANDLE handle, // This function is supported when not running meego too. A raster-backed // pixmap will be created... but when you switch back to 'meego', it'll // be replaced with a EGL shared image backing. - return QMeeGoRuntime::pixmapFromEGLSharedImage(handle, softImage); + return QPixmap(QMeeGoRuntime::pixmapDataFromEGLSharedImage(handle, softImage)); } QPixmap QMeeGoGraphicsSystemHelper::pixmapWithGLTexture(int w, int h) { ENSURE_RUNNING_MEEGO; - return QMeeGoRuntime::pixmapWithGLTexture(w, h); + return QPixmap(QMeeGoRuntime::pixmapDataWithGLTexture(w, h)); } bool QMeeGoGraphicsSystemHelper::destroyEGLSharedImage(Qt::HANDLE handle) diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h index 02f2fa2..2bb75eb 100644 --- a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h @@ -89,6 +89,13 @@ public: switching is 'meego'. */ static bool isRunningMeeGo(); + + //! Returns true if running with a 'runtime' graphicssystem. + /*! + This function can be used in combination with ::runningGraphicsSystemName to figure out + the existing situation. + */ + static bool isRunningRuntime(); //! Switches to meego graphics system. /*! diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro index 1e6e233..4d69fac 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 qmeegoliveimage.h qmeegoruntime.h qmeegoliveimage_p.h qmeegolivepixmap_p.h -SOURCES = qmeegographicssystemhelper.cpp qmeegooverlaywidget.cpp qmeegoruntime.cpp qmeegolivepixmap.cpp qmeegoliveimage.cpp +HEADERS = qmeegographicssystemhelper.h qmeegooverlaywidget.h qmeegolivepixmap.h qmeegoruntime.h qmeegolivepixmap_p.h +SOURCES = qmeegographicssystemhelper.cpp qmeegooverlaywidget.cpp qmeegoruntime.cpp qmeegolivepixmap.cpp diff --git a/tools/qmeegographicssystemhelper/qmeegoliveimage.cpp b/tools/qmeegographicssystemhelper/qmeegoliveimage.cpp deleted file mode 100644 index 83a1e28..0000000 --- a/tools/qmeegographicssystemhelper/qmeegoliveimage.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** 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 "qmeegoliveimage.h" -#include "qmeegoliveimage_p.h" -#include "qmeegolivepixmap.h" -#include "qmeegolivepixmap_p.h" - -/* QMeeGoLiveImagePrivate */ - -QMeeGoLiveImagePrivate::QMeeGoLiveImagePrivate() -{ -} - -QMeeGoLiveImagePrivate::~QMeeGoLiveImagePrivate() -{ - if (attachedPixmaps.length() > 0) - qWarning("Destroying QMeeGoLiveImage but it still has QMeeGoLivePixmaps attached!"); -} - -void QMeeGoLiveImagePrivate::attachPixmap(QMeeGoLivePixmap* pixmap) -{ - attachedPixmaps << pixmap; -} - -void QMeeGoLiveImagePrivate::detachPixmap(QMeeGoLivePixmap* pixmap) -{ - attachedPixmaps.removeAll(pixmap); -} - -/* QMeeGoLiveImage */ - -QMeeGoLiveImage* QMeeGoLiveImage::liveImageWithSize(int w, int h, Format format, int buffers) -{ - if (format != Format_ARGB32_Premultiplied) { - qWarning("Only _ARGB32_Premultiplied format is supported for live images now!"); - return 0; - } - - if (buffers != 1) { - qWarning("Only single-buffer streams are supported at the moment"); - return 0; - } - - QMeeGoLiveImage *liveImage = new QMeeGoLiveImage(w, h); - return liveImage; -} - -QMeeGoLiveImage::QMeeGoLiveImage(int w, int h) : QImage(w, h, QImage::Format_ARGB32_Premultiplied), d_ptr(new QMeeGoLiveImagePrivate()) -{ - Q_D(QMeeGoLiveImage); - d->q_ptr = this; -} - -QMeeGoLiveImage::~QMeeGoLiveImage() -{ -} - -void QMeeGoLiveImage::lock(int buffer) -{ - if (buffer != 0) - qWarning("Only locking 0 buffer is supported at the moment!"); -} - -void QMeeGoLiveImage::release(int buffer) -{ - Q_D(QMeeGoLiveImage); - - if (buffer != 0) { - qWarning("Only locking 0 buffer is supported at the moment!"); - return; - } - - // We need to copy the update image to all the client QMeeGoLivePixmap's - foreach (QMeeGoLivePixmap* livePixmap, d->attachedPixmaps) - livePixmap->d_ptr->copyBackFrom((const void *) bits()); -} diff --git a/tools/qmeegographicssystemhelper/qmeegoliveimage.h b/tools/qmeegographicssystemhelper/qmeegoliveimage.h deleted file mode 100644 index 1e21e7b..0000000 --- a/tools/qmeegographicssystemhelper/qmeegoliveimage.h +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** -** -** 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 QMEEGOLIVEIMAGE_H -#define QMEEGOLIVEIMAGE_H - -#include <QImage> - -class QMeeGoLivePixmap; -class QMeeGoLiveImagePrivate; - -//! A streamable QImage subclass. -/*! -*/ - -class QMeeGoLiveImage : public QImage -{ -public: - //! Format specifier. - /*! - Used to specify the format of the underlying image data for QMeeGoLiveImage. - */ - enum Format { - Format_ARGB32_Premultiplied //! 32bit, AARRGGBB format. The typical Qt format. - }; - - //! Locks the access to the image. - /*! - All drawing/access to the underlying image data needs to happen between - ::lock() and ::unlock() pairs. - */ - void lock(int buffer = 0); - - //! Unlocks the access to the image. - /*! - All drawing/access to the underlying image data needs to happen between - ::lock() and ::unlock() pairs. - */ - void release(int buffer = 0); - - //! Destroys the image. - /*! - It's a mistake to destroy an image before destroying all the QMeeGoLivePixmaps - built on top of it. You should first destroy all the QMeeGoLivePixmaps. - */ - virtual ~QMeeGoLiveImage(); - - //! Creates and returns a new live image with the given parameters. - /*! - The new image is created with the given width w and the given height h. - The format specifies the color format used by the image. Optionally, a - number of buffers can be specfied for a stream-like behavior. - */ - static QMeeGoLiveImage* liveImageWithSize(int w, int h, Format format, int buffers = 1); - -private: - QMeeGoLiveImage(int w, int h); //! Private bits. - Q_DISABLE_COPY(QMeeGoLiveImage) - Q_DECLARE_PRIVATE(QMeeGoLiveImage) - -protected: - QScopedPointer<QMeeGoLiveImagePrivate> d_ptr; - - friend class QMeeGoLivePixmap; - friend class QMeeGoLivePixmapPrivate; -}; - -#endif diff --git a/tools/qmeegographicssystemhelper/qmeegoliveimage_p.h b/tools/qmeegographicssystemhelper/qmeegoliveimage_p.h deleted file mode 100644 index 085fed4..0000000 --- a/tools/qmeegographicssystemhelper/qmeegoliveimage_p.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** 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 "qmeegoliveimage.h" - -#ifndef QMEEGOLIVEIMAGE_P_H -#define QMEEGOLIVEIMAGE_P_H - -class QMeeGoLiveImagePrivate -{ -public: - Q_DECLARE_PUBLIC(QMeeGoLiveImage); - QMeeGoLiveImagePrivate(); - virtual ~QMeeGoLiveImagePrivate(); - void attachPixmap(QMeeGoLivePixmap* pixmap); - void detachPixmap(QMeeGoLivePixmap* pixmap); - - QList <QMeeGoLivePixmap*> attachedPixmaps; - QMeeGoLiveImage *q_ptr; - - friend class QMeeGoLivePixmap; - friend class QMeeGoLivePixmapPrivate; -}; - -#endif diff --git a/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp b/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp index 2a1c04b..b9dbb2b 100644 --- a/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp +++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp @@ -43,121 +43,101 @@ #include <private/qimage_p.h> #include <private/qpixmap_raster_p.h> #include "qmeegolivepixmap_p.h" -#include "qmeegoliveimage_p.h" +#include "qmeegoruntime.h" #include <QSharedMemory> /* QMeeGoLivePixmapPrivate */ -QMeeGoLivePixmapPrivate::QMeeGoLivePixmapPrivate() : shm(0), shmSerial(0), owns(true), parentImage(0) +QMeeGoLivePixmapPrivate::QMeeGoLivePixmapPrivate(Qt::HANDLE h) : handle(h) { } -void QMeeGoLivePixmapPrivate::copyBackFrom(const void *raw) +QMeeGoLivePixmapPrivate::~QMeeGoLivePixmapPrivate() { - Q_Q(QMeeGoLivePixmap); - - q->detach(); - shm->lock(); - uchar *dest = ((uchar *) shm->data()) + (2 * sizeof(int)); - memcpy(dest, raw, q->width() * q->height() * 4); - shm->unlock(); } -QMeeGoLivePixmapPrivate::~QMeeGoLivePixmapPrivate() +/* QMeeGoLivePixmap */ + +QMeeGoLivePixmap* QMeeGoLivePixmap::livePixmapWithSize(int w, int h, Format format) { - Q_Q(QMeeGoLivePixmap); + QImage::Format qtFormat; + if (format == Format_RGB16) + qtFormat = QImage::Format_RGB16; + else if (format == Format_ARGB32_Premultiplied) + qtFormat = QImage::Format_ARGB32_Premultiplied; + else { + qWarning("Unsupported live pixmap format!"); + return 0; + } - if (parentImage) - parentImage->d_ptr->detachPixmap(q); - - if (shm) - shm->detach(); - - if (owns) - delete shm; -} + Qt::HANDLE liveTextureHandle = QMeeGoRuntime::createLiveTexture(w, h, qtFormat); + if (! liveTextureHandle) { + qWarning("Failed to create a live texture with given size!"); + return NULL; + } -/* QMeeGoLivePixmap */ + return QMeeGoLivePixmap::fromHandle(liveTextureHandle); +} -QMeeGoLivePixmap::QMeeGoLivePixmap(QPixmapData *p) : QPixmap(p), d_ptr(new QMeeGoLivePixmapPrivate()) +QMeeGoLivePixmap::QMeeGoLivePixmap(QPixmapData *p, Qt::HANDLE h) : QPixmap(p), d_ptr(new QMeeGoLivePixmapPrivate(h)) { Q_D(QMeeGoLivePixmap); d->q_ptr = this; } -QMeeGoLivePixmap* QMeeGoLivePixmap::fromLiveImage(QMeeGoLiveImage *liveImage) +QMeeGoLivePixmap* QMeeGoLivePixmap::fromHandle(Qt::HANDLE liveTextureHandle) { - static int counter = 100; - QSharedMemory *shm = NULL; - uchar* imgData = NULL; - int *header = NULL; - int w = liveImage->width(); - int h = liveImage->height(); - - counter++; - shm = new QSharedMemory(QString(QLatin1String("QMeeGoLivePixmap%1")).arg(counter)); - shm->create((w * h * 4) + 2 * sizeof(int)); // +2 to store width & height - shm->attach(); - - imgData = ((uchar *) shm->data()) + (2 * sizeof(int)); - header = (int *) shm->data(); - - header[0] = w; - header[1] = h; - - QImage img(imgData, w, h, QImage::Format_ARGB32_Premultiplied); - - QPixmapData *pmd = new QRasterPixmapData(QPixmapData::PixmapType); - pmd->fromImage(img, Qt::NoOpaqueDetection); - - QMeeGoLivePixmap *livePixmap = new QMeeGoLivePixmap(pmd); - livePixmap->d_ptr->shm = shm; - livePixmap->d_ptr->owns = true; - livePixmap->d_ptr->shmSerial = counter; - livePixmap->d_ptr->parentImage = liveImage; - - liveImage->d_ptr->attachPixmap(livePixmap); + Qt::HANDLE eglImage = QMeeGoRuntime::liveTextureToEGLImage(liveTextureHandle); + if (! eglImage) { + qWarning("Failed to bind the live texture as an egl image!"); + return NULL; + } - return livePixmap; + QPixmapData *pmd = QMeeGoRuntime::pixmapDataFromEGLImage(eglImage); + if (! pmd) { + qWarning("Failed to allocate a pixmap data from a given live texture egl image!"); + return NULL; + } + + return new QMeeGoLivePixmap(pmd, liveTextureHandle); } -QMeeGoLivePixmap* QMeeGoLivePixmap::fromHandle(Qt::HANDLE handle) +Qt::HANDLE QMeeGoLivePixmap::handle() { - QSharedMemory *shm = NULL; - int *header; - int width; - int height; - uchar* imgData; - - shm = new QSharedMemory(QString(QLatin1String("QMeeGoLivePixmap%1")).arg(handle)); - shm->attach(); - - shm->lock(); - header = (int *) shm->data(); - width = header[0]; - height = header[1]; - shm->unlock(); - - imgData = ((uchar *) shm->data()) + (2 * sizeof(int)); - QImage img(imgData, width, height, QImage::Format_ARGB32_Premultiplied); - - QPixmapData *pmd = new QRasterPixmapData(QPixmapData::PixmapType); - pmd->fromImage(img, Qt::NoOpaqueDetection); - - QMeeGoLivePixmap *livePixmap = new QMeeGoLivePixmap(pmd); - livePixmap->d_ptr->shm = shm; - livePixmap->d_ptr->owns = false; - livePixmap->d_ptr->shmSerial = handle; - - return livePixmap; + Q_D(QMeeGoLivePixmap); + return d->handle; } QMeeGoLivePixmap::~QMeeGoLivePixmap() { } -Qt::HANDLE QMeeGoLivePixmap::handle() +QImage* QMeeGoLivePixmap::lock() +{ + 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); +} + +void QMeeGoLivePixmap::release(QImage *img) { Q_D(QMeeGoLivePixmap); - return d->shmSerial; + // FIXME Make sure we're locked! + QMeeGoRuntime::unlockLiveTexture(d->handle); + delete img; } diff --git a/tools/qmeegographicssystemhelper/qmeegolivepixmap.h b/tools/qmeegographicssystemhelper/qmeegolivepixmap.h index 2fa9db2..12fe994 100644 --- a/tools/qmeegographicssystemhelper/qmeegolivepixmap.h +++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap.h @@ -43,7 +43,6 @@ #define QMEEGOLIVEPIXMAP_H #include <QPixmap> -#include "qmeegoliveimage.h" class QMeeGoLivePixmapPrivate; class QSharedMemory; @@ -56,13 +55,17 @@ class QImage; class QMeeGoLivePixmap : public QPixmap { public: - //! Creates new pixmap from the given QMeeGoLiveImage. - /*! - The created QMeeGoLivePixmap will be attached to the given QMeeGoLiveImage. - Updates to the QMeeGoLiveImage will be represented on this newly created - QMeeGoLivePixmap. + enum Format { + Format_RGB16, //! 16bit, 5-6-5 RGB format. + Format_ARGB32_Premultiplied //! 32bit, AARRGGBB format. The typical Qt format. + }; + + //! Creates and returns a new live pixmap with the given parameters. + /*! + The new pixmap is created with the given width w and the given height h. + The format specifies the color format used by the pixmap. */ - static QMeeGoLivePixmap* fromLiveImage(QMeeGoLiveImage *liveImage); + static QMeeGoLivePixmap* livePixmapWithSize(int w, int h, Format format); //! Creates a new QMeeGoLivePixmap from the specified handle. /*! @@ -75,24 +78,30 @@ public: The handle can be used to share QMeeGoLivePixmap cross-process. */ Qt::HANDLE handle(); + + //! Locks the access to the pixmap. + /*! + The returned image can be used for direct access. + */ + QImage* lock(); + + //! Unlocks the access to the pixmap. + /*! + */ + void release(QImage *img); //! Destroys the QMeeGoLivePixmap. /*! - All QMeeGoLivePixmaps attached to a given QMeeGoLiveImage have to be destroyed - before the QMeeGoLiveImage itself is destroyed. */ virtual ~QMeeGoLivePixmap(); private: - QMeeGoLivePixmap(QPixmapData *p); + QMeeGoLivePixmap(QPixmapData *p, Qt::HANDLE h); Q_DISABLE_COPY(QMeeGoLivePixmap) Q_DECLARE_PRIVATE(QMeeGoLivePixmap) protected: QScopedPointer<QMeeGoLivePixmapPrivate> d_ptr; //! Private bits. - - friend class QMeeGoLiveImage; - friend class QMeeGoLiveImagePrivate; }; #endif diff --git a/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h b/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h index c2591dc..22347d6 100644 --- a/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h +++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h @@ -48,19 +48,12 @@ class QMeeGoLivePixmapPrivate { public: Q_DECLARE_PUBLIC(QMeeGoLivePixmap); - QMeeGoLivePixmapPrivate(); - void copyBackFrom(const void *raw); + QMeeGoLivePixmapPrivate(Qt::HANDLE handle); virtual ~QMeeGoLivePixmapPrivate(); - QSharedMemory *shm; - int shmSerial; - bool owns; - QMeeGoLiveImage *parentImage; + Qt::HANDLE handle; QMeeGoLivePixmap *q_ptr; - - friend class QMeeGoLiveImage; - friend class QMeeGoLiveImagePrivate; }; #endif diff --git a/tools/qmeegographicssystemhelper/qmeegoruntime.cpp b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp index 70b5dc1..44f9f58 100644 --- a/tools/qmeegographicssystemhelper/qmeegoruntime.cpp +++ b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp @@ -51,21 +51,36 @@ 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); 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 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; + void QMeeGoRuntime::initialize() { @@ -80,17 +95,26 @@ 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_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"); - - 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 = (QMeeGoLiveTextureCreateFunc) library.resolve("qt_meego_live_texture_create"); + 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"); + + if (qt_meego_image_to_egl_shared_image && qt_meego_pixmapdata_from_egl_shared_image && qt_meego_pixmapdata_from_egl_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) { qDebug("Successfully resolved MeeGo graphics system: %s %s\n", qPrintable(libraryPrivate->fileName), qPrintable(libraryPrivate->fullVersion)); } @@ -108,18 +132,25 @@ Qt::HANDLE QMeeGoRuntime::imageToEGLSharedImage(const QImage &image) return qt_meego_image_to_egl_shared_image(image); } -QPixmap QMeeGoRuntime::pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage) +QPixmapData* QMeeGoRuntime::pixmapDataFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage) { ENSURE_INITIALIZED; Q_ASSERT(qt_meego_pixmapdata_from_egl_shared_image); - return QPixmap(qt_meego_pixmapdata_from_egl_shared_image(handle, softImage)); + 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); } -QPixmap QMeeGoRuntime::pixmapWithGLTexture(int w, int h) +QPixmapData* QMeeGoRuntime::pixmapDataWithGLTexture(int w, int h) { ENSURE_INITIALIZED; Q_ASSERT(qt_meego_pixmapdata_with_gl_texture); - return QPixmap(qt_meego_pixmapdata_with_gl_texture(w, h)); + return qt_meego_pixmapdata_with_gl_texture(w, h); } bool QMeeGoRuntime::destroyEGLSharedImage(Qt::HANDLE handle) @@ -156,3 +187,46 @@ void QMeeGoRuntime::setTranslucent(bool translucent) Q_ASSERT(qt_meego_set_translucent); qt_meego_set_translucent(translucent); } + +Qt::HANDLE QMeeGoRuntime::createLiveTexture(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); +} + +bool QMeeGoRuntime::lockLiveTexture(Qt::HANDLE h) +{ + ENSURE_INITIALIZED; + Q_ASSERT(qt_meego_live_texture_lock); + return qt_meego_live_texture_lock(h); +} + +bool QMeeGoRuntime::unlockLiveTexture(Qt::HANDLE h) +{ + ENSURE_INITIALIZED; + Q_ASSERT(qt_meego_live_texture_unlock); + return qt_meego_live_texture_unlock(h); +} + +void QMeeGoRuntime::destroyLiveTexture(Qt::HANDLE h) +{ + ENSURE_INITIALIZED; + Q_ASSERT(qt_meego_live_texture_destroy); + qt_meego_live_texture_destroy(h); +} + +void QMeeGoRuntime::queryLiveTexture(Qt::HANDLE h, void **data, int *pitch) +{ + ENSURE_INITIALIZED; + Q_ASSERT(qt_meego_live_texture_query); + qt_meego_live_texture_query(h, data, pitch); +} + +Qt::HANDLE QMeeGoRuntime::liveTextureToEGLImage(Qt::HANDLE handle) +{ + ENSURE_INITIALIZED; + Q_ASSERT(qt_meego_live_texture_to_egl_image); + return qt_meego_live_texture_to_egl_image(handle); +} + diff --git a/tools/qmeegographicssystemhelper/qmeegoruntime.h b/tools/qmeegographicssystemhelper/qmeegoruntime.h index 82fdb52..048b9be 100644 --- a/tools/qmeegographicssystemhelper/qmeegoruntime.h +++ b/tools/qmeegographicssystemhelper/qmeegoruntime.h @@ -48,13 +48,20 @@ public: static void initialize(); static Qt::HANDLE imageToEGLSharedImage(const QImage &image); - static QPixmap pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage); - static QPixmap pixmapWithGLTexture(int w, int h); + 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); private: static bool initialized; |