diff options
Diffstat (limited to 'tools/qmeegographicssystemhelper')
13 files changed, 1333 insertions, 0 deletions
diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp new file mode 100644 index 0000000..0670ac4 --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp @@ -0,0 +1,133 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#define ENSURE_RUNNING_MEEGO {if (! QMeeGoGraphicsSystemHelper::isRunningMeeGo()) { qFatal("Using meego functionality but not running meego graphics system!"); }} + +#include "qmeegographicssystemhelper.h" +#include <private/qapplication_p.h> +#include <private/qgraphicssystem_runtime_p.h> +#include <private/qpixmap_raster_p.h> +#include "qmeegoruntime.h" + +QString QMeeGoGraphicsSystemHelper::runningGraphicsSystemName() +{ + if (! QApplicationPrivate::instance()) { + qWarning("Querying graphics system but application not running yet!"); + return QString(); + } + + QString name = QApplicationPrivate::instance()->graphics_system_name; + if (name == QLatin1String("runtime")) { + QRuntimeGraphicsSystem *rsystem = (QRuntimeGraphicsSystem *) QApplicationPrivate::instance()->graphics_system; + name = rsystem->graphicsSystemName(); + } + + return name; +} + +bool QMeeGoGraphicsSystemHelper::isRunningMeeGo() +{ + return (runningGraphicsSystemName() == QLatin1String("meego")); +} + +void QMeeGoGraphicsSystemHelper::switchToMeeGo() +{ + if (isRunningMeeGo()) + return; + + if (QApplicationPrivate::instance()->graphics_system_name != QLatin1String("runtime")) + qWarning("Can't switch to meego - switching only supported with 'runtime' graphics system."); + else { + QApplication *app = static_cast<QApplication *>(QCoreApplication::instance()); + app->setGraphicsSystem(QLatin1String("meego")); + } +} + +void QMeeGoGraphicsSystemHelper::switchToRaster() +{ + if (runningGraphicsSystemName() == QLatin1String("raster")) + return; + + if (QApplicationPrivate::instance()->graphics_system_name != QLatin1String("runtime")) + qWarning("Can't switch to raster - switching only supported with 'runtime' graphics system."); + else { + QApplication *app = static_cast<QApplication *>(QCoreApplication::instance()); + app->setGraphicsSystem(QLatin1String("raster")); + } +} + +Qt::HANDLE QMeeGoGraphicsSystemHelper::imageToEGLSharedImage(const QImage &image) +{ + ENSURE_RUNNING_MEEGO; + return QMeeGoRuntime::imageToEGLSharedImage(image); +} + +QPixmap QMeeGoGraphicsSystemHelper::pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage) +{ + // 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); +} + +QPixmap QMeeGoGraphicsSystemHelper::pixmapWithGLTexture(int w, int h) +{ + ENSURE_RUNNING_MEEGO; + return QMeeGoRuntime::pixmapWithGLTexture(w, h); +} + +bool QMeeGoGraphicsSystemHelper::destroyEGLSharedImage(Qt::HANDLE handle) +{ + ENSURE_RUNNING_MEEGO; + return QMeeGoRuntime::destroyEGLSharedImage(handle); +} + +void QMeeGoGraphicsSystemHelper::updateEGLSharedImagePixmap(QPixmap *p) +{ + ENSURE_RUNNING_MEEGO; + return QMeeGoRuntime::updateEGLSharedImagePixmap(p); +} + +void QMeeGoGraphicsSystemHelper::setTranslucent(bool translucent) +{ + ENSURE_RUNNING_MEEGO; + QMeeGoRuntime::setTranslucent(translucent); +} diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h new file mode 100644 index 0000000..02f2fa2 --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h @@ -0,0 +1,175 @@ +/**************************************************************************** +** +** 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 QMEEGOGRAPHICSSYSTEMHELPER_H +#define QMEEGOGRAPHICSSYSTEMHELPER_H + +#include <QPixmap> +#include <QImage> +#include "qmeegolivepixmap.h" + +class QLibrary; + +//! The base class for accressing special meego graphics system features. +/*! + This class is a helper class with static-only methods for accessing various + meego graphics system functionalities. The way it works is that the helper + dynamically calls-in to the loaded graphicssystem plugin... therefore, you're + expected to make sure that you're indeed running with 'meego' before using any + of the specialized methods. + + In example: + + \code + QPixmap p; + if (QMeeGoGraphicsSystemHelper::isRunningMeeGo()) { + p = QMeeGoGraphicsSystemHelper::pixmapWithGLTexture(64, 64); + } else { + p = QPixmap(64, 64); + } + \endcode + + Calling any of the meego-specific features while not running meego might + give unpredictable results. The only functions safe to call at all times are: + + \code + QMeeGoGraphicsSystemHelper::isRunningMeeGo(); + QMeeGoGraphicsSystemHelper::runningGraphicsSystemName(); + QMeeGoGraphicsSystemHelper::switchToMeeGo(); + QMeeGoGraphicsSystemHelper::switchToRaster(); + \endcode +*/ + +class Q_DECL_EXPORT QMeeGoGraphicsSystemHelper +{ +public: + //! Returns true if running meego. + /*! + Returns true if the currently active (running) system is 'meego' with OpenGL. + This returns both true if the app was started with 'meego' or was started with + 'runtime' graphics system and the currently active system through the runtime + switching is 'meego'. + */ + static bool isRunningMeeGo(); + + //! Switches to meego graphics system. + /*! + 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'. + */ + static void switchToMeeGo(); + + //! Switches to raster graphics system + /*! + When running with the 'runtime' graphics system, sets the currently active + 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. + */ + static void switchToRaster(); + + //! Returns the name of the active graphics system + /*! + Returns the name of the currently active system. If running with 'runtime' graphics + system, returns the name of the active system inside the runtime graphics system + */ + static QString runningGraphicsSystemName(); + + //! Creates a new EGL shared image. + /*! + Creates a new EGL shared image from the given image. The EGL shared image wraps + a GL texture in the native format and can be easily accessed from other processes. + */ + static Qt::HANDLE imageToEGLSharedImage(const QImage &image); + + //! Creates a QPixmap from an EGL shared image + /*! + Creates a new QPixmap from the given EGL shared image handle. The QPixmap can be + used for painting like any other pixmap. The softImage should point to an alternative, + software version of the graphical resource -- ie. obtained from theme daemon. The + softImage can be allocated on a QSharedMemory slice for easy sharing across processes + too. When the application is migrated ToRaster, this softImage will replace the + contents of the sharedImage. + + It's ok to call this function too when not running 'meego' graphics system. In this + case it'll create a QPixmap backed with a raster data (from softImage)... but when + the system is switched back to 'meego', the QPixmap will be migrated to a EGL-shared image + backed storage (handle). + */ + static QPixmap pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage); + + //! 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 + this destroys the image for all processes using it. + */ + static bool destroyEGLSharedImage(Qt::HANDLE handle); + + //! Updates the QPixmap backed with an EGLShared image. + /*! + This function re-reads the softImage that was specified when creating the pixmap with + ::pixmapFromEGLSharedImage and updates the EGL Shared image contents. It can be used + to share cross-proccess mutable EGLShared images. + */ + static void updateEGLSharedImagePixmap(QPixmap *p); + + //! Create a new QPixmap with a GL texture. + /*! + Creates a new QPixmap which is backed by an OpenGL local texture. Drawing to this + QPixmap will be accelerated by hardware -- unlike the normal (new QPixmap()) pixmaps, + which are backed by a software engine and only migrated to GPU when used. Migrating those + GL-backed pixmaps when going ToRaster is expsensive (they need to be downloaded from + GPU to CPU) so use wisely. + */ + static QPixmap pixmapWithGLTexture(int w, int h); + + //! Sets translucency (alpha) on the base window surface. + /*! + This function needs to be called *before* any widget/content is created. + When called with true, the base window surface will be translucent and initialized + with QGLFormat.alpha == true. + */ + static void setTranslucent(bool translucent); +}; + +#endif diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro new file mode 100644 index 0000000..1e6e233 --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro @@ -0,0 +1,10 @@ +TEMPLATE = lib +TARGET = QtMeeGoGraphicsSystemHelper + +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 diff --git a/tools/qmeegographicssystemhelper/qmeegoliveimage.cpp b/tools/qmeegographicssystemhelper/qmeegoliveimage.cpp new file mode 100644 index 0000000..83a1e28 --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegoliveimage.cpp @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** 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 new file mode 100644 index 0000000..1e21e7b --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegoliveimage.h @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** 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 new file mode 100644 index 0000000..085fed4 --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegoliveimage_p.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** 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 new file mode 100644 index 0000000..2a1c04b --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp @@ -0,0 +1,163 @@ +/**************************************************************************** +** +** 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 "qmeegolivepixmap.h" +#include <private/qimage_p.h> +#include <private/qpixmap_raster_p.h> +#include "qmeegolivepixmap_p.h" +#include "qmeegoliveimage_p.h" +#include <QSharedMemory> + +/* QMeeGoLivePixmapPrivate */ + +QMeeGoLivePixmapPrivate::QMeeGoLivePixmapPrivate() : shm(0), shmSerial(0), owns(true), parentImage(0) +{ +} + +void QMeeGoLivePixmapPrivate::copyBackFrom(const void *raw) +{ + 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() +{ + Q_Q(QMeeGoLivePixmap); + + if (parentImage) + parentImage->d_ptr->detachPixmap(q); + + if (shm) + shm->detach(); + + if (owns) + delete shm; +} + +/* QMeeGoLivePixmap */ + +QMeeGoLivePixmap::QMeeGoLivePixmap(QPixmapData *p) : QPixmap(p), d_ptr(new QMeeGoLivePixmapPrivate()) +{ + Q_D(QMeeGoLivePixmap); + d->q_ptr = this; +} + +QMeeGoLivePixmap* QMeeGoLivePixmap::fromLiveImage(QMeeGoLiveImage *liveImage) +{ + 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); + + return livePixmap; +} + +QMeeGoLivePixmap* QMeeGoLivePixmap::fromHandle(Qt::HANDLE 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; +} + +QMeeGoLivePixmap::~QMeeGoLivePixmap() +{ +} + +Qt::HANDLE QMeeGoLivePixmap::handle() +{ + Q_D(QMeeGoLivePixmap); + return d->shmSerial; +} diff --git a/tools/qmeegographicssystemhelper/qmeegolivepixmap.h b/tools/qmeegographicssystemhelper/qmeegolivepixmap.h new file mode 100644 index 0000000..2fa9db2 --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** 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 QMEEGOLIVEPIXMAP_H +#define QMEEGOLIVEPIXMAP_H + +#include <QPixmap> +#include "qmeegoliveimage.h" + +class QMeeGoLivePixmapPrivate; +class QSharedMemory; +class QImage; + +//! A pixmap representing streamed content. +/*! +*/ + +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. + */ + static QMeeGoLivePixmap* fromLiveImage(QMeeGoLiveImage *liveImage); + + //! Creates a new QMeeGoLivePixmap from the specified handle. + /*! + The handle can be used to share QMeeGoLivePixmap cross-process. + */ + static QMeeGoLivePixmap* fromHandle(Qt::HANDLE handle); + + //! Returns the handle for this QMeeGoLivePixmap. + /*! + The handle can be used to share QMeeGoLivePixmap cross-process. + */ + Qt::HANDLE handle(); + + //! 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); + 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 new file mode 100644 index 0000000..c2591dc --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** 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 "qmeegolivepixmap.h" + +#ifndef QMEEGOLIVEPIXMAP_P_H +#define QMEEGOLIVEPIXMAP_P_H + +class QMeeGoLivePixmapPrivate +{ +public: + Q_DECLARE_PUBLIC(QMeeGoLivePixmap); + QMeeGoLivePixmapPrivate(); + void copyBackFrom(const void *raw); + virtual ~QMeeGoLivePixmapPrivate(); + + QSharedMemory *shm; + int shmSerial; + bool owns; + QMeeGoLiveImage *parentImage; + + QMeeGoLivePixmap *q_ptr; + + friend class QMeeGoLiveImage; + friend class QMeeGoLiveImagePrivate; +}; + +#endif diff --git a/tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp new file mode 100644 index 0000000..f9f14ae --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** 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 <QDebug> +#include <QEvent> +#include <QMouseEvent> +#include <QCoreApplication> +#include "qmeegooverlaywidget.h" +#include "qmeegographicssystemhelper.h" +#include "qmeegoruntime.h" + +QMeeGoOverlayWidget::QMeeGoOverlayWidget(int surfaceWidth, int surfaceHeight, QWidget *parent) : QWidget(parent, 0), + sw(surfaceWidth), + sh(surfaceHeight) +{ + if (! QMeeGoGraphicsSystemHelper::isRunningMeeGo()) + qFatal("QMeeGoOverlayWidget can only be used when running with 'meego' graphics system!"); + + QMeeGoRuntime::setSurfaceFixedSize(surfaceWidth, surfaceHeight); + + scaleW = sw / 864.0; + scaleH = sh / 480.0; + installEventFilter(this); +} + +QPoint QMeeGoOverlayWidget::convertPoint(const QPoint &p) +{ + int x = p.x() * scaleW; + int y = p.y() * scaleH; + return QPoint(x, y); +} + +void QMeeGoOverlayWidget::showEvent(QShowEvent *) +{ + QMeeGoRuntime::setSurfaceScaling(0, 0, width(), height()); +} + +bool QMeeGoOverlayWidget::eventFilter(QObject *, QEvent *event) +{ + if (event->spontaneous() == false) + return false; + + switch(event->type()) { + case QEvent::MouseButtonPress: + case QEvent::MouseButtonRelease: + { + QMouseEvent *e = static_cast <QMouseEvent *>(event); + QMouseEvent newEvent = QMouseEvent(e->type(), + convertPoint(e->pos()), + convertPoint(e->globalPos()), + e->button(), + e->buttons(), + e->modifiers()); + QCoreApplication::sendEvent(this, &newEvent); + return true; + } + + default: + return false; + } +} diff --git a/tools/qmeegographicssystemhelper/qmeegooverlaywidget.h b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.h new file mode 100644 index 0000000..c2c08b4 --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** 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 QMEEGOOVERLAYWIDGET_H +#define QMEEGOOVERLAYWIDGET_H + +#include <QWidget> + +//! A widget automatically scaling it's content. +/*! +*/ + +class QMeeGoOverlayWidget : public QWidget +{ +public: + //! Constructs a new scaling widget. + /*! + The real surface used for this widget will have the specified + width and height. + */ + QMeeGoOverlayWidget(int surfaceWidth, int surfaceHeight, QWidget *parent = 0); + + + //! Event filtering function. + /*! + Converts coordinates for mouse/touch event. Do not + call manually. + */ + bool eventFilter(QObject *obj, QEvent *event); + + //! Standard override. + /*! + The surface scaling on the target paint device is being + set when the widget is displayed for the first time. + */ + virtual void showEvent(QShowEvent *event); + +private: + //! Converts coordinates between real & virtual area of the widget. + QPoint convertPoint(const QPoint &p); + + int sw; /// Surface real width. + int sh; /// Surface real height. + float scaleW; /// Width scaling factor. + float scaleH; /// Height scaling factor. +}; + +#endif diff --git a/tools/qmeegographicssystemhelper/qmeegoruntime.cpp b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp new file mode 100644 index 0000000..70b5dc1 --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp @@ -0,0 +1,158 @@ +/**************************************************************************** +** +** 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 "qmeegoruntime.h" + +#include <private/qlibrary_p.h> +#include <private/qfactoryloader_p.h> +#include <private/qgraphicssystemplugin_p.h> + +#define ENSURE_INITIALIZED {if (!initialized) initialize();} + +bool QMeeGoRuntime::initialized = false; + +typedef int (*QMeeGoImageToEglSharedImageFunc) (const QImage&); +typedef QPixmapData* (*QMeeGoPixmapDataFromEglSharedImageFunc) (Qt::HANDLE handle, const QImage&); +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); + +static QMeeGoImageToEglSharedImageFunc qt_meego_image_to_egl_shared_image = NULL; +static QMeeGoPixmapDataFromEglSharedImageFunc qt_meego_pixmapdata_from_egl_shared_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; + +void QMeeGoRuntime::initialize() +{ + QFactoryLoader loader(QGraphicsSystemFactoryInterface_iid, QLatin1String("/graphicssystems"), Qt::CaseInsensitive); + + QLibraryPrivate *libraryPrivate = loader.library(QLatin1String("meego")); + Q_ASSERT(libraryPrivate); + + QLibrary library(libraryPrivate->fileName, libraryPrivate->fullVersion); + + bool success = library.load(); + + 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_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) + { + qDebug("Successfully resolved MeeGo graphics system: %s %s\n", qPrintable(libraryPrivate->fileName), qPrintable(libraryPrivate->fullVersion)); + } + } else { + Q_ASSERT(false); + } + + initialized = true; +} + +Qt::HANDLE QMeeGoRuntime::imageToEGLSharedImage(const QImage &image) +{ + ENSURE_INITIALIZED; + Q_ASSERT(qt_meego_image_to_egl_shared_image); + return qt_meego_image_to_egl_shared_image(image); +} + +QPixmap QMeeGoRuntime::pixmapFromEGLSharedImage(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)); +} + +QPixmap QMeeGoRuntime::pixmapWithGLTexture(int w, int h) +{ + ENSURE_INITIALIZED; + Q_ASSERT(qt_meego_pixmapdata_with_gl_texture); + return QPixmap(qt_meego_pixmapdata_with_gl_texture(w, h)); +} + +bool QMeeGoRuntime::destroyEGLSharedImage(Qt::HANDLE handle) +{ + ENSURE_INITIALIZED; + Q_ASSERT(qt_meego_destroy_egl_shared_image); + return qt_meego_destroy_egl_shared_image(handle); +} + +void QMeeGoRuntime::updateEGLSharedImagePixmap(QPixmap *p) +{ + ENSURE_INITIALIZED; + Q_ASSERT(qt_meego_update_egl_shared_image_pixmap); + return qt_meego_update_egl_shared_image_pixmap(p); +} + +void QMeeGoRuntime::setSurfaceFixedSize(int w, int h) +{ + ENSURE_INITIALIZED; + Q_ASSERT(qt_meego_set_surface_fixed_size); + qt_meego_set_surface_fixed_size(w, h); +} + +void QMeeGoRuntime::setSurfaceScaling(int x, int y, int w, int h) +{ + ENSURE_INITIALIZED; + Q_ASSERT(qt_meego_set_surface_scaling); + qt_meego_set_surface_scaling(x, y, w, h); +} + +void QMeeGoRuntime::setTranslucent(bool translucent) +{ + ENSURE_INITIALIZED; + Q_ASSERT(qt_meego_set_translucent); + qt_meego_set_translucent(translucent); +} diff --git a/tools/qmeegographicssystemhelper/qmeegoruntime.h b/tools/qmeegographicssystemhelper/qmeegoruntime.h new file mode 100644 index 0000000..82fdb52 --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegoruntime.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** 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 <QPixmap> +#include <QImage> + +class QMeeGoRuntime +{ +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 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); + +private: + static bool initialized; +}; |