From ca1a8a7f4ad1fb249f47085e6ad0cf133122c0f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 6 Sep 2010 13:19:30 +0200 Subject: Renamed meego graphics system helper files. --- .../meegographicssystemhelper.pro | 19 --- .../mgraphicssystemhelper.cpp | 106 --------------- .../mgraphicssystemhelper.h | 148 --------------------- tools/qmeegographicssystemhelper/mliveimage.cpp | 88 ------------ tools/qmeegographicssystemhelper/mliveimage.h | 79 ----------- tools/qmeegographicssystemhelper/mliveimage_p.h | 36 ----- tools/qmeegographicssystemhelper/mlivepixmap.cpp | 136 ------------------- tools/qmeegographicssystemhelper/mlivepixmap.h | 71 ---------- tools/qmeegographicssystemhelper/mlivepixmap_p.h | 39 ------ .../qmeegographicssystemhelper/moverlaywidget.cpp | 72 ---------- tools/qmeegographicssystemhelper/moverlaywidget.h | 59 -------- tools/qmeegographicssystemhelper/mruntime.cpp | 112 ---------------- tools/qmeegographicssystemhelper/mruntime.h | 36 ----- .../qmeegographicssystemhelper.cpp | 106 +++++++++++++++ .../qmeegographicssystemhelper.h | 148 +++++++++++++++++++++ .../qmeegographicssystemhelper.pro | 19 +++ .../qmeegographicssystemhelper/qmeegoliveimage.cpp | 88 ++++++++++++ tools/qmeegographicssystemhelper/qmeegoliveimage.h | 79 +++++++++++ .../qmeegographicssystemhelper/qmeegoliveimage_p.h | 36 +++++ .../qmeegolivepixmap.cpp | 136 +++++++++++++++++++ .../qmeegographicssystemhelper/qmeegolivepixmap.h | 71 ++++++++++ .../qmeegolivepixmap_p.h | 39 ++++++ .../qmeegooverlaywidget.cpp | 72 ++++++++++ .../qmeegooverlaywidget.h | 59 ++++++++ tools/qmeegographicssystemhelper/qmeegoruntime.cpp | 112 ++++++++++++++++ tools/qmeegographicssystemhelper/qmeegoruntime.h | 36 +++++ 26 files changed, 1001 insertions(+), 1001 deletions(-) delete mode 100644 tools/qmeegographicssystemhelper/meegographicssystemhelper.pro delete mode 100644 tools/qmeegographicssystemhelper/mgraphicssystemhelper.cpp delete mode 100644 tools/qmeegographicssystemhelper/mgraphicssystemhelper.h delete mode 100644 tools/qmeegographicssystemhelper/mliveimage.cpp delete mode 100644 tools/qmeegographicssystemhelper/mliveimage.h delete mode 100644 tools/qmeegographicssystemhelper/mliveimage_p.h delete mode 100644 tools/qmeegographicssystemhelper/mlivepixmap.cpp delete mode 100644 tools/qmeegographicssystemhelper/mlivepixmap.h delete mode 100644 tools/qmeegographicssystemhelper/mlivepixmap_p.h delete mode 100644 tools/qmeegographicssystemhelper/moverlaywidget.cpp delete mode 100644 tools/qmeegographicssystemhelper/moverlaywidget.h delete mode 100644 tools/qmeegographicssystemhelper/mruntime.cpp delete mode 100644 tools/qmeegographicssystemhelper/mruntime.h create mode 100644 tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp create mode 100644 tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h create mode 100644 tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro create mode 100644 tools/qmeegographicssystemhelper/qmeegoliveimage.cpp create mode 100644 tools/qmeegographicssystemhelper/qmeegoliveimage.h create mode 100644 tools/qmeegographicssystemhelper/qmeegoliveimage_p.h create mode 100644 tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp create mode 100644 tools/qmeegographicssystemhelper/qmeegolivepixmap.h create mode 100644 tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h create mode 100644 tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp create mode 100644 tools/qmeegographicssystemhelper/qmeegooverlaywidget.h create mode 100644 tools/qmeegographicssystemhelper/qmeegoruntime.cpp create mode 100644 tools/qmeegographicssystemhelper/qmeegoruntime.h diff --git a/tools/qmeegographicssystemhelper/meegographicssystemhelper.pro b/tools/qmeegographicssystemhelper/meegographicssystemhelper.pro deleted file mode 100644 index cab096e..0000000 --- a/tools/qmeegographicssystemhelper/meegographicssystemhelper.pro +++ /dev/null @@ -1,19 +0,0 @@ -TEMPLATE = lib -TARGET = meegographicssystemhelper -QT += gui -INCLUDEPATH += '../' -LIBS += -L../plugin -CONFIG += debug -VERSION = 0.1.9 -HEADERS = mgraphicssystemhelper.h moverlaywidget.h mlivepixmap.h mliveimage.h mruntime.h mliveimage_p.h mlivepixmap_p.h -SOURCES = mgraphicssystemhelper.cpp mgraphicssystemhelper.h moverlaywidget.h moverlaywidget.cpp mruntime.cpp mruntime.h mlivepixmap.cpp mlivepixmap.h mliveimage.h mliveimage.cpp mliveimage_p.h mlivepixmap_p.h - -target.path = /usr/lib/ - -headers.files = mgraphicssystemhelper.h moverlaywidget.h mlivepixmap.h mliveimage.h -headers.path = /usr/include/meegographicssystemhelper/ - -pkg.files = meegographicssystemhelper.pc -pkg.path = /usr/lib/pkgconfig/ - -INSTALLS += target headers pkg diff --git a/tools/qmeegographicssystemhelper/mgraphicssystemhelper.cpp b/tools/qmeegographicssystemhelper/mgraphicssystemhelper.cpp deleted file mode 100644 index ff921fd..0000000 --- a/tools/qmeegographicssystemhelper/mgraphicssystemhelper.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#define ENSURE_RUNNING_MEEGO {if (! MGraphicsSystemHelper::isRunningMeeGo()) { qFatal("Using meego functionality but not running meego graphics system!"); }} - -#include "mgraphicssystemhelper.h" -#include "../private/qapplication_p.h" -#include "../private/qgraphicssystem_runtime_p.h" -#include "../private/qpixmap_raster_p.h" -#include "mruntime.h" - -QString MGraphicsSystemHelper::runningGraphicsSystemName() -{ - if (! QApplicationPrivate::instance()) { - qWarning("Querying graphics system but application not running yet!"); - return ""; - } - - QString name = QApplicationPrivate::instance()->graphics_system_name; - if (name == "runtime") { - QRuntimeGraphicsSystem *rsystem = (QRuntimeGraphicsSystem *) QApplicationPrivate::instance()->graphics_system; - name = rsystem->graphicsSystemName(); - } - - return name; -} - -bool MGraphicsSystemHelper::isRunningMeeGo() -{ - return (runningGraphicsSystemName() == "meego"); -} - -void MGraphicsSystemHelper::switchToMeeGo() -{ - if (runningGraphicsSystemName() == "meego") - return; - - if (QApplicationPrivate::instance()->graphics_system_name != "runtime") - qWarning("Can't switch to meego - switching only supported with 'runtime' graphics system."); - else { - QApplication *app = static_cast(QCoreApplication::instance()); - app->setGraphicsSystem("meego"); - } -} - -void MGraphicsSystemHelper::switchToRaster() -{ - if (runningGraphicsSystemName() == "raster") - return; - - if (QApplicationPrivate::instance()->graphics_system_name != "runtime") - qWarning("Can't switch to raster - switching only supported with 'runtime' graphics system."); - else { - QApplication *app = static_cast(QCoreApplication::instance()); - app->setGraphicsSystem("raster"); - } -} - -Qt::HANDLE MGraphicsSystemHelper::imageToEGLSharedImage(const QImage &image) -{ - ENSURE_RUNNING_MEEGO; - return MRuntime::imageToEGLSharedImage(image); -} - -QPixmap MGraphicsSystemHelper::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 MRuntime::pixmapFromEGLSharedImage(handle, softImage); -} - -QPixmap MGraphicsSystemHelper::pixmapWithGLTexture(int w, int h) -{ - ENSURE_RUNNING_MEEGO; - return MRuntime::pixmapWithGLTexture(w, h); -} - -bool MGraphicsSystemHelper::destroyEGLSharedImage(Qt::HANDLE handle) -{ - ENSURE_RUNNING_MEEGO; - return MRuntime::destroyEGLSharedImage(handle); -} - -void MGraphicsSystemHelper::updateEGLSharedImagePixmap(QPixmap *p) -{ - ENSURE_RUNNING_MEEGO; - return MRuntime::updateEGLSharedImagePixmap(p); -} - -void MGraphicsSystemHelper::setTranslucent(bool translucent) -{ - ENSURE_RUNNING_MEEGO; - MRuntime::setTranslucent(translucent); -} diff --git a/tools/qmeegographicssystemhelper/mgraphicssystemhelper.h b/tools/qmeegographicssystemhelper/mgraphicssystemhelper.h deleted file mode 100644 index 1966648..0000000 --- a/tools/qmeegographicssystemhelper/mgraphicssystemhelper.h +++ /dev/null @@ -1,148 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#ifndef MGRAPHICSSYSTEMHELPER_H -#define MGRAPHICSSYSTEMHELPER_H - -#include -#include -#include "mlivepixmap.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 (MGraphicsSystemHelper::isRunningMeeGo()) { - p = MGraphicsSystemHelper::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 - MGraphicsSystemHelper::isRunningMeeGo(); - MGraphicsSystemHelper::runningGraphicsSystemName(); - MGraphicsSystemHelper::switchToMeeGo(); - MGraphicsSystemHelper::switchToRaster(); - \endcode -*/ - -class MGraphicsSystemHelper -{ -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/mliveimage.cpp b/tools/qmeegographicssystemhelper/mliveimage.cpp deleted file mode 100644 index 37ead21..0000000 --- a/tools/qmeegographicssystemhelper/mliveimage.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#include "mliveimage.h" -#include "mliveimage_p.h" -#include "mlivepixmap.h" -#include "mlivepixmap_p.h" - -/* MLiveImagePrivate */ - -MLiveImagePrivate::MLiveImagePrivate() -{ -} - -MLiveImagePrivate::~MLiveImagePrivate() -{ - if (attachedPixmaps.length() > 0) - qWarning("Destroying MLiveImage but it still has MLivePixmaps attached!"); -} - -void MLiveImagePrivate::attachPixmap(MLivePixmap* pixmap) -{ - attachedPixmaps << pixmap; -} - -void MLiveImagePrivate::detachPixmap(MLivePixmap* pixmap) -{ - attachedPixmaps.removeAll(pixmap); -} - -/* MLiveImage */ - -MLiveImage* MLiveImage::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; - } - - MLiveImage *liveImage = new MLiveImage(w, h); - return liveImage; -} - -MLiveImage::MLiveImage(int w, int h) : QImage(w, h, QImage::Format_ARGB32_Premultiplied), d_ptr(new MLiveImagePrivate()) -{ - Q_D(MLiveImage); - d->q_ptr = this; -} - -MLiveImage::~MLiveImage() -{ -} - -void MLiveImage::lock(int buffer) -{ - if (buffer != 0) - qWarning("Only locking 0 buffer is supported at the moment!"); -} - -void MLiveImage::release(int buffer) -{ - Q_D(MLiveImage); - - 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 MLivePixmap's - foreach (MLivePixmap* livePixmap, d->attachedPixmaps) - livePixmap->d_ptr->copyBackFrom((const void *) bits()); -} \ No newline at end of file diff --git a/tools/qmeegographicssystemhelper/mliveimage.h b/tools/qmeegographicssystemhelper/mliveimage.h deleted file mode 100644 index f945b34..0000000 --- a/tools/qmeegographicssystemhelper/mliveimage.h +++ /dev/null @@ -1,79 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#ifndef MLIVEIMAGE_H -#define MLIVEIMAGE_H - -#include - -class MLivePixmap; -class MLiveImagePrivate; - -//! A streamable QImage subclass. -/*! -*/ - -class MLiveImage : public QImage -{ -public: - //! Format specifier. - /*! - Used to specify the format of the underlying image data for MLiveImage. - */ - 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 MLivePixmaps - built on top of it. You should first destroy all the MLivePixmaps. - */ - virtual ~MLiveImage(); - - //! 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 MLiveImage* liveImageWithSize(int w, int h, Format format, int buffers = 1); - -private: - MLiveImage(int w, int h); //! Private bits. - Q_DISABLE_COPY(MLiveImage) - Q_DECLARE_PRIVATE(MLiveImage) - -protected: - QScopedPointer d_ptr; - - friend class MLivePixmap; - friend class MLivePixmapPrivate; -}; - -#endif diff --git a/tools/qmeegographicssystemhelper/mliveimage_p.h b/tools/qmeegographicssystemhelper/mliveimage_p.h deleted file mode 100644 index 0789b93..0000000 --- a/tools/qmeegographicssystemhelper/mliveimage_p.h +++ /dev/null @@ -1,36 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#include "mliveimage.h" - -#ifndef MLIVEIMAGE_P_H -#define MLIVEIMAGE_P_H - -class MLiveImagePrivate -{ -public: - Q_DECLARE_PUBLIC(MLiveImage); - MLiveImagePrivate(); - virtual ~MLiveImagePrivate(); - void attachPixmap(MLivePixmap* pixmap); - void detachPixmap(MLivePixmap* pixmap); - - QList attachedPixmaps; - MLiveImage *q_ptr; - - friend class MLivePixmap; - friend class MLivePixmapPrivate; -}; - -#endif \ No newline at end of file diff --git a/tools/qmeegographicssystemhelper/mlivepixmap.cpp b/tools/qmeegographicssystemhelper/mlivepixmap.cpp deleted file mode 100644 index 2f7abd7..0000000 --- a/tools/qmeegographicssystemhelper/mlivepixmap.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#include "mlivepixmap.h" -#include "../private/qimage_p.h" -#include "../private/qpixmap_raster_p.h" -#include "mlivepixmap_p.h" -#include "mliveimage_p.h" -#include - -/* MLivePixmapPrivate */ - -MLivePixmapPrivate::MLivePixmapPrivate() : shm(0), shmSerial(0), owns(true), parentImage(0) -{ -} - -void MLivePixmapPrivate::copyBackFrom(const void *raw) -{ - Q_Q(MLivePixmap); - - q->detach(); - shm->lock(); - uchar *dest = ((uchar *) shm->data()) + (2 * sizeof(int)); - memcpy(dest, raw, q->width() * q->height() * 4); - shm->unlock(); -} - -MLivePixmapPrivate::~MLivePixmapPrivate() -{ - Q_Q(MLivePixmap); - - if (parentImage) - parentImage->d_ptr->detachPixmap(q); - - if (shm) - shm->detach(); - - if (owns) - delete shm; -} - -/* MLivePixmap */ - -MLivePixmap::MLivePixmap(QPixmapData *p) : QPixmap(p), d_ptr(new MLivePixmapPrivate()) -{ - Q_D(MLivePixmap); - d->q_ptr = this; -} - -MLivePixmap* MLivePixmap::fromLiveImage(MLiveImage *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("MLivePixmap%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); - - MLivePixmap *livePixmap = new MLivePixmap(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; -} - -MLivePixmap* MLivePixmap::fromHandle(Qt::HANDLE handle) -{ - QSharedMemory *shm = NULL; - int *header; - int width; - int height; - uchar* imgData; - - shm = new QSharedMemory(QString("MLivePixmap%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); - - MLivePixmap *livePixmap = new MLivePixmap(pmd); - livePixmap->d_ptr->shm = shm; - livePixmap->d_ptr->owns = false; - livePixmap->d_ptr->shmSerial = handle; - - return livePixmap; -} - -MLivePixmap::~MLivePixmap() -{ -} - -Qt::HANDLE MLivePixmap::handle() -{ - Q_D(MLivePixmap); - return d->shmSerial; -} diff --git a/tools/qmeegographicssystemhelper/mlivepixmap.h b/tools/qmeegographicssystemhelper/mlivepixmap.h deleted file mode 100644 index dee4d2a..0000000 --- a/tools/qmeegographicssystemhelper/mlivepixmap.h +++ /dev/null @@ -1,71 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#ifndef MLIVEPIXMAP_H -#define MLIVEPIXMAP_H - -#include -#include "mliveimage.h" - -class MLivePixmapPrivate; -class QSharedMemory; -class QImage; - -//! A pixmap representing streamed content. -/*! -*/ - -class MLivePixmap : public QPixmap -{ -public: - //! Creates new pixmap from the given MLiveImage. - /*! - The created MLivePixmap will be attached to the given MLiveImage. - Updates to the MLiveImage will be represented on this newly created - MLivePixmap. - */ - static MLivePixmap* fromLiveImage(MLiveImage *liveImage); - - //! Creates a new MLivePixmap from the specified handle. - /*! - The handle can be used to share MLivePixmap cross-process. - */ - static MLivePixmap* fromHandle(Qt::HANDLE handle); - - //! Returns the handle for this MLivePixmap. - /*! - The handle can be used to share MLivePixmap cross-process. - */ - Qt::HANDLE handle(); - - //! Destroys the MLivePixmap. - /*! - All MLivePixmaps attached to a given MLiveImage have to be destroyed - before the MLiveImage itself is destroyed. - */ - virtual ~MLivePixmap(); - -private: - MLivePixmap(QPixmapData *p); - Q_DISABLE_COPY(MLivePixmap) - Q_DECLARE_PRIVATE(MLivePixmap) - -protected: - QScopedPointer d_ptr; //! Private bits. - - friend class MLiveImage; - friend class MLiveImagePrivate; -}; - -#endif diff --git a/tools/qmeegographicssystemhelper/mlivepixmap_p.h b/tools/qmeegographicssystemhelper/mlivepixmap_p.h deleted file mode 100644 index 4ff64de..0000000 --- a/tools/qmeegographicssystemhelper/mlivepixmap_p.h +++ /dev/null @@ -1,39 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#include "mlivepixmap.h" - -#ifndef MLIVEPIXMAP_P_H -#define MLIVEPIXMAP_P_H - -class MLivePixmapPrivate -{ -public: - Q_DECLARE_PUBLIC(MLivePixmap); - MLivePixmapPrivate(); - void copyBackFrom(const void *raw); - virtual ~MLivePixmapPrivate(); - - QSharedMemory *shm; - int shmSerial; - bool owns; - MLiveImage *parentImage; - - MLivePixmap *q_ptr; - - friend class MLiveImage; - friend class MLiveImagePrivate; -}; - -#endif \ No newline at end of file diff --git a/tools/qmeegographicssystemhelper/moverlaywidget.cpp b/tools/qmeegographicssystemhelper/moverlaywidget.cpp deleted file mode 100644 index 8f64b3f..0000000 --- a/tools/qmeegographicssystemhelper/moverlaywidget.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#include -#include -#include -#include -#include "moverlaywidget.h" -#include "mgraphicssystemhelper.h" -#include "mruntime.h" - -MOverlayWidget::MOverlayWidget(int surfaceWidth, int surfaceHeight, QWidget *parent) : QWidget(parent, 0), - sw(surfaceWidth), - sh(surfaceHeight) -{ - if (! MGraphicsSystemHelper::isRunningMeeGo()) - qFatal("MOverlayWidget can only be used when running with 'meego' graphics system!"); - - MRuntime::setSurfaceFixedSize(surfaceWidth, surfaceHeight); - - scaleW = sw / 864.0; - scaleH = sh / 480.0; - installEventFilter(this); -} - -QPoint MOverlayWidget::convertPoint(const QPoint &p) -{ - int x = p.x() * scaleW; - int y = p.y() * scaleH; - return QPoint(x, y); -} - -void MOverlayWidget::showEvent(QShowEvent *event) -{ - MRuntime::setSurfaceScaling(0, 0, width(), height()); -} - -bool MOverlayWidget::eventFilter(QObject *obj, QEvent *event) -{ - if (event->spontaneous() == false) - return false; - - switch(event->type()) { - case QEvent::MouseButtonPress: - case QEvent::MouseButtonRelease: - { - QMouseEvent *e = static_cast (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/moverlaywidget.h b/tools/qmeegographicssystemhelper/moverlaywidget.h deleted file mode 100644 index f45a673..0000000 --- a/tools/qmeegographicssystemhelper/moverlaywidget.h +++ /dev/null @@ -1,59 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#ifndef MOVERLAYWIDGET_H -#define MOVERLAYWIDGET_H - -#include - -//! A widget automatically scaling it's content. -/*! -*/ - -class MOverlayWidget : public QWidget -{ -public: - //! Constructs a new scaling widget. - /*! - The real surface used for this widget will have the specified - width and height. - */ - MOverlayWidget(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/mruntime.cpp b/tools/qmeegographicssystemhelper/mruntime.cpp deleted file mode 100644 index b1b0874..0000000 --- a/tools/qmeegographicssystemhelper/mruntime.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#include "mruntime.h" - -#define ENSURE_INITIALIZED {if (!initialized) initialize();} - -QLibrary* MRuntime::library = NULL; -bool MRuntime::initialized = false; - -typedef int (*MImageToEglSharedImageFunc) (const QImage&); -typedef QPixmapData* (*MPixmapDataFromEglSharedImageFunc) (Qt::HANDLE handle, const QImage&); -typedef QPixmapData* (*MPixmapDataWithGLTextureFunc) (int w, int h); -typedef bool (*MDestroyEGLSharedImageFunc) (Qt::HANDLE handle); -typedef void (*MUpdateEglSharedImagePixmapFunc) (QPixmap*); -typedef void (*MSetSurfaceFixedSizeFunc) (int w, int h); -typedef void (*MSetSurfaceScalingFunc) (int x, int y, int w, int h); -typedef void (*MSetTranslucentFunc) (bool translucent); - -static MImageToEglSharedImageFunc m_image_to_egl_shared_image = NULL; -static MPixmapDataFromEglSharedImageFunc m_pixmapdata_from_egl_shared_image = NULL; -static MPixmapDataWithGLTextureFunc m_pixmapdata_with_gl_texture = NULL; -static MDestroyEGLSharedImageFunc m_destroy_egl_shared_image = NULL; -static MUpdateEglSharedImagePixmapFunc m_update_egl_shared_image_pixmap = NULL; -static MSetSurfaceFixedSizeFunc m_set_surface_fixed_size = NULL; -static MSetSurfaceScalingFunc m_set_surface_scaling = NULL; -static MSetTranslucentFunc m_set_translucent = NULL; - -void MRuntime::initialize() -{ - library = new QLibrary("/usr/lib/qt4/plugins/graphicssystems/libmeegographicssystem.so"); - Q_ASSERT(library); - - m_image_to_egl_shared_image = (MImageToEglSharedImageFunc) library->resolve("m_image_to_egl_shared_image"); - m_pixmapdata_from_egl_shared_image = (MPixmapDataFromEglSharedImageFunc) library->resolve("m_pixmapdata_from_egl_shared_image"); - m_pixmapdata_with_gl_texture = (MPixmapDataWithGLTextureFunc) library->resolve("m_pixmapdata_with_gl_texture"); - m_destroy_egl_shared_image = (MDestroyEGLSharedImageFunc) library->resolve("m_destroy_egl_shared_image"); - m_update_egl_shared_image_pixmap = (MUpdateEglSharedImagePixmapFunc) library->resolve("m_update_egl_shared_image_pixmap"); - m_set_surface_fixed_size = (MSetSurfaceFixedSizeFunc) library->resolve("m_set_surface_fixed_size"); - m_set_surface_scaling = (MSetSurfaceScalingFunc) library->resolve("m_set_surface_scaling"); - m_set_translucent = (MSetTranslucentFunc) library->resolve("m_set_translucent"); - - - initialized = true; -} - -Qt::HANDLE MRuntime::imageToEGLSharedImage(const QImage &image) -{ - ENSURE_INITIALIZED; - Q_ASSERT(m_image_to_egl_shared_image); - return m_image_to_egl_shared_image(image); -} - -QPixmap MRuntime::pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage) -{ - ENSURE_INITIALIZED; - Q_ASSERT(m_pixmapdata_from_egl_shared_image); - return QPixmap(m_pixmapdata_from_egl_shared_image(handle, softImage)); -} - -QPixmap MRuntime::pixmapWithGLTexture(int w, int h) -{ - ENSURE_INITIALIZED; - Q_ASSERT(m_pixmapdata_with_gl_texture); - return QPixmap(m_pixmapdata_with_gl_texture(w, h)); -} - -bool MRuntime::destroyEGLSharedImage(Qt::HANDLE handle) -{ - ENSURE_INITIALIZED; - Q_ASSERT(m_destroy_egl_shared_image); - return m_destroy_egl_shared_image(handle); -} - -void MRuntime::updateEGLSharedImagePixmap(QPixmap *p) -{ - ENSURE_INITIALIZED; - Q_ASSERT(m_update_egl_shared_image_pixmap); - return m_update_egl_shared_image_pixmap(p); -} - -void MRuntime::setSurfaceFixedSize(int w, int h) -{ - ENSURE_INITIALIZED; - Q_ASSERT(m_set_surface_fixed_size); - m_set_surface_fixed_size(w, h); -} - -void MRuntime::setSurfaceScaling(int x, int y, int w, int h) -{ - ENSURE_INITIALIZED; - Q_ASSERT(m_set_surface_scaling); - m_set_surface_scaling(x, y, w, h); -} - -void MRuntime::setTranslucent(bool translucent) -{ - ENSURE_INITIALIZED; - Q_ASSERT(m_set_translucent); - m_set_translucent(translucent); -} diff --git a/tools/qmeegographicssystemhelper/mruntime.h b/tools/qmeegographicssystemhelper/mruntime.h deleted file mode 100644 index 34474cc..0000000 --- a/tools/qmeegographicssystemhelper/mruntime.h +++ /dev/null @@ -1,36 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation -** -** This library is free software; you can redistribute it and/or -** modify it 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. -** -****************************************************************************/ - -#include -#include -#include - -class MRuntime -{ -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; - static QLibrary *library; -}; \ No newline at end of file diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp new file mode 100644 index 0000000..ff921fd --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.cpp @@ -0,0 +1,106 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#define ENSURE_RUNNING_MEEGO {if (! MGraphicsSystemHelper::isRunningMeeGo()) { qFatal("Using meego functionality but not running meego graphics system!"); }} + +#include "mgraphicssystemhelper.h" +#include "../private/qapplication_p.h" +#include "../private/qgraphicssystem_runtime_p.h" +#include "../private/qpixmap_raster_p.h" +#include "mruntime.h" + +QString MGraphicsSystemHelper::runningGraphicsSystemName() +{ + if (! QApplicationPrivate::instance()) { + qWarning("Querying graphics system but application not running yet!"); + return ""; + } + + QString name = QApplicationPrivate::instance()->graphics_system_name; + if (name == "runtime") { + QRuntimeGraphicsSystem *rsystem = (QRuntimeGraphicsSystem *) QApplicationPrivate::instance()->graphics_system; + name = rsystem->graphicsSystemName(); + } + + return name; +} + +bool MGraphicsSystemHelper::isRunningMeeGo() +{ + return (runningGraphicsSystemName() == "meego"); +} + +void MGraphicsSystemHelper::switchToMeeGo() +{ + if (runningGraphicsSystemName() == "meego") + return; + + if (QApplicationPrivate::instance()->graphics_system_name != "runtime") + qWarning("Can't switch to meego - switching only supported with 'runtime' graphics system."); + else { + QApplication *app = static_cast(QCoreApplication::instance()); + app->setGraphicsSystem("meego"); + } +} + +void MGraphicsSystemHelper::switchToRaster() +{ + if (runningGraphicsSystemName() == "raster") + return; + + if (QApplicationPrivate::instance()->graphics_system_name != "runtime") + qWarning("Can't switch to raster - switching only supported with 'runtime' graphics system."); + else { + QApplication *app = static_cast(QCoreApplication::instance()); + app->setGraphicsSystem("raster"); + } +} + +Qt::HANDLE MGraphicsSystemHelper::imageToEGLSharedImage(const QImage &image) +{ + ENSURE_RUNNING_MEEGO; + return MRuntime::imageToEGLSharedImage(image); +} + +QPixmap MGraphicsSystemHelper::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 MRuntime::pixmapFromEGLSharedImage(handle, softImage); +} + +QPixmap MGraphicsSystemHelper::pixmapWithGLTexture(int w, int h) +{ + ENSURE_RUNNING_MEEGO; + return MRuntime::pixmapWithGLTexture(w, h); +} + +bool MGraphicsSystemHelper::destroyEGLSharedImage(Qt::HANDLE handle) +{ + ENSURE_RUNNING_MEEGO; + return MRuntime::destroyEGLSharedImage(handle); +} + +void MGraphicsSystemHelper::updateEGLSharedImagePixmap(QPixmap *p) +{ + ENSURE_RUNNING_MEEGO; + return MRuntime::updateEGLSharedImagePixmap(p); +} + +void MGraphicsSystemHelper::setTranslucent(bool translucent) +{ + ENSURE_RUNNING_MEEGO; + MRuntime::setTranslucent(translucent); +} diff --git a/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h new file mode 100644 index 0000000..1966648 --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.h @@ -0,0 +1,148 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#ifndef MGRAPHICSSYSTEMHELPER_H +#define MGRAPHICSSYSTEMHELPER_H + +#include +#include +#include "mlivepixmap.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 (MGraphicsSystemHelper::isRunningMeeGo()) { + p = MGraphicsSystemHelper::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 + MGraphicsSystemHelper::isRunningMeeGo(); + MGraphicsSystemHelper::runningGraphicsSystemName(); + MGraphicsSystemHelper::switchToMeeGo(); + MGraphicsSystemHelper::switchToRaster(); + \endcode +*/ + +class MGraphicsSystemHelper +{ +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..cab096e --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegographicssystemhelper.pro @@ -0,0 +1,19 @@ +TEMPLATE = lib +TARGET = meegographicssystemhelper +QT += gui +INCLUDEPATH += '../' +LIBS += -L../plugin +CONFIG += debug +VERSION = 0.1.9 +HEADERS = mgraphicssystemhelper.h moverlaywidget.h mlivepixmap.h mliveimage.h mruntime.h mliveimage_p.h mlivepixmap_p.h +SOURCES = mgraphicssystemhelper.cpp mgraphicssystemhelper.h moverlaywidget.h moverlaywidget.cpp mruntime.cpp mruntime.h mlivepixmap.cpp mlivepixmap.h mliveimage.h mliveimage.cpp mliveimage_p.h mlivepixmap_p.h + +target.path = /usr/lib/ + +headers.files = mgraphicssystemhelper.h moverlaywidget.h mlivepixmap.h mliveimage.h +headers.path = /usr/include/meegographicssystemhelper/ + +pkg.files = meegographicssystemhelper.pc +pkg.path = /usr/lib/pkgconfig/ + +INSTALLS += target headers pkg diff --git a/tools/qmeegographicssystemhelper/qmeegoliveimage.cpp b/tools/qmeegographicssystemhelper/qmeegoliveimage.cpp new file mode 100644 index 0000000..37ead21 --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegoliveimage.cpp @@ -0,0 +1,88 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include "mliveimage.h" +#include "mliveimage_p.h" +#include "mlivepixmap.h" +#include "mlivepixmap_p.h" + +/* MLiveImagePrivate */ + +MLiveImagePrivate::MLiveImagePrivate() +{ +} + +MLiveImagePrivate::~MLiveImagePrivate() +{ + if (attachedPixmaps.length() > 0) + qWarning("Destroying MLiveImage but it still has MLivePixmaps attached!"); +} + +void MLiveImagePrivate::attachPixmap(MLivePixmap* pixmap) +{ + attachedPixmaps << pixmap; +} + +void MLiveImagePrivate::detachPixmap(MLivePixmap* pixmap) +{ + attachedPixmaps.removeAll(pixmap); +} + +/* MLiveImage */ + +MLiveImage* MLiveImage::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; + } + + MLiveImage *liveImage = new MLiveImage(w, h); + return liveImage; +} + +MLiveImage::MLiveImage(int w, int h) : QImage(w, h, QImage::Format_ARGB32_Premultiplied), d_ptr(new MLiveImagePrivate()) +{ + Q_D(MLiveImage); + d->q_ptr = this; +} + +MLiveImage::~MLiveImage() +{ +} + +void MLiveImage::lock(int buffer) +{ + if (buffer != 0) + qWarning("Only locking 0 buffer is supported at the moment!"); +} + +void MLiveImage::release(int buffer) +{ + Q_D(MLiveImage); + + 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 MLivePixmap's + foreach (MLivePixmap* livePixmap, d->attachedPixmaps) + livePixmap->d_ptr->copyBackFrom((const void *) bits()); +} \ No newline at end of file diff --git a/tools/qmeegographicssystemhelper/qmeegoliveimage.h b/tools/qmeegographicssystemhelper/qmeegoliveimage.h new file mode 100644 index 0000000..f945b34 --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegoliveimage.h @@ -0,0 +1,79 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#ifndef MLIVEIMAGE_H +#define MLIVEIMAGE_H + +#include + +class MLivePixmap; +class MLiveImagePrivate; + +//! A streamable QImage subclass. +/*! +*/ + +class MLiveImage : public QImage +{ +public: + //! Format specifier. + /*! + Used to specify the format of the underlying image data for MLiveImage. + */ + 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 MLivePixmaps + built on top of it. You should first destroy all the MLivePixmaps. + */ + virtual ~MLiveImage(); + + //! 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 MLiveImage* liveImageWithSize(int w, int h, Format format, int buffers = 1); + +private: + MLiveImage(int w, int h); //! Private bits. + Q_DISABLE_COPY(MLiveImage) + Q_DECLARE_PRIVATE(MLiveImage) + +protected: + QScopedPointer d_ptr; + + friend class MLivePixmap; + friend class MLivePixmapPrivate; +}; + +#endif diff --git a/tools/qmeegographicssystemhelper/qmeegoliveimage_p.h b/tools/qmeegographicssystemhelper/qmeegoliveimage_p.h new file mode 100644 index 0000000..0789b93 --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegoliveimage_p.h @@ -0,0 +1,36 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include "mliveimage.h" + +#ifndef MLIVEIMAGE_P_H +#define MLIVEIMAGE_P_H + +class MLiveImagePrivate +{ +public: + Q_DECLARE_PUBLIC(MLiveImage); + MLiveImagePrivate(); + virtual ~MLiveImagePrivate(); + void attachPixmap(MLivePixmap* pixmap); + void detachPixmap(MLivePixmap* pixmap); + + QList attachedPixmaps; + MLiveImage *q_ptr; + + friend class MLivePixmap; + friend class MLivePixmapPrivate; +}; + +#endif \ No newline at end of file diff --git a/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp b/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp new file mode 100644 index 0000000..2f7abd7 --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap.cpp @@ -0,0 +1,136 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include "mlivepixmap.h" +#include "../private/qimage_p.h" +#include "../private/qpixmap_raster_p.h" +#include "mlivepixmap_p.h" +#include "mliveimage_p.h" +#include + +/* MLivePixmapPrivate */ + +MLivePixmapPrivate::MLivePixmapPrivate() : shm(0), shmSerial(0), owns(true), parentImage(0) +{ +} + +void MLivePixmapPrivate::copyBackFrom(const void *raw) +{ + Q_Q(MLivePixmap); + + q->detach(); + shm->lock(); + uchar *dest = ((uchar *) shm->data()) + (2 * sizeof(int)); + memcpy(dest, raw, q->width() * q->height() * 4); + shm->unlock(); +} + +MLivePixmapPrivate::~MLivePixmapPrivate() +{ + Q_Q(MLivePixmap); + + if (parentImage) + parentImage->d_ptr->detachPixmap(q); + + if (shm) + shm->detach(); + + if (owns) + delete shm; +} + +/* MLivePixmap */ + +MLivePixmap::MLivePixmap(QPixmapData *p) : QPixmap(p), d_ptr(new MLivePixmapPrivate()) +{ + Q_D(MLivePixmap); + d->q_ptr = this; +} + +MLivePixmap* MLivePixmap::fromLiveImage(MLiveImage *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("MLivePixmap%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); + + MLivePixmap *livePixmap = new MLivePixmap(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; +} + +MLivePixmap* MLivePixmap::fromHandle(Qt::HANDLE handle) +{ + QSharedMemory *shm = NULL; + int *header; + int width; + int height; + uchar* imgData; + + shm = new QSharedMemory(QString("MLivePixmap%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); + + MLivePixmap *livePixmap = new MLivePixmap(pmd); + livePixmap->d_ptr->shm = shm; + livePixmap->d_ptr->owns = false; + livePixmap->d_ptr->shmSerial = handle; + + return livePixmap; +} + +MLivePixmap::~MLivePixmap() +{ +} + +Qt::HANDLE MLivePixmap::handle() +{ + Q_D(MLivePixmap); + return d->shmSerial; +} diff --git a/tools/qmeegographicssystemhelper/qmeegolivepixmap.h b/tools/qmeegographicssystemhelper/qmeegolivepixmap.h new file mode 100644 index 0000000..dee4d2a --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap.h @@ -0,0 +1,71 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#ifndef MLIVEPIXMAP_H +#define MLIVEPIXMAP_H + +#include +#include "mliveimage.h" + +class MLivePixmapPrivate; +class QSharedMemory; +class QImage; + +//! A pixmap representing streamed content. +/*! +*/ + +class MLivePixmap : public QPixmap +{ +public: + //! Creates new pixmap from the given MLiveImage. + /*! + The created MLivePixmap will be attached to the given MLiveImage. + Updates to the MLiveImage will be represented on this newly created + MLivePixmap. + */ + static MLivePixmap* fromLiveImage(MLiveImage *liveImage); + + //! Creates a new MLivePixmap from the specified handle. + /*! + The handle can be used to share MLivePixmap cross-process. + */ + static MLivePixmap* fromHandle(Qt::HANDLE handle); + + //! Returns the handle for this MLivePixmap. + /*! + The handle can be used to share MLivePixmap cross-process. + */ + Qt::HANDLE handle(); + + //! Destroys the MLivePixmap. + /*! + All MLivePixmaps attached to a given MLiveImage have to be destroyed + before the MLiveImage itself is destroyed. + */ + virtual ~MLivePixmap(); + +private: + MLivePixmap(QPixmapData *p); + Q_DISABLE_COPY(MLivePixmap) + Q_DECLARE_PRIVATE(MLivePixmap) + +protected: + QScopedPointer d_ptr; //! Private bits. + + friend class MLiveImage; + friend class MLiveImagePrivate; +}; + +#endif diff --git a/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h b/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h new file mode 100644 index 0000000..4ff64de --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegolivepixmap_p.h @@ -0,0 +1,39 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include "mlivepixmap.h" + +#ifndef MLIVEPIXMAP_P_H +#define MLIVEPIXMAP_P_H + +class MLivePixmapPrivate +{ +public: + Q_DECLARE_PUBLIC(MLivePixmap); + MLivePixmapPrivate(); + void copyBackFrom(const void *raw); + virtual ~MLivePixmapPrivate(); + + QSharedMemory *shm; + int shmSerial; + bool owns; + MLiveImage *parentImage; + + MLivePixmap *q_ptr; + + friend class MLiveImage; + friend class MLiveImagePrivate; +}; + +#endif \ No newline at end of file diff --git a/tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp new file mode 100644 index 0000000..8f64b3f --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.cpp @@ -0,0 +1,72 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include +#include +#include +#include +#include "moverlaywidget.h" +#include "mgraphicssystemhelper.h" +#include "mruntime.h" + +MOverlayWidget::MOverlayWidget(int surfaceWidth, int surfaceHeight, QWidget *parent) : QWidget(parent, 0), + sw(surfaceWidth), + sh(surfaceHeight) +{ + if (! MGraphicsSystemHelper::isRunningMeeGo()) + qFatal("MOverlayWidget can only be used when running with 'meego' graphics system!"); + + MRuntime::setSurfaceFixedSize(surfaceWidth, surfaceHeight); + + scaleW = sw / 864.0; + scaleH = sh / 480.0; + installEventFilter(this); +} + +QPoint MOverlayWidget::convertPoint(const QPoint &p) +{ + int x = p.x() * scaleW; + int y = p.y() * scaleH; + return QPoint(x, y); +} + +void MOverlayWidget::showEvent(QShowEvent *event) +{ + MRuntime::setSurfaceScaling(0, 0, width(), height()); +} + +bool MOverlayWidget::eventFilter(QObject *obj, QEvent *event) +{ + if (event->spontaneous() == false) + return false; + + switch(event->type()) { + case QEvent::MouseButtonPress: + case QEvent::MouseButtonRelease: + { + QMouseEvent *e = static_cast (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..f45a673 --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegooverlaywidget.h @@ -0,0 +1,59 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#ifndef MOVERLAYWIDGET_H +#define MOVERLAYWIDGET_H + +#include + +//! A widget automatically scaling it's content. +/*! +*/ + +class MOverlayWidget : public QWidget +{ +public: + //! Constructs a new scaling widget. + /*! + The real surface used for this widget will have the specified + width and height. + */ + MOverlayWidget(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..b1b0874 --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegoruntime.cpp @@ -0,0 +1,112 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include "mruntime.h" + +#define ENSURE_INITIALIZED {if (!initialized) initialize();} + +QLibrary* MRuntime::library = NULL; +bool MRuntime::initialized = false; + +typedef int (*MImageToEglSharedImageFunc) (const QImage&); +typedef QPixmapData* (*MPixmapDataFromEglSharedImageFunc) (Qt::HANDLE handle, const QImage&); +typedef QPixmapData* (*MPixmapDataWithGLTextureFunc) (int w, int h); +typedef bool (*MDestroyEGLSharedImageFunc) (Qt::HANDLE handle); +typedef void (*MUpdateEglSharedImagePixmapFunc) (QPixmap*); +typedef void (*MSetSurfaceFixedSizeFunc) (int w, int h); +typedef void (*MSetSurfaceScalingFunc) (int x, int y, int w, int h); +typedef void (*MSetTranslucentFunc) (bool translucent); + +static MImageToEglSharedImageFunc m_image_to_egl_shared_image = NULL; +static MPixmapDataFromEglSharedImageFunc m_pixmapdata_from_egl_shared_image = NULL; +static MPixmapDataWithGLTextureFunc m_pixmapdata_with_gl_texture = NULL; +static MDestroyEGLSharedImageFunc m_destroy_egl_shared_image = NULL; +static MUpdateEglSharedImagePixmapFunc m_update_egl_shared_image_pixmap = NULL; +static MSetSurfaceFixedSizeFunc m_set_surface_fixed_size = NULL; +static MSetSurfaceScalingFunc m_set_surface_scaling = NULL; +static MSetTranslucentFunc m_set_translucent = NULL; + +void MRuntime::initialize() +{ + library = new QLibrary("/usr/lib/qt4/plugins/graphicssystems/libmeegographicssystem.so"); + Q_ASSERT(library); + + m_image_to_egl_shared_image = (MImageToEglSharedImageFunc) library->resolve("m_image_to_egl_shared_image"); + m_pixmapdata_from_egl_shared_image = (MPixmapDataFromEglSharedImageFunc) library->resolve("m_pixmapdata_from_egl_shared_image"); + m_pixmapdata_with_gl_texture = (MPixmapDataWithGLTextureFunc) library->resolve("m_pixmapdata_with_gl_texture"); + m_destroy_egl_shared_image = (MDestroyEGLSharedImageFunc) library->resolve("m_destroy_egl_shared_image"); + m_update_egl_shared_image_pixmap = (MUpdateEglSharedImagePixmapFunc) library->resolve("m_update_egl_shared_image_pixmap"); + m_set_surface_fixed_size = (MSetSurfaceFixedSizeFunc) library->resolve("m_set_surface_fixed_size"); + m_set_surface_scaling = (MSetSurfaceScalingFunc) library->resolve("m_set_surface_scaling"); + m_set_translucent = (MSetTranslucentFunc) library->resolve("m_set_translucent"); + + + initialized = true; +} + +Qt::HANDLE MRuntime::imageToEGLSharedImage(const QImage &image) +{ + ENSURE_INITIALIZED; + Q_ASSERT(m_image_to_egl_shared_image); + return m_image_to_egl_shared_image(image); +} + +QPixmap MRuntime::pixmapFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage) +{ + ENSURE_INITIALIZED; + Q_ASSERT(m_pixmapdata_from_egl_shared_image); + return QPixmap(m_pixmapdata_from_egl_shared_image(handle, softImage)); +} + +QPixmap MRuntime::pixmapWithGLTexture(int w, int h) +{ + ENSURE_INITIALIZED; + Q_ASSERT(m_pixmapdata_with_gl_texture); + return QPixmap(m_pixmapdata_with_gl_texture(w, h)); +} + +bool MRuntime::destroyEGLSharedImage(Qt::HANDLE handle) +{ + ENSURE_INITIALIZED; + Q_ASSERT(m_destroy_egl_shared_image); + return m_destroy_egl_shared_image(handle); +} + +void MRuntime::updateEGLSharedImagePixmap(QPixmap *p) +{ + ENSURE_INITIALIZED; + Q_ASSERT(m_update_egl_shared_image_pixmap); + return m_update_egl_shared_image_pixmap(p); +} + +void MRuntime::setSurfaceFixedSize(int w, int h) +{ + ENSURE_INITIALIZED; + Q_ASSERT(m_set_surface_fixed_size); + m_set_surface_fixed_size(w, h); +} + +void MRuntime::setSurfaceScaling(int x, int y, int w, int h) +{ + ENSURE_INITIALIZED; + Q_ASSERT(m_set_surface_scaling); + m_set_surface_scaling(x, y, w, h); +} + +void MRuntime::setTranslucent(bool translucent) +{ + ENSURE_INITIALIZED; + Q_ASSERT(m_set_translucent); + m_set_translucent(translucent); +} diff --git a/tools/qmeegographicssystemhelper/qmeegoruntime.h b/tools/qmeegographicssystemhelper/qmeegoruntime.h new file mode 100644 index 0000000..34474cc --- /dev/null +++ b/tools/qmeegographicssystemhelper/qmeegoruntime.h @@ -0,0 +1,36 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation +** +** This library is free software; you can redistribute it and/or +** modify it 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. +** +****************************************************************************/ + +#include +#include +#include + +class MRuntime +{ +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; + static QLibrary *library; +}; \ No newline at end of file -- cgit v0.12