diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-09-10 16:20:20 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-09-10 16:20:20 (GMT) |
commit | 3dc18b19ee2a02b93cc509a9162bf0a3900c6fd0 (patch) | |
tree | 7865bc34d720c17d68f84570be836cc52e8fb5aa | |
parent | 72cc21e597f2d77ea1be3c1a3f7df36d8909d2fc (diff) | |
parent | e78274d5f8c0eb5c10b9b58e069b90b6475c6f71 (diff) | |
download | Qt-3dc18b19ee2a02b93cc509a9162bf0a3900c6fd0.zip Qt-3dc18b19ee2a02b93cc509a9162bf0a3900c6fd0.tar.gz Qt-3dc18b19ee2a02b93cc509a9162bf0a3900c6fd0.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2:
Prevented crash in GL window surface when deleting native child widgets.
Fix a regression where setPreferredSize(QSize(100, -1)) did not work.
Force MeeGo touch to use native graphics system for now.
Fixed compiler warnings in meego graphics system helper.
Added meego graphics system helper to features/qt.prf and syncqt.
Use QFactoryLoader to ensure we get the correct graphics system plugin.
Updated license headers for meego graphics system helper.
Fixed compilation and API of meego graphics system helper.
Renamed meego graphics system helper files.
Imported meego graphics system helper sources.
Updated license headers for meego graphics system.
Fixed compilation and API of meego graphics system.
Renamed meego graphics system files.
Imported meego graphics system sources.
Fix cache_cost initialization of QFontEngineMultiWin
Fix crash when using unprintable chars in QStaticText
Don't waste memory on the share widget in the GL window surface.
38 files changed, 2376 insertions, 9 deletions
@@ -51,6 +51,7 @@ my %modules = ( # path to module name map "QtWebKit" => "$basedir/src/3rdparty/webkit/WebCore", "phonon" => "$basedir/src/phonon", "QtMultimedia" => "$basedir/src/multimedia", + "QtMeeGoGraphicsSystemHelper" => "$basedir/tools/qmeegographicssystemhelper", ); my %moduleheaders = ( # restrict the module headers to those found in relative path "QtWebKit" => "../WebKit/qt/Api", diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf index 4fd804d..e59319f 100644 --- a/mkspecs/features/qt.prf +++ b/mkspecs/features/qt.prf @@ -36,7 +36,7 @@ INCLUDEPATH = $$QMAKE_INCDIR_QT $$INCLUDEPATH #prepending prevents us from picki win32:INCLUDEPATH += $$QMAKE_INCDIR_QT/ActiveQt # As order does matter for static libs, we reorder the QT variable here -TMPLIBS = declarative webkit phonon multimedia dbus testlib script scripttools svg qt3support sql xmlpatterns xml egl opengl openvg gui network core +TMPLIBS = declarative webkit phonon multimedia dbus testlib script scripttools svg qt3support sql xmlpatterns xml egl opengl openvg gui network core meegographicssystemhelper for(QTLIB, $$list($$TMPLIBS)) { contains(QT, $$QTLIB): QT_ORDERED += $$QTLIB } @@ -175,6 +175,7 @@ for(QTLIB, $$list($$lower($$unique(QT)))) { } } else:isEqual(QTLIB, declarative):qlib = QtDeclarative else:isEqual(QTLIB, multimedia):qlib = QtMultimedia + else:isEqual(QTLIB, meegographicssystemhelper):qlib = QtMeeGoGraphicsSystemHelper else:message("Unknown QT: $$QTLIB"):qlib = !isEmpty(qlib) { target_qt:isEqual(TARGET, qlib) { diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index 62d565a..a26dcd8 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -244,6 +244,14 @@ QObject *QFactoryLoader::instance(const QString &key) const return 0; } +#ifdef Q_WS_X11 +QLibraryPrivate *QFactoryLoader::library(const QString &key) const +{ + Q_D(const QFactoryLoader); + return d->keyMap.value(d->cs ? key : key.toLower()); +} +#endif + void QFactoryLoader::refreshAll() { QMutexLocker locker(qt_factoryloader_mutex()); diff --git a/src/corelib/plugin/qfactoryloader_p.h b/src/corelib/plugin/qfactoryloader_p.h index 10e6e2a..068c6c7 100644 --- a/src/corelib/plugin/qfactoryloader_p.h +++ b/src/corelib/plugin/qfactoryloader_p.h @@ -77,6 +77,10 @@ public: QStringList keys() const; QObject *instance(const QString &key) const; +#ifdef Q_WS_X11 + QLibraryPrivate *library(const QString &key) const; +#endif + void update(); static void refreshAll(); diff --git a/src/gui/egl/qeglcontext_p.h b/src/gui/egl/qeglcontext_p.h index cae8164..5bc8f09 100644 --- a/src/gui/egl/qeglcontext_p.h +++ b/src/gui/egl/qeglcontext_p.h @@ -107,6 +107,9 @@ private: static QEglContext *currentContext(QEgl::API api); static void setCurrentContext(QEgl::API api, QEglContext *context); + + friend class QMeeGoGraphicsSystem; + friend class QMeeGoPixmapData; }; QT_END_NAMESPACE diff --git a/src/gui/graphicsview/qgraphicslayoutitem.cpp b/src/gui/graphicsview/qgraphicslayoutitem.cpp index 3707591..634f68c 100644 --- a/src/gui/graphicsview/qgraphicslayoutitem.cpp +++ b/src/gui/graphicsview/qgraphicslayoutitem.cpp @@ -234,7 +234,7 @@ void QGraphicsLayoutItemPrivate::setSize(Qt::SizeHint which, const QSizeF &size) if (userSizeHints) { if (size == userSizeHints[which]) return; - } else if (!size.isValid()) { + } else if (size.width() < 0 && size.height() < 0) { return; } diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 82dd83a..e99f6ca 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -94,6 +94,10 @@ #include <stdlib.h> +#if defined(Q_WS_X11) && !defined(QT_NO_EGL) +#include <link.h> +#endif + #include "qapplication_p.h" #include "qevent_p.h" #include "qwidget_p.h" @@ -768,6 +772,13 @@ QApplication::QApplication(int &argc, char **argv, Type type , int _internal) : QCoreApplication(*new QApplicationPrivate(argc, argv, type)) { Q_D(QApplication); d->construct(); QApplicationPrivate::app_compile_version = _internal;} +#if defined(Q_WS_X11) && !defined(QT_NO_EGL) +static int qt_matchLibraryName(dl_phdr_info *info, size_t, void *data) +{ + const char *name = static_cast<const char *>(data); + return strstr(info->dlpi_name, name) != 0; +} +#endif /*! \internal @@ -785,6 +796,19 @@ void QApplicationPrivate::construct( // the environment variable has the lowest precedence of runtime graphicssystem switches if (graphics_system_name.isEmpty()) graphics_system_name = QString::fromLocal8Bit(qgetenv("QT_GRAPHICSSYSTEM")); + +#if defined(Q_WS_X11) && !defined(QT_NO_EGL) + if (graphics_system_name.isEmpty()) { + bool linksWithMeeGoTouch = dl_iterate_phdr(qt_matchLibraryName, const_cast<char *>("libmeegotouchcore")); + bool linksWithMeeGoGraphicsSystemHelper = dl_iterate_phdr(qt_matchLibraryName, const_cast<char *>("libQtMeeGoGraphicsSystemHelper")); + + if (linksWithMeeGoTouch && !linksWithMeeGoGraphicsSystemHelper) { + qWarning("Running non-meego graphics system enabled MeeGo touch, forcing native graphicssystem\n"); + graphics_system_name = QLatin1String("native"); + } + } +#endif + // Must be called before initialize() qt_init(this, qt_appType #ifdef Q_WS_X11 diff --git a/src/gui/painting/qgraphicssystem_runtime_p.h b/src/gui/painting/qgraphicssystem_runtime_p.h index 0232241..421fbeb 100644 --- a/src/gui/painting/qgraphicssystem_runtime_p.h +++ b/src/gui/painting/qgraphicssystem_runtime_p.h @@ -177,6 +177,7 @@ private: friend class QRuntimePixmapData; friend class QRuntimeWindowSurface; + friend class QMeeGoGraphicsSystem; }; QT_END_NAMESPACE diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp index 82de0d5..ef1b504 100644 --- a/src/gui/text/qfontengine_win.cpp +++ b/src/gui/text/qfontengine_win.cpp @@ -1296,6 +1296,7 @@ QFontEngineMultiWin::QFontEngineMultiWin(QFontEngineWin *first, const QStringLis engines[0] = first; first->ref.ref(); fontDef = engines[0]->fontDef; + cache_cost = first->cache_cost; } void QFontEngineMultiWin::loadEngine(int at) @@ -1317,6 +1318,8 @@ void QFontEngineMultiWin::loadEngine(int at) engines[at] = new QFontEngineWin(fam, hfont, stockFont, lf); engines[at]->ref.ref(); engines[at]->fontDef = fontDef; + + // TODO: increase cost in QFontCache for the font engine loaded here } QT_END_NAMESPACE diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp index b950b13..7a5dec4 100644 --- a/src/gui/text/qstatictext.cpp +++ b/src/gui/text/qstatictext.cpp @@ -448,7 +448,6 @@ namespace { currentItem.font = ti.font(); currentItem.charOffset = m_chars.size(); currentItem.numChars = ti.num_chars; - currentItem.numGlyphs = ti.glyphs.numGlyphs; currentItem.glyphOffset = m_glyphs.size(); // Store offset into glyph pool currentItem.positionOffset = m_glyphs.size(); // Offset into position pool currentItem.useBackendOptimizations = m_useBackendOptimizations; @@ -463,8 +462,8 @@ namespace { ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions); int size = glyphs.size(); - Q_ASSERT(size == ti.glyphs.numGlyphs); Q_ASSERT(size == positions.size()); + currentItem.numGlyphs = size; m_glyphs.resize(m_glyphs.size() + size); m_positions.resize(m_glyphs.size()); diff --git a/src/opengl/qpixmapdata_gl_p.h b/src/opengl/qpixmapdata_gl_p.h index 4cb67b0..f000993 100644 --- a/src/opengl/qpixmapdata_gl_p.h +++ b/src/opengl/qpixmapdata_gl_p.h @@ -168,6 +168,7 @@ private: mutable QGLPixmapGLPaintDevice m_glDevice; friend class QGLPixmapGLPaintDevice; + friend class QMeeGoPixmapData; }; QT_END_NAMESPACE diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index e84bc29..f98dcff 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -190,7 +190,10 @@ public: QGLWidget *shareWidget() { if (!initializing && !widget && !cleanedUp) { initializing = true; - widget = new QGLWidget; + + widget = new QGLWidget(QGLFormat(QGL::SingleBuffer | QGL::NoDepthBuffer | QGL::NoStencilBuffer)); + widget->resize(1, 1); + // We dont need this internal widget to appear in QApplication::topLevelWidgets() if (QWidgetPrivate::allWidgets) QWidgetPrivate::allWidgets->remove(widget); @@ -342,12 +345,14 @@ QGLWindowSurface::~QGLWindowSurface() void QGLWindowSurface::deleted(QObject *object) { - // Make sure that the fbo is destroyed before destroying its context. - delete d_ptr->fbo; - d_ptr->fbo = 0; - QWidget *widget = qobject_cast<QWidget *>(object); if (widget) { + if (widget == window()) { + // Make sure that the fbo is destroyed before destroying its context. + delete d_ptr->fbo; + d_ptr->fbo = 0; + } + QWidgetPrivate *widgetPrivate = widget->d_func(); if (widgetPrivate->extraData()) { union { QGLContext **ctxPtr; void **voidPtr; }; @@ -419,6 +424,8 @@ QPaintDevice *QGLWindowSurface::paintDevice() QGLContext *ctx = reinterpret_cast<QGLContext *>(window()->d_func()->extraData()->glContext); ctx->makeCurrent(); + + Q_ASSERT(d_ptr->fbo); return d_ptr->fbo; } diff --git a/src/plugins/graphicssystems/graphicssystems.pro b/src/plugins/graphicssystems/graphicssystems.pro index 0788933..29a1f34 100644 --- a/src/plugins/graphicssystems/graphicssystems.pro +++ b/src/plugins/graphicssystems/graphicssystems.pro @@ -7,3 +7,7 @@ contains(QT_CONFIG, shivavg) { # Only works under X11 at present !win32:!embedded:!mac:SUBDIRS += shivavg } + +!win32:!embedded:!mac:!symbian:CONFIG += x11 + +x11:contains(QT_CONFIG, opengles2):contains(QT_CONFIG, egl):SUBDIRS += meego diff --git a/src/plugins/graphicssystems/meego/meego.pro b/src/plugins/graphicssystems/meego/meego.pro new file mode 100644 index 0000000..d750d34 --- /dev/null +++ b/src/plugins/graphicssystems/meego/meego.pro @@ -0,0 +1,13 @@ +TARGET = qmeegographicssystem +include(../../qpluginbase.pri) + +QT += gui opengl + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/graphicssystems + +HEADERS = qmeegographicssystem.h qmeegopixmapdata.h qmeegoextensions.h +SOURCES = qmeegographicssystem.cpp qmeegographicssystem.h qmeegographicssystemplugin.h qmeegographicssystemplugin.cpp qmeegopixmapdata.h qmeegopixmapdata.cpp qmeegoextensions.h qmeegoextensions.cpp + +target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems +INSTALLS += target + diff --git a/src/plugins/graphicssystems/meego/qmeegoextensions.cpp b/src/plugins/graphicssystems/meego/qmeegoextensions.cpp new file mode 100644 index 0000000..e7f6439 --- /dev/null +++ b/src/plugins/graphicssystems/meego/qmeegoextensions.cpp @@ -0,0 +1,129 @@ +/**************************************************************************** +** +** 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 "qmeegoextensions.h" +#include <private/qeglcontext_p.h> +#include <private/qpixmapdata_gl_p.h> + +bool QMeeGoExtensions::initialized = false; +bool QMeeGoExtensions::hasImageShared = false; +bool QMeeGoExtensions::hasSurfaceScaling = false; + +/* Extension funcs */ + +typedef EGLBoolean (EGLAPIENTRY *eglQueryImageNOKFunc)(EGLDisplay, EGLImageKHR, EGLint, EGLint*); +typedef EGLNativeSharedImageTypeNOK (EGLAPIENTRY *eglCreateSharedImageNOKFunc)(EGLDisplay, EGLImageKHR, EGLint*); +typedef EGLBoolean (EGLAPIENTRY *eglDestroySharedImageNOKFunc)(EGLDisplay, EGLNativeSharedImageTypeNOK); +typedef EGLBoolean (EGLAPIENTRY *eglSetSurfaceScalingNOKFunc)(EGLDisplay, EGLSurface, EGLint, EGLint, EGLint, EGLint); + +static eglQueryImageNOKFunc _eglQueryImageNOK = 0; +static eglCreateSharedImageNOKFunc _eglCreateSharedImageNOK = 0; +static eglDestroySharedImageNOKFunc _eglDestroySharedImageNOK = 0; +static eglSetSurfaceScalingNOKFunc _eglSetSurfaceScalingNOK = 0; + +/* Public */ + +void QMeeGoExtensions::ensureInitialized() +{ + if (!initialized) + initialize(); + + initialized = true; +} + +EGLNativeSharedImageTypeNOK QMeeGoExtensions::eglCreateSharedImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint *props) +{ + if (! hasImageShared) + qFatal("EGL_NOK_image_shared not found but trying to use capability!"); + + return _eglCreateSharedImageNOK(dpy, image, props); +} + +bool QMeeGoExtensions::eglQueryImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint prop, EGLint *v) +{ + if (! hasImageShared) + qFatal("EGL_NOK_image_shared not found but trying to use capability!"); + + return _eglQueryImageNOK(dpy, image, prop, v); +} + +bool QMeeGoExtensions::eglDestroySharedImageNOK(EGLDisplay dpy, EGLNativeSharedImageTypeNOK img) +{ + if (! hasImageShared) + qFatal("EGL_NOK_image_shared not found but trying to use capability!"); + + return _eglDestroySharedImageNOK(dpy, img); +} + +bool QMeeGoExtensions::eglSetSurfaceScalingNOK(EGLDisplay dpy, EGLSurface surface, int x, int y, int width, int height) +{ + if (! hasSurfaceScaling) + qFatal("EGL_NOK_surface_scaling not found but trying to use capability!"); + + return _eglSetSurfaceScalingNOK(dpy, surface, x, y, width, height); +} + +/* Private */ + +void QMeeGoExtensions::initialize() +{ + QGLContext *ctx = (QGLContext *) QGLContext::currentContext(); + qt_resolve_eglimage_gl_extensions(ctx); + + if (QEgl::hasExtension("EGL_NOK_image_shared")) { + qDebug("MeegoGraphics: found EGL_NOK_image_shared"); + _eglQueryImageNOK = (eglQueryImageNOKFunc) eglGetProcAddress("eglQueryImageNOK"); + _eglCreateSharedImageNOK = (eglCreateSharedImageNOKFunc) eglGetProcAddress("eglCreateSharedImageNOK"); + _eglDestroySharedImageNOK = (eglDestroySharedImageNOKFunc) eglGetProcAddress("eglDestroySharedImageNOK"); + + Q_ASSERT(_eglQueryImageNOK && _eglCreateSharedImageNOK && _eglDestroySharedImageNOK); + hasImageShared = true; + } + + if (QEgl::hasExtension("EGL_NOK_surface_scaling")) { + qDebug("MeegoGraphics: found EGL_NOK_surface_scaling"); + _eglSetSurfaceScalingNOK = (eglSetSurfaceScalingNOKFunc) eglGetProcAddress("eglSetSurfaceScalingNOK"); + + Q_ASSERT(_eglSetSurfaceScalingNOK); + hasSurfaceScaling = true; + } +} + diff --git a/src/plugins/graphicssystems/meego/qmeegoextensions.h b/src/plugins/graphicssystems/meego/qmeegoextensions.h new file mode 100644 index 0000000..7f219de --- /dev/null +++ b/src/plugins/graphicssystems/meego/qmeegoextensions.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** 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 MEXTENSIONS_H +#define MEXTENSIONS_H + +#include <EGL/egl.h> +#include <EGL/eglext.h> +#include <GLES2/gl2.h> +#include <GLES2/gl2ext.h> +#include <private/qgl_p.h> +#include <private/qeglcontext_p.h> +#include <private/qpixmapdata_gl_p.h> + +/* Extensions decls */ + +#ifndef EGL_SHARED_IMAGE_NOK +#define EGL_SHARED_IMAGE_NOK 0x30DA +typedef void* EGLNativeSharedImageTypeNOK; +#endif + +#ifndef EGL_GL_TEXTURE_2D_KHR +#define EGL_GL_TEXTURE_2D_KHR 0x30B1 +#endif + +#ifndef EGL_FIXED_WIDTH_NOK +#define EGL_FIXED_WIDTH_NOK 0x30DB +#define EGL_FIXED_HEIGHT_NOK 0x30DC +#endif + +/* Class */ + +class QMeeGoExtensions +{ +public: + static void ensureInitialized(); + + static EGLNativeSharedImageTypeNOK eglCreateSharedImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint *props); + static bool eglQueryImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint prop, EGLint *v); + static bool eglDestroySharedImageNOK(EGLDisplay dpy, EGLNativeSharedImageTypeNOK img); + static bool eglSetSurfaceScalingNOK(EGLDisplay dpy, EGLSurface surface, int x, int y, int width, int height); + +private: + static void initialize(); + + static bool initialized; + static bool hasImageShared; + static bool hasSurfaceScaling; +}; + +#endif diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp new file mode 100644 index 0000000..e2c8425 --- /dev/null +++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp @@ -0,0 +1,248 @@ +/**************************************************************************** +** +** 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 <private/qpixmap_raster_p.h> +#include <private/qwindowsurface_gl_p.h> +#include <private/qegl_p.h> +#include <private/qglextensions_p.h> +#include <private/qgl_p.h> +#include <private/qimagepixmapcleanuphooks_p.h> +#include <private/qapplication_p.h> +#include <private/qgraphicssystem_runtime_p.h> +#include <private/qimage_p.h> +#include <private/qeglproperties_p.h> +#include <private/qeglcontext_p.h> + +#include "qmeegopixmapdata.h" +#include "qmeegographicssystem.h" +#include "qmeegoextensions.h" + +bool QMeeGoGraphicsSystem::surfaceWasCreated = false; + +QMeeGoGraphicsSystem::QMeeGoGraphicsSystem() +{ + qDebug("Using the meego graphics system"); +} + +QMeeGoGraphicsSystem::~QMeeGoGraphicsSystem() +{ + qDebug("Meego graphics system destroyed"); + qt_destroy_gl_share_widget(); +} + +QWindowSurface* QMeeGoGraphicsSystem::createWindowSurface(QWidget *widget) const +{ + QMeeGoGraphicsSystem::surfaceWasCreated = true; + QWindowSurface *surface = new QGLWindowSurface(widget); + surface->window()->setAttribute(Qt::WA_NoSystemBackground); + return surface; +} + +QPixmapData *QMeeGoGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const +{ + // Long story short: without this it's possible to hit an + // unitialized paintDevice due to a Qt bug too complex to even + // explain here... not to mention fix without going crazy. + // MDK + QGLShareContextScope ctx(qt_gl_share_widget()->context()); + + return new QRasterPixmapData(type); +} + +QPixmapData *QMeeGoGraphicsSystem::createPixmapData(QPixmapData *origin) +{ + // If the pixmap is a raster type... + // and if the pixmap pointer matches our mapping... + // create a shared image instead with the given handle. + + if (origin->classId() == QPixmapData::RasterClass) { + QRasterPixmapData *rasterClass = static_cast <QRasterPixmapData *> (origin); + void *rawResource = static_cast <void *> (rasterClass->buffer()->data_ptr()->data); + + if (QMeeGoPixmapData::sharedImagesMap.contains(rawResource)) + return new QMeeGoPixmapData(); + } + + return new QRasterPixmapData(origin->pixelType()); +} + +QPixmapData* QMeeGoGraphicsSystem::wrapPixmapData(QPixmapData *pmd) +{ + QString name = QApplicationPrivate::instance()->graphics_system_name; + if (name == "runtime") { + QRuntimeGraphicsSystem *rsystem = (QRuntimeGraphicsSystem *) QApplicationPrivate::instance()->graphics_system; + QRuntimePixmapData *rt = new QRuntimePixmapData(rsystem, pmd->pixelType());; + rt->m_data = pmd; + rt->readBackInfo(); + rsystem->m_pixmapDatas << rt; + return rt; + } else + return pmd; +} + +void QMeeGoGraphicsSystem::setSurfaceFixedSize(int /*width*/, int /*height*/) +{ + if (QMeeGoGraphicsSystem::surfaceWasCreated) + qWarning("Trying to set surface fixed size but surface already created!"); + +#ifdef QT_WAS_PATCHED + QEglProperties *properties = new QEglProperties(); + properties->setValue(EGL_FIXED_WIDTH_NOK, width); + properties->setValue(EGL_FIXED_HEIGHT_NOK, height); + QGLContextPrivate::setExtraWindowSurfaceCreationProps(properties); +#endif +} + +void QMeeGoGraphicsSystem::setSurfaceScaling(int x, int y, int width, int height) +{ + QMeeGoExtensions::ensureInitialized(); + QMeeGoExtensions::eglSetSurfaceScalingNOK(QEgl::display(), QEglContext::currentContext(QEgl::OpenGL)->currentSurface, x, y, width, height); +} + +void QMeeGoGraphicsSystem::setTranslucent(bool translucent) +{ + QGLWindowSurface::surfaceFormat.setSampleBuffers(false); + QGLWindowSurface::surfaceFormat.setSamples(0); + QGLWindowSurface::surfaceFormat.setAlpha(translucent); +} + +QPixmapData *QMeeGoGraphicsSystem::pixmapDataFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage) +{ + if (softImage.format() != QImage::Format_ARGB32_Premultiplied && + softImage.format() != QImage::Format_ARGB32) { + qFatal("For egl shared images, the soft image has to be ARGB32 or ARGB32_Premultiplied"); + return NULL; + } + + if (QMeeGoGraphicsSystem::meeGoRunning()) { + QMeeGoPixmapData *pmd = new QMeeGoPixmapData; + pmd->fromEGLSharedImage(handle, softImage); + return QMeeGoGraphicsSystem::wrapPixmapData(pmd); + } else { + QRasterPixmapData *pmd = new QRasterPixmapData(QPixmapData::PixmapType); + pmd->fromImage(softImage, Qt::NoOpaqueDetection); + + // Make sure that the image was not converted in any way + if (pmd->buffer()->data_ptr()->data != + const_cast<QImage &>(softImage).data_ptr()->data) + qFatal("Iternal misalignment of raster data detected. Prolly a QImage copy fail."); + + QMeeGoPixmapData::registerSharedImage(handle, softImage); + return QMeeGoGraphicsSystem::wrapPixmapData(pmd); + } +} + +void QMeeGoGraphicsSystem::updateEGLSharedImagePixmap(QPixmap *pixmap) +{ + QMeeGoPixmapData *pmd = (QMeeGoPixmapData *) pixmap->pixmapData(); + + // Basic sanity check to make sure this is really a QMeeGoPixmapData... + if (pmd->classId() != QPixmapData::OpenGLClass) + qFatal("Trying to updated EGLSharedImage pixmap but it's not really a shared image pixmap!"); + + pmd->updateFromSoftImage(); +} + +QPixmapData *QMeeGoGraphicsSystem::pixmapDataWithGLTexture(int w, int h) +{ + QGLPixmapData *pmd = new QGLPixmapData(QPixmapData::PixmapType); + pmd->resize(w, h); + return QMeeGoGraphicsSystem::wrapPixmapData(pmd); +} + +bool QMeeGoGraphicsSystem::meeGoRunning() +{ + if (! QApplicationPrivate::instance()) { + qWarning("Application not running just yet... hard to know what system running!"); + return false; + } + + QString name = QApplicationPrivate::instance()->graphics_system_name; + if (name == "runtime") { + QRuntimeGraphicsSystem *rsystem = (QRuntimeGraphicsSystem *) QApplicationPrivate::instance()->graphics_system; + name = rsystem->graphicsSystemName(); + } + + return (name == "meego"); +} + +/* C API */ + +int qt_meego_image_to_egl_shared_image(const QImage &image) +{ + return QMeeGoPixmapData::imageToEGLSharedImage(image); +} + +QPixmapData* qt_meego_pixmapdata_from_egl_shared_image(Qt::HANDLE handle, const QImage &softImage) +{ + return QMeeGoGraphicsSystem::pixmapDataFromEGLSharedImage(handle, softImage); +} + +QPixmapData* qt_meego_pixmapdata_with_gl_texture(int w, int h) +{ + return QMeeGoGraphicsSystem::pixmapDataWithGLTexture(w, h); +} + +bool qt_meego_destroy_egl_shared_image(Qt::HANDLE handle) +{ + return QMeeGoPixmapData::destroyEGLSharedImage(handle); +} + +void qt_meego_set_surface_fixed_size(int width, int height) +{ + QMeeGoGraphicsSystem::setSurfaceFixedSize(width, height); +} + +void qt_meego_set_surface_scaling(int x, int y, int width, int height) +{ + QMeeGoGraphicsSystem::setSurfaceScaling(x, y, width, height); +} + +void qt_meego_set_translucent(bool translucent) +{ + QMeeGoGraphicsSystem::setTranslucent(translucent); +} + +void qt_meego_update_egl_shared_image_pixmap(QPixmap *pixmap) +{ + QMeeGoGraphicsSystem::updateEGLSharedImagePixmap(pixmap); +} diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.h b/src/plugins/graphicssystems/meego/qmeegographicssystem.h new file mode 100644 index 0000000..905f0c3 --- /dev/null +++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** 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 MGRAPHICSSYSTEM_H +#define MGRAPHICSSYSTEM_H + +#include <private/qgraphicssystem_p.h> + +class QMeeGoGraphicsSystem : public QGraphicsSystem +{ +public: + QMeeGoGraphicsSystem(); + ~QMeeGoGraphicsSystem(); + + virtual QWindowSurface *createWindowSurface(QWidget *widget) const; + virtual QPixmapData *createPixmapData(QPixmapData::PixelType) const; + virtual QPixmapData *createPixmapData(QPixmapData *origin); + + static QPixmapData *wrapPixmapData(QPixmapData *pmd); + static void setSurfaceFixedSize(int width, int height); + static void setSurfaceScaling(int x, int y, int width, int height); + static void setTranslucent(bool translucent); + + static QPixmapData *pixmapDataFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage); + static QPixmapData *pixmapDataWithGLTexture(int w, int h); + static void updateEGLSharedImagePixmap(QPixmap *pixmap); + +private: + static bool meeGoRunning(); + + static bool surfaceWasCreated; +}; + +/* C api */ + +extern "C" { + Q_DECL_EXPORT int qt_meego_image_to_egl_shared_image(const QImage &image); + Q_DECL_EXPORT QPixmapData* qt_meego_pixmapdata_from_egl_shared_image(Qt::HANDLE handle, const QImage &softImage); + Q_DECL_EXPORT QPixmapData* qt_meego_pixmapdata_with_gl_texture(int w, int h); + Q_DECL_EXPORT void qt_meego_update_egl_shared_image_pixmap(QPixmap *pixmap); + Q_DECL_EXPORT bool qt_meego_destroy_egl_shared_image(Qt::HANDLE handle); + Q_DECL_EXPORT void qt_meego_set_surface_fixed_size(int width, int height); + Q_DECL_EXPORT void qt_meego_set_surface_scaling(int x, int y, int width, int height); + Q_DECL_EXPORT void qt_meego_set_translucent(bool translucent); +} + +#endif diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.cpp b/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.cpp new file mode 100644 index 0000000..7c142eb --- /dev/null +++ b/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** 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 "qmeegographicssystemplugin.h" +#include "qmeegographicssystem.h" + +QStringList QMeeGoGraphicsSystemPlugin::keys() const +{ + QStringList list; + list << "meego"; + return list; +} + +QGraphicsSystem *QMeeGoGraphicsSystemPlugin::create(const QString&) +{ + return new QMeeGoGraphicsSystem; +} + +Q_EXPORT_PLUGIN2(meego, QMeeGoGraphicsSystemPlugin) diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.h b/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.h new file mode 100644 index 0000000..336458f --- /dev/null +++ b/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** 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 MGRAPHICSSYSTEMPLUGIN_H +#define MGRAPHICSSYSTEMPLUGIN_H + +#include <private/qgraphicssystemplugin_p.h> + +class QMeeGoGraphicsSystemPlugin : public QGraphicsSystemPlugin +{ +public: + virtual QStringList keys() const; + virtual QGraphicsSystem *create(const QString&); +}; + +#endif diff --git a/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp b/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp new file mode 100644 index 0000000..33611dc --- /dev/null +++ b/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp @@ -0,0 +1,206 @@ +/**************************************************************************** +** +** 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 "qmeegopixmapdata.h" +#include "qmeegoextensions.h" +#include <private/qimage_p.h> +#include <private/qwindowsurface_gl_p.h> +#include <private/qeglcontext_p.h> +#include <private/qapplication_p.h> +#include <private/qgraphicssystem_runtime_p.h> + +static EGLint preserved_image_attribs[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE }; + +QHash <void*, QMeeGoImageInfo*> QMeeGoPixmapData::sharedImagesMap; + +/* Public */ + +QMeeGoPixmapData::QMeeGoPixmapData() : QGLPixmapData(QPixmapData::PixmapType) +{ +} + +void QMeeGoPixmapData::fromTexture(GLuint textureId, int w, int h, bool alpha) +{ + resize(w, h); + texture()->id = textureId; + m_hasAlpha = alpha; + softImage = QImage(); +} + +QImage QMeeGoPixmapData::toImage() const +{ + return softImage; +} + +void QMeeGoPixmapData::fromImage(const QImage &image, + Qt::ImageConversionFlags flags) +{ + void *rawResource = static_cast <void *> (((QImage &) image).data_ptr()->data); + + if (sharedImagesMap.contains(rawResource)) { + QMeeGoImageInfo *info = sharedImagesMap.value(rawResource); + fromEGLSharedImage(info->handle, image); + } else { + // This should *never* happen since the graphics system should never + // create a QMeeGoPixmapData for an origin that doesn't contain a raster + // image we know about. But... + qWarning("QMeeGoPixmapData::fromImage called on non-know resource. Falling back..."); + QGLPixmapData::fromImage(image, flags); + } +} + +void QMeeGoPixmapData::fromEGLSharedImage(Qt::HANDLE handle, const QImage &si) +{ + if (si.isNull()) + qFatal("Trying to build pixmap with an empty/null softimage!"); + + QGLShareContextScope ctx(qt_gl_share_widget()->context()); + + QMeeGoExtensions::ensureInitialized(); + + bool textureIsBound = false; + GLuint newTextureId; + GLint newWidth, newHeight; + + glGenTextures(1, &newTextureId); + glBindTexture(GL_TEXTURE_2D, newTextureId); + + glFinish(); + EGLImageKHR image = QEgl::eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_SHARED_IMAGE_NOK, + (EGLClientBuffer)handle, preserved_image_attribs); + + if (image != EGL_NO_IMAGE_KHR) { + glFinish(); + glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image); + GLint err = glGetError(); + if (err == GL_NO_ERROR) + textureIsBound = true; + + QMeeGoExtensions::eglQueryImageNOK(QEgl::display(), image, EGL_WIDTH, &newWidth); + QMeeGoExtensions::eglQueryImageNOK(QEgl::display(), image, EGL_HEIGHT, &newHeight); + + QEgl::eglDestroyImageKHR(QEgl::display(), image); + glFinish(); + } + + if (textureIsBound) { + // FIXME Remove this ugly hasAlphaChannel check when Qt lands the NoOpaqueCheck flag fix + // for QGLPixmapData. + fromTexture(newTextureId, newWidth, newHeight, + (si.hasAlphaChannel() && const_cast<QImage &>(si).data_ptr()->checkForAlphaPixels())); + softImage = si; + QMeeGoPixmapData::registerSharedImage(handle, softImage); + } else { + qWarning("Failed to create a texture from a shared image!"); + glDeleteTextures(1, &newTextureId); + } +} + +Qt::HANDLE QMeeGoPixmapData::imageToEGLSharedImage(const QImage &image) +{ + QGLShareContextScope ctx(qt_gl_share_widget()->context()); + + QMeeGoExtensions::ensureInitialized(); + + glFinish(); + QGLPixmapData pixmapData(QPixmapData::PixmapType); + pixmapData.fromImage(image, 0); + GLuint textureId = pixmapData.bind(); + + glFinish(); + EGLImageKHR eglimage = QEgl::eglCreateImageKHR(QEgl::display(), QEglContext::currentContext(QEgl::OpenGL)->context(), + EGL_GL_TEXTURE_2D_KHR, + (EGLClientBuffer) textureId, + preserved_image_attribs); + glFinish(); + + if (eglimage) { + EGLNativeSharedImageTypeNOK handle = QMeeGoExtensions::eglCreateSharedImageNOK(QEgl::display(), eglimage, NULL); + QEgl::eglDestroyImageKHR(QEgl::display(), eglimage); + glFinish(); + return (Qt::HANDLE) handle; + } else { + qWarning("Failed to create shared image from pixmap/texture!"); + return 0; + } +} + +void QMeeGoPixmapData::updateFromSoftImage() +{ + m_dirty = true; + m_source = softImage; + ensureCreated(); + + if (softImage.width() != w || softImage.height() != h) + qWarning("Ooops, looks like softImage changed dimensions since last updated! Corruption ahead?!"); +} + +bool QMeeGoPixmapData::destroyEGLSharedImage(Qt::HANDLE h) +{ + QGLShareContextScope ctx(qt_gl_share_widget()->context()); + QMeeGoExtensions::ensureInitialized(); + + QMutableHashIterator <void*, QMeeGoImageInfo*> i(sharedImagesMap); + while (i.hasNext()) { + i.next(); + if (i.value()->handle == h) + i.remove(); + } + + return QMeeGoExtensions::eglDestroySharedImageNOK(QEgl::display(), (EGLNativeSharedImageTypeNOK) h); +} + +void QMeeGoPixmapData::registerSharedImage(Qt::HANDLE handle, const QImage &si) +{ + void *raw = static_cast <void *> (((QImage) si).data_ptr()->data); + QMeeGoImageInfo *info; + + if (! sharedImagesMap.contains(raw)) { + info = new QMeeGoImageInfo; + info->handle = handle; + info->rawFormat = si.format(); + sharedImagesMap.insert(raw, info); + } else { + info = sharedImagesMap.value(raw); + if (info->handle != handle || info->rawFormat != si.format()) + qWarning("Inconsistency detected: overwriting entry in sharedImagesMap but handle/format different"); + } +} diff --git a/src/plugins/graphicssystems/meego/qmeegopixmapdata.h b/src/plugins/graphicssystems/meego/qmeegopixmapdata.h new file mode 100644 index 0000000..8af33bd --- /dev/null +++ b/src/plugins/graphicssystems/meego/qmeegopixmapdata.h @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** 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 MPIXMAPDATA_H +#define MPIXMAPDATA_H + +#include <private/qpixmapdata_gl_p.h> + +struct QMeeGoImageInfo +{ + Qt::HANDLE handle; + QImage::Format rawFormat; +}; + +class QMeeGoPixmapData : public QGLPixmapData +{ +public: + QMeeGoPixmapData(); + void fromTexture(GLuint textureId, int w, int h, bool alpha); + + virtual void fromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage); + virtual void fromImage (const QImage &image, Qt::ImageConversionFlags flags); + virtual QImage toImage() const; + virtual void updateFromSoftImage(); + + QImage softImage; + + static QHash <void*, QMeeGoImageInfo*> sharedImagesMap; + + static Qt::HANDLE imageToEGLSharedImage(const QImage &image); + static bool destroyEGLSharedImage(Qt::HANDLE h); + static void registerSharedImage(Qt::HANDLE handle, const QImage &si); +}; + +#endif diff --git a/tests/auto/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp b/tests/auto/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp index 879e12b..dbffa6e 100644 --- a/tests/auto/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp +++ b/tests/auto/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp @@ -75,6 +75,7 @@ private slots: void setPreferredSize_data(); void setPreferredSize(); void setSizePolicy_data(); + void setPreferredSize2(); void setSizePolicy(); }; @@ -343,6 +344,13 @@ void tst_QGraphicsLayoutItem::setPreferredSize() } } +void tst_QGraphicsLayoutItem::setPreferredSize2() +{ + SubQGraphicsLayoutItem layoutItem; + layoutItem.setPreferredSize(QSizeF(30, -1)); + QCOMPARE(layoutItem.preferredWidth(), qreal(30)); +} + void tst_QGraphicsLayoutItem::setSizePolicy_data() { QTest::addColumn<QSizePolicy>("policy"); diff --git a/tests/auto/qstatictext/tst_qstatictext.cpp b/tests/auto/qstatictext/tst_qstatictext.cpp index 2a60e9e..68c3ea9 100644 --- a/tests/auto/qstatictext/tst_qstatictext.cpp +++ b/tests/auto/qstatictext/tst_qstatictext.cpp @@ -91,6 +91,8 @@ private slots: void drawStruckOutText(); void drawOverlinedText(); void drawUnderlinedText(); + + void unprintableCharacter_qtbug12614(); }; void tst_QStaticText::init() @@ -753,5 +755,14 @@ void tst_QStaticText::drawUnderlinedText() QCOMPARE(imageDrawText, imageDrawStaticText); } +void tst_QStaticText::unprintableCharacter_qtbug12614() +{ + QString s(QChar(0x200B)); // U+200B, ZERO WIDTH SPACE + + QStaticText staticText(s); + + QVERIFY(staticText.size().isValid()); // Force layout. Should not crash. +} + QTEST_MAIN(tst_QStaticText) #include "tst_qstatictext.moc" 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; +}; diff --git a/tools/tools.pro b/tools/tools.pro index f254230..8f23fe4 100644 --- a/tools/tools.pro +++ b/tools/tools.pro @@ -43,3 +43,7 @@ embedded: SUBDIRS += makeqpf CONFIG+=ordered QTDIR_build:REQUIRES = "contains(QT_CONFIG, full-config)" + +!win32:!embedded:!mac:!symbian:CONFIG += x11 + +x11:contains(QT_CONFIG, opengles2):contains(QT_CONFIG, egl):SUBDIRS += qmeegographicssystemhelper |